open-design/apps/web/tests/hooks
Sid 8b16d21785
fix(web): coalesce chokidar rewrite bursts before refreshing files (#2326)
Agent rewrites surface to chokidar as `unlink` + `add` (+ optional
`change`) within a single tick. ProjectView refreshes the file list
on every event, so the open tab's active file vanishes for one frame
between the `unlink` and the `add`. FileWorkspace's `activeFile`
resolver returns null when the active name disappears from
`visibleFiles`, and the preview falls back to an empty state mid-run.

Add a trailing-coalesce around the file-changed refresh:
  - First event arms an 80ms quiet window.
  - Subsequent events inside the window reset it.
  - A 250ms maxWait cap ensures a sustained edit storm still flushes.
  - The intermediate `unlink` is absorbed by the next `add` and the
    UI only sees a single, file-present refresh.

The coalesce is a small `useCoalescedCallback` hook so the timing
contract is unit-testable without standing up ProjectView. Tests
cover the rewrite burst, isolated single triggers, the maxWait cap
under sustained triggers, latest-callback semantics, and unmount
cleanup.

Fixes #2195
2026-05-20 11:12:53 +08:00
..
useCoalescedCallback.test.tsx fix(web): coalesce chokidar rewrite bursts before refreshing files (#2326) 2026-05-20 11:12:53 +08:00
useDesignMdState.test.tsx fix(web): parse Provenance with Markdown-bold labels (#1584) 2026-05-14 11:04:24 +08:00
useFinalizeProject.test.tsx Fix finalize provider routing for Gemini BYOK (#1964) 2026-05-18 18:03:44 +08:00
useProjectDetail.test.tsx feat(web): add Finalize design package + Continue in CLI buttons (#451) (#974) 2026-05-10 11:44:32 +08:00