Skip to main content

SHEET 06 OF 41

/DOC/:SLUG

PART:
03 DOCUMENTATION
CIRCULATION:
PUBLIC
SOURCE:
pages/Doc/[...Slug].astro
AS OF:
2026-12-02

How Mountain, Cocoon, and the Wind workbench initialise and establish their IPC connections on every launch.

/Workflows

Application Startup and Handshake

How Mountain, Cocoon, and the Wind workbench initialise and establish their IPC connections on every launch.

PUBLISHED WORKFLOWS Source/Content/doc/workflow-startup.md UNAVAILABLE UNAVAILABLE ARCHITECTURE 0

Land starts in three overlapping phases: the native Mountain binary starts its gRPC listener and spawns the Cocoon Node.js sidecar, Cocoon bootstraps and completes the extension-host initialization handshake, and the Wind workbench renders in the Tauri webview. The Mountain↔Cocoon handshake is the hard ordering constraint that gates extension activation; everything else proceeds in parallel.

This is the foundational workflow that enables all others. Once the handshake completes and the workbench paints its first frame, the system is ready for user interaction and all dependent workflows - opening files, executing commands, language features - can proceed.

For the same sequence as a reader-facing checklist - what to observe after a build and where to look when a checkpoint does not happen - see First Launch Checkpoints.

Mermaid diagram

Phase 1 - Mountain native startup

  1. The OS launches the Mountain binary. The main function in Element/Mountain/Source/Binary/Main/Entry.rs builds a multi-thread Tokio runtime and, inside it, builds the central ApplicationState::default(), wraps it in an Arc, and manages it on Tauri’s Builder with .manage(). The .setup() hook registers the land:// service registry, starts the DNS server, and calls AppLifecycleSetup, which spawns the post-setup task. The MountainEnvironment (which implements every Common trait) is created later, in AppLifecycle.rs; AppRuntime is not part of this path - no such type exists under Element/Mountain/Source.

  2. Inside the post-setup task, four jobs run in three ordered stages:

    1. ConfigurationInitialize - reads all settings.json files from disk into AppState.Configuration (stage 1, parallel with the extension scan).

    2. ExtensionPopulate - walks extension roots and loads manifests into AppState.Extension (stage 1, parallel with configuration). If a pre-baked extensions.manifest.json exists on disk (written by Sky/Source/Function/Build/BakeExtensionManifest.ts, which runs from Sky’s prepublishOnly in Mountain’s beforeBuildCommand), this step completes in under 50 ms. On first boot or when the cache is absent, a parallel join_all live scan runs (~1200 ms) and caches the result for subsequent launches.

    3. VineStart - starts the Vine gRPC server on 127.0.0.1:50051, with Cocoon’s 127.0.0.1:50052 in the same pool, and begins listening for connections from Cocoon (stage 2, parallel with the configuration re-merge).

    4. CocoonStart (which calls InitializeCocoon, ProcessManagement/CocoonManagement.rs) - spawns the Node.js sidecar process (stage 3, parallel with the Air sidecar). It constructs a detailed environment that includes VSCODE_PARENT_PID, so the child terminates automatically when Mountain exits. The exact command is:

      node ./Element/Cocoon/Scripts/cocoon/bootstrap-fork.js

      Mountain then dials Cocoon’s gRPC server on port 50052 with exponential backoff under a hard 30-second connect budget, sends the InitializeExtensionHost request, and validates Cocoon’s "initialized" response.

Phase 2 - Cocoon bootstrap and handshake

Cocoon’s Source/Service/Effect/Bootstrap.ts runs seven stages in strict order:

  1. Environment - records Node.js version, platform, and architecture.

  2. Configuration - resolves MOUNTAIN_GRPC_PORT (50051) and COCOON_GRPC_PORT (50052); populates globalThis.__cocoonBootstrapConfig and globalThis.__LandTiers.

  3. RPCServer - starts Cocoon’s own gRPC server on port 50052; the bootstrap logs [Cocoon] gRPC server status: followed by [Cocoon] gRPC services started successfully. This must complete before Mountain’s 30-second connection budget expires.

  4. ModuleInterceptor - installs the require() interceptor, remapping electron to Tauri stubs and patching VS Code bundle loading.

  5. MountainConnection - TCP-probes Mountain on port 50051 and opens the gRPC channel. Once the gRPC services are up, the bootstrap sends a cocoon.ready notification to Mountain carrying pid, port (COCOON_GRPC_PORT) and version, then logs [Cocoon] Readiness signaled to Mountain and [Cocoon] Bootstrap complete - Cocoon ready for Mountain integration.

  6. Extensions - activates enabled extensions concurrently (up to 8 in parallel). Extension activation uses topological ordering: if extension A declares extensionDependencies: ["B"], extension B activates first. An InProgress set prevents circular dependency deadlocks.

  7. HealthCheck - optional final service health sweep.

