Skip to content

feat(sdk): patchy/hotkeys obeys a viewer's single-key shortcut setting - #1279

Merged
allisonmahmood merged 1 commit into
mainfrom
feat/hotkeys-obey-shortcut-setting-1274
Nov 11, 2026
Merged

allisonmahmood merged 1 commit into
mainfrom
feat/hotkeys-obey-shortcut-setting-1274

Conversation

@allisonmahmood

@allisonmahmood allisonmahmood commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

What changed

A viewer who uses speech input can be tripped by single-key shortcuts, and #1224 lets them turn those off. patchy/hotkeys didn't know about such a setting, and Mod+/ (the one sure way into the shortcuts sheet) could be taken by a narrower hotkey. Now patchy/hotkeys obeys the setting the shell will pass to the frame, its sheet has the setting row from the picked mocks, and Mod+/ always opens the sheet. Today's shell doesn't name the frame, so nothing changes until #1275 lands: every shortcut stays on and the row stays hidden.

Closes #1274

Look at

The sheet in a stub shell that names the frame patchy:shortcuts=on. It opens with Mod+/, the row asks the shell (here a stub that answers after a moment), and the sheet comes back on its row with the new state. While shortcuts are off, character shortcuts show inactive keycaps and say "key off" to screen readers; Ctrl chords and Mod+/ don't change.

sheet-setting.mp4

Classification works on the parsed binding (characterShortcut in hotkeyRules.ts). A binding is a character shortcut when every step types text with no Mod, Ctrl or Alt: Shift, Space, +, AltGr and dead-key characters, and the numpad's digits, operators and symbols (*, #, parentheses) count; named keys (including a NumLock-off numpad's) and mixed sequences don't. within an element is exempt, but within body or the root element isn't. Suppression is checked as each key arrives, in the chord callback and in allowStep, and never uses enabled: false. So a stopped hotkey stays listed, and the sheet's copy of a command keeps the classification of the place it came from.

One transport per document, with one FIFO. Tier 1's createClient used to make its own postMessage transport, while tier 2 and the file hooks shared the document's. On a page with both, two transports took the one bootstrap port, and close() closed the port for everyone. Now every client takes a share of the document's transport (createClientTransport), and the transport follows one model, written in the doc comment above its queue:

  • Every call is queued, then dispatched. While queued, its client's close() cancels it: it rejects with unknown_outcome and is never sent. From the moment the transport starts sending it, serialization included, close no longer touches it, and it settles with the reply.
  • One FIFO per document holds every client's queued calls, query subscriptions included, in call order. When the port arrives, it drains in order. Anything new during a drain, including a call made by a getter during serialization or by a callback during the drain, joins behind the entries still queued. Only while the FIFO is empty does a call go straight to the port.
  • Tier 2 handler calls take their place when made, and are prepared from the descriptors that the bootstrap brings before the drain. A mutation's key needs the server's clock, so a mutation whose turn comes before the clock steps out of line. It doesn't hold back the calls behind it, and joins the back of the FIFO once the clock is known.
  • The guarantee: calls reach the shell in the order they entered the FIFO, across the bootstrap and across clients. A call enters when its preparation is done, not when its method is invoked. Work a method does first, such as canonicalizing a tier 2 handler's arguments, whose getters may make calls of their own, or reading a Blob for files.put, can let a later call enter first. Beyond that, the one exception is a tier 2 mutation made before the server's clock is known (always so before the bootstrap): it goes out once the clock arrives, after calls made later. On main, order across the bootstrap followed promise timing instead. A tier 2 handler call made before the bootstrap went out behind other calls made after it, and a closed client's queued calls were rejected because it closed its own transport.
  • close() never closes the port. patchy/hotkeys reuses the document's transport, or makes it as it evaluates, but only when the frame is named.

Mod+/ is caught on the window, outside TanStack's matching. Inside that matching, a narrower hotkey or a sequence under way (such as G Mod+/ after G) claims the key before chords run. So the sheet listens for Mod+/ itself, in the window's capture phase, takes it there, and starts any pending sequence over as it opens.

How it was verified

  • Unit (vitest). hotkeyRules.test.ts covers classification across every case in the issue. documentTransport.test.ts runs both tiers on one port: tier 1 closes, tier 2 keeps working, both close with zero consumers left, then both remount on the same port, and pagehide closes it. clientTransport.test.ts covers shortcuts.setting still waiting after 40 s and then resolving. In each tier, it also covers writes and route sets queued before the bootstrap by a client that closes: they reject with unknown_outcome and never reach the port, while another client on the same transport still sends. Over a real MessageChannel, a tier 1 and a tier 2 client queue a route set, a query subscription, a file discard and an insert, beside a closed client's insert. The route's first callback, as the bootstrap lands, sets a later path. The shell receives them in call order without the closed client's insert, and the route ends on the later path. Three more cases, over a real channel:
    • a queued insert and tier 2 query whose clients close after the shell has received them but before it replies: both settle with the replies;
    • an insert whose row getter, read during serialization, makes another client that sets /second, followed by a queued /first: the shell gets the insert, then /first, then /second;
    • a tier 2 query and a mutation queued before the bootstrap, then a route set from the route's first callback: the query goes out, then the route set, then the mutation once the stream's hello brings the clock, keyed from it.
  • Browser tier (test/browser-tier1/hotkeys.spec.ts), on a stub shell that creates the iframe already named before inserting it:
    • with Off, A, Shift+A, G H and ? do nothing, while Mod+K, Escape, a within key and Mod+/ work. Mod+/ opens the sheet even with focus inside a narrower within Mod+/ binding that stops propagation, and after G with G Mod+/ registered. That G starts over as the sheet opens, so a following Escape is the page's own, not G Escape;
    • the sheet's row (a button with aria-haspopup="dialog") and its inactive keycaps;
    • the row calls shortcuts.setting with {}. With the clock fast-forwarded, the stub answers after 40 s and the sheet reopens focused on the row, now On;
    • with On, everything fires;
    • imported after the bootstrap, beside an eager client (shares its port, row shown) and alone (no port, row hidden). The value applies both ways, and a custom hotkey still leaves Mod+/ opening the sheet;
    • under today's real shell, everything fires and the sheet has no row.
  • Results at 8cc2fa0. pnpm format:check, pnpm lint and pnpm typecheck pass. The touched vitest files (transport, clients, query registry and the hotkeys suites) pass, 92 of 92. The whole tier 1 browser suite passes, 91 of 91, which includes the hotkeys file's 12. The packed tier 2 smoke, with its keyed mutation retry against a real server, passes too.
    • Red first, from review round 3. On 2d15be2, the close-after-receipt test fails with promise rejected "PatchyError: The runtime reply was lost." instead of resolving. The getter test fails with expected [ 'route.set /second', …(2) ] to deeply equal [ 'tables.insert', …(2) ]. The tier 2 test fails with expected [ 'route.set /second', …(1) ] to deeply equal [ 'server.call notes.count', …(1) ].
    • Red first, from review round 2. On 9b142c2, Sol's repro failed with expected [ 'route.set /second', …(3) ] to deeply equal [ 'route.set /first', …(3) ]. The final test fails there with expected [ 'subscriptions.subscribe', …(4) ] to deeply equal [ 'route.set /first', …(4) ]. Removing just the subscription's place in the queue fails it too.
    • Red first, from review round 1. On bc2f59e, the queued-before-bootstrap tests fail with expected [ undefined, 'tables.insert', …(1) ] to deeply equal [ undefined ] in tier 1 and [ undefined, 'files.discard', …(2) ] in tier 2. The sequence step fails at expect(sheet).toBeVisible() after G, then Ctrl+/. Classification fails with expected [ '[NumpadParenLeft]', …(3) ] to deeply equal [].
    • Red first, earlier. With the Mod+/ opener removed, the narrower-binding step fails on toBeVisible(). With the deadline exemption removed, the 40 s test fails on toBeFocused() (the sheet came back still Off), and the unit test fails with promise rejected "PatchyError: The runtime reply was lost." instead of resolving. On the base, the shared-port test fails on expect(port.closed).toBe(false).
    • pnpm verify at bc2f59e. format, lint, typecheck, synth, postgres-concurrency, tier2-smoke and browser passed. install, cli-smoke and install.test.ts stopped on "npm is not on PATH": this machine's /usr/bin/node has no npm beside it, and the installer is untouched. Two timeouts under load from other worktrees, in PatchesApi.test.ts and PgliteCompanyDatabases.test.ts, passed when rerun alone under Node and Bun.
  • Not checked here: the shell side (naming the frame, the dialog, answering shortcuts.setting) is The shell turns on the single-key shortcut setting, with its dialog and the account menu switch #1275, and reading the stored value is Patchy stores each person's single-key shortcut setting #1273. So I couldn't test "Off stored under today's shell" with a stored Off. Today's shell names no frame, which is the same input.

