Skip to main content

Elements

Wind: Frontend Service Layer

Wind is the Effect-TS service layer for the VS Code workbench, enabling it to function inside a Tauri WebView by recreating the essential VS Code renderer environment through typed error and dependency injection patterns.

PUBLISHED ELEMENTS Source/Content/doc/wind.md UNAVAILABLE UNAVAILABLE 13

Wind: Frontend Service Layer 🍃

Wind is the Effect-TS service layer for the VS Code workbench.

  • Wind enables the workbench to function inside a Tauri WebView.
  • It recreates the essential VS Code renderer environment.
  • It implements core services through Effect-TS typed error and dependency injection patterns.
  • It connects the frontend to Mountain’s Rust backend through Tauri’s invoke() and event system.

Mermaid diagram

Overview 📋

Wind provides the Effect-TS native service layer that Sky consumes.

  • It replaces VS Code’s Electron IPC pipeline with typed Tauri commands.
  • These commands are routed to Rust handlers in Mountain.
  • This eliminates the untyped serialization layer.
  • It preserves full VS Code workbench compatibility.
AttributeValue
LanguageTypeScript (Effect-TS v3.21)
FrameworkVite
IPCTauri invoke() + events
Dependencies@codeeditorland/output, @tauri-apps/api, effect, @effect/platform
Consumed bySky

Architecture 🏗️

Mermaid diagram

Module Map 🗺️

PathPurpose
Source/Preload.tsElectron/Node.js API shim (see Polyfills)
Source/Effect/Service implementations (each domain as Define/Implement/Problem)
Source/Function/Install.tsLayer composition and installation entry point
Source/Function/Install/Layer composition details
Source/Workbench/VS Code workbench integration
Source/Telemetry/PostHogBridge.tsIn-webview PostHog client
Source/IPC/Channel.tsTauri event channel definitions
Source/Utility/Tier.tsTier configuration reader
Source/Types/TypeScript type definitions
Source/Bootstrap/Bootstrap type definitions

Service Architecture 🏗️

Each Wind service follows a consistent module structure using the Define/Implement/Problem pattern:

Mermaid diagram

This pattern provides:

  • Define.ts: Exports the Effect-TS Tag that identifies the service. Functions that depend on the service use Tag for compile-time dependency tracking.
  • Implement.ts: Exports the concrete Layer with the Tauri-backed implementation. Uses @tauri-apps/api/invoke for Mountain communication.
  • Problem.ts: Exports typed error types as Effect-TS Cause subtypes, enabling structured error handling.

Example Service Structure

// Effect/Clipboard/Define.ts
export class Clipboard extends Context.Tag("Clipboard")<
	Clipboard,
	{ readonly readText: Effect<string, ClipboardProblem> }
>() {}

// Effect/Clipboard/Implement.ts
export const ClipboardLive = Layer.succeed(
	Clipboard,
	Clipboard.of({
		readText: Effect.tryPromise({
			try: () => invoke("get_clipboard", { format: "text" }),
			catch: (e) => new ClipboardProblem({ message: String(e) }),
		}),
	}),
);

// Effect/Clipboard/Problem.ts
export class ClipboardProblem extends Data.TaggedError("ClipboardProblem")<{
	message: string;
}> {}

Layer Composition 🧩

Wind services compose into three Layer stacks:

// TauriLiveLayer: All production services for Tauri WebView
export const TauriLiveLayer: Layer<Clipboard | Configuration | Editor | ... > =
    Layer.mergeAll(
        ClipboardLayer,
        ConfigurationLayer,
        EditorLayer,
        TerminalLayer,
        DialogLayer,
        FileServiceLayer,
        WindowLayer,
        // ... all ~40 services
    );

// ElectronLiveLayer: Electron-compatible implementations
export const ElectronLiveLayer: Layer<...> = Layer.mergeAll(
    ElectronClipboardLayer,
    ElectronConfigurationLayer,
    // ... Electron-specific implementations
);

// TestLayer: Mock implementations for extension test runner
export const TestLayer: Layer<...> = Layer.mergeAll(
    MockClipboardLayer,
    MockConfigurationLayer,
    // ... mock implementations
);