Between stages 5 and 6, Mountain completes the handshake:

  • Mountain connects to Cocoon’s gRPC server and calls ProcessManagement/InitializationData.rs, which assembles the full ISandboxConfiguration + IExtensionHostInitData payload. This payload includes: workspace roots, extension list and metadata, configuration state (argv.json, settings.json, keybindings.json), registered profiles, dataFolderName (a primary crash source when missing), perfMarks, loggers, colorScheme, mainPid, and OS metadata (platform, arch, release, hostname).

  • Mountain sends the InitializeExtensionHost request to Cocoon, containing this initialization payload. The proto RPC is named InitExtensionHost; the proto also still defines InitialHandshake, whose Mountain handler logs [CocoonService] Initial handshake received from Cocoon. Cocoon’s gRPC server dispatches the initialization request as InitializeExtensionHost and answers "initialized".

  • Cocoon’s InitializeExtensionHost handler fires: it uses the payload to create and provide the InitDataLayer, runs FullAppInitialization, resolves the ExtensionHostProvider, installs the RequireInterceptor so every require('vscode') returns the Cocoon shim, and activates startup extensions (* activation event). The topological ordering from the Extensions stage (step 6) ensures that extension dependency chains resolve correctly before providers register. At this point, workflows like Language Features and Webviews can begin, as extensions register their providers.

Phase 3 - Wind workbench launch

These steps run in parallel with Phase 2, starting from the moment Tauri opens the main window.

  1. Tauri loads index.html in the webview, built by Sky/Source/pages/Mountain.astro. The Astro page produces the static HTML shell that bootstraps the Wind application script. Wind/Source/Preload.ts executes first, shimming window.vscode with Tauri-backed implementations for ipcRenderer and process. This shim is the critical bridge that allows the VS Code workbench code to run in a non-Electron, Tauri-based webview context.

  2. The main Wind entry script waits for DOM ready, then runs the workbench entry (web.main.js). The workbench’s concrete service handles are written to globalThis.__CEL_SERVICES__ by the ExposeWorkbenchAccessor.ts output transform right after workbench.startup(), once the dependency-injection container has populated every createDecorator-registered service (see Sky/Source/Function/Sky/Bridge.ts, line 110). Each service is backed by Tauri IPC calls or native Rust commands, replacing the Electron APIs that VS Code’s workbench would normally consume.

  3. workbench.startup() kicks off the entire UI rendering lifecycle - creating every UI part: Activity Bar, Status Bar, Side Bar, Editor Part, and instantiating the editor pane itself. Each part begins requesting data from Wind services, which in turn invoke Mountain IPC for filesystem reads, command lists, configuration values, and extension contributions.

  4. As these parts are created, they trigger downstream workflows. For example, the File Explorer uses IFileService to list directory contents (triggering the Opening a File workflow), and the Command Palette uses ICommandService (triggering the Executing a Command workflow). Extension contributions to the UI (views, menus, keybindings) are registered via the IExtensionService, which is populated during Cocoon’s startup extension activation in Phase 2.

  5. Extension activation timing after handshake: Once Cocoon’s InitializeExtensionHost handler completes (Phase 2), activated extensions begin contributing to the workbench in real-time. The IExtensionService on the Wind side subscribes to a gRPC stream from Cocoon that relays activatedExtension events as each extension finishes its activate() call. This means the Command Palette and language features become available progressively - the first extension’s contributions appear before the last one has finished activating. The workbench does not block paint on extension activation; it renders its chrome immediately and populates contributed UI elements as the extension stream arrives.

Important

The workbench’s first meaningful paint depends on Mountain returning the InitializationData payload promptly. Delays in the extension scan (Phase 1, step 2) or the handshake round-trip (Phase 2, stage 5) directly delay first sidebar render. The pre-baked manifest and the RPCServer-before-MountainConnection bootstrap ordering are the two changes that keep first paint under 800 ms.

What you should see: in the boot log, Mountain’s [LandFix:Tier] lines before the Tokio runtime spins up, then Cocoon’s [Cocoon] gRPC services started successfully line, then [Cocoon] Readiness signaled to Mountain, and finally the workbench’s first frame. A blank workbench means the handshake never completed - see Troubleshooting.

Failure modes

The sequence above fails in a small number of places, and each one leaves a different trace. Read the boot log in order - Mountain’s [LandFix:Tier] lines, then Cocoon’s [Cocoon] gRPC services started successfully, then [Cocoon] Readiness signaled to Mountain, then the first frame - and stop at the first line that never appears.

Symptom Where the sequence broke What to check
Blank workbench, no first frame Phase 2, stages 3-5 - Cocoon’s gRPC server never accepted Mountain’s connection, so the 30-second connect budget ran out Whether [Cocoon] gRPC services started successfully printed at all. If it did not, Cocoon never bootstrapped.
[Cocoon] gRPC services started successfully never prints, port conflict Phase 2, stage 3 - another process holds 50052 An orphaned Cocoon from a previous run: lsof -i :50052, then kill the PID.
Crash during InitializeExtensionHost Phase 2, handshake response - the payload was incomplete dataFolderName in the initialization data. It is the payload’s primary crash source when missing.
Chrome paints, extension contributions missing Phase 2, stage 6 - activation stream stalled The activatedExtension events from Cocoon. The workbench does not block paint on activation, so a quiet stream looks like a working shell.
First launch is slow, later launches are not Phase 1, step 2 - the pre-baked manifest was absent Whether extensions.manifest.json exists. The live scan costs ~1200 ms; the cache path is under 50 ms.
Cocoon survives Mountain’s exit Phase 1, step 4 - the child was not tied to the parent VSCODE_PARENT_PID in the spawned environment. Without it the sidecar is not terminated automatically.

A blank workbench is therefore almost always a handshake problem rather than a rendering problem. Troubleshooting covers the port and environment checks that follow from that.


See Also

Workflows, 11 PAGES, page 1 of 11

THE LAYER'S INDEX

NEXT: /BLOG 04 BLOG

NOTES FROM THE BUILD, NEWEST FIRST

〈06〉 /DOC/:SLUG 41 SHEETS AS OF: 2026-12-02