Skip to content

fix(ui-kit): a dispatched Escape still closes a watched panel (#4230) - #4231

Merged
schlessera merged 2 commits into
mainfrom
fix/2577-untrusted-escape
Nov 17, 2026
Merged

schlessera merged 2 commits into
mainfrom
fix/2577-untrusted-escape

Conversation

@schlessera

@schlessera schlessera commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Refs #4230 (red-main incident; this is its declared fix). Follows #2577 / #4194.

What this does

Main run 44150545208 at cc10821 (#4194) failed browser (3): ArtifactTheme.stories.tsx > Layout Phone and Layout Desktop, in storybook and storybook-light, on "Escape returns to the file link".

Cause (reproduced locally at cc10821, then traced inside the story):

  • The Files panel's close watcher is armed, and the overlay stack correctly steps aside for it.
  • But the story's userEvent comes from Storybook's play context and dispatches a synthetic keydown (isTrusted: false).
  • An untrusted Escape never raises a platform close request, so the watcher never fired.
  • With a watcher armed, the helper's keydown path stood aside too. Nothing took the Escape, and the panel stayed open.

Fix:

  • A real Escape is still taken only through the watcher, which is what Android back uses.
  • An untrusted Escape is taken by the keydown path whether or not a watcher is armed, both in watchCloseRequests (packages/ui-kit/src/internal/close-request.ts) and in the overlay stack's document listener (overlay-stack.ts).
  • It cannot close twice, because an untrusted keydown never reaches a watcher.

Proof

  • The failing story: ArtifactTheme.stories.tsx 4/4 in storybook and in storybook-light, where it failed on the merged head (reproduced locally before the fix).
  • New test in close-requests.pointer.tsx, for each of the Sessions drawer, the Settings pane and the Files pane: "a dispatched (untrusted) Escape still closes it once while its watcher is armed". The surface closes, the watcher sees no close request, and focus returns to the opener.
  • Mutations (each restored):
    • Helper ignores untrusted Escape while armed: fails the Settings and Files pane cases.
    • Overlay stack ignores it while watching: fails the Sessions drawer case, and the ArtifactTheme Layout Phone story again.
  • Browser suites: close-requests.pointer.tsx 27/27 on rail-fine, rail-coarse and rail-mixed; overlay-stacking.pointer.tsx 160/160.
  • Typecheck, lint and check:pr pass.

Collisions

bun scripts/collisions.ts --json --pr 4231 at head 719d109: closure reports with #3054, #3056, #3059, #3069, #3581, #3622, #4151, #4179, #4196, #4198, #4199, #4200.

{"version":1,"kind":"brain-check-pr-receipt","head":"701c957527ccbc4a1c785ac816184ca21c6bdb90","base":"origin/main","mode":"focused","startedAt":"2026-11-17T19:36:29.594Z","finishedAt":"2026-11-17T19:37:14.741Z","checks":[{"name":"all lint and leakage gates","categories":["changeset"],"outcome":"passed","elapsedMs":13828.282875},{"name":"environment documentation","categories":["changeset"],"outcome":"passed","elapsedMs":106.71548100000291},{"name":"pending changeset package names","categories":["changeset"],"outcome":"passed","elapsedMs":67.09392800000205},{"name":"contribution changeset","categories":["changeset"],"outcome":"passed","elapsedMs":20.08760500000062},{"name":"affected fast invariants","categories":["verify","unit"],"outcome":"passed","elapsedMs":31107.011177999997}]}

🤖 Generated with Claude Code

An untrusted (dispatched) Escape keydown never raises a close request,
so with a panel's close watcher armed, nothing took it: the keydown
fallback and the overlay stack both stepped aside for the watcher. The
storybook ArtifactTheme play functions dispatch their Escape this way
and failed main run 44150545208 ("Escape returns to the file link").
Both keydown paths now take an untrusted Escape whether or not a watcher
is armed; a real one still arrives only through the watcher.

Refs #4230

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@schlessera schlessera added this to the 0.45.0 milestone Nov 17, 2026
@uploads-sh

uploads-sh Bot commented Nov 17, 2026

Copy link
Copy Markdown

No uploads on this PR yet

This PR changes UI files (packages/ui-react/tests/browser/close-requests.pointer.tsx). Screenshots help reviewers see what changed.

  • From the CLI: uploads put before.png after.png --pr 4231
  • From an agent: ask it to attach screenshots with uploads.sh
  • By hand: drag images into the PR description and they're imported automatically
Tips for agents

Label each shot so reviewers know what they're seeing. Labels apply to every file in a call, so run one put per shot:

uploads put after.png --pr 4231 --meta path=/settings --state after --caption "Saved settings toast"
uploads put chat.png --pr 4231 --app ios --screen "Chat" --state after

No CLI? With the Uploads MCP, call sign_upload_url for files on disk (or put) with repo, pr: 4231 and the same screen, state and caption fields.

This comment updates with each upload, so you don't need to post the images yourself. A shot or two in the PR description is still welcome. Check what's attached with uploads list --pr 4231. More in the github-screenshots skill or the agent docs.

Workspace admins can turn this comment off in Settings → GitHub · docs

@schlessera

Copy link
Copy Markdown
Owner Author

Independent review

Reviewed head 719d109 against base 18da31b. Reviewer: agent. No findings.

{
  "version": 1,
  "kind": "brain-review-receipt",
  "pr": 4231,
  "head": "719d10988b66e402d439881ce10820e0a96724dd",
  "base": "18da31bc64a03c8bafa5ea8043028e32df80f7d1",
  "reviewer": "agent",
  "outcome": "no-findings",
  "findings": []
}

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