Skip to content

fix(studio): keep Escape in another approval card from denying the active ask - #2332

Merged
peppescg merged 3 commits into
mainfrom
fix/studio-escape-active-card-2258
Oct 15, 2026
Merged

peppescg merged 3 commits into
mainfrom
fix/studio-escape-active-card-2258

Conversation

@peppescg

@peppescg peppescg commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Part of a 4-PR stack: #2329 → #2330 → #2331 → #2332. Review in any order; merge bottom-up.

Summary

With two or more pending asks in a chat, Escape pressed while focus was inside a card that isn't the active ask's denied the active ask. That is a different request from the one the reader was looking at. #2251 fixed the same problem for the approval detail panel; this PR fixes it for the cards.

Escape now answers no ask from another ask's card. From the active ask's card, the composer, a side panel that isn't an approval, or the page, Escape still denies the active ask, as #1975 designed.

The only visible change is one sentence of help text on the Keyboard shortcuts page. The screenshots below show the behavior itself: two pending asks, Escape pressed in the second card, Before and After.

What changed

  • chat-escape.ts: one helper, inOtherAskCard, and one early return at the ask layer. When the press comes from inside a [data-approval-scope] card that isn't marked data-active-ask, Escape returns after disarming the draft hint. It sends no deny, no plan iterate, and no unavailable-plan message. The layers above the ask (an open dialog or menu, a text selection) and below it (side panel, run, draft) are unchanged. The diff is 14 added lines and no other edits, so it stays clear of the chat-escape.ts cleanups listed in Large batch of tiny follow-up fixes #2303 section B.
  • approval-panel.tsx: the card is marked data-active-ask while it shows the surface's active ask. The mark comes from useActiveEscapeAsk, the same check behind the card's "Esc to Deny" hint and its letter keys, so Escape denies from the card that shows "Esc to Deny".
  • plan-review-card.tsx: the plan-review card is marked data-approval-scope, and data-active-ask while it shows the active ask, so the rule covers plan cards too. This includes a stale plan card from an older run next to the current plan: it keeps its Raw arguments toggle, and Escape from there used to iterate the current plan. Letter keys don't change: plan cards never had them, and from inside a plan card approvalOwnsKey still matches no ordinary card.
  • Docs: the Keyboard shortcuts page says, in one sentence, that Escape closes a detail panel showing a different request and does nothing in another request's card. user-docs/operating/studio.md is unchanged: docs(studio): shrink the Escape section to what the app does not show #2314 removed the sentence this PR edited, and the guide now defers the Escape order to the Keyboard shortcuts page. See "Overlap with docs(studio): shrink the Escape section to what the app does not show #2314 and fix(studio): make the Escape double-press window strictly under 500 ms #2318" below.

Overlap with #2314 and #2318

This PR overlapped #2318, which also edits chat-escape.ts and approval-interactions.test.tsx, and #2314, which removed the studio.md Escape sentence that this PR edited. Both have merged, and this branch is rebased onto them: it keeps #2314's removal of the studio.md sentence, and the Keyboard shortcuts sentence here still applies.

Escape from another ask's card

The issue allowed Escape to act on that card's own ask or to do nothing. It does nothing:

  • It doesn't deny the active ask, which isn't the request the reader is looking at.
  • It doesn't deny the card's own ask either. Escape and the Y, A, W, N, and D keys only ever answer the surface's active ask. A card that isn't active shows no "Esc to Deny" and has no keyboard verdicts. feat(studio): port the prototype's chat approval card, detail panel, and shortcuts #2251 made the same choice for the detail panel: a panel showing an ask other than the active one closes on Escape and never denies the ask it shows. A card has nothing to close.
  • It doesn't fall through to the side panel, the run, or the draft. While an ask is pending, Escape stops at the ask layer, as it already does when the ask's controls are unavailable. Falling through would let a press in another card stop the run.

Denying stays the only verdict Escape gives. Escape never approves.

