Skip to main content

Module WorkspaceDelta

Module WorkspaceDelta 

Source
Expand description

§WorkspaceDelta

Dispatches $deltaWorkspaceFolders notifications from Mountain to Cocoon whenever the open workspace folder set mutates. Called by every site that flips the folder list (boot-time seed, the MountainWorkspaceOpen* commands, pick-folder navigation, Wind add/remove, and the Cocoon-driven $updateWorkspaceFolders request).

The delta is computed by [WorkspaceState::SetWorkspaceFoldersReturnDelta] and shipped as a fire-and-forget Vine notification: Cocoon’s NotificationHandler converts it into a didChangeWorkspaceFolders event on WorkspaceEventEmitter, which powers every extension’s vscode.workspace.onDidChangeWorkspaceFolders subscription. The same payload primes the local workspace snapshot in WorkspaceNamespace so vscode.workspace.workspaceFolders returns the fresh list on subsequent synchronous reads.

Functions§

DispatchDeltaWorkspaceFolders
Dispatch $deltaWorkspaceFolders to Cocoon. Returns immediately if both arrays are empty - no point waking the sidecar for a no-op mutation.
FolderToWire 🔒
Serialisation shape matching the Cocoon-side Workspace shim. Mirrors the camelCase DTO Sky already serialises for workspaces:getFolders, so the Cocoon handler can pass the payload through to extension listeners without renaming fields.
PersistRecentlyOpened 🔒
Append every folder in Added to ~/.land/workspaces/RecentlyOpened.json, deduping by URI and capping at 50 entries (the VS Code default). Swallows every error - a failed write must not prevent the workspace change.
UpdateWorkspaceFoldersAndBroadcast
Variant that additionally emits a sky://workspaces/changed Tauri event so Wind/Sky can update their own caches (recent-folders list, sidebar breadcrumb) without polling workspaces:getFolders. Preferred call site whenever the caller already has an AppHandle in scope.
UpdateWorkspaceFoldersAndNotify
Convenience wrapper: update the state and fire the delta in one call.