Mountain is the primary Tauri application and native Rust backend for the Land code editor. Mountain:
- Implements every abstract trait from
Common - Hosts the
gRPCserver - Manages application state
- Dispatches
Tauricommands - Orchestrates sidecar processes
Overview 📋
Mountain is a Rust binary built with Tauri v2 and tonic gRPC:
- It is the single native process that owns all OS-level capabilities:
- file system
- terminal PTY
- clipboard
- dialogs
- It coordinates the
Cocoonextension host andAirbackground daemon
| Attribute | Value |
|---|---|
| Language | Rust (edition 2024) |
| Framework | Tauri v2 |
| gRPC | tonic + prost |
| Dependencies | Common, Echo, Mist, tauri, tauri-plugin-dialog, tauri-plugin-fs, tonic, prost, keyring, portable-pty, tokio |
| Sidecars | Cocoon (Node.js), Air (Rust daemon) |
Application Lifecycle 🔄
Startup Sequence 🚀
fn main()
|
v
1. Tauri::Builder::default() created
|
v
2. .setup(|app| {
a. Create AppState (thread-safe state container)
b. Create MountainEnvironment (implements all Common traits)
c. Create AppRuntime (Echo-backed execution engine)
d. Spawn tokio background task for post-setup init
e. Return Ok(())
})
|
v
3. Post-setup background task:
|
+---> InitializeConfiguration()
| - Read settings.json files from disk
| - Populate AppState with configuration values
|
+---> ExtensionManagement::scan()
| - Walk extension directories
| - Load and validate extension manifests
| - Populate AppState extension registry
|
+---> Vine::server::Initialize()
| - Start gRPC server on NetworkMountainPort (default: 50051)
|
+---> InitializeCocoon()
| - Spawn Node.js bootstrap-fork.js
| - Wait for $initialHandshake gRPC notification
| - Send initExtensionHost with InitData payload
|
v
4. System ready for user interaction
Shutdown Sequence 🛑
1. Tauri window close requested
2. SIGTERM sent to Cocoon sidecar (graceful, 5s timeout)
3. SIGTERM sent to Air sidecar (if running)
4. AppState persisted (settings, window state)
5. gRPC server gracefully drained (in-flight requests complete)
6. Echo scheduler shutdown (in-flight tasks complete)
7. Tokio runtime shutdown
8. Process exits
Module Architecture 🗺️
Element/Mountain/Source/
+-- Binary/
| +-- Main/
| | +-- Entry.rs - fn main(), Tauri builder
| | +-- Setup.rs - .setup() hook
| | +-- Shutdown.rs - Graceful shutdown
| | +-- Tray.rs - System tray icon
| | +-- IPC/ - IPC handler registration
| | +-- Register/ - Command registration
| | +-- Initialize/ - Startup initialization
| | +-- Debug/ - Debug build utilities
| | +-- Service/ - Service layer initialization
+-- ApplicationState/
| +-- State.rs - Central state struct
| +-- Internal/ - Internal state management
| +-- DTO/ - State transfer objects
+-- Environment/
| +-- MountainEnvironment.rs - Common trait implementations
| +-- CommandProvider.rs - Command execution provider
| +-- ConfigurationProvider/ - Configuration provider
| +-- FileSystemProvider/ - File system provider
| +-- TerminalProvider.rs - Terminal PTY provider
| +-- ... (24+ providers)
+-- Vine/ (gRPC)
| +-- Server/ - gRPC server (tonic)
+-- ProcessManagement/
| +-- CocoonManagement.rs - Cocoon sidecar lifecycle
| +-- InitializationData.rs - Startup payload construction
| +-- NodeResolver/ - Node.js binary resolution
+-- IPC/ (Tauri)
| +-- TauriIPCServer.rs - Tauri IPC server
| +-- WindServiceHandlers/ - Wind-specific handlers
| +-- WindAdvancedSync/ - Sync handlers
| +-- DevLog/ - Developer logging
+-- RPC/ (Internal dispatch)
| +-- CocoonService/ - Cocoon gRPC service implementation
+-- RunTime/
| +-- ApplicationRunTime/ - Effect execution engine
| +-- Execute/ - Effect execution
| +-- Shutdown/ - Runtime shutdown
+-- Command/ - Command implementation
+-- Track/ - Request tracking
+-- ExtensionManagement/ - Extension lifecycle
+-- FileSystem/ - File system operations
+-- Workspace/ - Workspace management
+-- LandFixTier.rs - Runtime tier banner
+-- Library.rs - Library root
ApplicationState 📦
The central state container managed by Tauri:
pub struct AppState {
configuration: RwLock<ConfigurationMap>,
extensions: RwLock<ExtensionRegistry>,
workspaces: RwLock<WorkspaceManager>,
// ... additional state domains
}
| State Domain | Access Pattern | Persistence |
|---|---|---|
| Configuration | RwLock<HashMap> |
settings.json on disk |
| Extensions | RwLock<Vec<Manifest>> |
Scan on startup |
| Workspaces | RwLock<Vec<Workspace>> |
Window state on shutdown |
| Active editors | RwLock<HashMap<URI, EditorState>> |
Transient |
- State is accessed through
Tauri’sState<AppState>managed type - Available in every command handler
Environment and Providers 🧩
MountainEnvironment implements every trait from Common. Each capability has
a dedicated Provider:
| Provider | Common Trait | Implementation |
|---|---|---|
FileSystemProvider |
FileSystem |
tokio::fs native operations |
ConfigurationProvider |
Configuration |
JSON file read/write with merge |
TerminalProvider |
Terminal |
portable-pty PTY management |
UserInterfaceProvider |
UserInterface |
tauri-plugin-dialog |
CommandProvider |
CommandExecutor |
Command registry + dispatch |
DocumentProvider |
Document |
Text model management |
ExtensionManagementService |
ExtensionManagementService |
VSIX install + manifest scan |
SearchProvider |
Search |
ripgrep-based search |
SecretProvider |
Secret |
OS keyring (keyring crate) |
StorageProvider |
Storage |
JSON file key-value |
WorkspaceProvider |
Workspace |
Folder management |
IPCProvider |
IPC |
gRPC proxy to Cocoon |
Provider Registration 📝
impl MountainEnvironment {
pub fn new(app_state: AppState) -> Self {
Self {
file_system: Arc::new(FileSystemProvider::new(app_state.clone())),
configuration: Arc::new(ConfigurationProvider::new(app_state.clone())),
terminal: Arc::new(TerminalProvider::new()),
// ... all 24+ providers
}
}
}
Tauri Command System ⌨️
Mountain registers Tauri commands as typed Rust handlers:
#[tauri::command]
async fn read_file(
path: String,
state: State<'_, AppState>,
) -> Result<Vec<u8>, String> {
let fs = state.file_system();
fs.read_file(Path::new(&path))
.await
.map_err(|e| e.to_string())
}
Registered Command Categories
| Category | Example Commands | Handler |
|---|---|---|
| File System | read_file, write_file, stat, readdir | FileSystemProvider |
| Configuration | get_configuration, set_configuration | ConfigurationProvider |
| Terminal | create_terminal, write_terminal, resize_terminal | TerminalProvider |
| Dialog | open_dialog, save_dialog, show_message | UserInterfaceProvider |
| Clipboard | get_clipboard, set_clipboard | Clipboard |
| Extension | install_extension, list_extensions | ExtensionManagementService |
| Search | search_files, search_text | SearchProvider |
| Window | set_window_size, focus_window | Window management |
| Lifecycle | quit, restart | Process management |
gRPC Service (Vine) 🌐
Mountain hosts the Vine gRPC server for Cocoon and Air communication.
Server Configuration ⚙️
// Server listens on NetworkMountainPort (default: 50051)
let addr = format!("127.0.0.1:{}", config.network_mountain_port)
.parse()
.expect("Invalid gRPC address");
Server::builder()
.add_service(ExtensionHostServer::new(service_impl))
.serve(addr)
.await?;
Note
Mountain’s Vine server listens on 50051 by default; Air’s AirService server listens on 50053, in its own process. The two ports are configured independently.
Service Handlers 📋
| Service | RPC | Handler Module |
|---|---|---|
| ExtensionHost | Initialize | ProcessManagement/InitializationData.rs |
| ExtensionHost | ExecuteCommand | RPC/CocoonService/Command/ |
| ExtensionHost | ProvideHover | RPC/CocoonService/Provider/ |
| ExtensionHost | CreateWebviewPanel | RPC/CocoonService/Window/ |
| ExtensionHost | HealthCheck | Vine/Server/ |
Process Management ⚙️
Cocoon Management 🔄
The CocoonManagement module handles the Cocoon sidecar lifecycle:
- Environment construction: Sets
PATH,VSCODE_PARENT_PID, tier env vars - Process spawn:
std::process::Commandspawnsnode bootstrap-fork.js - Health monitoring:
gRPCheartbeat (5s interval, 3 miss timeout) - Crash recovery: Up to 3 automatic restarts with exponential backoff
- Graceful shutdown:
SIGTERM, 5s timeout,SIGKILLon timeout
Air Management 🔄
The AirManagement module handles Air sidecar lifecycle:
- Process spawn: Spawns
Airbinary with configured data directory - gRPC connection: Connects to
Airon port 50053 - Service registration:
Airreports available services (updater, indexer, etc.) - Health monitoring: Bidirectional heartbeat
- Coordination:
Mountaindispatches background work viaPerformAction
IPC and Event System 📡
Mountain pushes events to Wind/Sky via Tauri’s event system:
// Emit configuration change event
app_handle.emit("configuration-changed", serde_json::json!({
"keys": ["editor.fontSize", "workbench.colorTheme"]
})).ok();
Event Catalog
| Event | Payload | Trigger |
|---|---|---|
configuration-changed |
{ keys: string[] } |
Configuration save |
extension-activated |
{ id: string } |
Extension activation |
terminal-data |
{ id: number, data: string } |
PTY output |
file-changed |
{ path: string, type: string } |
File watcher |
theme-changed |
{ theme: string } |
Theme switch |
window-state-changed |
{ state: string } |
Window resize/move |
Cache System 💾
Mountain implements two caching subsystems:
| Cache | Purpose | Implementation |
|---|---|---|
AssetMemoryMap |
Asset file mmap caching | Memory-mapped files with LRU eviction |
PathCanon |
Path canonicalization cache | LRU cache of realpath() results |
Extension Management 🧩
| Operation | Implementation |
|---|---|
| Scan | Walk extension directories, parse package.json manifests |
| Install | VSIX extraction to extension directory |
| Uninstall | Remove extension directory |
| List | Read extension registry from AppState |
Related Documentation 📚
- Common - Abstract trait definitions
- Echo - Task scheduler integration
- Mist - DNS isolation
- Air - Background daemon
- Vine -
gRPCprotocol definitions - BuildPipeline - Build pipeline
- InterComponentProtocol - Protocol specification
- 🟠 Low-Level Shim - Engine-level prototype hooks
- 🔵 Coverage / Telemetry - Application-level service routing
Project Maintainers: Source Open (Source/[email protected]) | GitHub Repository | Report an Issue
The record this page documents, as the site files it: the six facts the claim is checked against, and the three files the manual names to check it.
WORKING, 06
- FORM:
- NATIVE BACKEND
- WRITTEN IN:
- RUST
- BOUNDARY:
- VINE GRPC TAURI IPC
- DEPENDS ON:
- COMMON VINE
- MANUAL:
- /DOC/DEEP-DIVE-MOUNTAIN
- EVIDENCE:
- MANIFEST PLACEHOLDER PLATE NOT IN BUILD
# TRACE / MOUNTAIN 03 STEPS
- 01
Binary.rsTHE TAURI ENTRY - 02
IPC/WindServiceHandlers/mod.rsTHE WIND IPC SURFACE - 03
ApplicationState/Internal/ExtensionScanner/LoadFromCache.rsTHE EXTENSION SCAN
SOURCE: /DOC/DEEP-DIVE-MOUNTAIN