Behavior kept on purpose

  • The composer, side panels, and the page still deny the active ask. This is the feat(studio): complete chat approvals, plan review, and Escape flow #1975 design, which the issue left open to change. None of these places belongs to an ask, so the active ask, the one whose card shows "Esc to Deny", is the only ask Escape can mean there. Denying is the safe direction, since the agent can ask again. Keeping it also keeps the documented Escape order and a one-press deny from the composer, without moving focus into a card first.
  • The active ask's card and its detail panel still deny it, and a detail panel showing a different ask still closes (feat(studio): port the prototype's chat approval card, detail panel, and shortcuts #2251).
  • The Escape order: an open dialog or menu, then a text selection, the active ask (deny, or iterate a plan), the side panel, the run, and the draft. A selection inside another ask's card is still cleared first.
  • The double-Escape draft clear in the composer: one press shows the hint, and a released second press within half a second clears the draft.
  • A held Escape acts on nothing. The hook already ignored auto-repeat and a second keydown before the release; this PR pins that.

No regression

Pins first

62655918f adds tests only, before any product change. It passed on main (42b933fb4) and passes on this branch, unchanged.

chat-escape.cards.test.tsx (new, 6 tests) runs useChatEscape on a surface with the real approval and plan-review cards, as in the workspace and the side thread:

  • Escape from the active ask's card (two of its controls), the composer, a side panel that isn't an approval, or the page denies the active ask. With an active plan, it iterates the plan.
  • One layer per press: an open menu, a text selection, the active ask, the side panel, the run, then the draft (arm, then clear).
  • A held Escape (auto-repeat, or a second keydown before the release) iterates, denies, closes, and stops nothing, also from the active ask's own card.
  • An Escape that ends an IME composition does nothing.
  • Clearing the draft needs a released second press.

approval-interactions.test.tsx (1 test) runs the real workspace and side thread through the exact verdict route. With two pending asks, a held Escape in the active card posts nothing, and a press there denies ask 1. A press from outside every card then denies ask 2: from the workspace's composer, or from a thread control, because the thread's composer is disabled while its run waits.

The pins catch the guards they cover. Removing the repeat guard, the unreleased-key guard, or the IME guard, or moving the panel layer above the ask, fails them.

New tests

deebcd319 adds 5 tests with the fix.

In chat-escape.cards.test.tsx:

  • Focus in the second ask's card, on each of its four buttons with two presses each: nothing is denied, and the side panel, the run, and the draft stay as they were. From the active card, Escape still denies ask 1; the second card is then the active one and denies ask 2.
  • Every pairing with a plan: an active plan with focus in an ordinary card, an active ordinary ask with focus in a plan card, two plans, and an active plan whose control is unavailable (no "unavailable" message from another card). From the composer, each press still acts on the active ask.
  • A text selection inside another ask's card is still cleared first.

In approval-interactions.test.tsx:

  • On the workspace and the side thread, with two pending asks and focus in the second card (Raw arguments, Allow once, Deny), Escape posts nothing: no verdict for ask 1 or ask 2, and no stop. Both cards keep every verdict enabled. Escape from the first card then posts one deny, for ask 1.
  • With an ordinary ask active and a plan card pending, Escape from the plan card (Raw arguments, Iterate) posts nothing. From the ordinary card it denies that ask, and the plan card then shows "Esc to Iterate".

Mutation proof

With every test in place, the product files were put back to main's version, all together and then one at a time:

Reverted to main Failing Passing
All three product files the 5 new tests 25, every pin included
chat-escape.ts only the 5 new tests 25
plan-review-card.tsx only the 2 plan-card tests 28
approval-panel.tsx only 7: three hook pins, the integration pin, and three new tests 23

The last row shows the pins also guard the fix: without the active card's mark, the hook would treat the active ask's own card as another card, and Escape would stop denying from it.

Existing tests

