- add server keybinding compiler for shortcuts and `when` AST parsing - switch websocket/server config payload to resolved keybinding rules - update web keybinding logic/types to consume resolved payload directly - add/adjust contract, server, and web tests (including plus-key parsing) and docs
3.1 KiB
Keybindings
T3 Code reads keybindings from:
~/.t3/keybindings.json
Schema source of truth:
Server-side parsing/default resolution/merging:
The file must be a JSON array of rules:
[
{ "key": "mod+j", "command": "terminal.toggle" },
{ "key": "mod+d", "command": "terminal.split", "when": "terminalFocus" },
{ "key": "mod+shift+d", "command": "terminal.new", "when": "terminalFocus" },
{ "key": "mod+shift+o", "command": "chat.new" },
{ "key": "mod+o", "command": "editor.openFavorite" }
]
Rule Shape
Each entry supports:
key(required): shortcut string, likemod+j,ctrl+k,cmd+shift+dcommand(required): action IDwhen(optional): boolean expression controlling when the shortcut is active
Invalid rules are ignored. Invalid config files are ignored. Warnings are logged by the server.
Available Commands
terminal.toggle: open/close terminal drawerterminal.split: split terminal (in focused terminal context by default)terminal.new: create new terminal (in focused terminal context by default)chat.new: create a new chat thread for the active projecteditor.openFavorite: open current project/worktree in the last-used editor
Key Syntax
Supported modifiers:
mod(cmdon macOS,ctrlon non-macOS)cmd/metactrl/controlshiftalt/option
Examples:
mod+jmod+shift+dctrl+lcmd+k
when Conditions
Currently available context keys:
terminalFocusterminalOpen
Supported operators:
!(not)&&(and)||(or)- parentheses:
()
Examples:
"when": "terminalFocus""when": "terminalOpen && !terminalFocus""when": "terminalFocus || terminalOpen"
Unknown condition keys evaluate to false.
Defaults
Built-in defaults are resolved on the server and sent to the web client via server.getConfig:
terminal.toggle:mod+jterminal.split:mod+dwhenterminalFocusterminal.new:mod+shift+dwhenterminalFocuschat.new:mod+shift+oeditor.openFavorite:mod+o
If you define any rules for a command, the default rule for that command is removed on the server.
Server-Resolved Payload
~/.t3/keybindings.json is parsed and compiled on the server. The web client receives resolved rules (including parsed shortcut/when fields) and does not parse raw keybinding strings.
See:
Precedence
- Rules are evaluated in array order.
- For a key event, the last rule where both
keymatches andwhenevaluates totruewins. - That means precedence is across commands, not only within the same command.