Thurbox keybindings, themes, settings and search
Working reference indexed by AGENTS.md. The rationale behind these decisions is owned by the docs under docs/; a change that invalidates what this says updates it in the same PR.
Keybindings
Every chord goes through one registry (kernel::registry). Mods declare
keys in their declaration table; the kernel resolves a press to an action and hands
it back to the mod that claimed it. There is no hardcoded table to keep in step
with a help screen, because the help modal renders the registry.
Global chords in the shipped interface (the kernel's own, plus the two session
chords the bundled panes declare — Ctrl+N is 70_new_session's and
Ctrl+J/Ctrl+K are 10_sessions', so each is an ordinary mod binding):
| Key | Action |
|-----|--------|
| Ctrl+Q | Quit (sessions keep running) |
| Ctrl+N | New session (the creation flow; declared by 70_new_session) |
| Ctrl+H / Ctrl+L | Focus previous / next pane |
| Ctrl+J / Ctrl+K | Select next / previous session (declared by 10_sessions) |
| Ctrl+, / F6 | Settings (] for the Interface tab) |
| Ctrl+Y / F4 | Theme picker |
| Ctrl+P | Command palette — every action, filtered as you type |
| F1 / Ctrl+G | Keybindings help |
| F10 | Reload the interface from disk |
| F12 | Perf HUD |
| Ctrl+C / Ctrl+V (+ Cmd+C / Cmd+V on macOS) | Copy the selection / paste — copy only with [clipboard] copy_on_select = false; by default a drag's release copies and Ctrl+C is the interrupt |
Everything else belongs to a mod and is listed in F1. Rebindings persist to
ui.json — a user decision, distinct from the delivery facts in .bundled.json;
trust and the disabled set live in mod-state.json beside it.
Reserved is not the same as kernel-owned. Five chords are handled before the
registry is consulted and cannot be rebound at all (registry::RESERVED: quit,
F10, Ctrl+H/Ctrl+L, F12) — they are the escape route out of a pane that
consumes every key. Everything else the kernel owns is an ordinary binding with
no Lua mod behind it: the modal chords (kernel::modals::bindings) and copy
and paste (kernel::clipboard). Copy and paste resolve through the registry,
so a Mac user can put copy on Cmd+C. They resolve ahead of a float's
exclusive grab so they still work from any pane, and copy
declines the chord when there is no selection so Ctrl+C still interrupts the
agent.
A topmost open floating mod may handle the reserved focus actions through
on_focus_cycle("next"|"previous"), under the key hook's budget. true consumes
without changing pane focus; false, no hook, or an error keeps the normal pane
cycle. Closed and covered floats are not offered it. This is an opt-in hook,
not a way to claim reserved chords; quit, reload and recovery remain reserved.
docs/thurbox/mods.md → Floating views and the native focus cycle has the example.
Two properties the registry holds and tests/keymap.rs asserts:
- A mod-scoped claim does not outrank a global one. This is why search does
not take Ctrl+P/Ctrl+N: doing so would take Ctrl+N from new-session
everywhere.
- A chord freed by a removed pane stays unbound rather than being silently
reused by whatever loads next.
Registry::detect_conflicts finds every chord two overlapping scopes both claim,
and thurbox-cli mod check is where that set surfaces — as warnings, naming
both claimants and which one wins. It is the only reporting surface the conflict
set has, and it exists for the mod author, who cannot know which keys their
users have already spent.
Terminal passthrough. thurbox's chords share the Ctrl+<letter> namespace with
readline (Ctrl+A, Ctrl+E, Ctrl+W, Ctrl+U, Ctrl+R, Ctrl+D, …). While a
session terminal is focused, a chord a mod flags as passthrough reaches the agent
instead. Navigation and app-control chords (Ctrl+H/J/K/L, Ctrl+Q, Ctrl+N) are
never deferred — they are the way out of a focused terminal.
macOS. The kitty keyboard protocol is pushed at startup
(PushKeyboardEnhancementFlags(DISAMBIGUATE_ESCAPE_CODES | REPORT_EVENT_TYPES), gated on
supports_keyboard_enhancement(), popped in restore_terminal and the panic hook
because ratatui::restore() does not). That is what makes cmd+… bindable at all
(iTerm2 3.5+, kitty, WezTerm, Ghostty — not Terminal.app) and what separates
Ctrl+/ from the bytes a legacy terminal sends for it. Cmd then reaches the
registry as an ordinary modifier (KeyPress::cmd, canonical spelling cmd+…),
and the pty boundary refuses a SUPER-modified key, so an unbound Cmd chord is
swallowed rather than injected into the agent as a bare letter. The **emulator
still decides**: it applies its own Cmd+Q/W/N/T/C/V, Cmd+K, … first, and only
what it leaves free arrives. So Cmd+C/Cmd+V are shipped as macOS defaults
and documented as conditional — an emulator that forwards a shortcut it did not
perform (Ghostty's performable: keybinds) passes them on, one that swallows its
own does not, and thurbox can do nothing about a key it never receives. F-keys
need Fn on Mac laptops unless "Use F1, F2, etc. as standard function keys" is
on.
Key releases. Event types are pushed with the flags so a binding declared
release = true can be told when its key is let go
(on_action(action, { event = "press" | "release" })). The routing is one struct,
coordinator::input::Holds: a release reaches only the mod that took the
press (matched by key code, since ctrl is often released first) and is dropped
otherwise — never a modal, on_key, a field or the pty; a held key's repeats are
swallowed (on Windows, whose console reports repeats as presses, a press of a held
key is one); every other repeat is handed on as the press a legacy terminal
sent, so nothing that did not ask changes. thurbox.keyboard.releases is
unsupported / negotiated / reported (kernel::host::KeyReleases):
negotiated once the push is accepted or on Windows, reported once a release
has actually arrived. Nothing infers a release from time. A release travels
through the Windows paste coalescer in its place (sort_key) — after a paste
it comes out behind the Paste, not discarded — and is routed when dispatched; one
nobody holds returns before the publish, so it draws no frame. The flags are
popped before a terminal editor takes the screen (still on the alternate
screen, where they were pushed) and pushed again after. tests/tui_e2e.rs drives
it on a pty that answers the kitty query (KittyTerminal).
Windows. The console reports AltGr as Ctrl+Alt, so the pair is dropped at
the input boundary (coordinator::input::resolve_altgr) for any character no key
produces unmodified — punctuation, or a non-ASCII letter. Without it every AltGr
character (\ on AZERTY, @/[/] on QWERTZ) would be swallowed by every
text field and reach the agent ESC-wrapped. A Ctrl+Alt+letter/digit chord is
untouched, and the rule is Windows-only: elsewhere the terminal composes AltGr
itself before thurbox sees the key.
Themes
Thirty-six palettes — twenty-eight dark, eight light; the enumeration is in
theme and docs/thurbox/features.md. Users add their own in
~/.config/thurbox/themes.toml (a built-in base plus per-colour overrides); they
appear in the picker after the built-ins and persist by name exactly like a preset.
kernel::theme::Themes resolves them and publishes roles to Lua
(ui/lib/theme.lua), so a mod asks for theme.accent or theme.muted rather
than a colour — which is what lets one mod look right under all thirty-six. Pick
one with Ctrl+Y (or F4, avoiding terminals that take Ctrl+Y as DSUSP); the choice
persists as theme in interface.json (config::interface_state), and other
thurbox processes pick it up when they next start.
The picker (kernel::modals::theme) filters behind /, mirroring the file-viewer
and review find so its keys stay consistent: j/k (+ arrows, PageUp/PageDown,
g/G, Home/End) navigate, and only after / do letters append to a query —
matched against display name and stable id with a live matched/total count.
Entries group under Dark/Light headers drawn inside their entry's row, so
selection, hitboxes and the scrollbar stay in entry space and a header disappears
with its filtered-out section. The index addresses the match list, so refining a
query keeps the cursor on the same theme when it survives — narrowing cannot apply a
palette other than the previewed one.
Settings panel
Ctrl+, (or F6) opens a kernel-owned modal (kernel::modals::settings) —
chrome about thurbox itself, so it overlays the arrangement, captures input and
stays out of the focus ring. Mods contribute data to it: declare
{ id, desc, default } and the modal grows a row. A text setting declared
list = true (the session list's folded_hosts/folded_repos) shows its entry
count in the row and its unescaped entries in the footer when selected; the value
column is capped at VALUE_WIDTH_MAX so one long value cannot starve the rest. A text setting declared
choices = { … } is stepped through them like a core enum (Enter/Space/←/→),
never typed into, and lists them in the footer; Registry::set_setting refuses a
value outside them and a stored one the mod no longer offers falls back to the
default (Setting::admits).
Two halves on one screen:
- Mod settings go through
Registry::set_setting— in-process, effective on
the next frame. Nothing to save, no Cancel.
- Core settings are
settings.toml, written back through atoml_edit
DocumentMut so the seed's documentation comments survive.
Whether a core row applies live or waits for a restart is **asked of
Settings::restart_only_differs**, which with what Config::adopt takes into
force is derived from the one per-field table session::settings::FIELDS —
never a second list beside the field, which could drift from it.
Restart-only rows are marked ⟳.
The panel is handed Config::on_disk, not Config::in_force. They are
different documents on purpose: a restart-only change is written to the file and
deliberately not taken into force, so a panel drafting from what is in force
would propose reverting every such change already saved on the next save.
] switches to the Interface tab (kernel::modals::interface). Panes are
grouped by where they came from — YOURS / PACKAGE · <name> / SHIPPED — and the
rest (modules, docs, layout.lua, mods.toml) under SUPPORT FILES, listed on
a or when one needs attention (failed, deleted, edited). A row names the file, one
state word (failed, not loaded, deleted, not placed, off, on screen,
on demand, hidden; no word shared with a source or a key), what it asks for and
whether it holds it (run not granted; read from Trust::grants, the rule the
enforced grant uses), then edited. not loaded is a pane held back by
another file's failure (a reload is all or nothing): only the file the error names
is failed, and while the bundled floor runs the coordinator hands the inventory
the user's error from floor_cause, since the bundled host reports none. The
header line counts failed / not granted / off and shows the directory as
~/…. Four detail lines under the list explain the selected row: kind, slot, full
source and path; why it is in that state (a load error wraps over the fix line);
the fix (an unplaced pane gets its { slot = "…" } line, hedged because the
shipped layout places search only while it is open); what it asks to run and
whether that is granted. The footer lists only the keys that act on that row:
space turn off/on · t grant/revoke · r restore · d delete · a all files,
dropping hints from the end to fit before the Close pill. d always asks twice;
r asks twice on an edited file (nothing keeps a pane's edits; layout.lua
goes to .bak); t asks twice when granting (the footer names the file and
its capabilities; any other key cancels) and revokes on one press. The cursor
follows its file by path, since an action re-sorts the list. It is chrome rather
than a pane because a recovery tool must not be the thing that is broken.
It is therefore the recovery path for a broken interface, and the shape of that
is not symmetric: a failed row sorts to the top with its load error under the list,
but r only writes back a copy thurbox ships — it refuses for a file the user
wrote ("thurbox ships no version of it") and points an installed pane at
thurbox-cli mod sync. For a pane of the user's own the way back is space:
present on disk, not loaded, so nothing tried to load it and its error is silent
until it is switched on. Each of the four keys reloads the interface, so the result
is on the next frame. The reload failed panel is not painted over an open system
modal, so it never covers this tab, the tool for fixing it; it returns on close.
Documented for users in docs/thurbox/mods.md → When something goes wrong; the same three answers with no TTY are mod list / mod dir /
mod check.
settings.toml is live-reloaded (mtime poll): an outside edit re-applies the
live half and toasts, noting a restart when restart_only_differs says so.
[features] code_review,file_viewer,info_panel,global_searchand
three_panel_min_colsare gone: nothing read them. They are in
session::settings::RETIRED_KEYS, so an existingsettings.tomlthat sets one
keeps loading with a "no longer read" notice.
features.tasksstays in
IGNORED_KEYS, accepted with no notice.
Global search
ui/mods/65_search.lua — a full-width strip above the chrome bands. Two
result sections: sessions (name, agent, branch, repo — matched in Lua
every frame) and text (every line each session's agent pane and shell still
hold, scrollback included, matched by the kernel on a worker).
- Query grammar is
lib.fuzzy.query, shared with the session list: words (all
must match, any order), "phrase", /regex/ (text only), in:/repo: filters,
smart case. The terms half mirrors kernel::search::Query; keep the two parsers
in step. Exact (substring/phrase/regex) ranks above subsequence; terminal
subsequences must be tight (≤ 2× the word).
- Terminal text is a want: on every change of the ask (no debounce) the pane
leaves the terms in store.want_content (filters resolved to ids in
want_content.sessions) and the kernel answers as thurbox.search
(kernel::search::SearchStore). An open strip with nothing typed asks with "",
which reads every history into the cache and matches nothing, so the first
keystroke is warm. The loop only clones parser handles; reading and matching are
on a worker (up to 4 threads), a superseded run gives up, each terminal's lock is
held for at most CHUNK_ROWS rows at a time, and a history is cached per
terminal by output stamp and brought up to date by reading only what was printed
since — re-run on output at most once a second. Caps: 50 hits per session, 200
total. The pane memoises results on (query, scope, thurbox.sessions,
thurbox.search) identity, because it is not pure and renders every frame.
ADR-P26 has the numbers; cargo bench --bench search_cost re-measures them
(THURBOX_BENCH_CHECK=1 fails over budget), tests/search.rs pins the
memo, and scripts/dev/perf-run.sh --search Q [--typing] measures the whole
binary with the strip open.
- Preview and land: whichever text hit is selected — by an arrow, or by a
query landing the cursor on it — scrolls its terminal back with the row marked
(surface.mark) while focus stays in the strip; enter/click opens it there.
The strip re-reveals whenever the selected result's place (id, surface,
offset, row) changes, because a re-run search hands back the same hit id at a
new position once its agent prints or repaints, and a mark left at the old
offset sits on the wrong row. The strip asks the agent pane to do this — it writes
"<surface> <offset> <row>" (;-separated, -<surface> resets) to
store["terminal.reveal"] and runs command("action", {text = "terminal.reveal"}),
which reaches 20_agent.lua because a chord-less palette command routes to
its owner like a bound one (coordinator/mouse.rs::run_clicked_action).
- In-place highlighting: the strip publishes the ids it found as
store["search.matches"]; the session list dims every other row and lights its
own name matches through the same grammar.
- Keys:
ctrl+/toggles the strip (global);thurbox-cli ui action search.open
opens it and sets a query without toggling it closed. up/down,
pageup/pagedown, enter, tab
(everything → text → names), esc (puts back selection and scroll). The query
is a lib.textinput field, so it edits like a shell line — ctrl+a/e/b/f/d/w/u/k,
alt+b/f/d, ctrl/alt with the arrows, backspace and delete (the table in
ui/README.md; legacy ctrl+backspace arrives as reserved ctrl+h) — and takes
a paste: a focused pane whose tree holds a caret-owning input is where
on_paste replays the text (focused_typing), before any terminal, straight to
on_key so a pasted letter never fires a declared chord. One
deliberate divergence: no Ctrl+P/Ctrl+N inside the strip — every chord goes
through one registry where a mod-scoped claim does not outrank a global one.
Code review
The binary draws no diff view. The reviewer is a pane in its own
repository: