Skip to content

feat(sdk): a ready-made shortcuts sheet in patchy/hotkeys - #1107

Merged
allisonmahmood merged 3 commits into
mainfrom
feat/hotkey-sheet-1093
Nov 1, 2026
Merged

allisonmahmood merged 3 commits into
mainfrom
feat/hotkey-sheet-1093

Conversation

@allisonmahmood

@allisonmahmood allisonmahmood commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

What changed

Agents adding shortcuts each built their own ? sheet from useHotkeyList: every one looked different, and each cost the builder time. patchy/hotkeys now ships one. <HotkeySheet /> puts a ? button on the page and opens a shortcuts sheet, in the company look, that lists the patch's labelled hotkeys by group. While it is open the page's hotkeys wait; Escape, its close button or a tap outside closes it, and focus goes back.

Closes #1093. Stacked on #1098 (base feat/hotkeys-1092).

Look at

1. The sheet, direction A from the mock round. A demo patch published to a throwaway pnpm dev up team instance at this commit, with ? pressed. The Patchy look is on an emulated Mac (⌘); the company look is the dark linear fixture, on Linux (Ctrl).

Patchy look, desktop

Company look, desktop

Company look, desktop

Patchy look, phone Company look, phone
Patchy look, phone Company look, phone

At phone width it rises from the bottom edge with its own scroll, and its close button becomes a 44px "Close". The demo page's own header wraps the ? button onto a second row in the Patchy phone shot; that is the demo's CSS, not the sheet.

2. Customizing stays two additions.

import { HotkeySheet, useHotkey } from "patchy/hotkeys";

useHotkey("G H", goHome, { label: "Go home", group: "Navigation" });

<HotkeySheet />
<HotkeySheet title="Tracker shortcuts" hotkey="Mod+/" />

hotkey is checked like useHotkey's: <HotkeySheet hotkey="Ctrl+/" /> fails typecheck with 'Ctrl+/' isn't a chord: write 'Mod+/', which is ⌘ on a Mac and Ctrl elsewhere. Named groups list in first-seen order; ungrouped hotkeys, the sheet's own "Show shortcuts" included, come last under General; with no groups it is one list with no heading. Anything else is still a sheet of the builder's own from useHotkeyList, which now carries group.

3. Closing never waits on the dialog's close event. The sheet is a native <dialog> opened with showModal(), which brings the top layer, an inert page and focus restore. The first browser run caught Chrome firing close late: after a click on the close button it arrived only with the next keydown, so the sheet's HotkeyScope stayed mounted and swallowed that key. Now the sheet's state is the source of truth. The close button, a click on the scrim and the dialog's synchronous cancel (Escape) close it, and unmounting calls dialog.close(), which returns focus. The browser spec presses a page hotkey right after each way out.

Decisions worth a glance:

  • Escape closes through the dialog's own cancel, with no scoped Escape hotkey, so it stays out of the list. TanStack's code settles the two questions this hinged on: a scope holds the page's hotkeys back whether or not it registers any, and a held-back match doesn't cancel the key's default. So a page's own Escape hotkey waits and the dialog still closes; the spec has one.
  • Styles. The SDK ships no CSS files; a page's look reaches it as patchy/_generated/look.css, which the build inlines. So the first sheet mounted adds one <style> to <head>, in @layer patchy-hotkeys. It lands after the look's @layer look, so it beats the look's button and h2 styles, and the patch's own unlayered CSS beats it. <HotkeySheet /> stays one line with no import to remember, and the frame's CSP allows inline styles. It reads only --look-* tokens, each with a system colour when a page has no look, and nothing animates.
  • Tab stays on the close button, the dialog's only stop; otherwise it leaves the frame for Patchy's bar.
  • The opener's accessible name follows title, "Keyboard shortcuts" by default, so it names the dialog it opens.
  • A single list narrows the card to one column's width.

