Workflow
Executing a Command from the Command Palette
Unified command system dispatch: Mountain routes execution to native Rust handlers or proxied Cocoon commands.
Executing a Command from the Command Palette
Illustrates how Mountain’s command registry dispatches execution to either a native Rust handler or a proxied command in Cocoon.
Data Flow
User presses Ctrl+Shift+P
-> workbench.action.showCommands dispatched
-> QuickInputService.quickAccess.show()
-> CommandsQuickAccessProvider fetches all commands
-> TauriInvoke('mountain://command/get-all')
-> Mountain: CommandProvider.GetAllCommands()
-> Returns list of command IDs (native + proxied)
-> Quick Pick UI populates with command list
-> User types and selects "Format Document"
-> ICommandService.executeCommand('editor.action.formatDocument')
If NATIVE:
-> TauriInvoke('mountain://command/execute')
-> Mountain: CommandProvider.ExecuteCommand()
-> Lookup handler in CommandRegistry
-> Found CommandHandler::Native
-> Invoke native Rust function pointer
-> Execute command logic
-> Return result
If EXTENSION-PROVIDED:
-> TauriInvoke('mountain://command/execute')
-> Mountain: CommandProvider.ExecuteCommand()
-> Lookup handler in CommandRegistry
-> Found CommandHandler::Proxied
-> IpcProvider makes $executeContributedCommand gRPC to Cocoon
-> Cocoon looks up command in its registry
-> Execute extension's JavaScript function
-> Result returned to Mountain, forwarded to WindPhase 1: Opening the Command Palette (Wind/Sky)
- User presses
Ctrl+Shift+P.workbench.action.showCommandsis dispatched. QuickInputServiceopens the Quick Pick UI configured for commands.CommandsQuickAccessProviderneeds the list of all commands. Since the registry is in Mountain, it executesTauriInvoke('mountain://command/get-all').
Phase 2: Fetching Command List (Mountain)
- The Tauri command is dispatched to
track, which creates theCommon::command::GetAllCommandsEffect. CommandProvider.GetAllCommands()acquires a lock onAppState.CommandRegistryand returns the keys of the HashMap containing all registered native AND proxied command IDs.
Phase 3: Displaying and Selecting (Wind/Sky)
- The command list populates the Quick Pick UI.
- User selects a command, triggering
ICommandService.executeCommand(commandId).
Phase 4A: Native Command (Wind -> Mountain)
CommandServicein Wind forwards the request:TauriInvoke('mountain://command/execute', { commandId, args }).- Mountain’s
CommandExecutor::ExecuteCommandlooks up the handler inCommandRegistry. - Found as
CommandHandler::Native— invokes the corresponding Rust function pointer.
Phase 4B: Extension Command (Wind -> Mountain -> Cocoon)
- Mountain looks up the handler and finds
CommandHandler::Proxied { SidecarIdentifier: "cocoon-main", ... }. IpcProvidermakes a$executeContributedCommandgRPC request to Cocoon.- Cocoon’s
CommandsProviderlooks up the command in its registry and executes the extension’s JavaScript function. - Result is serialized and returned through Mountain back to Wind.
Key Source Files
Mountain/Source/Environment/CommandProvider.rs— command registryMountain/Source/Track/TrackLogic.rs— track dispatcherWind/Source/Application/QuickInput/Definition.ts— quick input service
