Skip to content

fix(settings): leave an Escape that already closed Files - #3036

Merged
devswha merged 3 commits into
mainfrom
fix/settings-escape-after-files
Nov 5, 2026
Merged

devswha merged 3 commits into
mainfrom
fix/settings-escape-after-files

Conversation

@devswha

@devswha devswha commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

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:

  1. Open Files.
  2. Open Settings with its shortcut.
  3. Click inside Files. Files is drawn above Settings (same layer, later in the DOM), so the click gives Files the keyboard.
  4. Press Escape once.

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

  • Failing first: with main's SettingsDialog.tsx, bun run check run --build bun scripts/files-prompt-regression.ts fails at the new step ("one Escape closed both Files and Settings"). With the fix, 8/8 scenarios pass.
  • bun run check fast on 3ddad3d (merged with main): success (typecheck, build, 12235 unit tests, 0 failures); files-prompt-regression 8/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.
  • Browser regressions that press Escape in Settings, run on this change before it moved to its own branch (same two-file diff on top of fix(files): keep Escape closing Files when the key re-renders the app #3026's head): 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-regression fails 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.
  • Skipped: bun run check full, Windows VM, Mac.

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]>
@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 7b83025 and 3ddad3d.

Files selected for processing: 2

  • scripts/files-prompt-regression.ts
  • src/components/SettingsDialog.tsx
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@devswha

devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Review at f5847c6: omo (dori review) CLEAR; Codex Terra (xhigh) raised two MEDIUMs, neither introduced by this PR.

  • MEDIUM (Codex), reproduced, pre-existing: Settings open, then Files from the palette. One Escape closes Settings underneath and leaves Files (in front) open. Same on main before fix(files): keep Escape closing Files when the key re-renders the app #3026, after fix(files): keep Escape closing Files when the key re-renders the app #3026 and with this PR: a probe gave "Settings closed, Files left" in 8/8 rounds on each. This PR does not change that order, so it does not block. Filed as a follow-up: Escape with two dialogs open can close the one underneath #3037.
  • MEDIUM (Codex), unreproduced, code reading: New workspace open, then Settings by its shortcut. NewSessionDialog's document listener runs first, closes New workspace and marks the key handled, so Settings now stays open (on main both closed). While a workspace is being created, Settings would not close on Escape (its X still does). It is part of the same stacking problem and is noted in the follow-up issue.
  • LOW (omo): a user-bound modified Escape chord (e.g. Ctrl+Escape) is marked handled by the shortcut dispatcher, so it would not close Settings. Bare Escape is unaffected. No change.
  • LOW (omo): the new step runs on desktop only. No change.

CodeRabbit: rate-limited, no review of this head.

@devswha

devswha commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Local merge gate (owner-approved): bun run check fast passed at this head, omo CLEAR at this head, Codex no PR-introduced finding (two pre-existing stacking MEDIUMs in #3037), threads resolved, merges cleanly. Fixes the MEDIUM #3026 introduced (one Escape closed both Files and Settings) with a failing-first step; files-prompt 8/8. device-security-demo fails the same way on main and is handled separately. Merged without waiting for GitHub CI.

@devswha
devswha merged commit 0e68af5 into main Nov 5, 2026
10 of 12 checks passed
@devswha
devswha deleted the fix/settings-escape-after-files branch November 5, 2026 18:01
devswha added a commit that referenced this pull request Nov 5, 2026
)

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant