feat(plugins): keyboard shortcuts leave the core for the keyboard-shortcuts plugin — app.keymap, optionalRequires #18

Closed
gabrielvidal wants to merge 0 commits from keyboard-shortcuts-plugin into main
pull from: keyboard-shortcuts-plugin
Owner

Summary

Keyboard shortcuts leave the core for a live plugin, keyboard-shortcuts (ai-agent-plugins, paired PR). Which keys run which command now belongs to the plugin: the defaults, each person's own bindings, the on/off switch, Settings → Keyboard (a nav: "settings" page) and the cheat sheet (an app.modal slot). The core keeps what a sandboxed frame can't do: the one keydown listener, the commands and their handlers. With no plugin installed there are no shortcuts. Prompt shortcuts are an optional peer, through the new optionalRequires manifest key: while the prompt-shortcuts plugin is on, the keymap gains the Composer group and a key per named prompt shortcut (Alt+C = Changes). These are Gabriel's picks in form keyboard-shortcuts-as-a-plugin_2aqd47.

Stacked: on What's new #14 (init.lang, the app modal / Settings hooks) and on prompt-shortcuts #17 (seed, nav: "settings", which it merges in). Merge it after both.

Key changes

  • provides: {"app.keymap": …} (backend/plugins/keymap.py, GET /api/plugins/keymap):
    • the provider runs as the caller (a guest gets the owner's managed install);
    • the answer is sanitized against the chord grammar and cached per user;
    • any plugin change drops the cache, as does a write by the provider for that user (SSE keymap → their tabs refetch).
  • Commands (lib/keyboard/actions.ts) no longer hold keys. Two command families are new:
    • composer.shortcut:<chip id> toggles a named chip (useComposerKeys);
    • modal:<plugin>:<slot> opens a plugin's modal (KeyboardHost), and closes it when it's the one open.
  • business/keyboard/keymap.ts:
    • useKeymap / useKeymapIndex / useCommandKeys;
    • the last keymap is kept in localStorage, so the first key after a load works;
    • the tooltip hints (⌘G, Alt+N on the profile switch) read it.
  • optionalRequires (manifest.py, proxyroutes.py, scheduler.py, info page):
    • optional peers, never checked at install / enable / disable / uninstall;
    • their exports and plugin:<peer>:<event> events open while they're on;
    • the info page has a Works with row (optionalRequires, peersActive);
    • part of the fingerprint only when set.
  • Frame bridges (PluginSandboxFrame):
    • commands() returns the app's commands for this person, in their language (business/keyboard/commands.ts);
    • keyChord(ev) runs the host's chord parser, so a key recorded in a frame matches what the app listens for.
  • Keys from plugin frames reach the app: a frame forwards each keydown it didn't preventDefault() (not plain typing, never Esc). The host takes it only while that frame has the focus, so g h works on a plugin page.
  • ui.pages[].desktopOnly for nav: "settings" pages keeps Settings → Keyboard out of a phone's drawer, as the core entry was.
  • Carry-over carryover.keyboard: each person's state.keyboard → the plugin's per-user keymap.json, once. The old key stays in the blob, unread.
  • Removed: business/keyboard/pages/Keyboard.tsx, CheatSheet.tsx, settings.keyboard and its setters, and the core Keyboard Settings entry.
    • /settings/keyboard redirects to /settings/p/keyboard-shortcuts/keyboard;
    • saved layouts map the old keyboard key onto the plugin page.
  • Docs: CLAUDE.md → Keyboard shortcuts; docs/plugins.md → "Keyboard shortcuts: the keymap, commands, optional peers".

Key decisions

  • The listener stays core. A sandboxed frame can't see the app's keys or move its router, composers or profiles. So the plugin owns which keys (data, page, cheat sheet), not what happens. This is the same split as composer.shortcuts.
  • Defaults live in the plugin; labels stay in the core. The core names its commands (the palette needs the names too, and they translate with the app). The plugin decides the keys and gates the Composer group on its peer.
  • One chord parser. The plugin's recorder asks the host (keyChord) instead of shipping a copy of keys.ts, whose physical-key and layout rules are subtle.
  • Catalog ids = the old action ids (only help now runs the plugin's modal), so the carry-over is a straight copy.
  • Forwarded keys need the focus. A frame can't press the app's keys behind the person's back.

Changelog

  • Changed: keyboard shortcuts are now the Keyboard shortcuts plugin's. Settings → Keyboard and the cheat sheet (?) are its pages, and your own keys carry over.
  • Added: give any prompt shortcut its own key (e.g. Alt+C toggles Changes) while the Prompt shortcuts plugin is on.
  • Added: shortcuts like g h now also work while a plugin page has the focus.
  • Added: a plugin's info page lists the plugins it works with when they're installed (Works with).

Test notes

  • Backend: test_plugin_keymap.py (9) covers the provider, the cache drop after a write, the optional peer's calls and events, and the carry-over. Every test_plugin* module plus test_guests, test_batch1_platform and the prompt-shortcuts modules pass, one process each in a throwaway /data. Only test_typed_plugins::test_records_carry_kind fails, and it fails on main too (git clone in the sandbox).
  • Frontend: tsc --noEmit is clean. vitest: 1059 pass; the 3 failures also fail on main (useShareTarget ×2, FreshContext).
  • Live local hub on this branch (bwrap, PLUGINS_SEED_DIR holding prompt-shortcuts + keyboard-shortcuts + command-palette, an owner blob with an old conv.new: n), driven with puppeteer:
    • the plugins were seeded;
    • the carried-over key was served;
    • /settings/keyboard redirected;
    • recording Alt+C on Changes went through keyChord + save, and the keymap updated at once;
    • g h pressed inside the plugin frame went Home;
    • ? opened the cheat sheet;
    • there were no console errors.
  • Not deployed from the EVOX2. Deploy from the Homelab once #14 and #17 are merged, and pull the plugins repo first: the seed: true plugin installs from the Homelab's ai-agent-plugins checkout at the first start.

Screenshots

01-keyboard-page.png
02-named-shortcut-key.png
03-cheat-sheet.png
07-info-details.png

## Summary Keyboard shortcuts leave the core for a live plugin, `keyboard-shortcuts` (ai-agent-plugins, paired PR). Which keys run which command now belongs to the plugin: the defaults, each person's own bindings, the on/off switch, **Settings → Keyboard** (a `nav: "settings"` page) and the **cheat sheet** (an `app.modal` slot). The core keeps what a sandboxed frame can't do: the one keydown listener, the commands and their handlers. With no plugin installed there are no shortcuts. Prompt shortcuts are an **optional peer**, through the new `optionalRequires` manifest key: while the prompt-shortcuts plugin is on, the keymap gains the Composer group and a key per named prompt shortcut (Alt+C = Changes). These are Gabriel's picks in form `keyboard-shortcuts-as-a-plugin_2aqd47`. **Stacked:** on What's new #14 (`init.lang`, the app modal / Settings hooks) and on prompt-shortcuts #17 (`seed`, `nav: "settings"`, which it merges in). Merge it after both. ## Key changes - **`provides: {"app.keymap": …}`** (`backend/plugins/keymap.py`, `GET /api/plugins/keymap`): - the provider runs as the caller (a guest gets the owner's managed install); - the answer is sanitized against the chord grammar and cached per user; - any plugin change drops the cache, as does a write by the provider for that user (SSE `keymap` → their tabs refetch). - **Commands** (`lib/keyboard/actions.ts`) no longer hold keys. Two command families are new: - `composer.shortcut:<chip id>` toggles a named chip (`useComposerKeys`); - `modal:<plugin>:<slot>` opens a plugin's modal (`KeyboardHost`), and closes it when it's the one open. - **`business/keyboard/keymap.ts`**: - `useKeymap` / `useKeymapIndex` / `useCommandKeys`; - the last keymap is kept in localStorage, so the first key after a load works; - the tooltip hints (⌘G, Alt+N on the profile switch) read it. - **`optionalRequires`** (`manifest.py`, `proxyroutes.py`, `scheduler.py`, info page): - optional peers, never checked at install / enable / disable / uninstall; - their `exports` and `plugin:<peer>:<event>` events open while they're on; - the info page has a *Works with* row (`optionalRequires`, `peersActive`); - part of the fingerprint only when set. - **Frame bridges** (`PluginSandboxFrame`): - `commands()` returns the app's commands for this person, in their language (`business/keyboard/commands.ts`); - `keyChord(ev)` runs the host's chord parser, so a key recorded in a frame matches what the app listens for. - **Keys from plugin frames reach the app:** a frame forwards each keydown it didn't `preventDefault()` (not plain typing, never Esc). The host takes it only while that frame has the focus, so `g h` works on a plugin page. - **`ui.pages[].desktopOnly`** for `nav: "settings"` pages keeps Settings → Keyboard out of a phone's drawer, as the core entry was. - **Carry-over `carryover.keyboard`:** each person's `state.keyboard` → the plugin's per-user `keymap.json`, once. The old key stays in the blob, unread. - **Removed:** `business/keyboard/pages/Keyboard.tsx`, `CheatSheet.tsx`, `settings.keyboard` and its setters, and the core Keyboard Settings entry. - `/settings/keyboard` redirects to `/settings/p/keyboard-shortcuts/keyboard`; - saved layouts map the old `keyboard` key onto the plugin page. - **Docs:** `CLAUDE.md` → Keyboard shortcuts; `docs/plugins.md` → "Keyboard shortcuts: the keymap, commands, optional peers". ## Key decisions - **The listener stays core.** A sandboxed frame can't see the app's keys or move its router, composers or profiles. So the plugin owns *which keys* (data, page, cheat sheet), not *what happens*. This is the same split as `composer.shortcuts`. - **Defaults live in the plugin; labels stay in the core.** The core names its commands (the palette needs the names too, and they translate with the app). The plugin decides the keys and gates the Composer group on its peer. - **One chord parser.** The plugin's recorder asks the host (`keyChord`) instead of shipping a copy of `keys.ts`, whose physical-key and layout rules are subtle. - **Catalog ids = the old action ids** (only `help` now runs the plugin's modal), so the carry-over is a straight copy. - **Forwarded keys need the focus.** A frame can't press the app's keys behind the person's back. ## Changelog - Changed: keyboard shortcuts are now the Keyboard shortcuts plugin's. Settings → Keyboard and the cheat sheet (`?`) are its pages, and your own keys carry over. - Added: give any prompt shortcut its own key (e.g. Alt+C toggles *Changes*) while the Prompt shortcuts plugin is on. - Added: shortcuts like `g h` now also work while a plugin page has the focus. - Added: a plugin's info page lists the plugins it works with when they're installed (*Works with*). ## Test notes - **Backend:** `test_plugin_keymap.py` (9) covers the provider, the cache drop after a write, the optional peer's calls and events, and the carry-over. Every `test_plugin*` module plus `test_guests`, `test_batch1_platform` and the prompt-shortcuts modules pass, one process each in a throwaway `/data`. Only `test_typed_plugins::test_records_carry_kind` fails, and it fails on main too (git clone in the sandbox). - **Frontend:** `tsc --noEmit` is clean. `vitest`: 1059 pass; the 3 failures also fail on main (`useShareTarget` ×2, `FreshContext`). - **Live local hub** on this branch (bwrap, `PLUGINS_SEED_DIR` holding prompt-shortcuts + keyboard-shortcuts + command-palette, an owner blob with an old `conv.new: n`), driven with puppeteer: - the plugins were seeded; - the carried-over key was served; - `/settings/keyboard` redirected; - recording Alt+C on *Changes* went through `keyChord` + `save`, and the keymap updated at once; - `g h` pressed inside the plugin frame went Home; - `?` opened the cheat sheet; - there were no console errors. - **Not deployed from the EVOX2.** Deploy from the Homelab once #14 and #17 are merged, and pull the plugins repo first: the `seed: true` plugin installs from the Homelab's ai-agent-plugins checkout at the first start. ## Screenshots ![01-keyboard-page.png](https://git.gabvdl.xyz/attachments/8b095a35-c5e1-4a0a-9fe6-c7288598e7fb) ![02-named-shortcut-key.png](https://git.gabvdl.xyz/attachments/36bbab3b-0956-42f8-b59c-e7d133d66236) ![03-cheat-sheet.png](https://git.gabvdl.xyz/attachments/f31c9b84-25e7-4113-968f-eb426064a96b) ![07-info-details.png](https://git.gabvdl.xyz/attachments/16a36dfc-a6d8-490c-9c26-9cfda3a26667)
gabrielvidal self-assigned this 2026-11-27 01:17:35 +01:00
gabrielvidal added 3 commits 2026-11-27 01:17:35 +01:00
Which keys run which command is now a live plugin's (`keyboard-shortcuts`,
ai-agent-plugins): the defaults, each person's own bindings, the on/off
switch, Settings → Keyboard (a nav "settings" page) and the cheat sheet (an
app.modal slot). The core keeps what a sandboxed frame can't do: the one
keydown listener, the commands and their handlers. No plugin, no shortcuts.

- provides `app.keymap` → GET /api/plugins/keymap (plugins/keymap.py):
  the provider run as the caller, sanitized, cached; dropped on any plugin
  change and after a write of the provider (SSE `keymap` to that user).
- commands: the app's (lib/keyboard/actions.ts, no defaults any more) plus
  `composer.shortcut:<chip id>` (a named guideline chip) and
  `modal:<pluginId>:<slotId>` (a plugin's modal — the cheat sheet).
- `optionalRequires`: optional peers — no install/enable checks, their
  exports and plugin events open while they are on; the info page's
  "Works with" row. prompt-shortcuts is the keyboard plugin's.
- frame bridges `commands()` and `keyChord()`; a frame's unused keys go on
  to the app's key layer while it has the focus (g h on a plugin page).
- carryover.keyboard: each person's state.keyboard → the plugin's
  keymap.json, once.
- the core Keyboard page, CheatSheet and settings.keyboard are gone;
  /settings/keyboard redirects to the plugin's page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Gabriel's form prompt-shortcuts-into-a-plugin_dkhipt: everything moves —
the owner's library, its editor and audience matrix, the guest sharing,
guests' own shortcuts and prefs, the built-in Changes chip. The core keeps
the composer's chips engine, the always-on notify line and the prompt pills.

Platform hooks (generic, reused by the keyboard-shortcuts move):
- ui.pages[].nav "settings" (+ group, after): a Settings entry routed at
  /settings/p/<id>/<page>, listed in the panel, the drawers, the search and
  the palette, right after the entry `after` names (a core id or another
  plugin page's id; else the end of its group).
- top-level "seed": true: an app plugin installed once from the seed dir at
  start, like provider-* / harness-*.
- composer.shortcuts: "position": "first", runners: [] and hidden kept, 64
  chips; a POSTed action of a provider drops its cache and publishes
  composer-shortcuts (guests too) so every composer refetches.
- frame bridges aiAgentPlugin.pickIcon (the app's glyph picker in a host
  dialog) and iconSvg(keys); a page's init.lang.

The move:
- carryover.prompt_shortcuts: the owner's promptShortcuts (audience made
  explicit, a pre-v4 blob folding the old guest list) → library.json, each
  guest's promptShortcuts + shortcutPrefs → their personal.json, once.
- settings v7 drops promptShortcuts / shortcutPrefs; settings/shortcuts.py,
  /api/me sharedShortcuts and guest-defaults promptShortcuts are gone.
- Settings → Skills & agents (/settings/setup) is its own entry;
  /settings/shortcuts forwards to the plugin's page (#skills → setup), saved
  panel and drawer layouts keep the old slot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Settings → Keyboard is a nav "settings" plugin page like Prompt shortcuts:
both core entries are gone, the old keys map onto the plugin pages in saved
layouts, a settings page may say desktopOnly, and the mock lists both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Owner

Merged into main as f3671ee38c by the auto-ship batch https://ai-agent.lab.gabvdl.xyz/conversation/01a21a60-f657-7368-89c8-21d61ac8f575

The merge also refreshed backend/authz/matrix.golden.txt (GET /api/plugins/keymap) and openapi.json..

Merged into `main` as f3671ee38cb1cdf4e6051794d4b4a76b94ecec16 by the auto-ship batch https://ai-agent.lab.gabvdl.xyz/conversation/01a21a60-f657-7368-89c8-21d61ac8f575 The merge also refreshed backend/authz/matrix.golden.txt (GET /api/plugins/keymap) and openapi.json..
gabrielvidal closed this pull request 2026-11-27 01:40:40 +01:00

Pull request closed

Please reopen this pull request to perform a merge.
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: gabrielvidal/ai-agent#18