Skip to content

docs(sdk): a hand-built shortcuts sheet keeps focus inside it - #1256

Merged
allisonmahmood merged 1 commit into
mainfrom
docs/hand-built-sheet-dialog-1137
Nov 11, 2026
Merged

allisonmahmood merged 1 commit into
mainfrom
docs/hand-built-sheet-dialog-1137

Conversation

@allisonmahmood

@allisonmahmood allisonmahmood commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

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.

Probe traces

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.

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
  • 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.

@github-actions github-actions Bot added area:server Touches the server area area:docs Touches the docs area size:s Under 100 changed lines labels Nov 6, 2026
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Review (GPT 6.1 Sol, xhigh), on 788ced7: FAIL. The diagnosis is right, and so is wrapping Tab at both ends. The guidance still has gaps.

  • P1, packages/sdk/skills/patchy-hotkeys/SKILL.md line 347. Native <dialog> doesn't do "everything except keep Tab inside".
    • If the opener disappears while the sheet is open, closing the sheet can't send focus back to it. In a Chromium reproduction, closing and unmounting the sheet left focus on body, even though a modal underneath stayed open.
    • HotkeySheet handles this through restore and rescue in hotkeys.ts.
    • Suggested fact: closing returns focus to the opener if it's still there, otherwise to a sensible control in the dialog or page that remains.
  • P1, line 349, and the PR's "Look at". Losing Escape isn't Chromium-only.
    • Firefox 155 also leaves the dialog open when Tab moves focus to a button in the parent document. Firefox only behaves differently when focus goes to browser chrome: then Escape still reaches the frame.
    • Suggested wording: Tab can leave the frame for the shell's controls or the browser's; Escape may then stop reaching the dialog. This also drops the claim that focus always lands on "Patchy's bar".
  • P2, line 350. Wrapping at the first and last control leaves two cases open.
    • No controls at all. A sheet of labels only focuses the dialog itself, so Tab leaves the frame in either direction, and Chromium then loses Escape.
    • Rows added while open. Endpoints worked out once go stale when a row is added and clicked.
    • Suggested: keep Tab inside the current tabbable elements, newly added ones included; with none, focus stays on the dialog. HotkeySheet avoids both through its permanent Close button and a fresh button query on every key press.
  • P3, line 345. The new text repeats itself and drifts into a recipe. State the frame-wide limit once, under Native <dialog>. Keep this bullet to what a hand-built sheet must do, the APIs, and when to choose HotkeySheet.

Verified:

  • showModal() moves focus in and makes the frame's own document inert, but leaves the parent document interactive.
  • Chromium 153 leaks before the first control and after the last. Firefox 155 leaks too, sometimes visiting the dialog itself first.
  • WebKit couldn't launch here because system dependencies are missing.
  • Distribution and Release impact are sound: this is the canonical project skill, generation serves it, and refresh delivers it. It's not breaking, needs no patchChanges, and is safe to roll back.

The SDK question. Sol favours an SDK fix as well, as a separate change. A shared helper inside the patch would keep focus inside any open modal dialog. It would start from packages/patchy/src/preact/runtime.ts, replace the sheet's own handler, and later cover the HTML client too.

  • The parent broker can't do it, because it can't see inside the opaque sandbox.
  • The cost is one listener, plus browser coverage for tabbable discovery, nested dialogs, empty dialogs and widgets that own Tab.
  • Patches already published would need rebuilding.

It shouldn't block finishing this docs fix.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Review round 2 (GPT 6.1 Sol, xhigh), on 550713f: FAIL. All four round 1 findings are fixed, and there were three new wording findings.

Round 1, all fixed:

  • The opener gone: the text now says focus falls back to the dialog underneath or the page.
  • Escape outside Chromium.
  • A sheet with no controls, and rows added while it's open.
  • The repetition.

Round 2:

  • P2: the Native <dialog> section's example has no Tab containment, while the section's last paragraph requires it.
  • P3: focus returns only to an element that can still take focus. A disabled opener is still in the page, but focus falls to body.
  • P3: say that Tab "can" leave the frame. In Firefox, the first Shift+Tab from the first control focuses the dialog itself.

Sol verified these in Chromium 153 and Firefox 155, in a frame with production's sandbox and CSP.