Release impact

Tick exactly one.

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

Patches already published keep the SDK they were built with and behave exactly as before. A patch rebuilt on this release changes in three ways:

  • Mod+/ always opens a mounted HotkeySheet, ahead of every other hotkey. A custom hotkey prop now replaces only ?. A page's own Mod+/ hotkey, within an element or not, never fires while a sheet is mounted. At page level that was already true.
  • client.close() leaves the document's connection open for the page's other clients. A client made after it reuses that connection instead of finding it closed.
  • A call already sent settles with its real outcome after close(), instead of being rejected as lost.

Calls a page makes before it connects to Patchy now reach the shell in the order they enter the transport, as described above. Tier 2 handler calls go out in their turn instead of behind later calls, except a mutation still waiting for the server's clock. The sheet's Mod+/ is no longer a hotkey registration, so useHotkeyList() lists the sheet's ? opener but not its Mod+/. A held Ctrl+/ toggles the sheet once, not on every key repeat. Under today's shell nothing else changes. A hotkeys-only page still opens no connection to the shell.

Suggested patchChanges line for the release:

patchy/hotkeys: Mod+/ always opens a mounted HotkeySheet, ahead of every other hotkey, and its hotkey prop replaces only ?, so a page's own Mod+/ hotkey, within an element or not, never fires while a sheet is mounted: move it to another chord. client.close() no longer closes the page's connection to Patchy: it stops that client's subscriptions and refuses its later calls, a call already sent settles with its own outcome, and a client made afterwards works.

  • What does a revert leave behind? Nothing: no schema, no stored data, no wire change the server sees. shortcuts.setting is shell-local and today's broker refuses it. The row that sends it only shows in a named frame, and nothing names one yet.
  • Does the release before it still work with that? Yes.

Notes for #1275: the SDK sends { v, id, op: "shortcuts.setting", args: {} } and expects a result whose value is the authoritative boolean (true = on). It applies no deadline. The decoder belongs beside decodeGeneratedDownload in the broker, and the broker must never forward this operation. The frame needs its name set before insertion (parser-created or set before append); setting it later doesn't reach a sandboxed document. A glossary entry for the setting is left for the docs pass there.

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 Nov 6, 2026
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Review (GPT 6.1 Sol, xhigh), on bc2f59e: FAIL.

  1. P2, packages/patchy/src/clientTransport.ts:530: closing a client can still send a queued write.
    • Call tier 1 tables.notes.insert() before the bootstrap, then client.close(), then deliver the bootstrap. The insert is sent and resolves.
    • On the base it rejects with unknown_outcome and sends nothing. call() bypasses the client's cancellable waits, and route.set() has the same problem.
    • Fix: make the waits before dispatch cancellable by the client, and check the lifecycle before sending, while calls already sent still settle.
  2. P2, packages/patchy/src/hotkeys.ts:316: a sequence can still take Mod+/.
    • Register G Mod+/, press G, then Ctrl+/. The sequence fires and the sheet stays closed. That includes with shortcuts off, since mixed sequences are exempt.
    • TanStack gives a continuing sequence ownership before chords are processed, which defeats the window-capture registration.
    • Fix: handle the permanent opener outside that arbitration, or bypass sequence ownership explicitly, and reset pending sequences when it opens. Add the browser case.
  3. P3, packages/patchy/src/hotkeyRules.ts:38: some printable numpad codes escape suppression.
    • A binding cast to [NumpadParenLeft] classifies as exempt. With shortcuts off, an event with key: "(" and code: "NumpadParenLeft" fires it.
    • The physical-code whitelist omits printable numpad codes: NumpadParenLeft, NumpadParenRight and NumpadHash. Include them, and test their parsed bindings.

On Mod+/ at window capture: Sol accepts reserving it for the guaranteed-opener contract. It necessarily breaks a patch's own Ctrl+/ handler, such as an editor's comment toggle, while a HotkeySheet is mounted. Yielding to a focused editor would weaken the guarantee and change the agreed requirement. The skill and patchChanges explain the tradeoff.

Verified:

  • The browser file passes, 12 of 12, and the three touched vitest files 57 of 57.
  • Ordinary events reach the page with shortcuts off, without being prevented. The sheet's copied within command works, and rows stay buttons.
  • In both tiers, calls already sent settle after close, later uncached calls reject, and closing one client keeps the shared port.
  • In-memory variants reproduced the claimed red results: without window capture the narrower binding wins, and without the deadline exemption the row stays Off after a 40 s reply.
  • The eleven scheduling edits keep their request, argument, retry and error assertions.
  • Hotkeys in an unnamed frame create no transport. Eager and dynamic imports, and today's shell, pass.
  • Hit every surface: the README and the skill are updated, and nothing else applies here; the broker side is The shell turns on the single-key shortcut setting, with its dialog and the account menu switch #1275's.
  • The rollback answers match the diff. Finding 1 affects rebuilt patches at once, though, so this head shouldn't ship unchanged.

allisonmahmood added a commit that referenced this pull request Nov 6, 2026
…nce under way

Review findings on #1279:
- A call a client made before the bootstrap waited inside the shared
  transport, so closing the client still let it go out. Each call now waits
  for the bootstrap as its client, cancellably, and goes out only if the
  client is still open; once bound, it goes out as it is made.
- A sequence continuing on Mod+/ owned the key before TanStack processed
  chords, so the sheet stayed shut. Mod+/ is now caught on the window
  outside that matching, and pending sequences start over as it opens.
- Printable numpad codes (Star, Hash, ParenLeft, ParenRight) count as
  typing text.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added size:xl Over 1,000 changed lines; review in multiple passes and removed size:l 501-1,000 changed lines labels Nov 6, 2026
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Review round 2 (GPT 6.1 Sol, xhigh), on 9b142c2: FAIL. All three round 1 findings are fixed, and there's one new finding.

Round 1, all fixed:

  • A closed client's writes and route changes queued before the bootstrap reject without being sent.
  • G Mod+/ can't take the opener, and opening the sheet resets pending sequences.
  • Printable numpad codes are suppressed with shortcuts off, the parentheses, hash and star included.

New:

  • P2, packages/patchy/src/clientTransport.ts:534: queued calls can be overtaken across the bootstrap.
    • Before the bootstrap, call client.route.set("/first") and subscribe to the route. In the initial "/" callback, call set("/second").
    • With a real MessageChannel, bc2f59e sends /first then /second, ending at /second. This head sends /second and then the queued /first, ending at the stale /first.
    • The immediate path overtakes queued dispatches that are still resolving.
    • Fix: drain the uncancelled queued dispatches in call order before allowing immediate sends, keeping client cancellation.

Verified:

  • Chromium and Firefox probes passed for:
    • IME composition and composition-commit events;
    • modal dialogs;
    • scopes;
    • key repeat;
    • unmounting;
    • Mac modifiers.
  • A text field's own Ctrl+/ is taken while the sheet is mounted, as documented and accepted.
  • Two mounted sheets both open, unchanged from bc2f59e, and the contract already says one per page.
  • Upload ownership transfer, subview isolation, cancellation, several clients across tiers, and remounting all passed.
  • Leaving Mod+/ out of useHotkeyList(), and toggling once per held press, are acceptable and documented.
  • The hotkeys browser file passes 12 of 12, the whole tier 1 browser suite 91 of 91, the touched vitest files 59 of 59, and the companion hotkeys suites 10 of 10.

allisonmahmood added a commit that referenced this pull request Nov 7, 2026
Review round 2 on #1279: a call queued before the bootstrap waited through
its own promise chain, so a call made right after the bootstrap, such as a
route set from the route's first callback, could go out ahead of it. The
postMessage transport now holds every call made before its port, from any
client, query subscriptions included, in one queue it sends in order the
moment the port arrives. A client that closed meanwhile still sends nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Review round 3 (GPT 6.1 Sol, xhigh), on 2d15be2: FAIL. Round 2's repro is fixed: with a real MessageChannel, this head sends /first then /second, and ends at /second.

