Skip to content

feat(keys): opt in to supported Herdr keybindings - #653

Closed
od-studio-webagency wants to merge 1 commit into
devswha:mainfrom
od-studio-webagency:feat/optional-herdr-keymap
Closed

od-studio-webagency wants to merge 1 commit into
devswha:mainfrom
od-studio-webagency:feat/optional-herdr-keymap

Conversation

@od-studio-webagency

@od-studio-webagency od-studio-webagency commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Change

Closes #642

  • 기본 꺼짐인 Herdr 키맵 가져오기와 PC별 읽기 API, 지원·예약·미지원 상태 표시를 추가합니다.
  • 현재 웹 단축키, 브라우저 예약키, IME·텍스트 편집·클립보드를 우선합니다. prefix·응답은 PC와 pane 소유권이 바뀌면 취소합니다.
  • 임의 shell/plugin 명령 본문은 반환하지 않고 실행도 하지 않습니다. 현재 AppActions로 지원되는 동작만 가져옵니다. #214의 별도 import 논의와 관련된 초안입니다.

Validation

생성 타입·타입·빌드 검사와 전체 단위 1962 통과·33 생략·0 실패. 실제 HTTP 계약에서 인증, local 별칭, origin, 메서드와 명령 경로 부재를 확인했습니다. 1440/390px 밝은·어두운 테마의 실제 브라우저에서 기본 꺼짐, prefix, text/IME 보호, 웹 단축키 우선, reload와 구형 bridge 오류 시 키맵 해제를 검증했습니다. 물리적 IME·모든 OS 예약키를 검증했다는 의미는 아닙니다.

모든 검증은 별도 작업 공간과 소유한 테스트/demo 환경에서 수행했습니다. 사용자의 실행 중 앱·terminal은 변경하지 않았습니다.

화면 증거

개인 대화나 사용자 세션이 아닌, 소유한 테스트/demo 환경의 가상 데이터로 촬영했습니다.

keymap-qa

@coderabbitai

coderabbitai Bot commented Oct 9, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@devswha

devswha commented Oct 11, 2026

Copy link
Copy Markdown
Owner

Closing this draft for now: there has been no activity since 2026-10-09 and it conflicts with main. Thank you for it; if you come back to herdr keybinding support, a fresh PR against current main is welcome.

@devswha devswha closed this Oct 11, 2026
devswha added a commit that referenced this pull request Nov 6, 2026
Part of #642

## What