Fixed in 2c216e2, using Sol's suggested wording:

  • the example is now introduced as showing opening and Escape, and points to the end of the section for keeping Tab inside;
  • focus returns "if that element can still take focus; if it has gone or is disabled, focus falls to the page's body";
  • Tab and Shift+Tab "can leave the frame".

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Now stacked on #1255 (fix/hotkey-sheet-scrim-drag-1136), so the shortcut work lands together with #1275.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Restacked onto main at 44acb65, in the chain main ← #1302 ← #1297 ← #1255 ← #1256 ← #1279 ← #1276 ← #1301. Every commit replayed cleanly: git range-diff shows each =, so the patch is byte-for-byte what was reviewed and accepted. The SDK's sheet (packages/patchy/src/hotkeys.ts and hotkeySheet.ts) is untouched on main since the base. The UI overhaul restyled Patchy's own pages, not the sheet a patch draws in its frame.

Nothing changed beyond the rebase.

Its own specs: none; this is skill text. At its head the SDK is #1255's, whose hotkeys.spec.ts passes as noted on #1255. CI is green apart from a stale install (${{ matrix.os }}) entry. That comes from a run cancelled when a later push superseded it, and the required install (linux|macos|windows) checks pass.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Re-chained onto main at c44e63f, without #1302, in the chain main ← #1297 ← #1255 ← #1256 ← #1279 ← #1276 ← #1301. Replayed unchanged: git range-diff shows every commit =.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Acceptance: PASS

I checked this PR as part of the six-PR chain at #1301's head 06476fe54aae64e52128c44709271f036fa2da59, which contains this head 9c7d11d472773c07e87783cc400b98250e0594cb, by Claude Opus 5.5 in Claude Code (T3 Code). The probes under check 10 of the full verdict cover its patchy-hotkeys text, in desktop Chromium with the frame isolated and in the headless shell. HotkeySheet kept Tab and Shift+Tab inside it across 14 presses, and Escape closed it. A bare showModal() dialog in the patch let Tab past its last button leave the frame, and Escape then missed it, leaving the dialog open: that's the failure the text tells builders of a sheet of their own to prevent. Every check on this head passed.

@allisonmahmood
allisonmahmood force-pushed the fix/hotkey-sheet-scrim-drag-1136 branch from e9329af to dbd9fea Compare November 11, 2026 18:02
Base automatically changed from fix/hotkey-sheet-scrim-drag-1136 to main November 11, 2026 18:15
@allisonmahmood
allisonmahmood force-pushed the docs/hand-built-sheet-dialog-1137 branch from 9c7d11d to 6d9e99b Compare November 11, 2026 18:16
@allisonmahmood
allisonmahmood merged commit 4f71367 into main Nov 11, 2026
26 checks passed
@allisonmahmood
allisonmahmood deleted the docs/hand-built-sheet-dialog-1137 branch November 11, 2026 18:28
allisonmahmood added a commit that referenced this pull request Nov 11, 2026
…h's sheet or the account menu (#1301)

## What changed

Speech input can type a letter that fires a patch's single-key shortcut.
#1224 lets each person turn those off. #1276 stores the choice and #1279
taught `patchy/hotkeys` to obey it, but nothing passed the choice to a
patch yet. Now Patchy's shell does:
- it names a viewer's patch frame with their setting;
- the shortcuts sheet's row opens Patchy's own dialog to change it;
- the account menu gets the same switch;
- a version built before the setting tells a viewer who turned shortcuts
off that its shortcuts still work.

