Repository navigation
fix(settings): leave an Escape that already closed Files - #3036
Conversation
Re-review of #3026 (Codex, reproduced): with Settings opened over Files and a click in Files (drawn above Settings), one Escape closed Files and then Settings. Settings now skips an Escape another dialog already took (defaultPrevented), as Files does, so each Escape closes one dialog. Co-authored-by: sisyphus-dev-ai <[email protected]>
|
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 38 seconds. 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. |
|
Review at f5847c6: omo (dori review) CLEAR; Codex Terra (xhigh) raised two MEDIUMs, neither introduced by this PR.
CodeRabbit: rate-limited, no review of this head. |
|
Local merge gate (owner-approved): |
) Fixes #3037. Follow-up to #3036. ## Problem Settings, Files and New workspace each close on their own `window` or `document` Escape listener. Those run in the order they were added, not in the order the dialogs are drawn, so with two dialogs open one Escape could close the dialog underneath and leave the one in front (the one with the keyboard) open: 1. Settings open, then the palette's Browse files: Files opens over Settings and takes the focus. Escape closed Settings and left Files open (reproduced, as in the issue). 2. New workspace open, then Settings with its shortcut: New workspace's `document` listener runs before Settings' `window` listener, so Escape closed New workspace and left Settings open. The issue had this from code reading only; it reproduces (the new regression step fails without the New workspace change). While a workspace was being created, it also took that Escape without closing. ## Change - `focusInOtherModal(surface)` in `src/lib/useFocusTrap.ts`: the focus is inside another `aria-modal` surface. It is the check `FilesDialog` has done inline since #3026; Files now calls the helper. - `SettingsDialog` and `NewSessionDialog` leave an Escape to the dialog that has the focus. Each Escape closes the dialog in front, and the one underneath closes on the next Escape. This follows the WAI-ARIA modal dialog pattern that the Codex and Claude desktop apps also follow: Escape belongs to the dialog that has the focus. Every dialog opened inside Settings (Confirm, Connect phone, usage sign-in, row menus) already handles its own Escape and stops it, so none of them depended on Settings closing. ## Validation - Failing first: `bun run check run --build bun scripts/files-prompt-regression.ts` with two new desktop steps (Files from the palette over Settings; Settings over New workspace). On origin/main the first step fails ("waiting for .files-dialog to be hidden"). With only the New workspace change removed, the second step fails (Settings stays open because New workspace closed instead). With the fix, 8/8 scenarios pass, also after rebasing on origin/main 02881f0. - `bun run check fast` on the rebased head: success (typecheck, build, 12289 unit tests, 0 failures). - Browser regressions, run in the CI runner image (`herdr-ci-runner:local`, `ci-browser-parallel.ts`, 6 workers) on the change before the rebase: 157/160 passed. I re-ran the 3 that failed side by side on origin/main 5b51cbe and on this change, in the same image: `ui-contexts-regression` and `revision-bound-update-demo-regression` pass on both (the first failures came from host load and a checkout whose git directory the container could not read). `unconfirmed-input-demo-regression` fails on both at the same line (`:64`, the terminal textarea wait), so it was already failing before this change. - `bun test scripts/changelog-fold.test.ts`: pass. - Skipped: `bun run check full`, Windows VM, Mac.
Follow-up to #3026 (#2631).
Problem
#3026 keeps Files' window Escape listener in place across renders. Before that, the listener swap was what made one Escape close only one of two stacked dialogs. Codex's re-review of #3026 at b7d3e06 found one more case where one Escape now closes two dialogs, and it reproduces:
Files closes, marks the key handled (
preventDefault), and then Settings' bubble listener closes Settings as well. Before #3026, only one of them closed.Change
SettingsDialog's Escape listener skips an Escape another dialog already took (event.defaultPrevented), as Files does since fix(files): keep Escape closing Files when the key re-renders the app #3026. Each Escape closes one dialog.files-prompt-regression.ts(desktop): opens Files, then Settings, clicks Files' Browse tab, and checks that one Escape closes Files and leaves Settings open, and that the next one closes Settings.No changelog fragment: this fixes behaviour that #3026 introduced and that has not been released.
Validation
SettingsDialog.tsx,bun run check run --build bun scripts/files-prompt-regression.tsfails at the new step ("one Escape closed both Files and Settings"). With the fix, 8/8 scenarios pass.bun run check faston 3ddad3d (merged with main): success (typecheck, build, 12235 unit tests, 0 failures);files-prompt-regression8/8 there too. An earlier run had one unrelated timeout (server/claude-store.test.ts, 60 s under the parallel run); that file passes 3/3 alone.agent-groups-demo,agent-lock-demo,cliproxy-settings,file-text-size-demo,file-viewer,hide-pc-demo,key-bar-customization-demo,pane-mute-demo,preferences-sync,relay-panel,settings-pages-demo,shortcut-exact-modifiers-demo,sidebar-declutter-demo,sidebar-split-access-demo,usage,ui-regression, all passing.device-security-demo-regressionfails on a pill/button height layout assertion at 390 px, and fails the same way on origin/main 0df1012 ("Cancel: 43.99 px tall"), so it is unrelated.bun run check full, Windows VM, Mac.