An opt-in **Settings → Shortcuts → Use herdr's prefix keys** (off by
default). It is turned on per device. When it is on, herdr's prefix
(`ctrl+b` unless herdr's `config.toml` sets another), followed by a key
herdr binds, runs the same action in the app:

| herdr action | In the app |
| --- | --- |
| `new_tab` | a terminal tab, opened at once (the same action as the tab
strip's terminal button) |
| `split_vertical` / `split_horizontal` | Split pane right / down |
| `zoom` | Zoom or unzoom pane |
| `previous_tab` / `next_tab`, `switch_tab` (`1..9`) | the tab before or
after, or the tab at that place in the strip |
| `rename_tab` | the tab's name field |
| `previous_workspace` / `next_workspace`, `new_workspace` | the
sidebar's step, or New workspace |
| `toggle_sidebar`, `settings` | the same actions as the app shortcuts |
| `help`, `goto`, `workspace_picker` | the command palette |

- **Read only, resolved as herdr resolves it.** `GET /api/herdr-ui`
gains an optional `keys` field: herdr's prefix and, for each action
above, the prefix bindings herdr keeps for it. It is read from the
serving PC's herdr `config.toml` through the existing hardened reader.
`shared/herdr-keys.ts` follows herdr's `validated_keybinds`
(src/config/keybinds.rs). A value may be one key or a list. Every
binding the config writes, custom commands included, registers before
the defaults, so a key the user gives any other action takes it from the
default. A prefix binding on the prefix itself is dropped, since the
prefix twice sends the prefix. A range belongs only to an indexed
action, and an indexed action takes digits only. `[keys.indexed]`
displaces its default. An unreadable prefix falls back to `ctrl+b`. A
value of the wrong type means herdr's defaults, as herdr reads no config
then. `[[keys.command]]` bodies are never returned. An older server
leaves out `keys`, and then nothing is taken.
- **Who gets each key.** Text fields, dialogs, menus and listboxes keep
their keys, and so does IME composition (`isComposing` / 229). The app's
own shortcuts win. The prefix and the key after it are consumed by the
app (`preventDefault` + `stopPropagation` in the window capture phase,
so xterm never encodes them). Any key with no action behind it goes to
the pane as typed, the prefix itself included, so pressing the prefix
twice sends it. Escape, a click, blur or hiding the tab cancels the
prefix.
- **Feedback.** While the prefix waits for its key, the header's
existing note pill reads "herdr prefix: press a key". This follows VS
Code's status-bar hint for a pending chord ("(Ctrl+K) was pressed.
Waiting for second key of chord…") and herdr/tmux's own prefix
indicator. It adds no new control.
- Settings lists the prefix and each binding it read, as written in
herdr's syntax. Actions that share an app action are grouped on one row:
`help`, `goto` and `workspace_picker` all open the palette.

Not in this slice: direct (non-prefix) bindings, other herdr actions
(directional focus, swap, resize, close, copy mode, `[[keys.command]]`),
and a per-PC keymap for remote PCs (it reads the serving PC's config, as
`copy_on_select` does). These can follow under #642.

Credit: the ownership policy (opt-in, fields/IME keep their keys,
unsupported actions do nothing) follows @od-studio-webagency's closed
draft #653. This is a fresh implementation against current main.

No new default-visible control: the setting is off by default, and the
header pill only shows while a prefix waits.

## Review fixes (one round)

- Codex: `constructor+b` was read as a plain `b` (the parser is now
herdr's, with a Map). An alertdialog now keeps its keys. App shortcuts
and protected targets win while the prefix is armed too. A held prefix's
key repeat is swallowed.
- omo: user bindings now beat defaults the way herdr's passes do (`zoom
= "prefix+?"` no longer opens the palette, `close_pane = "prefix+c"` no
longer opens a tab). Lists are read. herdr's full key-name table is used
(`space`, `backspace`, `period`, ...; herdr's `meta` is Alt). Indexed
rules are herdr's (`switch_tab = "prefix+3"` goes to tab 3, as herdr
does).

## Validation

- `bun run check fast`: green (typecheck, build, unit 12.4k).
- New unit tests: `server/herdr-ui.test.ts` (defaults, overrides,
unbinding, no command bodies), `src/lib/herdrKeys.test.ts` (syntax,
Korean-layout letters by position, `?` by character, arming, running,
pass-through, IME, Escape, custom prefix), `src/lib/herdrUi.test.ts`,
`src/lib/adjacentTarget.test.ts` (`numberedTabPane`),
`src/lib/settings.test.ts`, plus the route contract in
`server/api.contract.test.ts`.
- New browser regression `scripts/herdr-prefix-keys-demo-regression.ts`,
added to `scripts/ci-browser.sh`. It checks that the setting is off by
default, the Settings listing, the header pill, that Escape cancels, `s`
→ Settings, `?` → palette, `c` → new terminal tab, `1` → first tab, and
that the composer keeps Ctrl+B. It also takes screenshots at 1280 and
390 px, light and dark.
- Existing browser regressions run locally and green:
`shortcut-exact-modifiers-demo-regression`,
`pane-input-focus-demo-regression`, `terminal-keyboard-demo-regression`,
`settings-pages-demo-regression`.
- Skipped: `check full`, and Windows/macOS manual runs. The change is
browser-only plus a read of the config file through the existing reader.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(keys): optionally import Herdr keybindings and prefix commands

2 participants