Skip to content

fix: keep a side-panel file open on escape typed in its editor - #31653

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
fix/23975-escape-keeps-editor-open
Nov 7, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
fix/23975-escape-keeps-editor-open

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Pressing Escape while typing in a side-panel file's code editor no longer closes the file.

With a file open in the side panel's code editor, pressing Escape closes the file, or raises the "Discard unsaved changes?" prompt when the buffer has edits, even though the caret is in the editor.

Why it matters

Escape is an everyday key while editing: people press it out of habit from other editors to drop a selection or leave a mode. Every such press throws them out of the file they are working in. A clean file closes with no prompt and the reader's place is lost; an edited one interrupts the typing with a discard dialog.

Not a goal

  • Selectable editor keymaps (VS Code, Emacs, IntelliJ and so on) or a setting for Escape: the larger half of the issue, left for its own change.
  • Escape in full screen: it still leaves full screen, as the exit button's tooltip says.
  • Escape handling on any other surface: the side-panel artifact tab already leaves an editable field's Escape alone.

What changed (motivation → approach → change)

The side-panel file tab listens for Escape on the whole page and closes its file, and the code editor does not claim the key, so a press typed into the editor reached that close. The Files rail's filter beside it had the same problem: its Escape cleared the filter and closed the file too.

In MarkdownPanel.tsx the close now leaves a press alone when it was typed into an editable field inside the panel's own content row: the code editor above all, and the Files rail's filter. It asks isEditableTarget and checks the event's composed path for that row, because the editor's editable node sits in a shadow root. Escape from a button in the panel, or from anywhere outside it (the chat composer beside the panel included), still closes the file through the same guard.

The side-panel file tab paragraph in learn-cron-dashboard.md records the rule, and MarkdownPanel.escape.test.tsx pins it.

Backwards compatibility

Compatible: every way to close the file still works: Escape pressed outside an editable field of the panel, the panel's ×, and the tab chip's × and middle-click; full screen still leaves on Escape.

Reader: website/src/components/MarkdownPanel.tsx:guardedClose -- entry: chat -- still reached from Escape outside a field and from the × (MarkdownPanel.escape.test.tsx, MarkdownPanelCoverage.test.tsx "routes Escape through the same discard guard as the close button")
Reader: website/src/components/chat-input/escapeOwners.ts:anotherEscapeOwnerIsOpen -- entry: chat -- the open file still marks itself data-escape-owner, so the composer's stop and dictation gates yield exactly as before
Reader: website/src/pages/chat/FileBrowserRail.tsx:FileBrowserRail -- entry: chat -- its filter still clears on Escape (FileBrowserRail.test.tsx "clears the query on Escape"); leaving the field is now what closes the file

Tests

website/src/test/MarkdownPanel.escape.test.tsx mounts the panel on a code file with its editor (Pierre stubbed as a textarea), a Files rail holding a filter input and a button, and a composer textarea outside the panel. Escape typed in the editor or the filter leaves the file open; Escape on the rail's button closes it, and so does Escape typed in the composer. It fails on main (onClose called twice before the first assertion), and with the guard line removed.

Proof: not provable -- frontend test (prove.py runs Python only)

Determinism: 20 isolated runs green, then 5 runs with --sequence.shuffle (seeds 24362 to 24366) beside MarkdownPanelFindEscape.test.tsx and MarkdownPanel.editFocus.test.tsx at --maxWorkers=4, all green. The assertions are synchronous: a clean, unwatched buffer closes without an await.

The panel's other suites (every MarkdownPanel* spec, the side-panel tab-chip close specs, FileBrowserRail.test.tsx, stopButtonEscalation.test.tsx, editableTarget.test.ts) pass unchanged.

Manual verification

Not run in a browser. The test drives the panel's real document handler. In a real engine the editor's editable node is inside an open shadow root, and composedPath() lists both it and the panel's content row, which is the same read isEditableTarget already relies on for this editor.

Screenshots / video

Why no screenshot: Keyboard handling only: nothing on screen renders differently, a key press simply stops closing the file.

Related Issues

Closes #23975

Sibling sweep

Swept: git grep -l -E "ContentRenderer|CodeEditor|EditableCodeBlock" -- website/src, then each hit's Escape handling, plus every field inside the panel's content row
Sibling: website/src/pages/chat/FileBrowserRail.tsx:708 -- not affected -- its filter sits inside the panel's content row, so the one MarkdownPanel.tsx guard covers it
Sibling: website/src/components/ArtifactPanel.tsx:289 -- not affected -- its Escape handler already returns on an editable target
Sibling: website/src/components/library/SessionDocPreview.tsx -- not affected -- mounts ContentRenderer with editing={false}, no file editor
Sibling: website/src/apps/aws-control/DrivePageFileDialogs.tsx -- not affected -- its preview never mounts the editing surface

Pattern harvest

