feat: add configurable keybinds for slash commands#214
Closed
al4xdev wants to merge 7 commits into
Closed
Conversation
- Add KeybindMap type (Record<string, string>) for configurable keybinds - Add keybinds field to DeepcodingSettings and ResolvedDeepcodingSettings - Add normalizeKeybinds() to validate keybind entries - Add mergeKeybinds() with project-over-user precedence - Export KeybindMap from core public API
- Add matchKeybind() to match shortcut strings (e.g. "ctrl+shift+g") against raw input and InputKey with exact modifier matching - Add buildKeybindMatchers() to pre-compile a KeybindMap into an array of matchers for fast per-keystroke lookup
…dling - Add "keybind" to SlashCommandKind and BUILTIN_SLASH_COMMANDS with args hint (add <shortcut> <action>, remove <shortcut>, list) - Implement /keybind handler with add/remove/list subcommands that read/write settings.json (project-level if present, user-level fallback) - Integrate keybind checking in useTerminalInput callback: custom keybinds are matched before hardcoded shortcuts, only when no dropdown/menu is open to avoid conflicts - Resolve keybind action to SlashCommandItem and dispatch via handleSlashSelection (supports all built-in commands and skills) - Pass resolved settings keybinds from App to PromptInput - Export matchKeybind, buildKeybindMatchers, and KeybindMatcher from the UI barrel
- Add 19 unit tests for matchKeybind covering ctrl, shift, meta modifiers, exact matching, case insensitivity, digit/non-alpha keys, and edge cases - Add 4 integration tests for keybinds settings resolution: default empty, user-only, project-over-user merge, and invalid entry filtering - Update slash-commands test to include "keybind" in built-in names
Document the keybinds settings field following the same format as enabledSkills and mcpServers: - Shortcut format: ctrl+key, ctrl+shift+key, meta+key - Project-over-user merge precedence - Runtime management via /keybind add|remove|list
Add onKeybindsChanged callback so that keybinds added or removed via the /keybind slash command take effect immediately without requiring a session restart. The callback re-resolves settings from disk, matching the pattern used by handleModelConfigChange.
- Add /keybind slash command with add, remove, list subcommands - Auto-complete partial matches (/key -> /keybind) - Show usage hint on bare /keybind instead of opening view - /keybind list opens KeybindsView showing all configured keybinds - --global flag forces operations on user-level settings - Cross-level duplicate detection (merged keybind lookup) - KeybindsView shows [global]/[local] origin indicator - Custom keybind matchers trigger slash actions on shortcut press - Status message timeout increased to 8s for readability
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: add configurable keybinds for slash commands
Summary
Add a
keybindssettings field that maps keyboard shortcuts directly to slash command actions, so users can trigger commands like/exit,/new,/skillswithout typing/. Also adds a/keybindslash command for runtime management (add/remove/list).Motivation
Currently, all slash commands require typing
/command+ Enter. For frequent operations (exiting, starting a new session, opening the skills list), a keyboard shortcut is faster and more ergonomic. This feature lets users configure their own shortcuts and manage them at runtime without editing JSON by hand.Design
Configuration
New top-level field
settings.keybinds:{ "keybinds": { "ctrl+e": "exit", "ctrl+n": "new", "ctrl+s": "skills", "ctrl+m": "model" } }ctrl+key,ctrl+shift+key, ormeta+keyRuntime management
The
/keybindslash command supports three subcommands:Changes are persisted to
settings.jsonimmediately and take effect without restarting.Architecture
The feature follows the same pattern as
statuslineandenabledSkills:packages/core/src/settings.ts):KeybindMaptype,normalizeKeybinds(),mergeKeybinds(), integration intoresolveSettingsSources()packages/cli/src/ui/core/keybinds.ts):matchKeybind()converts shortcut strings (e.g."ctrl+shift+g") into exact-modifier predicates againstInputKey;buildKeybindMatchers()pre-compiles a map for fast per-keystroke lookupPromptInput.tsx): keybinds are checked before hardcoded shortcuts, resolving the action name to aSlashCommandItemand dispatching viahandleSlashSelection()slash-commands.ts): new"keybind"kind with subcommand parsing inhandleKeybindCommand(), reading/writing settings with project-over-user fallbackFiles Changed
packages/core/src/settings.tsKeybindMaptype, normalize/merge, resolved settingspackages/core/src/index.tsKeybindMappackages/core/src/tests/settings-and-notify.test.tspackages/cli/src/ui/core/keybinds.tspackages/cli/src/ui/core/slash-commands.ts"keybind"kind + built-in commandpackages/cli/src/ui/views/PromptInput.tsx/keybindhandlerpackages/cli/src/ui/views/App.tsxkeybindsprop +onKeybindsChangedcallbackpackages/cli/src/ui/index.tspackages/cli/src/tests/keybinds.test.tspackages/cli/src/tests/slash-commands.test.ts"keybind"to built-in namesdocs/configuration.mddocs/configuration_en.mdVerification