No existing test was modified or deleted, and all pass with their assertions unchanged. That includes chat-escape.test.tsx, approval-shortcuts.test.tsx, approval-panel.test.tsx, plan-review.test.tsx, the rest of approval-interactions.test.tsx (#2251's "closes a detail panel on Escape instead of denying a different ask" among them), and the e2e/chat-approval.spec.ts journeys.

The one helper change: sendAsks in approval-interactions.test.tsx takes an optional session id, defaulting to the one it used before, so it can drive the side thread. Its existing calls are unchanged.

Gates

All gates ran through the shared gate lock. This PR's base is #2331 (f4369bd0e), and this branch, the top of the stack, is 43f94d286.

Gate This branch (43f94d286)
Biome, typecheck, generated-artifact check pass: Biome 524 files; no drift
Server tests 27 files, 252 tests: 251 pass, 1 fails, and the failure is also on main (see #2331)
Web tests 178 files, 1,553 tests, all pass (#2331: 177 files, 1,541 tests)
Browser (task studio:browser) 170 tests: 132 passed, 38 skipped

The server failure is routes/knowledge.test.ts, which main fails at 4aa238f3c too; #2355 fixes it. After the rebase this PR changes no Markdown, so task docs does not apply.

  • The branch adds 12 web tests (7 pins and 5 new tests) in one new file and one existing file, and changes no other test or journey.
  • Every commit in this PR typechecks on its own.

Screenshots

Captured with a throwaway Playwright journey (Chromium, not committed) on the offline BFF fixtures in apps/web/e2e/fixtures.ts:

  • A loopback activity stream stays open, so both asks stay pending.
  • The clock is fixed at 2026-09-25 12:30 UTC, the time zone is Europe/Rome, and the locale is en-US.
  • Every frame is at desktop 1280×800 and phone 390×844, in light and dark. The "both cards" crops come from a taller viewport (1280×1150 and 390×1500), so both cards fit whole and stay legible.
  • Before is main (42b933fb4) and after is 27c6e6afc, this PR's head before the stack rebase; the rebased 43f94d286 carries the identical patch, without the studio.md sentence that docs(studio): shrink the Escape section to what the app does not show #2314 removed. Each tree was captured twice. The two runs matched pixel for pixel, apart from 22 and 32 px in two Before phone frames.
  • Red boxes mark regions where Before and After differ by at least 40 px.

The journey also logged the verdicts each press posted. Across both runs, all 16 Before journeys posted deny for the first ask when Escape was pressed in the second card, and all 16 After journeys posted nothing.

The Prototype column is the prototype (stack-08) with the same two asks. The prototype renders only the first pending ask as a card, with a "1 of 2" badge, so it has no second card to press Escape in. Its column shows that card in both Escape frames.

Escape in the second card

Just before Escape

Focus is on the second card's Raw arguments toggle, with its focus ring. The first card is the active ask: it shows the Y, W, and N keycaps and "Esc to Deny". Before and After are identical, pixel for pixel, because the fix changes nothing until the key is pressed. Deliberate difference from the prototype: Studio shows every pending ask as its own card, while the prototype shows only the first, with a "1 of 2" badge. The card itself is #2251's port of the prototype's card.

Just before Escape, both cards, desktop light

Dark, phone, and the whole page

Both cards, desktop, dark:

Just before Escape, both cards, desktop dark

Both cards, phone, light:

Just before Escape, both cards, phone light

Both cards, phone, dark:

Just before Escape, both cards, phone dark

Whole page, desktop, light:

Just before Escape, desktop light

Whole page, desktop, dark:

Just before Escape, desktop dark

Whole page, phone, light:

Just before Escape, phone light

Whole page, phone, dark:

Just before Escape, phone dark

After Escape

  • Before: Escape denied the first ask, which isn't the request the reader was looking at. Its card is gone, "Permission deny recorded." shows (in the whole-page frames), and the second card becomes the active ask.
  • After: nothing changes. Both asks stay pending, and focus stays in the second card.

In the whole-page frames, two of the small boxes, on the Stop button and the composer placeholder, are anti-aliasing after the transcript re-renders. The third is on the minimap rail, which has one marker fewer in Before. The prototype column repeats its one card. Deliberate difference from the prototype: the prototype's Escape denies its one visible ask from anywhere on the page, even while typing. Studio's Escape answers only from the active ask's card or from outside every card.

After Escape, both cards, desktop light

Dark, phone, and the whole page

Both cards, desktop, dark:

After Escape, both cards, desktop dark

Both cards, phone, light:

After Escape, both cards, phone light

Both cards, phone, dark:

After Escape, both cards, phone dark

Whole page, desktop, light:

After Escape, desktop light

Whole page, desktop, dark:

After Escape, desktop dark

Whole page, phone, light:

After Escape, phone light

Whole page, phone, dark:

After Escape, phone dark

Keyboard shortcuts page

The last paragraph of the "Escape in a chat" card replaces "A detail panel showing another request closes on Escape." with "Escape closes a detail panel showing another request and does nothing in another request's card." Deliberate difference from the prototype: the prototype has no "Escape in a chat" card. Its only Escape description is the General card's Esc row, shown in its column.

On the phone page frames, the box covers the whole card: the new sentence adds a line, and the centered card moves with it. The card crops box only the changed lines.

Keyboard shortcuts, Escape in a chat card, desktop light

Dark, phone, and the whole page

Card, desktop, dark:

Keyboard shortcuts card, desktop dark

Card, phone, light:

Keyboard shortcuts card, phone light

Card, phone, dark:

Keyboard shortcuts card, phone dark

Whole page, desktop, light:

Keyboard shortcuts, desktop light

Whole page, desktop, dark:

Keyboard shortcuts, desktop dark

Whole page, phone, light:

Keyboard shortcuts, phone light

Whole page, phone, dark:

Keyboard shortcuts, phone dark

Closes #2258
Part of #2210

🤖 Generated with Claude Code

@peppescg
peppescg force-pushed the fix/studio-escape-active-card-2258 branch from 0f6c6de to 43f94d2 Compare October 15, 2026 13:12
Base automatically changed from feat/studio-provider-display-names-2260 to main October 15, 2026 13:20
peppescg and others added 3 commits October 15, 2026 15:20
…approval cards

Pin how Escape behaves today on a chat surface that shows approval cards,
before Escape learns to tell the active ask's card from another ask's card.
The hook tests render the real approval and plan-review cards:

- One layer per press: an open menu, then a text selection, the active ask
  (deny, or iterate a plan), the side panel, the run, and the unsent draft.
- Escape from the active ask's card, the composer, a non-approval side
  panel, or the page denies the active ask, or iterates the active plan.
- A held Escape (auto-repeat, or a second keydown before the release) and an
  Escape that ends an IME composition act on nothing.
- Clearing the draft needs a released second press.

The workspace and side-thread test pins the same deny through the real
surfaces and the exact verdict route. sendAsks takes an optional session
id, defaulting to the one it used before, so it can drive the side thread.

Refs #2258

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…tive ask

With two or more pending asks, Escape from inside a card that isn't the
active ask's denied the active ask: a request other than the one the
reader was looking at.

Escape now answers no ask from another ask's card. Every pending ask's
card is marked data-approval-scope, and the active ask's card is also
marked data-active-ask. useChatEscape returns at the ask layer when the
press comes from a card without that mark. The card's own ask isn't
answered either: it isn't the active ask, so no key answers it, which
matches #2251's detail panel for such an ask, where Escape only closes.

The plan-review card is marked the same way, so Escape from a plan card
that isn't the active ask's neither denies the active ask nor iterates
the active plan.

Unchanged: from the active ask's card, the composer, a side panel that
isn't an approval, or the page, Escape still denies the active ask or
iterates the active plan. An open menu and a text selection still come
first, the double-Escape draft clear works as before, and a held Escape
still acts on nothing.

Tests cover two asks with focus in the second card (nothing is posted for
either ask, on the workspace and the side thread), a plan card that isn't
active, every ordinary and plan pairing at the hook, and a selection that
still clears from another card. They fail without the fix.

Closes #2258

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The Keyboard shortcuts page said only that Escape denies the active
request and closes a detail panel showing a different one. It now says,
in one sentence, that Escape does nothing in the card of a different
request or plan review. The Studio guide defers the full Escape order to
that page, so it needs no change.

Refs #2258

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@peppescg
peppescg force-pushed the fix/studio-escape-active-card-2258 branch from 43f94d2 to 0afc125 Compare October 15, 2026 13:20
@peppescg
peppescg merged commit e806207 into main Oct 15, 2026
30 of 31 checks passed
@peppescg
peppescg deleted the fix/studio-escape-active-card-2258 branch October 15, 2026 13:42
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Oct 20, 2026
2 tasks
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.

Studio chat: Escape inside a non-active approval card denies the active ask

2 participants