返回 CodeWhale
KEYBINDINGS.md
根目录 / docs / KEYBINDINGS.md
1 # Keybindings
2
3 > 阅读简体中文版:[zh_hans/KEYBINDINGS.md](zh_hans/KEYBINDINGS.md)
4
5 This is the source-of-truth catalog of every keyboard shortcut the TUI recognizes. Bindings are grouped by **context** — the focus or modal state they fire in. A binding listed under "Composer" only takes effect when the composer is focused; one under "Transcript" only when the transcript has focus; and so on.
6
7 Global key chords are not yet user-configurable — tracked for a future release (#436, #437). Hotbar slot actions are configurable with `[[hotbar]]` and `/hotbar`; the Hotbar activation chord remains `Alt-1` through `Alt-8`.
8
9 ## Global (any context)
10
11 | Chord | Action |
12 |----------------------|---------------------------------------------------------------|
13 | `/help`, `F1` or `Ctrl-/` | Toggle the help overlay. `/help` is what the chrome advertises: it is the one route every terminal delivers, where `F1` is eaten by tmux and some emulators and `Ctrl-/` encoding varies |
14 | `F2` | Toggle the typed Settings editor |
15 | `F3` | Open the provider/model picker (same as `/provider`) |
16 | `Ctrl-K` | Open the command palette (slash-command finder) |
17 | `Ctrl-C` | Cancel current turn / dismiss modal / arm-then-confirm quit |
18 | `Ctrl-B` | Move a supported foreground shell wait into `/jobs` so the turn can continue; use `/jobs` or `Bash` with `action: "wait"` to inspect it |
19 | `Ctrl-D` | Quit (only when the composer is empty) |
20 | `Tab` | When the composer is empty, cycle TUI mode: Plan → Work → Operate → Plan |
21 | `Shift+Tab` | Cycle permission posture: Ask → Auto-Review → Full Access. Live regardless of composer contents or whether a turn is running (suppressed only while a modal other than Config is open) |
22 | `Ctrl-T` | Cycle reasoning effort for the active model. Walks the same ladder as `/model` and `/effort` (catalog or documented route dialect). Always-thinking models omit `off`; Grok 4.6 includes `xhigh`. |
23 | `Ctrl-Shift-T` | Toggle live transcript overlay (sticky-tail auto-scroll) |
24 | `Ctrl-R` | Open the resume-session picker |
25 | `Ctrl-L` | Compact the conversation context (status line shows progress; no-op while a compaction is already running) |
26 | `Ctrl-O` | Open the reasoning detail for the selected or current turn, regardless of composer contents |
27 | `Ctrl-Alt-O` | Open the whole-turn Turn Inspector, regardless of composer contents |
28 | `Alt-V` / `Option-V` (macOS) | Open the details pager for the selected, visible, or most recent tool/sub-agent card; terminals that emit the legacy Option-V glyph are also handled |
29 | `Ctrl-Shift-E` / `Cmd-Shift-E` | Toggle the file tree in the workbar |
30 | `Ctrl-]` or `Ctrl-Tab` | Cycle the work dock: TODO → Agents → Jobs → Background. `Ctrl-]` is the portable chord — `Ctrl-Tab` only arrives under the kitty keyboard protocol |
31 | `Ctrl-Shift-Tab` | Cycle the work dock backwards |
32 | `Alt-G` / `Alt-Shift-G` | Scroll transcript to top / bottom when the composer is empty |
33 | `Alt-1`-`Alt-8` | Dispatch Hotbar slots 1-8 when no modal or inline picker is open |
34 | `Alt-!` / `Alt-@` / `Alt-#` / `Alt-$` | Select the workbar panel: Tasks / Agents / Context / Files |
35 | `Ctrl-Alt-0` | Toggle the workbar off / back to the bottom placement |
36 | `Alt-L` | Open the pager for the last message (composer empty) |
37 | `Alt-P` / `Alt-A` / `Alt-Y` | Jump to Plan / Work, or request Full Access (`Alt-Y` is the legacy permission channel — Work + Full Access — not a separate mode; it honors a locked approval policy) |
38 | `Ctrl-X` (Activity workbar) | Cancel all running background shell jobs |
39 | `Esc` | Close topmost modal · cancel slash menu · dismiss toast. During a compact that is serving an in-flight turn, Esc stops the turn (the compact is collateral). |
40
41 ## Composer
42
43 Editing the message you're about to send.
44
45 | Chord | Action |
46 |-----------------------------|---------------------------------------------------------|
47 | `Enter` | Send when idle; queue while busy; with an empty composer, send the next queued follow-up now |
48 | `Shift-Enter` / `Alt-Enter` / `Ctrl-J` | Insert a newline without sending (idle or busy) |
49 | `Ctrl-Enter` / `Cmd-Enter` | Send into the current turn; send normally when idle (when the terminal reports it distinctly) |
50 | `Ctrl-U` | Clear the whole draft (recoverable — see `Ctrl-Z`) |
51 | `Ctrl-Z` | Restore the cleared draft (only while the composer is empty) |
52 | `Ctrl-W` / `Ctrl-Backspace` / `Alt-Backspace` | Delete previous word |
53 | `Ctrl-A` / `Home` | Move to start of input / start of line (readline convention) |
54 | `Ctrl-E` / `End` | Move to end of input / end of line |
55 | `Ctrl-←` / `Alt-←` | Move backward one word |
56 | `Ctrl-→` / `Alt-→` | Move forward one word |
57 | `Shift-←` / `Shift-→` | Extend the selection one grapheme at a time |
58 | `Ctrl-Shift-←/→` / `Alt-Shift-←/→` | Extend the selection one word at a time |
59 | `Shift-Home` / `Shift-End` | Extend the selection to the start / end of the line |
60 | `Ctrl-Shift-Home` / `Ctrl-Shift-End` | Extend the selection to the start / end of the draft |
61 | `Ctrl-Shift-A` / `Cmd-A` | Select the whole draft (see note below) |
62 | `Ctrl-Shift-U` | Run `/update install` from the keyboard: check for and install the latest Codewhale release without leaving the TUI. Managed installs (Homebrew/npm/cargo) keep their package-manager gate; when already current the updater's "Already up to date." result is shown and nothing changes |
63 | Mouse drag | Select composer text; click moves the cursor |
64 | `Cmd-V` / `Ctrl-Shift-V` | Terminal-local paste (arrives as bracketed paste when supported) |
65 | `Ctrl-V` | Direct graphical clipboard paste; rich composer content becomes Markdown |
66 | `Ctrl-Y` | Yank (paste) from kill buffer |
67 | `↑` / `↓` | Cycle composer history (also selects popup/attachment items) |
68 | `Shift-↑` / `Shift-↓` | Browse conversation history |
69 | `Ctrl-P` / `Ctrl-N` | Navigate slash-command menu entries; `Ctrl-P` opens the file picker when the menu is empty |
70 | `Ctrl-G` / `Ctrl-S` | Stash current draft (`/stash pop` restores it); never sends or queues |
71 | `Alt-R` | Search prompt history (Alt-R to exit) |
72 | `Tab` | Slash-command / `@`-mention completion (popup-aware) |
73 | `Ctrl-Shift-O` / `F4` | Open the composer draft in `$VISUAL` / `$EDITOR`; F4 works when the terminal cannot distinguish Ctrl-Shift-O from Ctrl-O |
74 | `! command` | Run a shell command through normal approval, sandbox, and output surfaces |
75
76 Direct composer paste preserves headings, lists, links, tables and code from
77 HTML clipboard content. Plain text stays literal, and configuration fields
78 always paste literal text. SSH without a forwarded graphical display uses the
79 terminal's text paste. Copying a whole answer preserves its original Markdown,
80 without terminal wrapping or decorative rails; the destination app decides how
81 to render it. Transcript drag selections copy the same way by default:
82 Markdown source, whole cells joined with blank lines (see the Transcript
83 section below), with `tui.selection_copy_markdown = false` restoring rendered
84 text. Empty or oversized HTML falls back to plain text.
85
86 Set `composer_multiline_mode = true` to swap the portable `Enter` and
87 `Shift-Enter` behaviors: `Enter` inserts a newline and `Shift-Enter` sends.
88 `Alt-Enter`, `Ctrl-J`, and supported `Ctrl-Enter` / `Cmd-Enter` behavior stays
89 unchanged.
90
91 ### Selection semantics
92
93 Typing, pasting, `Backspace`, or `Delete` with an active selection replaces or
94 removes the selected text, like any GUI editor. Plain movement keys (arrows,
95 `Home`/`End`, word motions) collapse the selection. When a selection covers the
96 whole draft, deleting or typing over it stashes the outgoing text the same way
97 `Ctrl-U` does, so `Ctrl-Z` (on an empty composer) or `Alt-R` draft recovery can
98 bring it back.
99
100 Cursor movement and deletion are grapheme-aware: one `←`/`→` step or one
101 `Backspace` covers a full emoji ZWJ sequence, flag pair, or combining-mark
102 cluster — never half of one. CJK text moves and deletes per character as
103 expected.
104
105 **Why select-all is not `Ctrl-A`:** the composer follows the readline
106 convention, where `Ctrl-A` jumps to the start of the input (paired with
107 `Ctrl-E`). Select-all is `Ctrl-Shift-A` on every platform (like
108 `Ctrl-Shift-O` / `Ctrl-Shift-E`, it needs a terminal with an enhanced keyboard
109 protocol). On macOS terminals that forward the Command key (kitty, WezTerm,
110 iTerm2 with Command remapping), native `Cmd-A` also selects all; `Cmd-Shift-A`
111 works everywhere on macOS because Cmd normalizes to Ctrl.
112
113 ### Hotbar
114
115 Hotbar trigger semantics are intentionally `Alt-1` through `Alt-8` only. On macOS keyboards this is the Option/Alt key plus the number row. Bare `1`-`8` is normal text input in the composer and remains owned by pickers, onboarding, approval prompts, and modal views.
116
117 Function keys and `Cmd-1` through `Cmd-8` are not the primary Hotbar chords. Many terminals reserve those keys for tabs, windows, or OS shortcuts, and some never forward them to terminal apps. If a terminal is configured to send `Alt-1` for a custom shortcut, the Hotbar receives the same reliable chord.
118
119 Since #3807 a missing `hotbar` key renders **no bar** — fresh configs show no Hotbar until you configure `[[hotbar]]` slots (an explicit `hotbar = []` also disables it). When configured, a bar looks like:
120
121 | Slot | Chord | Default action | Label |
122 |------|---------|--------------------|-----------|
123 | 1 | `Alt-1` | `slash.workflow` | `wf` |
124 | 2 | `Alt-2` | `slash.goal` | `goal` |
125 | 3 | `Alt-3` | `slash.auto` | `auto` |
126 | 4 | `Alt-4` | `mode.plan` | `plan` |
127 | 5 | `Alt-5` | `mode.agent` | `agent` |
128 | 6 | `Alt-6` | `mode.operate` | `operate` |
129 | 7 | `Alt-7` | `palette.open` | `palette` |
130 | 8 | `Alt-8` | `sidebar.toggle` | `side` |
131
132 | Focus state | Hotbar behavior |
133 |-------------|-----------------|
134 | Composer empty, text, or whitespace | `Alt-1`-`Alt-8` dispatches a configured slot |
135 | Workbar focused, hidden, or auto | `Alt-1`-`Alt-8` still dispatches a configured slot |
136 | Slash menu or history search open | Blocked; the inline selector owns the key event |
137 | Command palette, help, approval, file picker, session picker, Fleet setup, or any modal stack | Blocked; the modal owns the key event |
138 | Onboarding | Blocked; onboarding owns numeric choices |
139
140 ### `@` mentions
141
142 Type `@<partial>` to open the file mention popup. `↑`/`↓` cycle the entries, `Tab` or `Enter` accepts. `Esc` hides the popup. As of v0.8.10 (#441), completions are re-ranked by mention frecency — files you mention often + recently float to the top.
143
144 Two mentions resolve to curated git context instead of a path (v0.9.2, #4067):
145
146 | Mention | Inlines | Byte budget |
147 |---------|---------|-------------|
148 | `@git` | `git status --short --branch` for the workspace | 8 KB |
149 | `@diff` | The working-tree diff, staged and unstaged (`git diff HEAD`) | 32 KB |
150
151 Both appear in the completion popup alongside paths, and both show up in the context inspector with their resolved size and, when the diff exceeds its budget, the truncation marker. When git is missing, the workspace is not a repository, or there is nothing to show, the turn carries an explicit `<git-unavailable>` note rather than silently contributing nothing. A path that merely starts with the token (`@diff.txt`, `@git/config`) stays a file mention.
152
153 ### `#` quick-add (memory)
154
155 When `[memory] enabled = true`, typing `# foo` and pressing `Enter` appends `foo` as a timestamped bullet to your memory file *without* sending a turn. See `docs/MEMORY.md`.
156
157 ## Transcript (when transcript has focus)
158
159 | Chord | Action |
160 |----------------------|-----------------------------------------------------|
161 | `↑` / `↓` | Scroll one line (bare arrows scroll when the composer is empty) |
162 | `Alt-↑` / `Alt-↓` | Scroll transcript (works with a draft in the composer) |
163 | `PgUp` / `PgDn` | Scroll one page |
164 | `Alt-G` / `Alt-Shift-G` | Jump to top / bottom |
165 | `Ctrl-Home` / `Ctrl-End` | Jump to top / bottom (also works from the composer) |
166 | `Alt-[` / `Alt-]` | Jump between tool output blocks |
167 | `Esc Esc` | Backtrack to a previous user message (`←`/`→` steps, `Enter` rewinds) |
168 | `Esc` | Return focus to composer |
169 | `Ctrl-Y` | With an empty composer, copy the focused transcript cell |
170 | `Alt-V` | Open raw detail for the focused tool or message |
171 | `Ctrl-O` | Open reasoning detail for the focused turn |
172 | `Enter` | Open the focused transcript block fullscreen |
173 | Mouse drag | Select transcript text in Codewhale |
174 | `Ctrl-C` | Copy an active Codewhale selection |
175 | `Cmd-click` (macOS) / `Ctrl-click` (Linux/Windows) | Open an OSC 8 link in a supporting terminal (terminal-owned) |
176
177 Bare printable keys are never transcript shortcuts. Under TUI-DOG-002 a
178 printable character always belongs to the composer — `j`, `k`, `g`, `G`, `y`,
179 `Y`, `r`, `v`, and `l` type themselves in every focus state, including
180 transcript selection. Earlier revisions of this table documented them as
181 navigation; they were never wired, and the help catalog has a test
182 (`transcript_navigation_catalog_does_not_advertise_bare_typing_keys`) that
183 keeps them out.
184
185 Releasing a drag selection, or pressing `Ctrl-C` with one active, copies the
186 intersected cells as Markdown source by default: each selected cell is
187 serialized the same way `Ctrl-Y` and `/copy` serialize it, partial
188 intersections round out to whole cells, cells join with blank lines, and the
189 toast names the copied cell count. Set `[tui] selection_copy_markdown = false`
190 to copy the rendered text as displayed instead.
191
192 For terminal-native selection, hold `Shift` while dragging (terminal support
193 varies), then use the terminal's own copy command: usually `Cmd-C` on macOS or
194 `Ctrl-Shift-C` on Linux/Windows. Those commands are handled by the local
195 terminal and are intentionally separate from Codewhale's `Ctrl-C` selection
196 binding. Over SSH, Codewhale sends copy requests back through OSC 52, or via
197 tmux's `load-buffer -w` path when running inside tmux.
198
199 ## Pointer (mouse)
200
201 The mouse is a first-class input. Every row here is wired in
202 `crates/tui/src/tui/mouse_ui.rs`.
203
204 | Gesture | Action |
205 |----------------------|-----------------------------------------------------|
206 | Wheel up / down | Scroll the transcript; over the composer, move the cursor a line at a time |
207 | Click | Activate the row, chip, or tool block under the pointer |
208 | Drag | Select transcript text, or drag the scrollbar |
209 | Right click | Open context actions for paste, selection, message details, context, and help |
210
211 Hover feedback follows the same rule: anything that responds to a click
212 highlights under the pointer. A row that highlights but does nothing, or acts
213 without highlighting first, is a bug worth reporting.
214
215 ## Work bar (after `Alt-W` claims focus)
216
217 | Chord | Action |
218 |----------------------|-----------------------------------------------------|
219 | `↑` / `↓` | Move selection |
220 | `Home` / `End` | Jump to the first / last row |
221 | `PageUp` / `PageDown`| Move selection a viewport at a time |
222 | `Enter` | Open the selected row's world (work inspector / agent details); on an already-open row, close it |
223 | `Esc` | Close the open detail, else return focus to the composer |
224 | any printable key | Return focus to the composer (typing always wins) |
225
226 Mouse parity: clicking any work-bar row does what `Enter` does, in every
227 panel and placement. `Alt-!`/`Alt-@`/`Alt-#`/`Alt-$` switch panels.
228
229 ## Slash-command palette (after `Ctrl-K` or typing `/`)
230
231 | Chord | Action |
232 |--------------------------------|-----------------------------------------------------|
233 | `↑` / `↓` / `Ctrl+P` / `Ctrl+N`| Move selection |
234 | `Enter` / `Tab` | Run / complete the highlighted command |
235 | `Esc` | Dismiss palette |
236
237 ## Session Picker (`Ctrl-R` or `/sessions`)
238
239 | Chord | Action |
240 |----------------------|-----------------------------------------------------|
241 | `↑` / `↓` / `j` / `k`| Move selection in the session list |
242 | `1`-`9` | Open the visible session history at that list slot |
243 | `PgUp` / `PgDn` | Page the history pane |
244 | `Enter` | Resume the selected session |
245 | `/` | Search sessions |
246 | `s` | Cycle sort order |
247 | `a` | Toggle current-workspace scope vs all workspaces |
248 | `e` | Archive / restore the selected session |
249 | `x` | Show or hide archived sessions |
250 | `d` | Delete selected session after confirmation |
251 | `Esc` / `q` | Close the picker |
252
253 Archive (`e`) is undestructive and needs no confirmation: the session stays on
254 disk and stays loadable, it just leaves the default list and stops being an
255 auto-resume candidate. Press `e` again to bring it back. Delete (`d`) is the
256 destructive one and keeps its confirmation.
257
258 ## Question sheet (`request_user_input`)
259
260 When the model asks a question, a **bottom-anchored sheet** opens over the
261 transcript. The conversation stays visible above it. The sheet grows with the
262 question and options; if they still do not fit, it scrolls so the highlighted
263 option and any typed custom response stay on screen. Resize is not required to
264 reveal content.
265
266 | Chord | Action |
267 |-------|--------|
268 | `↑` / `↓` / `k` / `j` | Move the highlight |
269 | `1`–`9` | Quick-pick that option |
270 | `Enter` | Confirm the highlight (or enter custom-response typing) |
271 | `Space` | Toggle a multi-select option |
272 | `←` / `h` | Previous question — change that answer. Esc is not back; it cancels the whole request. |
273 | `Esc` | Cancel the whole question request |
274 | `PageUp` / `PageDown` | Scroll the transcript while keeping the sheet open |
275 | `Home` / `End` | Go to the start / latest part of the transcript |
276 | `Alt+↑` / `Alt+↓` | Scroll the transcript three lines |
277 | Mouse wheel above the sheet | Scroll the transcript; side work surfaces keep their own input |
278 | Mouse wheel over the sheet | Browse the question content without changing the answer or highlight |
279
280 While the question sheet is open, `Ctrl+↑` / `Ctrl+↓` and `Shift+↑` / `Shift+↓`
281 also scroll the transcript three lines. Plain arrows continue to move the option
282 highlight.
283
284 After wheel browsing, option navigation or typing brings the highlighted option
285 or custom-response text back into view. Transcript scroll keys work in both
286 option selection and custom-response typing.
287
288 **Custom response.** Every question includes an "Other" row. Enter it, type,
289 then `Enter` to submit or `Esc` to return to the options without sending.
290
291 ## Approval modal (when a tool requests approval)
292
293 | Chord | Action |
294 |----------------------|-----------------------------------------------------|
295 | `y` / `Y` | Approve once |
296 | `a` / `A` | Approve all (auto-approve subsequent calls) |
297 | `n` / `N` / `Esc` | Deny |
298 | `e` | Edit the approved input before running |
299
300 ## Onboarding (first-run flow)
301
302 | Chord | Action |
303 |----------------------|-----------------------------------------------------|
304 | `Enter` | Advance to next step (Welcome → Language → API/trust gates → setup checkpoint) |
305 | `Esc` | Step back one screen |
306 | `1`–`9` | Pick a language (Language step) |
307 | `0`–`9` | Pick a provider (Provider step; SGLang, vLLM, and Ollama are keyless by default) |
308 | `y` / `Y` | Trust the workspace (Trust step) |
309 | `n` / `N` | Skip the trust prompt |
310
311 ## v0.8.29 audit notes
312
313 - **`Shift+Enter` / `Alt+Enter` newlines now work in VSCode on Windows (#1359).** crossterm's `PushKeyboardEnhancementFlags` command unconditionally returns `Unsupported` on Windows (`is_ansi_code_supported() == false`), so the Kitty keyboard protocol escape was never written to the terminal. Without it, VSCode's xterm.js stays in legacy mode where `Shift+Enter` is indistinguishable from plain `Enter`, causing the composer to send the message instead of inserting a newline. The fix writes the push/pop escapes (`\x1b[>1u` / `\x1b[<1u`) directly on Windows, bypassing crossterm's capability gate. VSCode integrated terminal and Windows Terminal ≥1.17 both honour the Kitty keyboard protocol; terminals that do not understand the sequences silently discard them.
314
315 ## v0.8.13 audit notes
316
317 - **Ctrl-S is stash, not history search.** Fixed in this revision — `Alt-R` is history search.
318 - **Phantom `Alt+Up` removed.** The "Edit last queued message" binding was listed in README but never existed in the key dispatch code.
319 - **Bare Up/Down arrows scroll transcript when composer empty (v0.8.13).** Previously the `should_scroll_with_arrows` gate was hardcoded to false, meaning bare arrows always navigated composer history even when the composer was empty. Users in virtual terminals (Ghostty, Codex, Kitty-protocol) were especially affected because they couldn't use Cmd+Up / Alt+Up shortcuts.
320 - **Configurable keymap (#436) and `tui.toml` (#437) remain deferred.** The `TuiPrefs` struct and loader exist in `settings.rs` but are not wired at startup. The named-binding registry that would let `~/.codewhale/tui.toml` override individual entries is still pending.
321 - **No other broken bindings found.** Every other chord listed above resolves to a live handler in `crates/tui/src/tui/ui.rs` (key-event dispatch) or `crates/tui/src/tui/app.rs` (mode + state transitions).
322
322 lines MARKDOWN