Expand description
§Command Module
Defines and registers all native (Rust-implemented) commands for the
Mountain application. Commands are organized by functionality and registered
at startup via the Bootstrap module.
§RESPONSIBILITIES
- Command Registration: Register all Tauri command handlers with the invoke_handler
- Module Organization: Group commands by domain (LanguageFeature, SCM, etc.)
- Handler Coordination: Delegate command execution to appropriate providers
- Error Propagation: Convert provider errors to Tauri-compatible strings
§MODULE STRUCTURE
Bootstrap: Registers all native commands and providers at startupLanguageFeature: Handles LSP-related commands (hover, completion, etc.)TreeView: Manages tree view UI commandsKeybinding: Handles keybinding-related commandsSourceControlManagement: SCM (git) command implementations
§ARCHITECTURAL ROLE
The Command module is the UI-to-Backend bridge:
Sky Frontend ──► Tauri invoke ──► Command Handler ──► Effect System ──► Providers§Design Patterns:
- Command Pattern: Each handler encapsulates a request
- Facade Pattern: Simple interface to complex backend operations
- Error Translation: Convert CommonError → String for Tauri
§VS Code Reference:
vs/workbench/services/commands/common/commandService.ts- Command registryvs/platform/commands/common/commands.ts- Command definitionsvs/base/parts/ipc/common/ipc.ts- IPC-based command execution
§COMMAND FLOW
- Registration: All command handlers registered in Binary::Main via
tauri::generate_handler![] - Invocation: Frontend calls
app.invoke("command_name", args) - Dispatch:
DispatchLogic::DispatchFrontendCommandroutes to effect - Execution: Effect runs via
ApplicationRunTimewith proper capabilities - Response: Result serialized and returned to frontend
§ERROR HANDLING
- All errors returned as
Result<T, String>for Tauri compatibility - Errors are logged with context before being returned
- Frontend receives descriptive error messages for user display
§PERFORMANCE
- Commands are async to avoid blocking the UI thread
- Minimal serialization overhead (direct JSON)
- Effect system provides async execution with scheduler
§TODO
- Add command metrics (invocation count, duration)
- Implement command throttling for high-frequency operations
- Add command permission validation
- Support command cancellation for long-running operations
§MODULE CONTENTS
Bootstrap: Command registration entry pointLanguageFeature: LSP hover/completion/definition commandsTreeView: Tree view manipulation commandsKeybinding: Keybinding resolution commandsSourceControlManagement: Git/SCM commands
Modules§
- Bootstrap
- Bootstrap (Command)
- Keybinding
- Keybinding (Command)
- Language
Feature - LanguageFeature (Command)
- Source
Control Management - SourceControlManagement (Command)
- Tree
View - TreeView (Command)