Skip to content

fix(gui): Escape over a page dialog closes only that dialog, not Add Provider (#8849) - #9012

Merged
lidge-jun merged 4 commits into
devfrom
codex/fb2100-escape-layer
Nov 20, 2026
Merged

lidge-jun merged 4 commits into
devfrom
codex/fb2100-escape-layer

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

Summary

Closes #8849

In the Add Provider modal's Accounts tab, pressing Escape on an OAuth risk warning (Anthropic, Google Antigravity or any other oauthTosRisk provider) 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's window Escape 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 plain alertdialogs 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-backdrop is 900, .modal-overlay uses --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/).

Warning open over Add Provider After one Escape
Before (dev) before: warning open before: both closed
After (this PR) after: warning open after: Add Provider still open

Codex login over Add Provider, after one Escape on the fixed build (only the Codex login closed; the next Escape closes Add Provider):

after: Codex login closed, Add Provider open

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):

Before Escape After one Escape
confirmation over Add Provider confirmation closed, Add Provider open

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-overlay remains. After: DIV[Add provider] remains.

Verification

  • Regression test first: gui/tests/add-provider-escape-stacked-overlay.test.tsx renders the real ProvidersPageModals composition with stateful page callbacks (each cancel really closes its overlay) and delivers Escape in browser order: the keydown on the focused element bubbles to window first, then the topmost open native <dialog> gets cancel unless 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.
  • Real browser check (fixed build): the OAuth warning, the Codex login and the Settings unsaved-changes confirmation, each over Add Provider, close alone on the first Escape; Add Provider closes on the second. Screenshots above.
  • 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 reach gui/), so the gui suite above is the relevant run.
  • Independent review: gpt-6.1-terra reviewer. Plan audited. Code review rounds 1-3 asked for Escape on the confirmations, a stateful browser-order test, a confirmation beneath another layer not taking Escape, and Escape following visual stacking; all fixed (the browser check also found and fixed the prevented-Escape race). Round 4 on af151ef: approve ("No new blocking findings"). Known limit, noted by the reviewer: the helper compares computed z-index values of the dashboard's own overlay classes. It is not a general resolver for nested CSS stacking contexts or the opening order of several native dialogs, so a future overlay that changes stacking should be checked against it.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed. (No user-facing docs describe this key handling.)
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults. (No auth change; no OAuth flow starts on Escape.)

…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).
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

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 4 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 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 d9120df and af151ef.

Files selected for processing: 5

  • gui/src/components/AddProviderModal.tsx
  • gui/src/components/overlay-layers.ts
  • gui/src/components/provider-workspace/ProviderDialogs.tsx
  • gui/src/pages/providers-page-modals.tsx
  • gui/tests/add-provider-escape-stacked-overlay.test.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

@github-actions github-actions Bot added the bug Something isn't working label Nov 20, 2026
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

✅ 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).
@lidge-jun
lidge-jun marked this pull request as ready for review November 20, 2026 20:00
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner November 20, 2026 20:00
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T20:01:54.719048Z af151ef Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@lidge-jun

Copy link
Copy Markdown
Owner Author

Maintainer integration into dev (MAINTAINERS.md dev-only exception), recorded by the coordinator for @lidge-jun.

@lidge-jun
lidge-jun merged commit 1c5d911 into dev Nov 20, 2026
40 of 41 checks passed
@lidge-jun
lidge-jun deleted the codex/fb2100-escape-layer branch November 20, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dashboard: Escape on an Accounts-tab OAuth warning dialog also closes the Add Provider modal

1 participant