New:

  • P2, packages/patchy/src/clientTransport.ts:563: a queued call already sent is rejected on close.
    • Queue an insert before the bootstrap and deliver the port. Wait until the other end receives the insert, then close the client before the reply.
    • This head rejects with unknown_outcome; 9b142c2 settles with the real result.
    • Fix: client close stops cancelling a call once dispatch begins; the call adopts the response.
  • P3, clientTransport.ts:437: re-entrant calls can overtake the drain.
    • An insert whose row getter, which runs during postMessage's serialization, creates another client and sets /second jumps the remaining queue, and the route ends at /first.
    • Fix: keep a draining state, and append re-entrant calls behind the existing entries until the queue is empty.
  • P3, clientTransport.ts:575: one tier 2 ordering gets worse than on the base.
    • A query handler queued before the bootstrap, then a route set in the first route callback: the base sends server.call then route.set, and this head reverses them.
    • Fix: reserve the handler dispatches that depend on descriptors before the bootstrap and prepare them when the descriptors arrive. Mutation clock gating stays.

Verified:

  • 89 of 89 vitest tests, and the whole tier 1 browser suite, 91 of 91.
  • Probes passed for:
    • upload ownership;
    • cancelled subscriptions;
    • clone-error settlement;
    • the bootstrap timeout;
    • the deadline exemption.

allisonmahmood added a commit that referenced this pull request Nov 7, 2026
Review round 3 on #1279. The transport now follows one model, written
above its queue:
- Every call is queued, then dispatched. A client's close cancels its
  queued calls, which reject with unknown_outcome unsent; a dispatched
  call settles with its reply.
- One FIFO per document holds every client's queued calls, subscriptions
  included, in call order. It drains in order when the port arrives, and
  anything new during a drain, re-entrant calls included, joins behind.
  Only an empty FIFO lets a call go straight to the port.
- Tier 2 handler calls take their turn when made and are prepared from the
  bootstrap's descriptors as it comes. A mutation without the server's
  clock steps out of line and takes a new turn once the clock is known.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Review round 4 (GPT 6.1 Sol, xhigh), on 8cc2fa0: FAIL on one P3. All three round 3 findings are fixed.

Round 3, all fixed:

  • Calls sent before their client closes settle with their replies.
  • Re-entrant calls made during serialization join behind the remaining queue.
  • A queued tier 2 query goes out before the route change made in the first route callback.

Sol's probes all passed:

  • cancellation at the phase boundary;
  • serialization failures;
  • a mutation rejoining the queue;
  • a clock that never arrives;
  • the bootstrap timing out;
  • subscriptions interleaved with calls;
  • the deadline and its exemption.

After 2,000 client lifecycles, the queue, pending replies, subscriptions, clock waiters and listeners all returned to zero. Focused vitest passes 92 of 92, the whole tier 1 browser suite 91 of 91, and CI's packed tier 2 smoke passes. The mutation-before-clock exception is described accurately and is acceptable.

  • P3: the stated guarantee was too broad. A call enters the FIFO after its preparation, so work a method does first can let a later call enter first: a tier 2 handler's argument getter that calls route.set(), or files.put reading a Blob. The FIFO itself passed every boundary probe.

Fixed in fdd7126, which is comment and PR-body only: the guarantee is now scoped to the order calls enter the FIFO, and names the preparation that comes first. No code changed.

allisonmahmood added a commit that referenced this pull request Nov 7, 2026
…nce under way

Review findings on #1279:
- A call a client made before the bootstrap waited inside the shared
  transport, so closing the client still let it go out. Each call now waits
  for the bootstrap as its client, cancellably, and goes out only if the
  client is still open; once bound, it goes out as it is made.
- A sequence continuing on Mod+/ owned the key before TanStack processed
  chords, so the sheet stayed shut. Mod+/ is now caught on the window
  outside that matching, and pending sequences start over as it opens.
- Printable numpad codes (Star, Hash, ParenLeft, ParenRight) count as
  typing text.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@allisonmahmood
allisonmahmood force-pushed the feat/hotkeys-obey-shortcut-setting-1274 branch from fdd7126 to 7ec220a Compare November 7, 2026 13:04
allisonmahmood added a commit that referenced this pull request Nov 7, 2026
Review round 2 on #1279: a call queued before the bootstrap waited through
its own promise chain, so a call made right after the bootstrap, such as a
route set from the route's first callback, could go out ahead of it. The
postMessage transport now holds every call made before its port, from any
client, query subscriptions included, in one queue it sends in order the
moment the port arrives. A client that closed meanwhile still sends nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
allisonmahmood added a commit that referenced this pull request Nov 7, 2026
Review round 3 on #1279. The transport now follows one model, written
above its queue:
- Every call is queued, then dispatched. A client's close cancels its
  queued calls, which reject with unknown_outcome unsent; a dispatched
  call settles with its reply.