Rule candidate: review-prompt
Pattern: a page-level Escape handler that closes a surface does not ask isEditableTarget for a field inside that surface

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners November 6, 2026 18:42
@bolichen97
bolichen97 requested a review from Zedmor November 6, 2026 18:42
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 6, 2026
@bolichen97
bolichen97 enabled auto-merge (squash) November 6, 2026 18:43
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 10db7f4b31d1a8685100512f27ecadaf0794b5a3 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

Nothing blocks: this changes only keyboard handling and adds or changes no visible control, so no screenshot is needed.

[UX-REVIEWED] 10db7f4

Description read

[DESCRIPTION-READ] 944817b17fb135d9b2ec2ba16234ef746336ef011ff3313f65eaa329b8a864bb

That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 10db7f4b31d1a8685100512f27ecadaf0794b5a3 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing to check.

What this change ships

Inventory (3 items) — 3 justified

Intent: let someone press Escape while editing a side-panel file without the file closing. This is a FIX (#23975).

  1. Escape typed in the side-panel code editor no longer closes the file or raises the discard prompt — justified
  2. Escape typed in the Files rail's filter clears the filter and no longer also closes the file — justified
  3. The side-panel file tab spec paragraph records the Escape rule — justified

[FIRST-PRINCIPLES-REVIEWED] 10db7f4

Description read

[DESCRIPTION-READ] fdc2abd75df76216ce7d289b804c799283452de5e5b78c302c35ba2b49ad16b9

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 10db7f4b31d1a8685100512f27ecadaf0794b5a3 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the change is a narrow guard on the existing Escape handler, it renders nothing new, and it is reverted by removing one line.

Notes

  • An Escape in the editor is now silent. It neither closes the file nor exits a mode, so a user can no longer close the file from the keyboard while the caret is in the editor. If that matters, the keymap follow-up the PR names should give the editor its own close binding.

[DESIGN-REVIEWED] 10db7f4

Description read

[DESCRIPTION-READ] 40a0be7fc8e0ed2d5622db949648363143ae99e5bb68b1effb717ae23a3665a5

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 10db7f4b31d1a8685100512f27ecadaf0794b5a3 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 10db7f4

Verdict parsed from the review's SHA-scoped output markers for commit 10db7f4b31d1a8685100512f27ecadaf0794b5a3.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 10db7f4b31d1a8685100512f27ecadaf0794b5a3 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 10db7f4b31d1a8685100512f27ecadaf0794b5a3 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 10db7f4

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 10db7f4b31d1a8685100512f27ecadaf0794b5a3 false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 6, 2026
Escape typed into an editable field of a side-panel file tab (the code
editor, or the Files rail's filter) no longer closes the file. The tab
listened for Escape on the whole page and the editor does not claim the
key, so a press meant for the editor closed the file mid-edit. Escape
from anywhere else, the chat composer included, still closes it.

Closes #23975
@bolichen97
bolichen97 force-pushed the fix/23975-escape-keeps-editor-open branch from 8cbf23a to 10db7f4 Compare November 7, 2026 02:11
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in website/src/components/MarkdownPanel.tsx and docs/system-specs/modules/learn-cron-dashboard.md since this head's CI ran (90a555f -> a47c2d4); CI re-running. The previous run's only red, test_the_package_stays_within_its_line_budget in backend shard 2 (Linux and Windows), was main's and is fixed on the new base by #31625; the change itself is byte-identical.

[operator: bolichen97]

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 7, 2026

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved for the on-call. Review lanes pass on 10db7f4, no conflict, no open change request.

@KiroCrewCaptain
KiroCrewCaptain merged commit 27fce31 into main Nov 7, 2026
96 of 97 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the fix/23975-escape-keeps-editor-open branch November 7, 2026 03:30
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 7, 2026
buluoray added a commit that referenced this pull request Nov 8, 2026
Escape typed into an editable field of a side-panel file tab (the code
editor, or the Files rail's filter) no longer closes the file. The tab
listened for Escape on the whole page and the editor does not claim the
key, so a press meant for the editor closed the file mid-edit. Escape
from anywhere else, the chat composer included, still closes it.

Closes #23975

(cherry picked from commit 27fce31)

Original author: Bolin Chen (#31653). Hand-resolved, docs/tests only: docs/system-specs/modules/learn-cron-dashboard.md  keep release's structure plus this commit's added and removed lines.
buluoray added a commit that referenced this pull request Nov 8, 2026
Escape typed into an editable field of a side-panel file tab (the code
editor, or the Files rail's filter) no longer closes the file. The tab
listened for Escape on the whole page and the editor does not claim the
key, so a press meant for the editor closed the file mid-edit. Escape
from anywhere else, the chat composer included, still closes it.

Closes #23975

(cherry picked from commit 27fce31)

Original author: Bolin Chen (#31653). Hand-resolved, docs/tests only: docs/system-specs/modules/learn-cron-dashboard.md  keep release's structure plus this commit's added and removed lines.
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.

Source-code subpanel: selectable editor keymaps and configurable Escape behavior

2 participants