Expand description
§UserInterfaceProvider (Environment)
Implements the UserInterfaceProvider trait for MountainEnvironment,
orchestrating all modal UI interactions like dialogs, messages, and quick
picks by communicating with the Sky frontend.
§RESPONSIBILITIES
§1. Modal Dialogs
- Open file/folder selection dialogs (
OpenDialog) - Save file dialogs (
SaveDialog) - Message boxes (
ShowMessage,ShowErrorMessage) - Input boxes for text entry (
InputBox) - Quick pick lists for selection (
QuickPick)
§2. Request-Response Pattern
- Send UI requests to Sky frontend via IPC
- Track pending requests with unique IDs
- Wait for responses with timeout handling
- Resolve results via
ResolveUIRequestcallback
§3. Thread Safety
- All methods are async and safe for concurrent access
- Pending requests stored in
ApplicationState.UI.PendingUserInterfaceRequests - Uses
tokio::sync::oneshotfor request-response coordination
§ARCHITECTURAL ROLE
UserInterfaceProvider is the UI bridge for Mountain:
Provider ──► UI Request ──► Sky Frontend ──► User Interaction ──► ResolveUIRequest§Position in Mountain
Environmentmodule: UI capability provider- Implements
CommonLibrary::UserInterface::UserInterfaceProvidertrait - Accessible via
Environment.Require<dyn UserInterfaceProvider>()
§Dependencies
ApplicationState: Pending request trackingIPCProvider: For sending messages to Skytauri::AppHandle: For window/parent references
§Dependents
- Any command that needs to show UI dialogs
DispatchLogic::ResolveUIRequest: Completes the request-response cycle- Error handlers: Show error messages to users
§DTO STRUCTURES
All UI operations use DTOs for type-safe options:
OpenDialogOptionsDTO: File/folder selection optionsSaveDialogOptionsDTO: Save file dialog optionsQuickPickOptionsDTO: Quick pick list configurationInputBoxOptionsDTO: Input box configurationMessageSeverity: Info, Warning, Error levels
§REQUEST FLOW
- Provider method called (e.g.,
ShowMessage) - Generate unique request ID
- Store
oneshot::SenderinPendingUserInterfaceRequestsmap - Send IPC message to Sky with request ID and options
- Sky shows UI and waits for user action
- User responds → Sky calls
ResolveUIRequestTauri command ResolveUIRequestlooks up sender by ID and sends result- Provider method returns result to caller
§ERROR HANDLING
- IPC failures:
CommonError::IPCError - Timeout:
CommonError::RequestTimeout - User cancellation:
Noneresult (not error) - Invalid arguments:
CommonError::InvalidArgument
§PERFORMANCE
- Requests are async and non-blocking
- Timeouts prevent indefinite waiting (default ~30s)
- Request IDs are time-based for uniqueness
- Pending request map uses
Arc<Mutex<>>for thread safety
§VS CODE REFERENCE
Borrowed from VS Code’s UI system:
vs/platform/dialogs/common/dialogs.ts- Dialog service APIvs/platform/prompt/common/prompt.ts- Input and quick pickvs/workbench/services/decorator/common/decorator.ts- Message service
§TODO
- Add support for custom dialog buttons and layouts
- Implement file/folder filters with glob patterns
- Add dialog position and sizing controls
- Support modal vs non-modal dialogs
- Add accessibility features (screen reader support)
- Implement dialog theming (dark/light mode)
- Add file type/extension selection in save dialog
- Support multi-select in quick pick and file dialogs
- Add async progress reporting during long operations
- Implement custom input validation (regex, etc.)
§MODULE CONTENTS
UserInterfaceProvider: Main struct implementing the trait- Dialog-specific methods:
ShowMessage,OpenDialog,SaveDialog - Selection methods:
QuickPick,InputBox - Request-response coordination logic
Structs§
Functions§
- Send
User 🔒Interface Request - A generic helper function to send a request to the Sky UI and wait for a response.