Layer Resolution

Mermaid diagram

Preload Shim Integration 🔌

Wind’s Preload.ts (see Polyfills.md for full details) runs before the workbench bundle loads:

Mermaid diagram

Service Catalog 📋

Core Infrastructure

ServiceModulePurpose
IPCEffect/IPC.tsTauri command invocation and event subscription
ConfigurationEffect/Configuration.tsRead/write settings via Mountain
EnvironmentEffect/Environment.tsOS environment variables and paths
MountainEffect/Mountain.tsgRPC-level communication with Mountain
MountainSyncEffect/MountainSync.tsSynchronous state snapshot from Mountain
LogEffect/LoggingStructured logging

Editor Services

ServiceModulePurpose
EditorEffect/Editor.tsText editor creation, focus, layout
ModelEffect/Model.tsDocument model creation and management
TextModelResolverEffect/TextModelResolver.tsURI-to-model resolution
CodeEditorEffect/WorkbenchEditor/Monaco editor widget
DecorationsEffect/Decorations.tsEditor decoration management
HistoryEffect/History.tsUndo/redo stack management

File System Services

ServiceModulePurpose
FilesEffect/Files.tsFile read/write via Mountain
WorkingCopyEffect/WorkingCopy.tsDirty state and conflict management
WorkspacesEffect/Workspaces.tsWorkspace root resolution

Window and UI Services

ServiceModulePurpose
ActivityBarEffect/ActivityBar.tsActivity bar state
SidebarEffect/Sidebar.tsSide bar visibility and view switching
StatusBarEffect/StatusBar.tsStatus bar items
PanelEffect/Panel.tsBottom panel (terminal, output)
NotificationEffect/Notification.tsToast notifications
ProgressEffect/Progress.tsLong-running operation progress
DialogEffect/WorkbenchDialog/Message boxes and input boxes
QuickInputEffect/QuickInput.tsQuick pick and input box

Clipboard, Terminal, and Extensions

ServiceModulePurpose
ClipboardEffect/Clipboard.tsSystem clipboard via Mountain
TerminalEffect/Terminal.tsIntegrated terminal management
ExtensionsEffect/Extensions.tsExtension install/uninstall/list
LanguageEffect/Language.tsLanguage mode detection
ThemesEffect/Themes.tsColor theme management
KeybindingEffect/Keybinding.tsKeyboard shortcut resolution
SearchEffect/Search.tsFile and text search via Mountain
TelemetryEffect/Telemetry.tsEvent telemetry
StorageEffect/Storage.tsKey-value storage
LifecycleEffect/Lifecycle.tsApplication lifecycle events
HealthEffect/Health.tsService health monitoring

Mountain IPC Service 🔌

The Mountain service (Effect/Mountain.ts) maintains a runtime connection to the Rust backend:

// Wind sends commands to Mountain via Tauri invoke
const fileContent: Uint8Array = await invoke("read_file", {
	path: workspaceFile.fsPath,
});

// Wind listens for Mountain events
await listen("configuration-changed", (event) => {
	syncConfiguration(event.payload);
});

Command Mapping

Wind ServiceTauri CommandMountain Handler
Files.readread_fileFileSystemProvider
Files.writewrite_fileFileSystemProvider
Configuration.getget_configurationConfigurationProvider
Configuration.setset_configurationConfigurationProvider
Terminal.createcreate_terminalTerminalProvider
Terminal.writewrite_terminalTerminalProvider
Dialog.openopen_dialogUserInterfaceProvider
Clipboard.readget_clipboardClipboard
Clipboard.writeset_clipboardClipboard

Workbench Integration 🔌

Wind integrates with the VS Code workbench by providing service implementations that satisfy the workbench’s dependency injection container:

// VS Code workbench expects IFileService
// Wind provides FileService that implements the same interface
const workbench = new Workbench({
	fileService: Wind.FileService,
	configurationService: Wind.Configuration,
	editorService: Wind.Editor,
	notificationService: Wind.Notification,
	// ... all services the workbench expects
});

await workbench.startup();

See Also


Project Maintainers: Source Open (Source/[email protected]) | GitHub Repository | Report an Issue