Repository navigation
fix(files): keep the Changes scope across a pane or PC switch again - #3028
Conversation
Co-authored-by: sisyphus-dev-ai <[email protected]> #3002 keyed RepoChanges by PC and pane, so a switch remounted it and the Branch scope fell back to Working tree; repo-diff-browser-qa timed out on Choose a branch. RepoChanges already starts the comparison over and drops late answers itself (#1857).
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 12 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
Reviews on 6349cd7:
|
|
Local merge gate (owner-approved): fixes a regression from #3002 on main (RepoChanges remounted on a PC or pane switch and reset the Branch scope to Working tree, also in the default layout with the setting off). Only that key is removed. repo-diff-browser-qa fails on main and passes here; files-panel-demo-regression passes; check fast green; omo CLEAR; Codex's MEDIUM/LOW describe behaviour from before #3002 (PR comment). Merged without waiting for GitHub CI to unblock main. |
…#3026) Fixes #2631 ## Cause The `files-prompt-regression.ts` Escape flake is a product bug. The diagnostics added in #2632 caught it 5 times on CI since then (runs 41935003970, 41942082835, 41959283541, 41980051339, 41985349024). Every time, the Escape reached `window` in the capture and bubble phases, focus was on `body`, no file viewer, diff or native modal was open, and Files stayed open. A local run with an init script that logs every window `keydown` listener add, remove and call showed what happened in the stuck rounds: 1. `useSplitView`'s bubble listener `cancel` (registered at startup, so before FilesDialog's) runs first and calls `clearDropPreview()`, which sets `paneDragging` and `dropAt` state. 2. When React does not bail out of that set, the microtask after that listener renders App before the next listener runs. 3. FilesDialog's `onClose` is an inline arrow in App, so its effect (`[onClose, viewing, docked]`) removes its window listener and adds a new one during that render. 4. A listener removed during dispatch is skipped, and one added during it is not called, so FilesDialog never sees that Escape. In the log: FilesDialog's listener was attached at 1430.9 ms, `cancel` ran at 1542.8 ms, then FilesDialog's listener was removed at 1550.1 ms and re-added at 1550.3 ms, with no call in between. ## Change - `FilesDialog` reads its latest props (`onClose`, `docked`) through `useEffectEvent`. Its window listener now changes only with `viewing`, so a render inside the same key press no longer swaps it out. - With the listener in place, Files also stands down when the focus is in another modal, and when another dialog already took the key (`preventDefault`). Each Escape closes one dialog, the one holding the keyboard, as main did. Without this, opening Settings with Files open and pressing Escape once closed both (review finding, reproduced). - `files-prompt-regression.ts` (desktop) adds a deterministic step. Files is reopened, and a pane `dragstart` shows the split guide, so the next Escape's `clearDropPreview` is a real state change and always re-renders App inside the key press. Escape must then put away both the guide and Files. A second step opens Settings over Files with its shortcut: one Escape must close Settings alone, the next Files. ## Validation - Review round (omo + Codex MEDIUM: one Escape closed Files and Settings together). A throwaway probe, 8 rounds per order at 1280 px: main left Files open after one Escape in both orders (Files over Settings, and Settings opened over Files). The first head closed both, 16/16. This head leaves Files open in both orders, 16/16, matching main. The new Settings step fails on the first head ("one Escape closed both Settings and Files") and passes now. - Failing first: with the new step and no product change, `bun run check run --build bun scripts/files-prompt-regression.ts` failed at that step (`.files-dialog` still visible after the split guide went away). With the fix, 8/8 scenarios pass. - Local stress repro (throwaway, instrumented script, Node PTY host, same flow as the check on fresh pages): 23 stuck out of 98 rounds before the fix, 0 out of 100 after. - `bun run check fast` on the merged head b7d3e06: success (typecheck, build, 12212 unit tests, 0 failures). - Browser regressions, `bun run check run` (files-prompt on b7d3e06, the rest on the round's commit before the last main merge, which touched FilesDialog only in #3028's Changes scope): `files-prompt-regression`, `files-panel-demo-regression`, `diff-find-demo-regression`, `diff-line-notes-demo-regression`, `deep-link-demo-regression`, `file-viewer-regression`, `ui-regression`, all passing. - Skipped: `bun run check full`, Windows VM, Mac. No UI change, so no screenshots. --------- Co-authored-by: sisyphus-dev-ai <[email protected]>
…pe, worktree focus and agy temp links (#4550) ## What Test bundle B5 of the test-suite plan: regression tests for four fixes that went in without one (two of them regressed before). Tests only; no production file changes. | # | Fix | Test | |---|---|---| | A1 | #4159 `scripts/build-cache.ts` re-checks the cache after taking the lock | `scripts/build-cache.test.ts`: two real `build-cache.ts` jobs on one key, ordered by gate files (`fs.watch`, no sleep). Job 2 misses the cache, meets job 1's lock, and is paused just before its retry; job 1 stores its build and releases. Both exit 0, one build in total, job 2's `dist/` restored from the cache. | | A2 | #3028 Changes keeps its scope when Files moves to another pane/PC | new `src/components/FilesDialog.test.tsx`: render `FilesDialog`, pick Branch, compare with `main`, rerender with another `paneId`, then the stale pane's answer arrives: Branch stays pressed and the stale file is not shown. | | A3 | #1222 the new worktree dialog focuses the Branch field | `src/components/WorktreeDialog.test.tsx`: in create mode focus is on the Branch input with its suggested value fully selected. | | A4 | #2030 agy catalog under a symlinked temp dir (macOS `/var -> /private/var`) | `server/agy.test.ts`: a new row of the WAL-catalog table runs the reader with `TMPDIR`/`TEMP`/`TMP` pointing at a symlink. | ## Evidence: each test goes red when its fix is reverted Each mutation was written into the production file, the test run, and the original bytes restored (sha256 checked; production diff is empty). | # | Revert | Result | |---|---|---| | A1 | `if (owner && restored())` -> `if (false && ...)` (no look under the lock) | red: builds `[1, 1]` instead of `[1, 0]` | | A2 | put back `key={`${machineId}:${paneId}`}` on `<RepoChanges>` (the key cbdcafa removed) | red: scope falls back to Working tree | | A3 | move `ref={first}` from the Branch input to the Name input (pre-#1222) | red: focus and selection on the Name input | | A4 | remove `snapshot = realpathSync(snapshot)` in `server/agy.ts` | red: only the symlinked row fails with `AgyUnavailable`; the other three rows stay green. **This reproduces on Linux too**: SQLite's `SQLITE_OPEN_NOFOLLOW` refuses a path with a symlinked directory component, so Linux CI guards #2030. | ## Validation - `bun test scripts/build-cache.test.ts src/components/FilesDialog.test.tsx src/components/WorktreeDialog.test.tsx server/agy.test.ts`: all new tests pass. - `bun scripts/typecheck.ts`: exit 0. - `bun run check fast` (P620, 241 s): typecheck, build, generated files ok; unit 24,890 pass, 160 skip, **1 fail**: `scripts/conventions.test.ts` "waits marked fixed" on `scripts/relay-new-pc-press-regression.ts:180`, which fails on `origin/main` itself (1d71a71) and is fixed by #4547; this PR does not touch that file. The branch takes main in once #4547 lands. - Browser regressions that name FilesDialog or the worktree dialog (`file-viewer-regression`, `files-panel-demo-regression`, `repo-diff-browser-qa`, `ui-regression`, `phone-worktree-sheet-regression`, ...): not run locally since no component code changes; they run in this PR's Integration and browser job (CI runner image).
What
Since #3002,
scripts/repo-diff-browser-qa.tstimes out on main (and on every PR's Integration and browser job) waiting for the Choose a branch button in the step "a branch list still on its way is dropped when the reader switches PC".#3002 keyed
RepoChangesinFilesDialogby PC and pane (key={${machineId}:${paneId}}). A switch of pane or PC while Files is open (Next pane, the sidebar) now remounts the changes list, so the Branch scope the reader picked falls back to Working tree. That also happens with the new setting off (the dialog), so it is a product regression, not a stale locator: #1857 made Changes keep its Branch scope across a pane, folder or PC switch (it starts the comparison over with no base) and drop answers for the target left behind by itself, and its tests assert exactly that (branchPressed: "true"after each switch).The fix removes only that key. The
DirectoryBrowserandPullRequestPanelkeys from #3002 stay, so the same pane id on another PC still lists that PC's folder (the PC-switch step inscripts/files-panel-demo-regression.ts).Validation
bun scripts/repo-diff-browser-qa.tson origin/main 6b72c09 (afterbun install --frozen-lockfileandbun run build): fails withTimeoutError: click: Timeout 15000ms exceeded ... waiting for getByRole('button', { name: 'Choose a branch', exact: true })right after the Korean branch review, as in CI.repository diff: browser OK ..., exit 0).bun scripts/files-panel-demo-regression.tswith this change: PASS 1280/390, light/dark (the PC-switch folder step included).bun run check fast: passed on 6349cd7 (unit 12200 pass, 0 fail; typecheck, build, generated files).No new test: the existing browser regression is the failing-first check.