Module Keybinding

Module Keybinding 

Source
Expand description

§Keybinding (Command)

RESPONSIBILITIES:

  • Defines Tauri command handlers for keybinding operations from Sky frontend
  • Bridges keybinding requests to KeybindingProvider
  • Handles keybinding resolution, conflict detection, and extension registration
  • Manages user keybinding preferences and extension contributions

ARCHITECTURAL ROLE:

  • Command module exposing keybinding functionality via Tauri IPC (#[command])
  • Delegates to Environment’s KeybindingProvider via DI with Require() trait
  • Acts as thin façade layer; all logic resides in provider implementation

COMMAND REFERENCE (Tauri IPC):

ERROR HANDLING:

  • Returns Result<Value, String> where errors sent to frontend
  • Provider errors converted to strings via map_err(|Error| Error.to_string())
  • TODO: Implement proper conflict detection and user keybinding storage

PERFORMANCE:

  • All commands are async but currently mostly stubs
  • Resolved keybindings query should be O(1) from cached state (TODO)

VS CODE REFERENCE:

  • vs/workbench/services/keybinding/browser/keybindingService.ts - keybinding service
  • vs/platform/keybinding/common/keybindingResolver.ts - keybinding resolution algorithm
  • vs/workbench/services/keybinding/common/keybinding.ts - keybinding data models
  • vs/workbench/common/keybindings.ts - keybinding registry and conflict detection

TODO:

  • Implement keybinding resolution with proper weighting (user > extension > default)
  • Add keybinding conflict detection across all registered bindings
  • Persist user keybinding overrides to ApplicationState
  • Implement extension keybinding registration/unregistration
  • Support keybinding context conditions (when clauses)
  • Add command argument handling in keybindings
  • Implement chord keybindings (multi-stroke sequences)
  • Add keybinding export/import functionality
  • Support platform-specific keybindings (Windows, macOS, Linux)
  • Implement keybinding search and discovery UI
  • Add keybinding documentation tooltips
  • Support macro recording and playback via keybindings

MODULE CONTENTS:

  • Tauri command functions (all #[command] pub async fn):
    • GetResolvedKeybinding - query final resolved keybindings
    • GetUserKeybindings - get user overrides (stub)
    • RegisterExtensionKeybindings - register extension bindings (stub)
    • UnregisterExtensionKeybindings - unregister extension bindings (stub)
    • CheckKeybindingConflicts - detect conflicts (stub)

Functions§

CheckKeybindingConflicts
GetResolvedKeybinding
GetUserKeybindings
RegisterExtensionKeybindings
UnregisterExtensionKeybindings