- One FIFO per document holds every client's queued calls, subscriptions
  included, in call order. It drains in order when the port arrives, and
  anything new during a drain, re-entrant calls included, joins behind.
  Only an empty FIFO lets a call go straight to the port.
- Tier 2 handler calls take their turn when made and are prepared from the
  bootstrap's descriptors as it comes. A mutation without the server's
  clock steps out of line and takes a new turn once the clock is known.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@allisonmahmood
allisonmahmood changed the base branch from main to docs/hand-built-sheet-dialog-1137 November 7, 2026 13:04
@allisonmahmood

Copy link
Copy Markdown
Owner Author

Now stacked on #1256 (docs/hand-built-sheet-dialog-1137), with #1255's scrim fix kept beside the setting row, 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. All five commits replayed with no conflicts. git range-diff shows four as =. The first, feat(sdk): patchy/hotkeys obeys…, differs only in context: the comment above reservedChord in hotkeyRules.ts now names the switcher (#1298), and this PR's lines next to it are unchanged.

Nothing changed beyond the rebase.

Its own specs at its head (f4ac4f5), hotkeys.spec.ts: 25 of 25, 12 in desktop Chromium and 13 in the headless shell. The local hotkeys test is held out of desktop for #1306. Run there anyway, it passes every step up to #1306's accessibility step.

CI: the first browser run failed in switcher.spec.ts, "a patch that grabs focus back never leaves the menu up while typing goes to the patch". The test's plain-HTML patch never logged "patch grabbed" within 15 s. This PR changes the SDK, not the shell or the switcher, and that patch uses no SDK. The case passed on main in desktop Chromium locally, at the top of the chain locally, and in #1302's CI. It's rerunning.

@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 with notes

I checked this PR as part of the six-PR chain at #1301's head 06476fe54aae64e52128c44709271f036fa2da59, which contains this head ee56f498f4728afbed0897569c6e820a32aff015, by Claude Opus 5.5 in Claude Code (T3 Code). Checks 1, 2, 6, 7 and 8 of the full verdict cover it, in desktop Chromium with the frame isolated and in the headless shell. Under a frame named off, A, G H and ? fired nothing, while Ctrl+K, Escape, a J within a list and Ctrl+/ fired. The sheet kept its commands as buttons, with dashed ", key off" keycaps, and clicking one ran it. Confirming the shell's dialog flipped every shortcut live with no reload, and the row's answer came back on the stored value after a dismissal mid-save. An unnamed frame, on a public patch, kept every shortcut and showed no row. The committed 0.38 bundle kept its shortcuts under Off. patchy dev named each viewer's frame with their own value. Ctrl+/ during a G opened the sheet, and the following H didn't complete G H. The SDK's ask with args: {} got its answer through the shell. Notes: Its one red check, install (${{ matrix.os }}), comes from a duplicate CI run on the same commit that was cancelled before its matrix expanded; the sibling CI run on this head passed. pidgeon-suite is still waiting in Pidgeon live's account-wide queue.

@allisonmahmood
allisonmahmood force-pushed the docs/hand-built-sheet-dialog-1137 branch from 9c7d11d to 6d9e99b Compare November 11, 2026 18:16
Base automatically changed from docs/hand-built-sheet-dialog-1137 to main November 11, 2026 18:28
@allisonmahmood
allisonmahmood force-pushed the feat/hotkeys-obey-shortcut-setting-1274 branch from ee56f49 to a677c2d Compare November 11, 2026 18:28
@allisonmahmood
allisonmahmood merged commit ad5965e into main Nov 11, 2026
25 checks passed
@allisonmahmood
allisonmahmood deleted the feat/hotkeys-obey-shortcut-setting-1274 branch November 11, 2026 18:41
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
…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: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:xl Over 1,000 changed lines; review in multiple passes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

patchy/hotkeys obeys a viewer's single-key shortcut setting

1 participant