How it was verified

  • packages/patchy/src/hotkeySheet.test.ts: groups in first-seen order, ungrouped last under General (joining a named General), one unnamed list when nothing has a group.
  • packages/patchy/src/hotkeys.test.ts: the published declarations accept group and HotkeySheet({ title, hotkey }), and refuse hotkey: "Ctrl+/" with useHotkey's message. <HotkeySheet hotkey="…" /> in JSX was checked by hand against the same declarations: Mod+/ passes, Ctrl+/ and Mod+Shift+K are refused.
  • test/browser-tier1/hotkeys.spec.ts adds the sheet in the published frame: ? opens it and focus moves to its close button; the listing by group with each hotkey's keys; the page's L, G H and Escape wait while it is open; Tab and Shift+Tab stay inside; Escape, the close button and a click on the scrim each close it, focus returns to where it was, and the next page hotkey fires at once. It failed on the late close event above before the fix.
  • pnpm check: format, lint, typecheck and synth pass. pnpm test: 2590 of 2605 pass. The 15 failures are CLI tests whose stub server received a stray GET / from a local port prober on this machine, a different set on a rerun, plus two load flakes that passed on rerun; none touch hotkeys.
  • pnpm test:postgres-concurrency: 28 passed. pnpm test:browser, the full tier 1 suite: 80 passed.
  • On Preact 11 (chore(deps): bump preact to 11.1.0 #975), after the stack was rebased: pnpm test:packed-preact-e2e passes. Opening and closing the sheet now run in a layout effect, so focus returns to the opener on close. The new export needs no change to the package build: it lives in the existing patchy/hotkeys entry, and its hooks share the page's Preact as useHotkey's do.

Release impact

  • Breaking — requires action from anyone already running this
  • Not breaking — no action required

Additive: a new export, a new optional hotkey option and a new optional field on ListedHotkey. Nothing server-side.

  • What does a revert leave behind? Published patches keep working, since a Helper is bundled into each patch. A repo that uses HotkeySheet or group and refreshes to a release without them fails its build until it drops them.
  • Does the release before it still work with that? Yes: no schema, wire or CLI change.

Built by Claude Opus 5.5 (claude-opus-5-5) in Claude Code, through T3 Code.

@github-actions github-actions Bot added area:server Touches the server area area:ci CI, shared testing infrastructure, development scripts and tooling area:cli Touches the cli area area:docs Touches the docs area size:l 501-1,000 changed lines labels Oct 30, 2026
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Sol review

Reviewed the stack diff against feat/hotkeys-1092, using #1093 and the decisions in #1086.

Standards

No merge-blocking findings. The props stay within the decided API, the skill describes mounting and customization without prescribing when to add a sheet, and the Release impact answers match the bundled-helper behavior.

Spec

[P2] Activate the exclusive scope before exposing the dialog — packages/patchy/src/hotkeys.ts:272–276. showModal() runs in a layout effect, while TanStack's HotkeysProvider activates its scope in a passive useEffect. There is therefore a window where the dialog is visible and its close button has focus, but the page's hotkeys still fire. In sandboxed Chromium and Firefox checks, dispatching L immediately after mounting the dialog ran the page's callback with no exclusive scope active. With a real keyboard press in Chromium, opening and immediately pressing Escape ran the page's Escape callback, prevented the default, and left the dialog open instead of reaching cancel. This breaks both the page-hotkey isolation and Escape requirements. Ensure the exclusive scope is active before the dialog opens, and cover a page key and Escape immediately after opening; the current browser test checks the full listing first, giving passive effects time to flush.

Validation: the package typecheck and all eight focused hotkey tests pass. JSX inference accepts valid chords/sequences and rejects invalid/reserved ones. Once scope activation has completed, focus trapping/restoration, all three closing paths, unmount cleanup, stacked sheets, immediate reopening, phone geometry and unlayered CSS overrides behaved correctly in Chromium and Firefox. WebKit could not launch because host libraries are missing. The expected dependency-age CI failure is excluded from findings; the policy was not changed. No checkout files were changed.

Standards: 0 blockers. Spec: 1 blocker, scope activation timing.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Fixed in f0c8b88. The P2 finding was right: the dialog opened in a layout effect, and TanStack switches the sheet's exclusive scope on in a passive effect, so a key that landed between the two reached the page.

Sheet now opens the dialog in a passive effect. That runs in the same synchronous pass as the provider's scope activation, so no key can land between them.

The browser test gains a step, "a key pressed the moment it opens waits too". It dispatches L from a MutationObserver as the dialog's open attribute appears, which is the earliest any key can arrive. Then it checks that the page's L didn't fire and that Escape still closes the sheet.

  • Before the fix the step fails: the page's L fires.
  • After the fix all three hotkeys browser tests pass in Chromium.

Locally, pnpm check passes format, lint, typecheck and synth. Its offline tests fail only in the CLI stub-request and execution tests: the CLI failures come from this machine's stray local-port probes, and the execution ones from load (#665). This stack doesn't touch either area.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Rebased onto #1098's Preact 11 fix, and focus returns again

I rebased onto 8de35be, the #1098 fix: HotkeyScope now holds its exclusive scope in a layout effect, so it is on from the commit that mounts it until the commit that removes it. On top of that rebase, this sheet test failed on Preact 11 for a reason of its own. Fixed in bee2675.

Cause. Sheet closed its dialog in a passive effect's cleanup. Preact 11 runs that after the next paint, by which point Preact has already removed the dialog from the page. A modal dialog that is closed after it has been removed returns focus to <body>, not to the element that opened it. In plain Chromium, close-then-remove leaves focus on the opener, and remove-then-close leaves it on BODY. The step "Escape closes it past the page's own Escape, and focus goes back" timed out waiting for #search to get focus.

Fix. The dialog opens and closes in a useLayoutEffect again. Preact runs that cleanup in the commit, before it removes the dialog. This undoes the passive open from cf5c016, which existed only so the dialog opened in the same pass as TanStack's passive scope activation. #1098 now activates the scope in the commit, so that gap is gone. The step "a key pressed the moment it opens waits too" still guards it.

Checks.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Acceptance: PASS with notes

Checked baa68ea (base d168798, #1098's head) on team, by Claude Opus 5.5 in Claude Code, through T3 Code.

Three of four fresh agents found HotkeySheet through the skill alone, without being told its name. Every sheet they published opened on the first ? with no click into the frame, in Chromium and Firefox. While it was open the page's hotkeys waited and Tab stayed inside. Escape, the close button and a scrim click each closed it, and focus went back. The fourth agent wrote its own sheet on purpose. Its brief asked for exactly two headings, and the ready-made sheet always adds a General heading for its own ? row (Note 1).

Done means

  • An agent adds the sheet in one line, and the patch gets a ? button and sheet in the company look listing its labelled shortcuts: passed.
    • Setup. I set the company look to the dark linear fixture, then gave four fresh Sonnet 5.5 agents a brief through the environment's agent launcher. Each repo's patchy-hotkeys skill was byte-identical to the head's, and all four read it.
    • The brief. It asks for a shared task tracker with G H, G D, a Mod+K search box, a C T add dialog and J/K/X, and for people to "press ? or click a button to see a sheet of all the shortcuts". It doesn't name a component.
    • Result. Both agents on that brief mounted <HotkeySheet />, and both grouped their hotkeys unasked.
    • Workspace. My two demo repos were in the same workspace. b2 listed their folders but read nothing in them.
  • While it's open the page's hotkeys wait. It closes on Escape or the close button, and focus goes back: passed, in every agent's sheet and in my demos (below), in both browsers.
  • Another agent changes its title and groups without writing its own sheet: passed, with Note 1.
    • The brief. Two agents got the same brief plus: title it "Tracker shortcuts" and list the shortcuts under Navigation and Tasks.
    • b2 used <HotkeySheet title="Tracker shortcuts" /> with group options.
    • b1 built its own from useHotkeyList: "The built-in sheet adds a third "General" heading for its own ? key, which would have broken your two-heading layout." The skill says exactly that, so it led b1 correctly.
Run Brief Sheet Heading Groups shown
a1 plain <HotkeySheet /> Keyboard shortcuts Navigate · Tasks · General (Show shortcuts)
a2 plain <HotkeySheet /> Keyboard shortcuts Navigate · Tasks · General
b1 title, two headings its own, from useHotkeyList Tracker shortcuts Navigation · Tasks
b2 title, two headings <HotkeySheet title="Tracker shortcuts" /> Tracker shortcuts Navigation · Tasks · General

I opened each tracker as Ben. Chromium and Firefox gave the same results:

Run First ? G D, J, X, C T while open Tab, Shift+Tab Escape G D at once after ? button, then close button Scrim click
a1, a2, b2 opens; focus on the close button page unchanged stay on the close button closes; focus back on the body it came from switches view focus in, then back on ? closes; focus on ?; G D fires
b1 (own sheet) opens page unchanged Chromium: focus leaves the frame. Firefox: Shift+Tab comes back Chromium: doesn't close, as focus had left. Firefox: closes Firefox only no ? button not checked

After C T's own dialog closed, ? opened the sheet again in a1, a2 and b2.

Dialog behaviour on Preact 11

I tested two demo patches of my own, in both browsers. The first has groups and the page's own Escape hotkey. The second has title="Tracker shortcuts" hotkey="Mod+/" and no groups. Every line below held in Chromium and Firefox.

Trace, demo one (Chromium; Firefox identical)
? opens: focus on BUTTON.hotkey-sheet-close
dialog named "Keyboard shortcuts" through aria-labelledby; :modal true
listing: Navigation [Go home G then H, Go to timeline G then T] · Tasks [Create task C then T, Log a thing L] · General [Show shortcuts ?, Search tasks Ctrl K]
document.getAnimations() while open: 0; transition 0s, animation none
while open, page keys fired: []; Tab, Tab, Shift+Tab focus: close button each time
Escape closes: page's own Escape didn't fire; focus back on BODY; L pressed at once fired ["L"]
? then L back to back: open, fired []
L dispatched as the open attribute appears: fired []
? then Escape back to back: closed, fired []
L dispatched the moment it closes: fired ["L"]
button opens: focus on the close button; close button closes: focus back on the ? button; L at once fired ["L"]
scrim click closes: focus back on the ? button; L at once fired ["L"]
  • Demo two. Ctrl+/ opens "Tracker shortcuts", a single list with no heading: Show shortcuts Ctrl /, Next task J, Previous task K. The card narrows to 448px. Every other line held there too.
  • Focus return. Focus came back to the body when the sheet opened from the body, and to the ? button when it opened from the button. CI's browser spec covers a page button focused before ?, and it passes.

Looks against mock A

  • Desktop. A centred card with groups as columns, and an Esc keycap as the close button.
    • The Patchy look gives it a hard border and shadow.
    • linear gives it its dark surface, hairline borders and Inter.
  • Phone width (390px). A bottom sheet with its own scroll, and a 44px "Close" word button. A tap on the scrim closes it, and so does a tap on Close, in both browsers and both looks.
  • Patch CSS. The patch's own unlayered .hotkey-sheet { border-color: rgb(220, 38, 38) } wins over the layer: the computed border is rgb(220, 38, 38).
  • Animation. None, and no transitions.
Patchy look, phone linear, phone
Patchy look, phone linear look, phone

Patchy look, desktop

linear desktop, an agent's sheet (b2) and the CSS override

linear look, desktop

b2's Tracker shortcuts in the linear look

Patch CSS overriding .hotkey-sheet's border, single list

Types

I typechecked a fresh patch repo against the head's SDK.

  • Accepted. <HotkeySheet />, title="Tracker shortcuts" hotkey="Mod+/" and hotkey="G S" typecheck. Shift+/ passes too, as useHotkey("Shift+/") does.
  • Refused, with useHotkey's messages:
src/probe.tsx(5,34): error TS2322: Type '"Ctrl+/"' is not assignable to type '"'Ctrl+/' isn't a chord: write 'Mod+/', which is ⌘ on a Mac and Ctrl elsewhere"'.
src/probe.tsx(6,34): error TS2322: Type '"Mod+Shift+K"' is not assignable to type '"'Mod+Shift+K' is kept by Patchy for its own shortcuts: choose another chord"'.
src/probe.tsx(8,34): error TS2322: Type '"Esc"' is not assignable to type '"'Esc' isn't a chord: write keys like 'Mod+K', 'Escape', '?' or 'G H', modifiers in the order Mod, Alt, Shift"'.
  • group. useHotkeyList()[0]?.group types as string | undefined, and a numeric group is refused. At runtime the groups reach the listing above. The PR's unit tests (hotkeySheet.test.ts, hotkeys.test.ts) pass: 5 of 5.

Golden journeys

  • Publish a page: passed. Ada's CLI and her agents published seven patches, and Ben opened each one and its sheet.
  • The rest: not touched. The change is SDK-only, with no server, API or CLI change. CI's browser and tier2-smoke pass on the head.

CI on baa68ea: every check passed. pidgeon-suite was still running when I posted, and attio-live was skipped.

Rollback answers: they match the diff.

  • The diff has no migration and no wire, CLI or infrastructure change.
  • A revert leaves published patches working, since the helper is bundled into each one.
  • A repo that uses HotkeySheet or group and refreshes to the older release fails its build until it drops them, the same as feat(sdk): patchy/hotkeys gives patches keyboard shortcuts #1098.
  • No one-way label is needed.

Not run

  • A real Mac (⌘ keycaps) and WebKit: there is no Mac here, and WebKit doesn't launch on this host.
  • A screen reader: I checked names through role and name queries only.

Notes

  1. The sheet's own row can't be grouped. Once any hotkey has a group, the sheet's own "Show shortcuts" row always lands under General, and nothing can move it.
    • One of the two agents asked for exactly two headings wrote its own sheet because of it.
    • This is mock A's decided behaviour and the skill states it, so it isn't a defect.
    • If "title and groups without writing its own sheet" should also cover a builder who wants only their own headings, a way to place that row would close the gap, for example a group prop on the sheet.
  2. The hand-built sheet shows what the ready-made one saves. In b1's sheet in Chromium, Tab took focus out of the frame, and Escape then stopped closing it.
    • The skill says a different sheet goes inside a HotkeyScope. It doesn't say the sheet must keep Tab inside and give focus back.
    • Outside this PR. It could be a line in the skill.
  3. A drag can close it. A drag that starts on the card, such as selecting a label, and ends on the scrim closes the sheet in both browsers. The click lands on the dialog, which is their common ancestor. A nit: checking where the pointer went down would fix it.
  4. A patch's element styles reach the sheet too. Unlayered element rules restyle it as well as deliberate hotkey-* overrides. a2's own kbd rule set the sheet's keycaps in its mono face. It looked on-brand there, and the README describes this behaviour.

allisonmahmood and others added 3 commits November 1, 2026 01:19
<HotkeySheet /> renders a ? button and a modal sheet that it and ? open,
listing every labelled hotkey under its new group option, in the company
look. While it is open the page's hotkeys wait; Escape, its close button
or a click outside closes it, and focus returns. title and hotkey
customize it; useHotkeyList still builds any other sheet.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…it opens

The dialog opened in a layout effect, while TanStack switches the sheet's
exclusive scope on in a passive one, so a key pressed in between reached
the page. Opening it in a passive effect puts both in the same pass.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The sheet closed its dialog in a passive effect's cleanup. Preact 11 runs
that after the next paint, once the dialog has left the page, and a modal
dialog closed after its removal returns focus to the body, not to where it
was. The dialog now opens and closes in a layout effect, which Preact runs
in the commit, before it removes the dialog.

The sheet opened in a passive effect only so that it opened in the same
pass as TanStack's scope activation. HotkeyScope now holds its scope from
the commit, so opening the dialog in the layout phase leaves no gap; the
"a key pressed the moment it opens waits too" step still passes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@allisonmahmood
allisonmahmood merged commit d5a7862 into main Nov 1, 2026
23 checks passed
@allisonmahmood
allisonmahmood deleted the feat/hotkey-sheet-1093 branch November 1, 2026 00:33
allisonmahmood added a commit that referenced this pull request Nov 1, 2026
## What changed

This adds release 33's What's new entry, written from `d5a7862`. It
covers everything merged since release 32's `through` (`58d94b3`). It
also sets the `patchy` release to `0.33.0` in
`packages/patchy/package.json` and `CURRENT_RELEASE`.

| Change | PRs |
| --- | --- |
| New: patches can have keyboard shortcuts that work as soon as the
patch opens, and `?` opens a sheet listing them in the company's look.
Repos pick it up at their next refresh | #1098, #1107 |

#1146 is release 32's own entry. The shortcuts and the sheet are one
change: the sheet lists the shortcuts and has nothing to show without
them.

## Look at

- **The entry**, at the top of `releases` in
`packages/core/src/whatsNew.ts`.
- **Rollback safety, from the live commit `3f4a842` (release 32) to
`d5a7862`:** #1098 and #1107.
  - **#1098 is labelled `one-way`.** Its answers hold:
- Published patches keep working on a rollback, because the helper is
bundled into each page.
- Refresh and `patchy dev` keep working, because release 32 carries
#1099. Generation there leaves out the `patchy-hotkeys` skill it doesn't
know, and the CLI removes the folder.
- A repo whose page imports `patchy/hotkeys` can't build a new version
until production rolls forward.
- **#1107** is additive: a new export and an optional option. A repo
that uses `HotkeySheet` or `group` can't build on the older release
either.
  - This is why #1099 went out alone in release 32 first.

**Rollback line:** If this release misbehaves, roll back to `3f4a842`
(release 32). Published patches keep working; a repo whose page imports
`patchy/hotkeys` can't publish a new version until production rolls
forward again.

## How it was verified

- **Tests.** `whatsNew.test.ts`, `schemas.test.ts` and
`WhatsNewPages.test.ts` pass (21 tests), and prettier passes on the
changed files.
- **The range.**
- **Sol reviews.** #1098 and #1107 were each reviewed by GPT 6.1 Sol,
with re-checks after the Preact 11 fixes. Every finding was resolved.
- **#1098's acceptance passed with notes** on its third round. The first
two failed on the skill: fresh agents misplaced a dialog's Escape, then
used `autofocus`. The third round's agents built trackers that work
entirely from the keyboard.
  - **#1107's acceptance passed with notes.**
- **Checks.** Each landed with all 12 required checks green on its final
head.
- **Not done:** Allison's Edge and real-Mac Mod+Shift+K checks, recorded
as a human gate in #1098's body. CI covers Chromium on Linux and an
emulated Mac.
- **Deploy state.** The live commit, pinned from `/healthz/deep`, is
`3f4a842` (release 32). The Deploy run updated last succeeded, and none
is unfinished.

## Release impact

- [ ] **Breaking** — requires action from anyone already running this
- [x] **Not breaking** — no action required

Text and version numbers only. The `0.33.0` bump tells CLIs and patch
repos installed before this deploy to upgrade, as every release does.

- **What does a revert leave behind?** Nothing.
- **Does the release before it still work with that?** Yes.

Built by Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, through T3
Code.

Co-authored-by: Claude Opus 5.5 <[email protected]>
allisonmahmood added a commit that referenced this pull request Nov 11, 2026
## What changed

The `patchy-hotkeys` skill said a shortcuts sheet of your own is built
from `useHotkeyList` and `hotkeyKeys` inside a `HotkeyScope`, and
stopped there. It didn't say the sheet is a dialog. In #1107's
acceptance, an agent's hand-built sheet let Tab leave the patch's frame,
and Escape then stopped closing it.

The skill now states two things:
- **Under Native `<dialog>`,** once, the limit every modal dialog in a
patch has. `showModal()` makes the patch's page inert, but not Patchy's
page around the frame. Tab past the dialog's tabbable elements leaves
the frame for the shell's controls or the browser's, and the keys
follow, so Escape can stop reaching the dialog. A modal dialog in a
patch therefore keeps Tab among the tabbable elements it has when the
key is pressed, or on itself when it has none. The same paragraph
corrects focus return: closing returns focus only to an element still in
the page, and otherwise focus falls to the body.
- **In the sheet section,** what a hand-built sheet must do. Focus moves
in as it opens, Tab stays inside, and Escape closes it. Closing puts
focus back where it was, or, if that element has gone, in its dialog or
on the page. The bullet also says when `HotkeySheet`, which already does
all of this, is the better choice.

Closes #1137

## Look at

**The two passages.**

Under Native `<dialog>`:

> The open state is the parent's: the dialog opens as it mounts and
closes as it unmounts, which returns focus to where it was while that
element is still in the page; if it has gone, focus falls to the page's
body. […]
>
> `showModal()` makes the patch's page inert, not Patchy's page around
its frame. Tab past a modal dialog's last tabbable element, Shift+Tab
before its first, or either in a dialog with none, leaves the frame for
the shell's controls or the browser's. Keys then go where focus went, so
Escape can stop reaching the dialog, which stays open. So a modal dialog
in a patch keeps Tab and Shift+Tab among the tabbable elements it has
when the key is pressed, and on the dialog itself while it has none.

In the shortcuts sheet section:

> - A sheet of your own is a modal dialog built from `useHotkeyList` and
`hotkeyKeys` inside a `HotkeyScope`. Focus moves into it as it opens,
Tab stays inside it as under Native `<dialog>`, and Escape closes it.
Closing puts focus back where it was, or, when that element has gone, in
the dialog it was in, or on the page. `HotkeySheet` already does all of
this and runs each command from its button or its keys; build your own
when its listing or look won't do.

**Before and after, in a scratch tier 1 patch, in Chromium and
Firefox.** I built hand-made sheets as `<dialog>`s that list
`useHotkeyList` rows with `hotkeyKeys` keycaps inside a `HotkeyScope`.
Each opens and closes as under Native `<dialog>`, and Escape closes it
through `onCancel`.
- **Old:** the old wording, with nothing else.
- **New:** the new wording. Tab and Shift+Tab move among the dialog's
tabbable elements, found on each key press, or stay on the dialog when
it has none. When the opener has gone, closing focuses the dialog it was
in.
- **Ends found at open:** Tab wrapped between endpoints worked out once
as the sheet opens. This was the natural reading of this PR's first
wording.

The shell had either nothing else focusable, so focus could only go to
the browser, or a button I added to the shell page beside the frame,
standing in for Patchy's bar.

| Case | Old, Chromium | Old, Firefox | New, both browsers |
| --- | --- | --- | --- |
| Filter field and Close button; Tab past Close | leaves for the
browser; Escape: **stays open** | leaves for the browser; Escape closes
| wraps to the field; Escape closes; focus back on the opener |
| The same, with a button in the shell page | lands on the shell button;
Escape: **stays open** | lands on the shell button; Escape: **stays
open** | wraps to the field |
| Shift+Tab before the field, with a button in the shell page | lands on
the shell button; Escape: **stays open** | visits the dialog, then the
shell button; Escape: **stays open** | wraps to Close |
| No controls, labels only; Tab or Shift+Tab | leaves for the browser or
the shell button; Escape: **stays open** | leaves; with the shell
button, Escape: **stays open** | focus stays on the dialog; Escape
closes |
| A row added while open is clicked, then Tab | leaves; Escape: **stays
open**. Ends found at open leak the same way | leaves; with the shell
button, Escape: **stays open**. Ends found at open leak the same | wraps
to the first row |
| Sheet opened from a button in a task dialog; that button removed;
Escape | focus on `body`, the task dialog still open | the same | focus
on the task dialog |

So the loss of Escape isn't Chromium's alone. Firefox keeps Escape only
when focus goes to the browser itself.

<details><summary>Probe traces</summary>

Chromium:

```
controls, old, nothing else in the shell
  Tab x3: field | Close | LEFT for the browser | LEFT for the browser | Escape: sheet STILL OPEN
  Shift+Tab x3: field | LEFT for the browser | LEFT for the browser | Close (came back round) | Escape: closed
controls, old, a button in the shell page
  Tab x3: field | Close | LEFT for shell-after | LEFT for the browser | Escape: sheet STILL OPEN
  Shift+Tab x3: field | LEFT for shell-before | LEFT for the browser | LEFT for shell-after | Escape: sheet STILL OPEN
controls, new (either shell)
  Tab x3: field | Close | field | Close | Escape: closed, focus on the opener
  Shift+Tab x3: field | Close | field | Close | Escape: closed, focus on the opener
none, old, a button in the shell page
  Tab x2: dialog | LEFT for shell-after | LEFT for the browser | Escape: sheet STILL OPEN
  Shift+Tab x2: dialog | LEFT for shell-before | LEFT for the browser | Escape: sheet STILL OPEN
none, new (either shell)
  Tab x2 and Shift+Tab x2: dialog | dialog | dialog | Escape: closed, focus on the opener
rows, old / ends found at open, a button in the shell page
  clicked "Late command" | Tab: LEFT for shell-after | Escape: sheet STILL OPEN
rows, new
  clicked "Late command" | Tab: "Show shortcuts" row | Escape: closed, focus on the opener
opener gone, old:  Escape: closed, focus on body | task dialog still open
opener gone, new:  Escape: closed, focus on dialog#task | task dialog still open
```

Firefox:

```
controls, old, nothing else in the shell
  Tab x3: field | Close | LEFT for the browser | LEFT for the browser | Escape: closed
  Shift+Tab x3: field | dialog | LEFT for the browser | LEFT for the browser | Escape: closed
controls, old, a button in the shell page
  Tab x3: field | Close | LEFT for shell-after | shell-after | Escape: sheet STILL OPEN
  Shift+Tab x3: field | dialog | LEFT for shell-before | shell-before | Escape: sheet STILL OPEN
controls, new (either shell)
  Tab x3 and Shift+Tab x3: field | Close | field | Close | Escape: closed, focus on the opener
none, old, a button in the shell page
  Tab x2: dialog | LEFT for shell-after | shell-after | Escape: sheet STILL OPEN
  Shift+Tab x2: dialog | LEFT for shell-before | shell-before | Escape: sheet STILL OPEN
none, new (either shell)
  Tab x2 and Shift+Tab x2: dialog | dialog | dialog | Escape: closed, focus on the opener
rows, old / ends found at open, a button in the shell page
  clicked "Late command" | Tab: LEFT for shell-after | Escape: sheet STILL OPEN
rows, new
  clicked "Late command" | Tab: "Show shortcuts" row | Escape: closed, focus on the opener
opener gone, old:  Escape: closed, focus on body | task dialog still open
opener gone, new:  Escape: closed, focus on dialog#task | task dialog still open
```

"LEFT" means the frame's `document.hasFocus()` was false. `shell-before`
and `shell-after` are the buttons added to the shell page on either side
of the frame.

</details>

## How it was verified

- **The scratch patch.** It was a tier 1 repo initialized against this
checkout's local instance. I checked it with Playwright under `patchy
dev`, which serves the production shell's frame, CSP and sandbox, in
Chromium and Firefox. I didn't publish it. Patchy's bar isn't on the
`patchy dev` page, so a button added to the shell page stood in for it.
- **Delivery.** `patchy refresh` in the scratch repo reported
`"skills":["patchy-hotkeys"]`. Its copy of the skill is now
byte-identical to `packages/sdk/skills/patchy-hotkeys/SKILL.md`.
- **Checks.** `pnpm format:check` and `pnpm lint` pass.
`packages/sdk/src/SdkApi.test.ts`, which packs and serves the project
skills, passes 22 of 22. No test or hash covers the project skill's
text: `skills-lock.json` hashes only the global `patchy` skill.
- **Not run.** `pnpm verify`, which CI runs. WebKit. No fresh agent
built a sheet from the new wording; acceptance covers that.

**Hit every surface.** These applied:
- **The CLI:** the project skill under `packages/sdk/skills`, served by
generation. No hash covers it, and refresh delivers it, as above.
- **`packages/patchy/README.md`:** its hotkeys part points to the skill
for the native `<dialog>` rules and doesn't describe a hand-built sheet,
so nothing there needs mirroring.

None of the others apply: no wire contract, dev loop, vocabulary,
migration, company resource, served page, reverse state or layout
change. `hotkeys.ts` needs no change: `HotkeySheet` already wraps Tab
over the buttons it has at each key press, always has its Close button,
and puts focus back in the dialog the viewer was in when the opener has
gone (`restore`, `rescue`).

**Left alone.** An SDK change that keeps Tab inside any open modal
dialog in a patch is a separate piece of work, to be filed. The Native
`<dialog>` example still shows only Escape handling.

## Release impact

- [ ] **Breaking** — requires action from anyone already running this
- [x] **Not breaking** — no action required

Skill text only. It reaches a patch repo at its next `patchy refresh` or
dev start. `patchChanges`: none. The text changes how a dialog or sheet
gets built, not how an existing patch behaves.

- **What does a revert leave behind?** Nothing. Repos refreshed in
between keep the newer text until their next refresh.
- **Does the release before it still work with that?** Yes.

Built by Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, through T3
Code.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ci CI, shared testing infrastructure, development scripts and tooling area:cli Touches the cli area area:docs Touches the docs area area:server Touches the server area size:l 501-1,000 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(sdk): a ready-made shortcuts sheet

1 participant