This is the top of the stack `main ← #1297 ← #1255 ← #1256 ← #1279 ←
#1276 ← this`, and the six land together. #1302, CI's move to desktop
Chromium, waits on #1402 and lands later. It's restacked onto `main`
after the UI overhaul (#1332–#1354) and the switcher (#1298, #1304), and
ported to both. The restack comment says what changed beyond conflict
resolution.

Closes #1275
Closes #1224

## Look at

**1. The frame is named in the shell's static markup, not by a script
that creates it.** A parser-created iframe gets its `name` attribute
before its browsing context exists. So the server renders
`name="patchy:shortcuts=on|off"` on the existing static iframe, after
`main`'s `data-waiting`, and only for a company or local shell rendered
for its viewer (`shell.ts`, `Pages.ts`). A public shell is everyone's
document, a member's included since #1339, so it never carries one, and
`renderPatchWrapper` throws if asked to. Probed before choosing, in
Chromium and Firefox:

| Probe, a sandboxed frame whose `src` a deferred script sets | Chromium
| Firefox |
| --- | --- | --- |
| Static markup with `name`: first load, a reload after the value
changed, back after it changed | `off`, `on`, `on` | `off`, `on`, `on` |
| A `<template>` cloned by script, as the ticket's creator would | same
| same |

In desktop Chromium, where the frame runs in its own process, the patch
reads `window.name === "patchy:shortcuts=off"` on first load and after a
new version's Reload re-creates the frame. Static markup keeps three
things:
- **No inline script and no CSP change.** The shell still admits only
the switcher relay's hash.
- **Both mixed-release pairings work.** The markup is `main`'s plus one
attribute (and `data-shortcuts-note`), so an older broker mounts it
unchanged, and this broker mounts an older unnamed shell as before.
`render.test.ts` pins that the frame differs from the unnamed one only
by its name.
- **Every re-creation renders again.** A new-version reload is a fresh
server render.

**2. Patchy's dialog** (`packages/serving/src/shortcuts.ts`), from the
mock's direction C. A running patch's shell keeps its own pinned style
subset on `main` (`servedStyles`; the overhaul left patch shells alone).
So the dialog stays a `shell-scrim` over one `note-info` `note-float`,
with `glyph-sm`, the primary button and a quiet Cancel. The setting's On
or Off is a served `tag` after the question. The old `pill` isn't in
that subset, and `main`'s pin test would refuse it, so it's gone.

| | Desktop | Phone |
| --- | --- | --- |
| The sheet's row | ![The sheet with its Single-key shortcuts row
reading Off, and dashed
keycaps](https://github.com/user-attachments/assets/081d4f78-b123-40f3-a830-5ddcbd14fd2d)
| ![The sheet as a bottom sheet on a phone, its row reading
Off](https://github.com/user-attachments/assets/6b720ace-142a-4a84-a102-0deae6fd486e)
|
| Patchy's dialog | ![Patchy's dialog: Turn off single-key shortcuts in
every patch except public ones?, an ON tag, Turn off and
Cancel](https://github.com/user-attachments/assets/e90123d3-9e4f-47ec-babb-19534349f39a)
| ![The dialog centred on a
phone](https://github.com/user-attachments/assets/5e214a77-e990-4efe-a882-7f41efdd8cb9)
|
| A failed save | ![The dialog turned amber, saying Couldn't save.
Nothing changed., with Try
again](https://github.com/user-attachments/assets/ec24539c-2f35-4fd6-8a30-48d2f291b7c4)
| ![The failed save on a
phone](https://github.com/user-attachments/assets/d540007f-c910-4ac5-961b-b2b21c42181b)
|

The sheet is the SDK's, drawn in the patch's own frame by #1279, and
`main` hasn't touched it.

The copy and the failure pattern are as reviewed:
- The title says what the switch covers: "Turn off single-key shortcuts
in every patch except public ones?", or "Turn on …". The buttons are
**Turn off**, **Turn on** and **Cancel**.
- A refused save, a 200 without `{ value }` and an empty 200 all turn
the note `note-warn`, with the alert line "Couldn't save. Nothing
changed." and **Try again**.

The abuse rules, each a step of the browser spec:
- One dialog at a time.
- A question needs `navigator.userActivation.isActive` in the shell.
- However the dialog closes, it arms a flag: Turn off or Turn on,
Cancel, Escape, or the browser closing it, mid-save or not. The flag
holds new dialogs off until a 250 ms poll reads the old activation as
lapsed. So a request on the press that answered the last dialog gets the
value with no dialog, and only a fresh press opens another.
- Only an `isTrusted` click saves.
- Dismissing never waits. Cancel or Escape mid-save closes the dialog at
once and returns focus to the frame. The save keeps the one-dialog slot
until the route answers, and the operation then resolves with what the
route stored, or with the setting as it was if the save failed or timed
out after 35 s.
- While tier 2's tools are starting, a question gets the setting as it
is.
- **New with the switcher:** while Patchy's switcher is open, a question
also gets the setting as it is, as the starting cover waits for it. If
the switcher is open over the dialog when it closes, the dialog leaves
focus with the switcher, which hands it back.

**3. The account menu's switch**, a no-script form in `main`'s personal
menu: name, Your agents, the switch, Sign out. It posts the value it
switches to, with `return` set to the page. On the overhaul's component
set, the item is the switch: a `menu-item` with `role="switch"` and
`aria-checked`, the `keyboard` icon, and core's `switch` drawn at its
end in the item's state. Core's `fields` and `menus` chunks gained the
two selectors that draw it. The account menu is 248px wide, up from 220,
so the label stays on one line beside the switch.

| Before | Off | After the press: the receipt, and On |
| --- | --- | --- |
| ![The account menu with name, email, Your agents and Sign
out](https://github.com/user-attachments/assets/f1ba9ba2-2514-402a-a1bf-1f83643bbd7f)
| ![The account menu with the Single-key shortcuts switch
off](https://github.com/user-attachments/assets/171a45ef-a592-41a0-b810-09315d9013cb)
| ![The receipt Turned on single-key shortcuts, and the switch
on](https://github.com/user-attachments/assets/c4c0bfb2-71eb-4cfd-9661-dbf575eab48b)
|
| ![The phone menu
before](https://github.com/user-attachments/assets/e3c6daf1-7faf-4d7f-adc7-b80a9301fefc)
| ![The phone menu with the switch
off](https://github.com/user-attachments/assets/4c450fa9-8bea-4e0f-825c-66d74866f9ac)
| ![The phone menu after the press, the switch
on](https://github.com/user-attachments/assets/ea8ca452-812a-4804-9780-acc608bab291)
|

"Before" is this branch's page with the switch's form removed in the
browser, which is exactly `main`'s account menu. `ViewerApi.ts` reads
the form before the session, so a signed-out post that names `return`
goes back to that page, whose own door signs in there.

**4. D1's note.** The note shows to a viewer whose setting is Off, on a
version from 0.33.0 on that doesn't claim `shortcutSetting`, unless its
recorded imports leave out `patchy/hotkeys`.
- **Only a repo build claims `shortcutSetting: 1`**
(`MANIFEST_CAPABILITIES` in `@patchy/api`). A single HTML file may carry
an older SDK bundled inline, so it claims nothing.
- **Recorded imports refine D1's release rule.** A repo build without
`patchy/hotkeys` in `sdkImports` gets no note. A single file records no
imports, so the release rule decides: from 0.33.0 on, the note shows.
- The note reuses the new-version bar in the shared bottom stack: "This
patch's single-key shortcuts still work until it's updated." with a
quiet **Dismiss**, kept per patch in the shell's `localStorage`.

| Desktop | Phone |
| --- | --- |
| ![The note bar at the bottom over the 0.38 bundle: This patch's
single-key shortcuts still work until it's updated.
Dismiss](https://github.com/user-attachments/assets/456c09d9-7ca4-4d06-87d3-50df231178cb)
| ![The note as a bottom sheet on a
phone](https://github.com/user-attachments/assets/f312e473-d3c0-4e65-aa50-91a34fc7fca4)
|

**5. The flow**, desktop then phone. The sheet's row leads to Patchy's
dialog, Turn off brings the sheet back on its row reading Off, then the
account menu turns them back on.


https://github.com/user-attachments/assets/d604fe56-04cd-416c-83fa-42e4beebc2f0


https://github.com/user-attachments/assets/17f547e2-472b-4c2d-90ac-98884108c875

## How it was verified

- **Unit (vitest)**, with the rest of the stack's touched files: 35
files, 330 tests, plus core's style rules, gallery and served-style pin
(358 with `render.test.ts`):
- `render.test.ts`: the frame's name after `data-waiting` in static
markup, and that it is the only difference from an unnamed frame. A
public shell refuses a viewer's setting. `ignoresShortcutSetting`'s
cases.
- `html.test.ts`: the account menu's switch, its value, its `return`,
and escaping.
  - `ViewerApi.test.ts`: a signed-out form post goes back to its page.
- `devServer.test.ts`: each dev person's own setting, and the route,
which writes the file before it changes what shells read.
- `executeConfig.test.ts`: a repo build's manifest records
`shortcutSetting`.
- `served-styles.test.ts`: the served styles' digest moved on purpose,
for the one rule that keeps the dialog's tag whole.
- **The browser tier** (`test/browser-tier1/shortcut-setting.spec.ts`):
thirteen tests on published patches through the real shell and broker,
as reviewed. That includes the committed 0.38 bundle
(`hotkeys-0.38.html`), whose shortcuts still fire under this shell with
Off stored, with no row and with the note.

  | Engine | Result |
  | --- | --- |
| Desktop Chromium, `channel: "chromium"`, frame isolated, from a local
config | 13 passed |
  | Chromium headless shell, as CI runs it | 13 passed |

`hotkeys.spec.ts` and `focus.spec.ts` pass in both as well. Company
patches put the setting's row first in the sheet's Tab order. The
unnamed-frame test opens a public patch.
- **The whole tier 1 suite** at this stack's top (`06476fe`), as `pnpm
verify` runs it in CI's headless shell: 168 of 168. At the previous
push, with #1302's desktop project as well, it also passed 168 of 168.
- **The rollback rehearsal**, against the live release 41 (`7f93b91`):
`7f93b91 → 06476fe → 7f93b91 → 06476fe`, all four steps passed in 116 s.
It covers #1276's migration, and the live release serving a repo build
that this head's CLI wrote with `shortcutSetting`.
- `pnpm verify` at this head: format, lint, typecheck, synth,
postgres-concurrency, cli-smoke, install, tier2-smoke and browser pass.
`test` and `test (bun)` had 15 timeouts while the machine's load average
was near 30. All 11 files rerun alone pass (216 tests), as does Bun's
`PatchesApi` (63). The previous push's `pnpm verify` passed every step.
The served shell's page state is exempt from the page-markup rules in
`.oxlintrc.json`, and `shortcuts.ts` joins `stream-status.ts` and
`downloads.ts` there for the same reason.
- **Hit every surface.**
  - Wire contract: `docs/API.md` is regenerated and current.
- CLI: README, the `patchy-hotkeys` project skill and the capability
catalogue. No command, flag or exit code changed.
  - Dev loop: `docs/DEVELOPMENT.md` and the `patchy-dev-loop` skill.
- Vocabulary: the Companies and patchy glossaries, and
`docs/product.md`.
- Served pages: the `ui-consistency` spec names the menu's switch, the
dialog and note in the shell's exception, and `shortcuts.ts` in the lint
exemption.
  - Reverse states: the switch turns it back on from both places.
- Not applicable: migrations (#1276's), company resources and the repo
layout.
- **Not run on this head:** Firefox and WebKit. Firefox passed 12 of 13
before the port, the tier 2 test being Chromium-only. WebKit can't
launch here, and CI has no WebKit.

## Release impact

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

The release that carries this carries the whole stack. Nothing needs
action. A viewer's shortcuts stay on until they turn them off, and
patches published before it behave as they did until rebuilt.

Suggested `patchChanges` line for the release, beside #1279's:

> patchy/hotkeys: a viewer can now turn single-key shortcuts off. Then a
page-wide hotkey whose every step types a character, such as `A`, `G H`
or `?`, fires nothing, while chords, named keys and hotkeys `within` an
element still fire. Label those commands so the sheet keeps them as
buttons, and write a key that belongs to one part of the page `within`
it. `window.name` carries the setting and is Patchy's: don't set it.

Landing note: #1276's migration is `0038_single_key_shortcuts`, above
#1217's `0037_feedback`. If another migration lands first, it renumbers.

- **What does a revert leave behind?**
- `shortcutSetting: 1` in the manifests of repo builds published
meanwhile. The release before reads stored manifests without refusing
extra keys, and in the rehearsal it served a version that carried the
field.
  - People's stored settings, from #1276.
  - Dismissed-note keys in browsers' `localStorage`.
- A CLI of this release refuses to publish to an older instance before
sending anything, as any mismatched release does.
- **Does the release before it still work with that?** Yes. Its shell
names no frame, so every shortcut is on, the sheet hides its row, and no
note shows.

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 12, 2026
## What changed

A patch's page runs in a frame inside Patchy's page. A `<dialog>` opened
with `showModal()` makes only the patch's own page inert. So Tab past
the dialog's last control, or Shift+Tab before its first, moved focus
out of the frame onto Patchy's controls or the browser's, and Escape
could then stop closing the dialog.

Pages built with the SDK now keep Tab inside a **plain** modal dialog,
and leave every richer dialog's Tab to the browser, exactly as it moves
today. A small helper in `patchy` (`packages/patchy/src/modalTab.ts`)
handles a Tab that nothing on the page took, from the last stop of the
plain modal dialog focus is in. It focuses the dialog's first stop, and
the reverse for Shift+Tab. A plain dialog with no controls keeps focus.

`patchy/preact`, the generated client and `HotkeySheet` install it once
per document. Patchy injects nothing into served pages, so **published
patches keep the old behaviour until they're rebuilt and published again
on the release that ships this.**

Closes #1263

## Look at

**What "plain" means** (`isPlain`, an allowlist). Every element in the
dialog must be one of these:
- ordinary containers and text: `div`, `span`, `p`, headings, `label`,
`form`, an enabled `fieldset` and its `legend`, lists, sectioning
elements, table elements, inline text tags, `br`, `hr`, `img` without
`usemap`, and SVG that only draws (no `a`, `use`, `foreignObject` or
`tabindex`);
- controls Tab stops on once: `button`, `a`, `select` with options that
have no `tabindex`, `details` whose first child is its own `summary`,
checkbox and one-line text-like `input`s, and an element with `tabindex`
0 or -1.

It must also have none of these, anywhere in the dialog:
- a `popover` attribute, or an open popover anywhere in the page;
- a computed `display: contents`, a `reading-flow` other than `normal`,
or `interactivity: inert` that no `inert` attribute inside the dialog
explains (Chromium draws the attribute as `interactivity: inert` too,
and its subtree is never a stop);
- a shadow root or custom element;
- a dialog or descendant that scrolls;
- a positive `tabindex`;
- editable content, a textarea or a radio.

Anything else makes the dialog not plain, and then the helper does
nothing.

**Cost.** A Tab first checks, with a tree walker, that nothing after the
focused element (before it, for Shift+Tab) may take focus. Only at an
end does it walk the dialog and read computed styles, so a Tab between
stops costs no more than that check.

**How it decides, unchanged from the last round.**
- **The topmost modal** is the one focus is in.
- **It decides last.** A capture listener on `window` re-appends the
deciding listener to the end of `window`'s list, so it runs after every
listener already on the key's way, and a `preventDefault()` from them
wins.
- **When it wraps,** it calls `preventDefault()` and `focus()` during
the keydown. There are no timers, no `blur` handling and no retries, and
nothing is inserted into the author's dialog. Escape is the browser's.

**`HotkeySheet` keeps its own Tab handler,** as on main. Its dialog
scrolls once its card outgrows the viewport, which makes it not plain,
and its buttons are all it holds. So its own wrap stays sure, and the
sheet is never worse than main. The helper sees that handler's
`preventDefault()` and stays out, and the sheet still installs the
helper for the page's other dialogs.

**Sol's round 3.**

| Item | Now | Step |
| --- | --- | --- |
| 1. Popover | any `popover` attribute, or an open popover anywhere in
the page, isn't plain | from the control that opened a popover in the
dialog |
| 2. `display: contents`, and stops inside editable content | not plain
| before a shadow host laid out as display: contents; before an editable
region with a stop inside that shows |
| 3. A closed root on a standard element | **dismissed** (below) | |
| 4. `<area href>` | `img` with `usemap` isn't plain, and `map` and
`area` aren't on the list | before an image map's link |
| 5. A scrolling dialog | not plain | in a dialog that scrolls |
| 6. `reading-flow` | not plain | where reading-flow orders the dialog |
| 7. A canceller registered during capture | **dismissed** (below) | |

The two dismissals:
- **Item 3** can't be detected. A closed root on a standard element
exposes no `shadowRoot`, and it takes page code attaching one to a `div`
inside a modal. It's stated in the code.
- **Item 7** needs a page that registers a bubble listener on `window`
from a capture listener during the same key's dispatch. That's exotic.
There's no cheap exact fix: once the bubble at `window` has begun,
nothing added later in that dispatch can run after it. It's stated in
the code.

**Sol's round 4**, four tightenings inside the allowlist:

| Item | Now | Step |
| --- | --- | --- |
| 1. `<details>` without an authored `<summary>` | plain only when its
first child is its own `summary` | before a details element whose
summary the browser draws |
| 2. SVG `<a>` in `<defs>` drawn through `<use>` | SVG with `a`, `use`,
`foreignObject` or a `tabindex` isn't plain | after SVG that draws a
link through use |
| 3. CSS `interactivity: inert` | not plain, unless an `inert` attribute
explains it | where CSS makes the first control inert |
| 4. `<option tabindex="0">` | an option or optgroup with a `tabindex`
isn't plain | from a select whose option is given a tabindex |

Soft runs in `chromium` (desktop) and `firefox`:
- **Main:** all four new steps pass in Chromium.
- **9a9f2d8:** in Chromium, all four fail. In Firefox, items 1, 2 and 4
fail.
- **The Firefox exception:** Firefox has no `interactivity`, so there
the dialog is plain and wraps. Like reading-flow, the step checks for
support, and that branch fails on main in Firefox.
- **Two cases didn't reproduce at first,** so I rebuilt them to Sol's
setups. A `select multiple` showed its option, which the old end check
already saw, so the select case is a dropdown. In the earlier round, the
editable case needed the region itself to be no stop while a stop inside
it shows.

**Sol's round 5.**
- **The P2, an `inert` ancestor outside the modal:** a modal dialog
escapes its ancestors' inertness. Native Tab from A reaches B in
Chromium and Firefox, and both report `interactivity: auto` inside it.
The helper used `closest("[inert]")`, found no stops, and cancelled the
Tab. It now counts `inert` only from the dialog down to the element
(`isInertIn`), for stops and for the `interactivity` rule alike.
- **The new step,** "in a dialog inside an inert container, whose
inertness it escapes":
- **on main:** Tab from A reaches B in both browsers, and only the wrap
that follows fails, as in every wrap step;
  - **at 87129a3:** it fails at B in both;
  - **at head:** it passes, with the wrap.
- **The P3:** the skill now says CSS `interactivity: inert` outside an
`inert` subtree.

**Red and green.** Every assertion was made soft for a local run, with
base source restored by `git restore --source=<base> --
packages/patchy/src packages/sdk/src/generateClient.ts`. The runs were
in the headless shell, desktop Chromium (`channel: "chromium"`, now the
repo's `chromium` project after #1302) and Firefox.

| Step | Main | Previous head 90f4f7c | Head |
| --- | --- | --- | --- |
| both ways round its controls, past the ones Tab skips | ✘ | ✓ | ✓ |
| with rows added while it is open | ✘ | ✓ | ✓ |
| in a dialog opened over it, though that one comes first in the page |
✘ | ✓ | ✓ |
| on the dialog itself while it has no controls | ✘ | ✓ | ✓ |
| after a wrap, a click on Patchy's page keeps focus there | ✘ (at the
wrap) | ✓ | ✓ |
| onto a first field that takes a quarter of a second to focus | ✘ | ✓ |
✓ |
| from the dialog on top once the one below is written open | ✘ (at the
wrap) | ✓ | ✓ |
| the Preact page's Native `<dialog>` | ✘ | ✓ | ✓ |
| where a window listener the page added later takes Tab | ✓ | ✓ | ✓ |
| a control that takes Tab, a removed row, a date input, a closed shadow
root, a radio group, positive tabindex | ✓ | ✓ | ✓ |
| from the control that opened a popover in the dialog | ✓ | ✘ | ✓ |
| before a shadow host laid out as display: contents | ✓ | ✘ | ✓ |
| before an editable region with a stop inside that shows | ✓ | ✘ | ✓ |
| before an image map's link | ✓ | ✘ in both Chromiums | ✓ |
| in a dialog that scrolls | ✓ | ✘ in both Chromiums | ✓ |
| where reading-flow orders the dialog | ✓, ✘ in Firefox | ✘ in both
Chromiums | ✓ |

The native steps assert that nothing took the Tab, so the browser moves
focus as on main. Where the browser has no `reading-flow`, as in
Firefox, that dialog's order is the page's, so it is plain and wraps;
the step checks for that.

At head, 9a73b37:
- all of `focus.spec.ts` with `--repeat-each=3` in `chromium` and
`firefox`: 60 passed;
- `hotkeys.spec.ts` and `shortcut-setting.spec.ts`: 27 passed.

**Where it installs.**
- **`patchy/preact`:** the issue named `preact/runtime.ts`, but the
repo's lint forbids `../` imports from `packages/patchy/src/preact/`, so
the call sits in `src/preact.ts`, the `patchy/preact` entry. Pages may
import only SDK entry points, so every Preact page imports it to render.
- **The generated client:** it calls `keepTabInModals()` from
`patchy/client`. Pages reach `patchy/client` only through the generated
client.

## How it was verified

- **Browser, tier 1:**
- **`focus.spec.ts`:** the three-way comparison above, in the headless
shell, desktop Chromium and Firefox (CI's projects, with Fission on).
- **Hotkeys and the shortcut setting:** `hotkeys.spec.ts` and
`shortcut-setting.spec.ts` in the `chromium` project, now desktop
Chromium, 27 passed. That includes the sheet's own Tab round its
buttons.
- **Unit:** the `client.test.ts` case per tier checks that the generated
client's page bundle carries the helper. With `hotkeys`, `hotkeySheet`,
`hotkeyRules`, `devLifecycle` and `pageImports`, 75 passed.
- **Checks:** `pnpm format:check`, `pnpm lint`, `pnpm typecheck:tests`,
and the `patchy` typecheck and build.
- **Not run:**
  - `pnpm verify` in full, WebKit, and headful browsers.
- The SDK's `install.test.ts`, which fails on this machine because its
sandboxed `PATH` finds no npm. It doesn't touch this change.

**Hit every surface.** These applied:
- **The CLI:** `patchy/client` exports `keepTabInModals`, and the
generated client calls it. `packages/patchy/README.md` says Tab wraps in
plain dialogs and richer ones keep the browser's.
- **Project skills:** the `patchy-hotkeys` project skill, which is
release-bound and has no lock hash. Its Native `<dialog>` section says
what counts as plain in a sentence, including that an open popover
anywhere in the page turns wrapping off, and drops the rule #1256 added
that told agents to handle Tab themselves.

None of the others apply: no wire contract, dev loop, vocabulary,
migration or company resource change. Served pages are untouched, since
Patchy injects nothing. There are no reverse states and no layout
change.

**Release note.** The line for the next release's `patchChanges`:

> In pages on `patchy/preact` or the generated client, Tab now wraps
inside a plain modal `<dialog>` opened with `showModal()`: from its last
control to its first, and Shift+Tab from its first to its last; a plain
dialog with no controls keeps focus. A plain dialog holds only ordinary
containers and text with buttons, links, selects, checkboxes, summaries,
one-line inputs and elements with `tabindex="0"`. A richer dialog, such
as one with a textarea, radio, date input, frame, popover, custom
element, scrolling region or positive `tabindex`, keeps the browser's
own Tab, and so does every dialog while a popover is open anywhere in
the page. There, Tab can still leave for Patchy's page, where Escape
stops closing the dialog. A patch's own Tab wrapping for a plain dialog
can come out. Versions already published behave as before until they're
built and published again.

## Release impact

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

SDK page behaviour only, and only in patches rebuilt on this release.
Nothing changes on the server or in published versions.

- **What does a revert leave behind?** Patches built and published while
this was in place keep the helper in their bundles. Nothing else.
- **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 12, 2026
…ey shortcuts (#1421)

## What changed

This adds release 42's What's new entry, written from `1cd6d12`. It
covers everything merged since release 41's `through` (`a25a9c5`), and
sets the `patchy` release to `0.42.0` in `packages/patchy/package.json`
and `CURRENT_RELEASE`.

| Change | PRs |
| --- | --- |
| New: Tell Patchy what it's missing | #1217, #1218, #1219, #1227, #1228
|
| New: Turn off single-key shortcuts | #1276, #1279, #1301 |
| Fixed: Typing reaches the patch again | #1407, #1412 |
| Fixed: Dialogs in patches keep your place | #1420, #1255 |
| Behind the scenes: plainer facts for agents building patches | #1249,
#1256, #1297, #1418 |
| Behind the scenes: Patchy stores teams and audiences ahead of teams |
#1416 |
| Patch changes: Mod+/ and `client.close()` in patchy/hotkeys;
single-key shortcuts can be off; Tab wraps in plain modal dialogs |
#1279, #1301, #1420 |

#1376 is release 41's own entry. #1400, #1406, #1414, #1415, #1302,
#1413 and #1419 are test, CI and dev tooling and need no line.

The teams bridge (#1416) ships alone in this release so teams (#1417)
can follow in the next one with a release to roll back to that reads its
data closed.

## Look at

- **The entry**, at the top of `releases` in
`packages/core/src/whatsNew.ts`.
- **Rollback safety, from the live commit `7f93b91` (release 41) to this
PR's merge.** No PR in the range is labelled `one-way`, and every
Release impact answer says release 41 still works:
- **#1217** adds migration `0037_feedback`, a schema release 41 never
reads. **#1227** and **#1228** write into it.
- **#1276** adds migration `0038_single_key_shortcuts`, a column with a
default that release 41 never selects.
- **#1416** adds migrations `0039_company_teams` to
`0041_connection_audiences`, which hold tables that stay empty until
teams ship, and widens one scope check. Its CI rehearsal ran `7f93b91 →
head → 7f93b91 → head` on one set of data, and all four steps passed.
- **#1279**, **#1301**, **#1255** and **#1420** change the SDK and the
shell. Patches built on this release carry a `shortcutSetting` manifest
field that release 41 reads without refusing, and its shell names no
frame, so every shortcut stays on.
- **#1218** and **#1219** add CLI commands and an optional
`feedbackHint` in `--json` failures. A CLI from this release refuses to
publish to an older instance before sending anything, as any mismatched
release does.
  - Everything else is skill text, docs, tests and CI.

If this release misbehaves, roll back to `7f93b91` (release 41).

Written by Claude Opus 5.5 in Claude Code, through T3 Code.

🤖 Generated with [Claude Code](https://claude.com/claude-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:docs Touches the docs area area:server Touches the server area size:s Under 100 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs(sdk): a hand-built shortcuts sheet keeps focus inside it

1 participant