Repository navigation
fix(gui): Escape over a page dialog closes only that dialog, not Add Provider (#8849) - #9012
Conversation
…Provider (#8849) The Add Provider modal listens for Escape on window and only knew its own overlays. Dialogs the providers page opens above it -- the OAuth risk warning of an Accounts-tab login, the Codex login, and the remove / unsaved-changes confirmations -- were invisible to that guard, so one Escape closed both layers. The page now tells the modal when one of its dialogs is open (stackedOverlayOpen).
|
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 4 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. |
|
✅ Deterministic PR hygiene checks passed. |
…#8849) Review: with the page telling Add Provider to leave Escape alone, the two plain alertdialog confirmations (remove provider, unsaved changes) had no Escape path of their own, so Escape did nothing while one was stacked. Both now cancel on Escape (the unsaved-changes dialog not while its save is in flight). The composition test now uses stateful page callbacks and delivers Escape in browser order (keydown first, then the native dialog cancel when not prevented), and asserts the top layer closes first and Add Provider on the next Escape.
…ayer (#8849) Review: the Settings tab's unsaved-changes confirmation is mounted in the page body, outside the Add Provider modal's stackedOverlayOpen guard, and can stay open while Add Provider (and the OAuth warning) open above it. Its window Escape listener then cancelled it from underneath, and its preventDefault could suppress the warning's native cancel. Confirmations now act only when their own backdrop is the topmost open layer (a native modal dialog is always above in-page overlays), and otherwise neither handle nor prevent the key. Two stateful multi-layer tests cover it (fail without the check).
…#8849) Review: document order is not the visual order -- .dialog-backdrop (z-index 900) paints above the Add Provider .modal-overlay (--z-modal), so a Settings confirmation left open could appear above a later Add Provider. Escape ownership now comes from one helper (gui/src/components/overlay-layers.ts): an open native modal dialog first, then the highest computed z-index, document order breaking ties. Both the confirmations and Add Provider consult it. Add Provider also ignores an Escape another layer already prevented: in a real browser the confirmation's cancel can remove its backdrop before Add Provider's listener runs, which closed both layers on one key. Real-browser check (GOAT preview, source build): Settings unsaved-changes confirmation over Add Provider -> first Escape closes the confirmation, second closes Add Provider. Tests: z-index case and prevented-Escape case (each fails without its guard).
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Maintainer integration into
|
Summary
Closes #8849
In the Add Provider modal's Accounts tab, pressing Escape on an OAuth risk warning (Anthropic, Google Antigravity or any other
oauthTosRiskprovider) closed the warning and the whole Add Provider modal. Accounts-tab logins go through the providers page, so the warning is the page's dialog (providers-page-modals.tsx), and the modal'swindowEscape listener (AddProviderModal.tsx) could not see it: it only knew its own overlays. The same was true for the other dialogs the page renders above the modal (the Codex login opened from an OpenAI or forward-provider row, and the remove / unsaved-changes confirmations).After: the page tells the modal when one of its dialogs is open (
stackedOverlayOpen), and the modal's Escape guard treats it like its own overlays, so Escape unwinds one layer at a time: the first Escape closes the top dialog, the next closes Add Provider. The remove-provider and unsaved-changes confirmations are plainalertdialogs with no Escape handling of their own, so they now cancel on Escape too (the unsaved-changes dialog not while its save is in flight, matching its disabled Save button). Escape belongs to the layer the user sees on top, decided by one helper (gui/src/components/overlay-layers.ts): an open native modal<dialog>first, then the highest computed z-index (.dialog-backdropis 900,.modal-overlayuses--z-modal), with document order breaking ties. Both Add Provider and the confirmations consult it. For example, the Settings tab's unsaved-changes confirmation can stay open while Add Provider opens beneath it visually, and Escape then closes the confirmation first. Add Provider also ignores an Escape another layer already prevented: in a real browser a confirmation's cancel can remove its backdrop before Add Provider's listener runs, which would otherwise close both on one key. No copy changes.Prior art: the WAI-ARIA Authoring Practices dialog pattern specifies that Escape closes the topmost dialog only; nested dialogs unwind one at a time (https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/).
Codex login over Add Provider, after one Escape on the fixed build (only the Codex login closed; the next Escape closes Add Provider):
Settings unsaved-changes confirmation (z-index 900) open above Add Provider, then after one Escape (only the confirmation closed; the next Escape closes Add Provider):
Screenshots: GOAT preview browser against a source proxy with a temporary home, Providers → Add Provider → Accounts → Log in on Anthropic (Claude), then Escape. Before (dev build): no
.modal-overlayremains. After:DIV[Add provider]remains.Verification
gui/tests/add-provider-escape-stacked-overlay.test.tsxrenders the realProvidersPageModalscomposition with stateful page callbacks (each cancel really closes its overlay) and delivers Escape in browser order: the keydown on the focused element bubbles towindowfirst, then the topmost open native<dialog>getscancelunless the keydown was prevented. For each page dialog (OAuth warning, Codex login, remove confirmation, unsaved changes), the first Escape closes that dialog and the second closes Add Provider; a save in flight cannot be abandoned with Escape; with no page dialog, Escape closes Add Provider. Before the fix the stacked cases failed (Add Provider closed with the dialog). Removing only the confirmation Escape handling fails the two confirmation cases. Two multi-layer cases mount the Settings-owned confirmation beneath Add Provider, optionally with the OAuth warning above; Escape unwinds warning → Add Provider → confirmation, and they fail without the topmost check. A z-index case (inline z-index mirroring the stylesheet) and a case where another layer already prevented the Escape each fail without their guard. 10/10 pass.cd gui && bun run test: 4783 pass, 0 fail.bun test tests/gui/oauth-tos-warning.test.ts(source scan of the Escape guard): pass.bun run lint:gui: exit 0.cd gui && tsc -b: exit 0.bun run typecheck: clean.bun run test:changed: selects 0 root tests for this gui-only diff (the root import graph does not reachgui/), so the gui suite above is the relevant run.Checklist