Repository navigation
prototype(sdk): give patches keyboard shortcuts like G H and Mod+K - #1052
Closed
allisonmahmood wants to merge 1 commit into
Closed
allisonmahmood wants to merge 1 commit into
allisonmahmood wants to merge 1 commit into
Conversation
Patchy's own hotkey API over a bundled TanStack Hotkeys, the shell focusing the patch frame on load, a patchy-hotkeys skill, a demo patch and a stress script. Prototype, not for merge. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 30, 2026
allisonmahmood
added a commit
that referenced
this pull request
Oct 31, 2026
## What changed An agent asked for pages at their own paths couldn't find `patchy.route` in any project skill. In #1052's trials, one read the generated `.d.ts` files to find it. Now `patchy-preact` has a Routes section: what `get`, `set` and `subscribe` do, the path rules, and that a link calls `set` instead of navigating the frame. `patchy-loop` points framework-free pages at that section. The `patchy-preact` description adds "give pages paths of their own" so agents reach for the skill when they need routes. Closes #1088 ## Look at **The Routes section** in `packages/sdk/skills/patchy-preact/SKILL.md`. It states facts and gives no router recipe, and it never says when to add routing. Each line was checked against the code. Three facts go beyond the README's routing paragraph: - Setting the path already shown still pushes a history entry, and no listener hears about it. The broker always calls `pushState`, and the client skips an unchanged path. - Every `%` in a path has to begin a valid escape. The broker's `decodeURIComponent` refuses anything else. - A frame that navigates loses its connection to Patchy. The broker stops the session on the frame's second `load`. **A fresh agent with the skill vs without it.** Same task on both sides, Sonnet 5.5. The before agent grepped `node_modules/patchy/dist/*.d.ts` and the package README to find routing. The after agent found Routes in the skills, opened no `.d.ts` file and answered that `patchy.route.set` and `subscribe` change the address: <!-- patchy-dev:trial:routes --> #### Trial `routes` > Build me a small team handbook patch: a Home page, a People page and a Policies page, each at its own address, so I can send someone a link straight to one page and the browser back and forward buttons work. Publish it when it works. Start your reply with one sentence on what in the page code changes the address. Before is `2449055` (where this branch left main) and after is `66bc56d` (docs/route-skills-1088), both on the `team` scenario, from `pnpm dev trial`. Those are the commits before the branch was rebased onto Preact 11. The routing text hasn't changed since, and acceptance re-ran a fresh agent at `8f2e238`. Each side gave the task to a fresh agent: after's `agent` launcher in the side's environment, Claude Code on `claude-sonnet-5-5` as the scenario's publisher, with the side's release of the Patchy skill and no personal instructions or settings, run without a person within 60 turns and 20 minutes. The log keeps each tool call, commands with their exit codes, and one line per failure; not the agent's reasoning or what its commands printed. Nothing in it matched a collected secret (each side's CLI state, machine-token and login-code shapes, email addresses outside the scenarios' example domains, secret-named variables, and any accounts the run acts as). One run is a smell test, not a measurement. | | Before | After | | --- | --- | --- | | Finished | Yes | Yes | | Commands | 15 | 12 | | Failures | 6 | 4 | | Help lookups | 0 | 0 | | Minutes | 1.9 | 1.8 | **Before** answered: “The page changes its address by calling `patchy.route.set(path)` from the nav link click handler `go` in `src/App.tsx`, and it reads the address back with `patchy.route.get()` and `patchy.route.subscribe()`, which also report back and forward. I haven't published it.” **After** answered: “The page changes the address through `patchy.route.set(path)` (called from the nav links) and `patchy.route.subscribe`. That is Patchy's routing API, not the History API I first named.” <details><summary>Before's log: 15 commands, 6 failures</summary> ```console skill patchy denied $ ls -la && patchy status --json; patchy whoami --json; ls .claude/skills/patchy/references ls in '<env>/cli/node_modules/patchy/skills/patchy/references' was blocked. For security, Claude Code may only list files in the allowed working directories for this session: '<env>/workspace', '/tmp/… exit 0 $ ls -la; patchy status --json; patchy whoami --json exit 0 $ patchy init team-handbook --tier 1 --purpose "Team handbook with Home, People and Policies pages, each at its own shareable address." --json 2>&1 | tail -20 exit 0 $ patchy look --json > <tmp>/look.json; head -c 600 <tmp>/look.json exit 0 $ cd <env>/workspace/team-handbook && cat AGENTS.md | head -60; cat .agents/skills/patchy-loop/SKILL.md | grep -n -i -B3 -A25 "route"; cat src/main.tsx src/App.tsx; ls; ls .agents/skills/patchy-look; gr… exit 0 $ grep -rn -i "route" .agents/skills/*/SKILL.md patchy/_generated/README.md patchy/_generated/client.ts | head -30; cat patchy.config.ts; cat src/styles.css | head -30; cat .agents/skills/patchy-look/SK… exit 0 $ cat patchy/_generated/client.ts | head -40; grep -rln "route" node_modules/patchy/ 2>/dev/null | head; exit 0 $ grep -n -i -B2 -A12 "route" node_modules/patchy/README.md | head -80; ls node_modules/patchy/dist/*.d.ts | head; grep -n -i -A8 "route" node_modules/patchy/dist/client.d.ts | head -50 denied $ cat > patchy.config.ts <<'EOF' … Contains brace with quote character (expansion obfuscation) write <env>/workspace/team-handbook/patchy.config.ts write <env>/workspace/team-handbook/src/App.tsx read <env>/workspace/team-handbook/src/styles.css edit <env>/workspace/team-handbook/src/styles.css exit 0 $ pnpm patchy refresh 2>&1 | tail -5; pnpm typecheck 2>&1 | tail -15; pnpm lint 2>&1 | tail -10 exit 0 $ pnpm patchy dev --json 2>&1 | tail -20; sed -n 1,200p .agents/skills/patchy-loop/SKILL.md | grep -n -i -E "browser|playwright|screenshot|exercise" | head denied $ which chromium chromium-browser google-chrome google-chrome-stable firefox 2>/dev/null; ls ~/.cache/ms-playwright 2>/dev/null; cd <env>/workspace/team-handbook && curl -s -o /dev/null -w "%{http_code}… This Bash command contains multiple operations. The following parts require approval: ls ~/.cache/ms-playwright, curl -s -o /dev/null -w "%{http_code}\n" http://127.0.0.1:36699/dev/localdev0000/people exit 4 $ which chromium chromium-browser google-chrome google-chrome-stable firefox /usr/bin/chromium denied $ cd <tmp> && curl -s -o /dev/null -w "%{http_code}\n" http://127.0.0.1:36699/dev/localdev0000/people; timeout 60 chromium --headless --no-sandbox --disable-gpu --user-data-di… This Bash command contains multiple operations. The following part requires approval: cd <tmp> && curl -s -o /dev/null -w "%{http_code}\n" http://127.0.0.1:36699/dev/localde… denied $ curl -s -o /dev/null -w "%{http_code}\n" http://127.0.0.1:36699/dev/localdev0000/people This command requires approval ``` </details> <details><summary>After's log: 12 commands, 4 failures</summary> ```console skill patchy exit 0 $ ls -a && patchy status --json && patchy whoami --json exit 0 $ patchy init ./team-handbook --tier 1 --purpose "Team handbook with Home, People and Policies pages, each at its own linkable address." --json 2>&1 | tail -20; cd team-handbook && ls && cat AGENTS.md |… exit 0 $ cat .agents/skills/patchy-preact/SKILL.md .agents/skills/patchy-look/SKILL.md; grep -n -i -B2 -A25 "route" .agents/skills/patchy-loop/SKILL.md | head -120; cat src/main.tsx src/App.tsx; ls src exit 0 $ grep -n -i -B3 -A30 "path" .agents/skills/patchy-preact/SKILL.md | sed -n 1,140p; cat src/main.tsx src/App.tsx; ls src; sed -n 1,60p .agents/skills/patchy-look/SKILL.md exit 0 $ cat src/styles.css; sed -n 60,120p .agents/skills/patchy-look/SKILL.md; cat patchy.config.ts; grep -n "route" patchy/_generated/client.ts | head denied $ cat > patchy.config.ts <<'EOF' … Contains brace with quote character (expansion obfuscation) write <env>/workspace/team-handbook/patchy.config.ts write <env>/workspace/team-handbook/src/App.tsx read <env>/workspace/team-handbook/patchy.json read <env>/workspace/team-handbook/src/styles.css edit <env>/workspace/team-handbook/src/styles.css exit 0 $ pnpm patchy refresh 2>&1 | tail -5; pnpm typecheck 2>&1 | tail; pnpm lint 2>&1 | tail -5 exit 0 $ pnpm patchy dev --json 2>&1 | tail -15 denied $ cd /tmp && for p in "" people policies; do curl -s -o /dev/null -w "%{http_code} /$p\n" http://127.0.0.1:38435/dev/localdev0000/$p; done; which chromium google-chrome chromium-browser 2>/dev/null; ls … A variable in this command can't be checked before it runs denied $ cd /tmp && curl -s -o /dev/null -w "%{http_code}\n" http://127.0.0.1:38435/dev/localdev0000/people; curl -s -o /dev/null -w "%{http_code}\n" http://127.0.0.1:38435/dev/localdev0000/policies; which chr… This Bash command contains multiple operations. The following parts require approval: cd /tmp, curl -s -o /dev/null -w "%{http_code}\n" http://127.0.0.1:38435/dev/localdev0000/people, curl -s -o /dev/… denied $ curl -s -o /dev/null -w "%{http_code}\n" http://127.0.0.1:38435/dev/localdev0000/people This command requires approval exit 0 $ pnpm patchy dev stop --api-url '<origin>' ``` </details> <!-- /patchy-dev:trial:routes --> ## How it was verified - **The facts against the code:** - `packages/patchy/src/clientTransport.ts`: the route's `get`, `set` and `subscribe`, including async notify, acknowledged-set adoption and queued notifications dropped on unsubscribe. - `packages/serving/src/broker.ts`: `routePath` rules, `route.set` → `pushState`, `popstate` → route event, frame reload → `stop()`, refusals as `invalid_request`. - `packages/patchy/src/devServer.ts` and `packages/serving/src/Pages.ts`: deep links are served in dev and hosted. - `packages/sdk/src/Generation.ts`: `patchy-preact` is installed on every tier 1 and 2 repo, vanilla included, so the loop pointer always resolves. - **The skill-pinning tests:** `vitest run packages/patchy/src/initProject.test.ts packages/sdk/src/SdkApi.test.ts` passed 37 of 37. The first pins the lint block in `patchy-preact`, which is unchanged. - **The trial:** `pnpm dev trial` ran twice with the same brief. The second run added only the request for a one-sentence answer, because the trial log keeps commands but not file contents. In the first run, too, the before agent grepped `.d.ts` files and the after agent read only the skills. Neither after agent published. The first said this machine was logged in as someone else. The second stopped when the launcher denied its `curl` checks. Neither stop has to do with routing. - **`pnpm verify`:** format, lint, typecheck, synth, postgres-concurrency, cli-smoke, install, tier2-smoke and browser passed. The offline `test` step failed locally on CLI stub-server tests that recorded a stray `GET /` none of them sent, plus a few load-timing tests. The failing set changed between runs, and none of those tests reads skill text. CI's run on this PR is the real check. - **Not checked:** `patchy dev` passes an opening address's encoded path to the page undecoded, while the hosted shell decodes it. The skill therefore claims decoding only for back, forward and `set`. ## Release impact Tick exactly one. - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — no action required. Only skill text changes; it reaches repos at their next refresh. - **What does a revert leave behind?** Repos refreshed in the meantime keep the Routes text in their managed skill copy until they refresh again. The text describes an API every release since routing shipped already has. - **Does the release before it still work with that?** Yes. No code, schema or contract changed. 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 1, 2026
## What changed
A patch could only get keyboard shortcuts if its builder's agent
hand-wrote `keydown` code. That code is easy to get wrong in text
fields, dialogs, sequences, other keyboard layouts and ⌘ versus Ctrl.
Now tier 1 and 2 pages import `patchy/hotkeys`, Patchy's own API over
TanStack Hotkeys, which is bundled inside it, and every tier 1 and 2
repo gets a `patchy-hotkeys` skill.
```tsx
import { HotkeyScope, formatHotkey, useHotkey, useHotkeyList } from "patchy/hotkeys";
useHotkey("G H", () => patchy.route.set("/"), { label: "Go home" });
useHotkey("Mod+K", openSearch, { label: "Search" });
```
Closes #1092. Part of #1086. Stacked on #1087, so keys reach the page
without a click.
Rebuilt from the #1052 prototype, with the issue's changes:
- **No `Control`.** A chord is `Mod`, `Alt` and `Shift`.
- **`HotkeyScope` is always exclusive.**
- **`Mod+Shift+K` is reserved.** The types refuse it in either letter
case, and a string cast past them is skipped with a console warning.
- **Conflicts warn in Patchy's words.** TanStack lets them through. Our
warning fires once, naming both labels, after every hook's update in a
render has landed.
- **Pins:** `@tanstack/preact-hotkeys` 0.17.1 over `@tanstack/hotkeys`
0.19.0, exact.
- **Licences:** both MIT notices, Hotkeys 2026 and Store 2021, are in
`dist/licenses`.
It costs 13.4 KB gzipped, only in pages that import it: a minimal Preact
page goes from 17.9 to 31.4 KB in Vite's production build.
## Look at
**A string that isn't a hotkey fails `pnpm typecheck`, saying what to
write instead.** `packages/patchy/src/hotkeys.test.ts` asserts these
lines exactly, against the published declarations:
```
consumer.ts(2,11): error TS2345: Argument of type '"Ctrl+K"' is not assignable to parameter of type '"'Ctrl+K' isn't a chord: write 'Mod+K', which is ⌘ on a Mac and Ctrl elsewhere"'.
consumer.ts(3,11): error TS2345: Argument of type '"Control+K"' is not assignable to parameter of type '"'Control+K' isn't a chord: write 'Mod+K', which is ⌘ on a Mac and Ctrl elsewhere"'.
consumer.ts(5,11): error TS2345: Argument of type '"Esc"' is not assignable to parameter of type '"'Esc' isn't a chord: write keys like 'Mod+K', 'Escape', '?' or 'G H', modifiers in the order Mod, Alt, Shift"'.
consumer.ts(7,11): error TS2345: Argument of type '"Mod+Shift+K"' is not assignable to parameter of type '"'Mod+Shift+K' is kept by Patchy for its own shortcuts: choose another chord"'.
consumer.ts(9,11): error TS2345: Argument of type '"G Mod+Shift+K"' is not assignable to parameter of type '"'Mod+Shift+K' is kept by Patchy for its own shortcuts: choose another chord"'.
```
The test also covers `"Cmd+K"`, `"Shift+Mod+K"`, `"Mod+Shift+k"` and
`"Ctrl+Shift+K"`. `"Mod+K"`, `"?"`, `"G H"`, `"Alt+ArrowUp"` and a
`Chord[]` built from data typecheck clean.
**A published tier 1 page in the shell**
(`test/browser-tier1/hotkeys.spec.ts`, Chromium):
- `G H` changes the route on the first press, with no click.
- In a text field, `L` waits and `Mod+Enter` fires.
- On a checkbox, radio or range, `L` fires, and Space and the arrow keys
still work the control.
- An open `HotkeyScope` holds back the page's `L` and its `G H`, while
its own `G H` fires. `useHotkeyList` still lists the page's labelled
hotkeys.
- Layouts use trusted key events:
- AZERTY's `?` (Shift on `KeyM`) fires `"?"`.
- Russian `о` on `KeyJ` fires `"J"`.
- AZERTY's Ctrl+`=` on the `/` key fires `"Mod+="`, not `"Mod+/"`
(TanStack/hotkeys#210).
- Ctrl+Shift on the `/` key, which types `?`, fires `"Mod+Shift+/"`: a
shifted ASCII symbol falls back to its key's position.
- On an emulated Mac, `formatHotkey("Mod+K")` is `⌘ K`, and Meta+Enter
fires `Mod+Enter` where Control+Enter doesn't.
- Two sibling components swap `K` and `L` in one state update, and
nothing warns. A third component binding `K` then warns once: `"Second"
and "Third" both use K`.
```
✓ [chromium] › test/browser-tier1/focus.spec.ts:16:1 › a patch hears the keyboard once its frame loads (166ms)
✓ [chromium] › test/browser-tier1/hotkeys.spec.ts:118:1 › patchy/hotkeys fires in the published frame across fields, scopes, layouts and a Mac (721ms)
✓ [chromium] › test/browser-tier1/hotkeys.spec.ts:227:1 › a conflict warning waits for every hook's update, so siblings swapping keys don't warn (293ms)
```
TanStack 0.19.0 fixed the checkbox, radio and range case
(TanStack/hotkeys#206), so the layer carries no workaround for it.
**Fresh agents, `pnpm dev trial` on Sonnet 5.5, two runs per brief.**
Before is #1087's head, which has no helper. After is this PR plus one
local-only commit, never pushed: a `minimumReleaseAgeExclude` for the
two TanStack versions, so the evidence install gets past the release-age
window. That window has since passed, and nothing pushed bypasses the
policy.
- **Directed: a task tracker with `G H`, `G D`, `C T` and `?`.**
- Run 1: the after agent took the single-file route, with no repo,
hand-wrote the keys in one HTML file and published. A single-file page
can't import `patchy/hotkeys` and never sees the project skill. My brief
didn't say tasks are saved, which made a static file a fair pick.
Choosing the route is the global skill's job, outside this PR.
- Run 2, adding "Tasks anyone adds should be saved for everyone": the
after agent read `patchy-hotkeys` and built every shortcut with
`useHotkey`, `HotkeyScope`, `useHotkeyList`, `formatHotkey` and
`hotkeyKeys`. Typecheck and lint were clean and `patchy dev` ran. It
stopped before publishing to look for a browser to press the keys in,
which is #1090. It opened type files only to find `patchy.route`, which
#1088 adds to the skills.
- **Undirected: a support queue "as fast to work through as possible".
Informational.**
- Run 1: the after agent read `patchy-hotkeys`, and its purpose line
says "keyboard-driven triage". The log keeps no file contents, so
whether it imported the helper isn't recorded.
- Run 2: the after agent imported `patchy/hotkeys` without being asked
and published. The before agent's page imported only `patchy/preact` and
the generated client.
<details><summary>Run 2, directed: task tracker</summary>
<!-- patchy-dev:trial:tracker -->
#### Trial `tracker`
> Make me a task tracker patch for our team. Tasks anyone adds should be
saved for everyone. I want to drive it from the keyboard: G then H goes
to the task list, G then D shows the done tasks, C then T opens a dialog
to create a task, and ? shows a list of every shortcut. Put in a few
example tasks. Publish it when it works. Start your reply with one
sentence naming what the page imports from patchy.
Before is `9ff46e3` (--base origin/fix/frame-focus-1087) and after is
`ccaa307` (feat/hotkeys-1092), both on the `team` scenario, from `pnpm
dev trial`.
Each side gave the task to a fresh agent: after's `agent` launcher in
the side's environment, Claude Code on `claude-sonnet-5-5` as the
scenario's publisher, with the side's release of the Patchy skill and no
personal instructions or settings, run without a person within 60 turns
and 20 minutes. The log keeps each tool call, commands with their exit
codes, and one line per failure; not the agent's reasoning or what its
commands printed. Redacted before writing: email addresses outside the
scenarios' example domains; the accounts the run acts as.
One run is a smell test, not a measurement.
| | Before | After |
| --- | --- | --- |
| Finished | Yes | Yes |
| Commands | 14 | 15 |
| Failures | 2 | 4 |
| Help lookups | 0 | 0 |
| Minutes | 1.8 | 1.5 |
**Before** answered: “The page imports `render`, `useState`,
`useEffect`, `useRef` and `useQuery` from `patchy/preact`, and its
config imports `defineConfig`, `table` and `t` from `patchy/config`.
It's published and company colleagues can open it:
<origin>/acme/team-tasks (version 1, tier 1).”
**After** answered: “The page imports `useState`, `useEffect` and
`useQuery` from `patchy/preact`, `useHotkey`, `HotkeyScope`,
`useHotkeyList`, `formatHotkey` and `hotkeyKeys` from `patchy/hotkeys`,
and `defineConfig`, `table` and `t` from `patchy/config`. I haven't
published it yet, for two reasons.”
<details><summary>Before's log: 14 commands, 2 failures</summary>
```console
skill patchy
exit 0 $ patchy status --json; patchy whoami --json
exit 0 $ patchy init ./team-tasks --tier 1 --purpose "Shared team task tracker: add tasks, mark them done, and drive it with keyboard shortcuts (G H list, G D done, C T create, ? help)." --json 2>&1 | tail -30…
exit 0 $ cd <env>/workspace/team-tasks && cat AGENTS.md CLAUDE.md patchy.config.ts src/*.tsx; cat .agents/skills/patchy-loop/SKILL.md; cat patchy/_generated/index.json | head -50; ls fixtures helpers
exit 0 $ cat patchy.config.ts src/*.tsx; ls fixtures helpers src; cat .agents/skills/patchy-tables/SKILL.md
exit 0 $ cat .agents/skills/patchy-preact/SKILL.md; sed -n 1,200p .agents/skills/patchy-loop/SKILL.md
exit 0 $ cat src/styles.css | head -40; grep -n -i -A12 fixture .agents/skills/patchy-loop/SKILL.md | head -60
denied $ cat > patchy.config.ts <<'EOF' …
Contains brace with quote character (expansion obfuscation)
write <env>/workspace/team-tasks/patchy.config.ts
write <env>/workspace/team-tasks/src/App.tsx
exit 0 $ pnpm patchy refresh 2>&1 | tail -5; pnpm typecheck 2>&1 | tail -20; pnpm lint 2>&1 | tail -10
exit 0 $ grep -n -B2 -A8 "Me\b" patchy/_generated/client.ts | head -40; grep -n "Id<" patchy/_generated/client.ts | head -5
exit 0 $ grep -rn "type Me\b\|interface Me\b" node_modules/patchy/dist --include=*.d.ts -A8 | head -20; grep -rn "export type Id\b" node_modules/patchy/dist --include=*.d.ts | head
denied $ sed -i 's/me?\.name ?? "Someone"/me?.user.name ?? "Someone"/; s/function toggle(id: string, done: boolean)/function toggle(id: (typeof rows)[number]["id"], done: boolean)/' src/App.tsx && pnpm typeche…
This Bash command contains multiple operations. The following part requires approval: sed -i 's/me?\.name ?? "Someone"/me?.user.name ?? "Someone"/; s/function toggle(id: string, done: boolean)/functio…
edit <env>/workspace/team-tasks/src/App.tsx
edit <env>/workspace/team-tasks/src/App.tsx
exit 0 $ pnpm typecheck 2>&1 | tail; pnpm lint 2>&1 | tail -5
exit 0 $ pnpm patchy dev --json 2>&1 | tail -15
exit 0 $ pnpm patchy dev stop 2>&1 | tail -2; pnpm patchy publish --json 2>&1 | tail -20
```
</details>
<details><summary>After's log: 15 commands, 4 failures</summary>
```console
skill patchy
exit 0 $ ls -a && patchy status --json && patchy whoami --json
exit 0 $ patchy init ./team-tasks --tier 1 --purpose "Shared team task tracker: add tasks everyone sees, mark them done, and drive it from the keyboard (G H list, G D done, C T new task, ? shortcuts)." --json …
exit 0 $ cd <env>/workspace/team-tasks && cat AGENTS.md patchy.config.ts src/*.tsx; cat .agents/skills/patchy-loop/SKILL.md .agents/skills/patchy-hotkeys/SKILL.md .agents/skills/patchy-tables/SKILL.md; ls src …
exit 0 $ cat patchy.config.ts; ls src fixtures; cat src/App.tsx src/main.tsx; cat .agents/skills/patchy-hotkeys/SKILL.md; cat .agents/skills/patchy-tables/SKILL.md
exit 0 $ grep -n -i -E "route|dialog|export|import" .agents/skills/patchy-preact/SKILL.md | head -50; cat src/styles.css | head -30; ls fixtures; grep -n -i fixture .agents/skills/patchy-loop/SKILL.md | head
denied $ cat > patchy.config.ts <<'EOF' …
Contains brace with quote character (expansion obfuscation)
write <env>/workspace/team-tasks/patchy.config.ts
write <env>/workspace/team-tasks/src/App.tsx
exit 0 $ cat >> src/styles.css <<'EOF' …
exit 0 $ grep -n -B2 -A8 "route" .agents/skills/patchy-preact/SKILL.md .agents/skills/patchy-loop/SKILL.md | head -40; grep -n "route" patchy/_generated/client.ts | head
exit 0 $ grep -rn -A12 "interface.*Route\|route:" node_modules/patchy/dist/*.d.ts 2>/dev/null | head -40
exit 0 $ grep -rln "subscribe" node_modules/patchy/ --include=*.d.ts 2>/dev/null | head; grep -rn "route" node_modules/patchy/ --include=*.d.ts 2>/dev/null | head
exit 0 $ grep -n -B2 -A14 "type Route\b\|interface Route\b" node_modules/patchy/dist/_types/config-ihDgouFZ.d.ts | head -40
denied $ python3 - <<'EOF' …
grep -n "Id\b" node_modules/patchy/dist/_types/config-ihDgouFZ.d.ts
edit <env>/workspace/team-tasks/src/App.tsx
edit <env>/workspace/team-tasks/src/App.tsx
edit <env>/workspace/team-tasks/src/App.tsx
exit 0 $ pnpm typecheck 2>&1 | tail; pnpm lint 2>&1 | tail; pnpm patchy dev --json 2>&1 | tail -15
denied $ which chromium chromium-browser google-chrome firefox 2>&1 | head; ls ~/.cache/ms-playwright 2>&1 | head -3; cd <env>/workspace/team-tasks && tail -15 .patchy/dev/*/dev.log
This Bash command contains multiple operations. The following part requires approval: head; ls ~/.cache/ms-playwright 2>&1
exit 3 $ which chromium chromium-browser google-chrome firefox
/usr/bin/chromium
```
</details>
<!-- /patchy-dev:trial:tracker -->
</details>
<details><summary>Run 2, undirected: support queue</summary>
<!-- patchy-dev:trial:queue -->
#### Trial `queue`
> Make me a support queue patch for our team to work through incoming
customer tickets. It should be as fast to work through as possible. Put
in a few example tickets. Publish it when it works. Start your reply
with one sentence naming what the page imports from patchy.
Before is `9ff46e3` (--base origin/fix/frame-focus-1087) and after is
`ccaa307` (feat/hotkeys-1092), both on the `team` scenario, from `pnpm
dev trial`.
Each side gave the task to a fresh agent: after's `agent` launcher in
the side's environment, Claude Code on `claude-sonnet-5-5` as the
scenario's publisher, with the side's release of the Patchy skill and no
personal instructions or settings, run without a person within 60 turns
and 20 minutes. The log keeps each tool call, commands with their exit
codes, and one line per failure; not the agent's reasoning or what its
commands printed. Redacted before writing: email addresses outside the
scenarios' example domains.
One run is a smell test, not a measurement.
| | Before | After |
| --- | --- | --- |
| Finished | Yes | Yes |
| Commands | 11 | 16 |
| Failures | 2 | 2 |
| Help lookups | 0 | 0 |
| Minutes | 1.5 | 2.6 |
**Before** answered: “The page imports `useQuery`, `useState`,
`useEffect`, `useMemo`, `useRef` and `render` from `patchy/preact`, and
the generated `patchy` table client from `patchy/_generated/client.js`.
The support queue is published at <origin>/acme/support-queue.”
**After** answered: “The page imports `patchy/preact` (Preact and the
`useQuery` hook), `patchy/hotkeys` (keyboard shortcuts), and
`patchy/config` (the table definition at build time). The support queue
is published at <origin>/acme/support-queue.”
<details><summary>Before's log: 11 commands, 2 failures</summary>
```console
skill patchy
exit 0 $ ls -a && patchy status --json && patchy whoami --json
exit 0 $ patchy init support-queue --tier 1 --purpose "Support queue for the team to triage and work through incoming customer tickets quickly with keyboard shortcuts: claim, reply, resolve, snooze." --json 2>…
exit 0 $ cat .agents/skills/patchy-preact/SKILL.md .agents/skills/patchy-tables/SKILL.md .agents/skills/patchy-look/SKILL.md; ls fixtures src; cat fixtures/* | head -20; cat patchy/_generated/context/table-not…
exit 0 $ sed -n 40,200p .agents/skills/patchy-preact/SKILL.md; echo =====; cat .agents/skills/patchy-tables/SKILL.md | head -150; ls fixtures src
exit 0 $ grep -n -i -B2 -A12 "fixture" .agents/skills/patchy-loop/SKILL.md | head -90; cat src/styles.css; grep -n "me\b" patchy/_generated/client.ts | head; grep -o "^\s*--look-[a-z-]*" patchy/_generated/look…
exit 0 $ grep -n -i "me\b\|me(" patchy/_generated/client.ts | head; grep -n -A8 "me()" .agents/skills/patchy-loop/SKILL.md | head -30; sed -n 1,40p patchy/_generated/look.css | cut -c1-120
denied $ cat > patchy.config.ts <<'EOF' …
Contains brace with quote character (expansion obfuscation)
write <env>/workspace/support-queue/patchy.config.ts
write <env>/workspace/support-queue/src/seed.ts
write <env>/workspace/support-queue/src/styles.css
write <env>/workspace/support-queue/src/App.tsx
exit 0 $ pnpm patchy refresh --json 2>&1 | tail -3; pnpm typecheck 2>&1 | tail -15; pnpm lint 2>&1 | tail -15
denied $ sed -i 's/}, \[sel?.id\]);/}, [sel?.id, sel?.reply]);/; s/useEffect(() => setReply(sel?.reply ?? ""), \[sel?.id\]);/useEffect(() => setReply(sel?.reply ?? ""), [sel?.id, sel?.reply]);/' src/App.tsx &&…
This Bash command contains multiple operations. The following part requires approval: sed -i 's/}, \[sel?.id\]);/}, [sel?.id, sel?.reply]);/; s/useEffect(() => setReply(sel?.reply ?? ""), \[sel?.id\])…
edit <env>/workspace/support-queue/src/App.tsx
exit 0 $ pnpm typecheck 2>&1 | tail -5; pnpm lint 2>&1 | tail -5; pnpm patchy dev --json 2>&1 | tail -5
exit 0 $ pnpm patchy dev logs 2>&1 | tail -8; pnpm patchy dev stop >/dev/null 2>&1; pnpm patchy publish --json 2>&1 | tail -5
```
</details>
<details><summary>After's log: 16 commands, 2 failures</summary>
```console
skill patchy
exit 0 $ ls -a && patchy status --json && patchy whoami --json
exit 0 $ patchy init ./support-queue --tier 1 --purpose "Support queue for the team to triage and work through incoming customer tickets quickly, with keyboard shortcuts, claim, reply and resolve." --json 2>&1…
exit 0 $ cat .agents/skills/patchy-hotkeys/SKILL.md .agents/skills/patchy-tables/SKILL.md .agents/skills/patchy-look/SKILL.md; ls fixtures src; cat fixtures/* | head -20; cat src/styles.css
exit 0 $ sed -n 40,200p .agents/skills/patchy-hotkeys/SKILL.md | head -90; echo =====; cat .agents/skills/patchy-tables/SKILL.md | head -150; ls fixtures src; cat src/styles.css | head -30
exit 0 $ grep -n -i -B2 -A12 "fixture" .agents/skills/patchy-loop/SKILL.md | head -80; grep -o "\-\-look-[a-z-]*:[^;]*" patchy/_generated/look.css | head -20; ls fixtures; cat patchy/_generated/context/table-n…
exit 0 $ grep -n "me()\|me:" -r .agents/skills/patchy-preact/SKILL.md .agents/skills/patchy-loop/SKILL.md | head; grep -n "useMe\|useQuery" .agents/skills/patchy-preact/SKILL.md | head
exit 0 $ grep -n "me\b" patchy/_generated/client.ts | head -8; grep -n "me" patchy/_generated/README.md | head
exit 0 $ cat patchy/_generated/client.ts | head -40; grep -rn "\.me\b\|me()" .agents/skills/patchy-preact/SKILL.md node_modules/patchy/dist/*.d.ts 2>/dev/null | head
exit 0 $ grep -rn "me:\|me(" node_modules/patchy/dist --include=*.d.ts | head -8
exit 0 $ grep -rn "me\b" node_modules/patchy/dist/_types/*.d.ts | grep -i "viewer\|Promise\|readonly me" | head -8
exit 0 $ grep -n "type Me\b\|interface Me\b" -A6 node_modules/patchy/dist/_types/config-ihDgouFZ.d.ts
denied $ cat > patchy.config.ts <<'EOF' …
Contains brace with quote character (expansion obfuscation)
write <env>/workspace/support-queue/patchy.config.ts
write <env>/workspace/support-queue/src/styles.css
write <env>/workspace/support-queue/src/App.tsx
exit 0 $ pnpm patchy refresh 2>&1 | tail -5; pnpm typecheck 2>&1 | tail -20; pnpm lint 2>&1 | tail -10
denied $ sed -i 's|^ useEffect(() => { setDraft(sel?.reply ?? ""); }, \[sel?.id\]);| // Reset the draft only when the selected ticket changes, not on every edit to it.\n // oxlint-disable-next-line react-ho…
This Bash command contains multiple operations. The following part requires approval: sed -i 's|^ useEffect(() => { setDraft(sel?.reply ?? ""); }, \[sel?.id\]);| // Reset the draft only when the sel…
edit <env>/workspace/support-queue/src/App.tsx
exit 0 $ pnpm lint 2>&1 | tail -5; pnpm typecheck 2>&1 | tail -3; pnpm patchy dev --json 2>&1 | tail -5
exit 0 $ pnpm patchy dev stop 2>&1 | tail -1; pnpm patchy publish --json 2>&1 | tail -15
```
</details>
<!-- /patchy-dev:trial:queue -->
</details>
## How it was verified
- **`pnpm verify`, at `13378bf`:** 9 of 10 suites pass, including
`browser` (the whole tier 1 suite), `cli-smoke`, `install` and
`tier2-smoke`. In `test`, 12 CLI and executor cases failed. Each failure
is an unexpected `GET /` or other stray request on a local stub server,
which the T3 Code harness sends to local ports on this machine. None are
in a file this PR touches, and the same tests failed or passed between
runs.
- **Packed tarball** (`scripts/packed-preact-e2e.mjs`, in `cli-smoke`).
A consumer of the packed `patchy` installs no `@tanstack` package. It
typechecks `patchy/hotkeys` with `skipLibCheck: false`, with a
`@ts-expect-error` on `"Mod+Shift+K"`. A `G H` hotkey then updates state
on the page's own Preact, in optimized dev and in the single-file build:
```
[packed-preact] patchy/hotkeys installs no TanStack package
[packed-preact] JSX, table and hotkey types resolve without a direct
Preact dependency
[packed-preact] optimized dev: signals, hooks, compat, useQuery and SDK
debugging share one runtime
[packed-preact] single-file published artifact runs with no development
instrumentation
```
- **Unit tests** (`hotkeyRules.test.ts`):
- A cast `"Mod+Shift+K"`, `"G mod+shift+k"` or `"Shift+Mod+K"` is left
out of registration with one warning each.
- Two enabled `Mod+K`s in one scope warn once, naming both labels. A
disabled duplicate, or the same keys in another scope, don't warn.
- **Page imports** (`pageImports.test.ts`):
- `patchy/hotkeys` builds and runs on the page graph: `⌘ K` on a Mac
`navigator`, `Ctrl+K` on Windows.
- It is `import_refused` on the server graph.
- With the entry point removed, the page case fails at the build.
- **Generation** (`SdkApi.test.ts`):
- On tiers 1 and 2 the skill installs with `patchy-preact`, and stays
when a repo moves from tier 2 to 1.
- It is in `index.json`'s skills and capabilities, and in
`patchy-loop`'s catalogue.
- Tier 0 is gone since #1048, so the issue's "fresh tier 0" and "moves
to tier 0" cases no longer exist.
- **Analytics** (`PatchesApi.test.ts`): a publish's `patch.created`
reports `patchy/hotkeys` among its SDK imports.
**Human checks: a merge gate only Allison can clear.** Headless browsers
can't show these, because synthetic key presses skip the browser's own
shortcuts.
- Done, by Allison on 2026-10-30, recorded on #1091: Mod+Shift+K reached
the page, and the browser did nothing of its own, in Chromium and Zen
(Firefox-based) on Linux.
- [ ] Edge: Mod+Shift+K reaches the page. Edge uses Ctrl+Shift+K to
duplicate the tab.
- [ ] A real Mac, in Safari and Chrome: Mod+Shift+K reaches the page,
and the page's shortcuts fire once. The suite runs Chromium on Linux and
only pretends to be a Mac.
**Preact 11.** Main moved to Preact 11.1.0 (#975) while this was open.
Preact 11 runs a passive effect's cleanup after the next paint, so the
layer now does its work in layout effects. `HotkeyScope` activates its
scope there (`c3d82f1`), and every hotkey registers and unregisters
there (`5246547`), so nothing is held back or fires a frame late. Three
acceptance rounds with fresh agents sharpened the skill's dialog section
(`9cf8ac9`, `d168798`): a dialog's own keys go inside its scope, the
page's hotkeys stay enabled, and a dialog focuses its field from code.
The TanStack pins resolve against Preact 11, and CI installs them with
the release-age policy on.
## Release impact
- [ ] **Breaking** — requires action from anyone already running this
- [x] **Not breaking** — no action required. A new page entry point and
a new project skill; nothing that exists changes.
Labelled `one-way`, so the deploying agent reads this:
- **What does a revert leave behind?** Three things:
- published versions whose page bundles `patchy/hotkeys`;
- repos holding `.agents/skills/patchy-hotkeys/`;
- repos whose source imports `patchy/hotkeys`.
- **Does the release before it still work with that?**
- **Viewers: yes.** Helper code is bundled into the page. `sdkImports`
isn't a serving allowlist: `packages/patches/src/Patches.ts` uses it
only to filter analytics.
- **Refresh and dev: only with #1089.** Today generation refuses a skill
it doesn't ship (`SdkApi.test.ts`: `patchy-removed` answers 422). After
a rollback to a release without #1089, every tier 1 and 2 repo refreshed
since this PR would fail refresh and `patchy dev`. **#1089 has to be
live in a release before this one ships.**
- **Repos that import `patchy/hotkeys`: no.** The older package has no
such entry, so their page graph is `import_refused`. They can't build a
new version until production rolls forward, as with any new helper.
Removing the entry point fails `pageImports.test.ts`'s hotkeys case
exactly that way.
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]>
Owner
Author
This was referenced Nov 6, 2026
allisonmahmood
added a commit
that referenced
this pull request
Nov 11, 2026
…1297) ## What changed Builder agents run `patchy dev` but had no word on how to check the page they built. In #1052's trials, one agent wrote its own DevTools-protocol driver and then told the person a working shortcut "may not register". Another shipped without testing. `patchy-loop` step 4 now says what's true of the dev page, so an agent can drive it with whatever browser tools it has. Patchy ships no browser, so the agent uses its own browser tools or installs Playwright from npm, in desktop Chromium, the browser Patchy supports. Each URL opens as its viewer with no sign-in, on its `127.0.0.1` host. The patch is `iframe#patch`, on an origin of its own. The frame takes focus as the patch loads, and tier 2's starting cover holds focus until it closes; keys pressed while it's up don't reach the patch. Patchy's own cards sit outside the frame. Input from the tool's keyboard and mouse reaches the patch as a person's would. Script differs: the Download button ignores a script's click, and a key dispatched inside the frame can run a matching hotkey but types nothing. Screenshots stay out of the repo, linking the rule the skill already has. Closes #1090 ## Look at **The new paragraph**, in `packages/sdk/skills/patchy-loop/SKILL.md` step 4. It's one paragraph, right after `url`, `colleagueUrl` and `guestUrl` are introduced. **Fresh agents, before and after.** Task: a snack-orders patch with a form, a Delivered button and N to jump to the Who field, checked in the dev page before reporting. Each row is one run per side, so treat it as a smell test. | Run | Before (main's text) | After (this branch) | | --- | --- | --- | | `pnpm dev eval`, Sonnet 5.5 high in its sandbox: nothing installed but Node, pnpm and the harness | Grepped `patchy-loop` for "browser\|playwright" and found nothing. Installed `playwright-core` from npm into a scratch folder and drove the system Chromium. Found the patch by scanning `page.frames()`. Reported "after each add, the cursor went back to Who". Its script never checked that, and it's false: the handler focuses Who while the field is still disabled. | Installed `playwright-core` the same way, then opened `iframe#patch` directly and also the `colleagueUrl` as a second viewer. Its check found that same focus bug, and it fixed and re-checked before publishing. Kept its scripts and screenshots outside the repo and said so. | | Same, the uncounted warm-up run | Same approach: published, graded pass. | Same approach, plus a focus-on-load probe: published, graded pass. | | Environment `agent` launcher, Sonnet, on a machine that already has Playwright | Used it with `frameLocator("iframe").first()`. Its report was true; I re-drove its page. | Used `iframe#patch`. Its check caught N typing an "n" into a field that kept focus after a save, and it fixed that. Its report was true; I re-drove its page. | None of the six runs wrote a DevTools-protocol driver. Every one pressed keys and clicked through Playwright's real input. Both eval sides pass grading: published, typechecks, opens ready. The difference is in what got checked. After's agents took the frame from the text, used the second viewer, and caught a focus bug that before's report claimed was fine. `pnpm dev trial` couldn't be used here: its agents can't sign in through this machine's model provider. The eval task was a scratch module, never committed. ## How it was verified I checked each fact in the shell source (`broker.ts` `handOffKeys`, `stream-status.ts`, `downloads.ts`, `devServer.ts`) and in a real tier 2 `patchy dev` session, driven by a Playwright script kept outside the repo: ``` owner status 200 cookies 0 colleague status 200 cookies 0 guest status 200 cookies 0 localhost status 404 iframes in top 1 top can reach contentDocument false top activeElement IFRAME#patch after real c without click: Keys: 1 after synthetic c in top: Keys: 1 after synthetic c inside frame: Keys: 2 script-clicked Download: no download card still up: true after clicking card text activeElement BODY# c after clicking card text: Keys: 4 real-clicked Download: download after Download activeElement IFRAME#patch c after Download: Keys: 5 input value after dispatched key: "" ``` Three of the issue's hypotheses were wrong, so the text says something different, and [the issue reply](#1090 (comment)) records why: - A `KeyboardEvent` dispatched inside the frame does fire the patch's hotkeys. It only fails to type into a field. - The buttons on Patchy's cards hand focus back to the frame. Only clicking a card's text moves focus out. - Playwright's `evaluate` grants user activation in Chromium, so the skill makes no claim about activation. The shell's Download button is the one `isTrusted` check. A `patchy refresh` against the local instance brought the new text into a patch repo's `.agents/skills/patchy-loop/SKILL.md`. Project skills are served by generation, so nothing else needed regenerating. `pnpm verify`: 9 of 11 suites pass locally. `test` and `test (bun)` fail only on extra requests in CLI stubs' request logs, a stray `GET /` or one call too many. A local tool on this machine probes loopback ports; CI runs the same suites on this PR. No failing test reads skill text, and the SDK generation tests pass. Surfaces from CLAUDE.md's list: - **The CLI.** The only one that applied: the project skill in `packages/sdk/skills`, served by generation. - **No CLI, `--json` or ADR-0004 change.** No command, flag or output changed. The global `patchy` skill is untouched, so `skills-lock.json` is too. - **`patchy-hotkeys`.** One line: its focus rule now also says a download card's buttons and the new-version bar's Not now hand focus back, matching the new text. No open PR edits that line. - **Didn't apply:** the wire contract, the dev loop, vocabulary, migrations, company resources, served pages, reverse states and the repo layout. ## Release impact Tick exactly one. - [ ] **Breaking** — requires action from anyone already running this - [x] **Not breaking** — no action required Skill text only. A patch repo picks it up on its next refresh or dev start. - **What does a revert leave behind?** Nothing. Repos that refreshed keep the text until their next refresh. - **Does the release before it still work with that?** Yes. Built by Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, through T3 Code. Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prototype, not for merge. It answers one question: can patches get great keyboard shortcuts (G then H to go home, C then T to create, Mod+K,
?for a sheet) through a Patchy layer over TanStack Hotkeys, and do agents build with it well?What changed
Patches can't install npm packages, and the patch runs in a sandboxed frame, so this adds three pieces:
patchy/hotkeys, Patchy's own API. Agents writeuseHotkey("G H", run, { label }),"Mod+K"and"?"; a string that isn't a hotkey fails typecheck and names the step to fix. TanStack is bundled inside and none of its types are published, so an upstream change lands inpackages/patchy/src/hotkeys.ts, not in patches.patchy-hotkeysskill, installed withpatchy-preacton tiers 1 and 2, plus a catalogue line.Look at
The demo patch's
?sheet, built fromuseHotkeyList():Stress test, 41/41 on Linux and on emulated macOS, in the real shell (
stress.mjs):patchy.route; a slow second step times out; Shift+G doesn't match G<HotkeyScope exclusive>silences page keys while C T's dialog is open"?"fires on US and AZERTY; Cyrillic on the J key still fires J; IME composition is ignoredTwo fresh Sonnet 5.5 agents built patches against this release:
useHotkeyListsheet and keycaps, in 5.6 min.Learnings
?sheet opened in an exclusive scope listed only its own Escape. Held chords repeat, sorepeat: falseexists for create and send."Shift+?"is layout-dependent and displays oddly, so the skill teaches"?".patchy.routeis in no skill. Agents grep.d.tsfiles to build G-sequence navigation.How it was verified
stress.mjsagainstpatchy dev, in headless Chromium with platform emulation for macOS. I drove both trial patches through the hosted shell after publish. The SDK suite passes (34/34).pnpm verifywas not run. Browser-reserved keys (Mod+T, W, N, L) can't be checked headless and need a hand check in a real browser.Try it
Release impact
Breaking — requires action from anyone already running this
Not breaking — no action required. Prototype, never merged.
What does a revert leave behind? Nothing; it never merges.
Does the release before it still work with that? Yes.
Model: Claude Opus 5.5. Harness: Claude Code in T3 Code.