|
| 1 | +# Sky β Deep Dive |
| 2 | + |
| 3 | +This document provides the technical foundation for the Sky UI component layer |
| 4 | +within the Land ecosystem. **Sky** renders the complete editor interface inside |
| 5 | +the Tauri webview using Astro, consuming state and services from the Wind |
| 6 | +service layer. |
| 7 | + |
| 8 | +--- |
| 9 | + |
| 10 | +## Architecture |
| 11 | + |
| 12 | +Sky is organized into three tiers: page routes that define Tauri webview entry |
| 13 | +points, workbench components that compose the VSCode-compatible editor layout, |
| 14 | +and utility functions that support the build and runtime process. |
| 15 | + |
| 16 | +```mermaid |
| 17 | +graph TB |
| 18 | + subgraph "Sky β UI Component Layer" |
| 19 | + Pages["Pages\nindex / Browser / Electron / Mountain / Isolation"] |
| 20 | + Workbenches["Workbench Components\nBrowser / Mountain / Default / NLS"] |
| 21 | + WorkbenchImpl["Workbench Implementations\nBrowserProxy/ Β· Electron/"] |
| 22 | + Functions["Function/\nDebug Β· Shared Β· Meta Β· Markup/Base"] |
| 23 | + end |
| 24 | +
|
| 25 | + subgraph "Wind β Service Layer" |
| 26 | + Preload["Preload.js β Environment Shim"] |
| 27 | + WindServices["Effect-TS Services"] |
| 28 | + TauriIntegrations["Tauri IPC Integrations"] |
| 29 | + end |
| 30 | +
|
| 31 | + subgraph "Mountain β Rust Backend" |
| 32 | + TauriEvents["Tauri Event System"] |
| 33 | + MountainCore["Mountain Core"] |
| 34 | + end |
| 35 | +
|
| 36 | + Pages --> Workbenches |
| 37 | + Pages --> WorkbenchImpl |
| 38 | + Workbenches --> Preload |
| 39 | + WorkbenchImpl --> Preload |
| 40 | + Workbenches --> WindServices |
| 41 | + WorkbenchImpl --> WindServices |
| 42 | + WindServices --> TauriIntegrations |
| 43 | + TauriIntegrations --> TauriEvents |
| 44 | + TauriEvents --> MountainCore |
| 45 | +``` |
| 46 | + |
| 47 | +--- |
| 48 | + |
| 49 | +## Key Modules |
| 50 | + |
| 51 | +| Path | Description | |
| 52 | +| :--- | :--- | |
| 53 | +| `Source/pages/index.astro` | Default entry point; reads environment variables to select workbench variant | |
| 54 | +| `Source/pages/Mountain.astro` | A2 workbench page β recommended production entry point | |
| 55 | +| `Source/pages/Browser.astro` | A1 browser-only workbench page | |
| 56 | +| `Source/pages/BrowserProxy.astro` | A1 browser workbench with services proxy | |
| 57 | +| `Source/pages/Electron.astro` | A3 workbench page with Electron polyfills | |
| 58 | +| `Source/pages/Isolation.astro` | Isolated mode page for extension sandboxing | |
| 59 | +| `Source/Workbench/Mountain.astro` | A2 workbench component β loads VSCode UI with Mountain providers | |
| 60 | +| `Source/Workbench/Browser.astro` | A1 workbench component β pure browser workbench | |
| 61 | +| `Source/Workbench/BrowserProxy/Layout.astro` | A1 layout with service proxy bootstrapping | |
| 62 | +| `Source/Workbench/BrowserProxy/Bootstrap.ts` | Initializes Effect-TS runtime and services for BrowserProxy | |
| 63 | +| `Source/Workbench/BrowserProxy/ServicesProxy.ts` | Service proxy implementation | |
| 64 | +| `Source/Workbench/Electron/Layout.astro` | A3 layout with Electron polyfill injection | |
| 65 | +| `Source/Workbench/Electron/Polyfills.ts` | Electron compatibility shims | |
| 66 | +| `Source/Workbench/NLS.astro` | Natural language support component | |
| 67 | +| `Source/Function/Debug.ts` | Build-time debug utilities | |
| 68 | +| `Source/Function/Shared.ts` | Shared runtime utilities | |
| 69 | +| `Source/Function/Meta.astro` | HTML meta tag component | |
| 70 | +| `Source/Function/Markup/Base.astro` | Base HTML layout skeleton | |
| 71 | +| `astro.config.ts` | Astro build configuration, alias resolution, Vite settings | |
| 72 | + |
| 73 | +--- |
| 74 | + |
| 75 | +## Data Flow |
| 76 | + |
| 77 | +The following sequence shows how a user action travels from the Sky UI through |
| 78 | +Wind services to the Mountain backend and back. |
| 79 | + |
| 80 | +```mermaid |
| 81 | +sequenceDiagram |
| 82 | + participant User as User Interaction |
| 83 | + participant Sky as Sky Component |
| 84 | + participant Wind as Wind Service |
| 85 | + participant Tauri as Tauri IPC |
| 86 | + participant Mountain as Mountain Backend |
| 87 | +
|
| 88 | + User->>Sky: Click / Keystroke |
| 89 | + Sky->>Wind: Call service method (e.g. DialogService) |
| 90 | + Wind->>Tauri: tauri invoke command |
| 91 | + Tauri->>Mountain: Rust command handler |
| 92 | + Mountain->>Tauri: Return result |
| 93 | + Tauri->>Wind: Resolve Effect |
| 94 | + Wind->>Sky: Updated state |
| 95 | + Sky->>User: Re-render component |
| 96 | +``` |
| 97 | + |
| 98 | +**Startup sequence:** |
| 99 | + |
| 100 | +1. Tauri loads the webview pointing at Sky's built output. |
| 101 | +2. The page route reads environment variables and selects a workbench variant. |
| 102 | +3. Wind's `Preload.ts` shims `window.vscode` globals before VSCode code runs. |
| 103 | +4. Wind bootstraps the Effect-TS service layer and establishes Tauri IPC. |
| 104 | +5. Sky components subscribe to Wind services for live state updates. |
| 105 | +6. Sky listens for Tauri events from Mountain (`sky://terminal/data`, |
| 106 | + `sky://scm/update-group`, `sky://configuration/changed`) to update UI. |
| 107 | + |
| 108 | +--- |
| 109 | + |
| 110 | +## Integration Points |
| 111 | + |
| 112 | +| Connecting Element | Direction | Mechanism | Description | |
| 113 | +| :--- | :--- | :--- | :--- | |
| 114 | +| **Wind** | Inbound | Direct import | Sky consumes Wind Effect-TS services for all business logic | |
| 115 | +| **Mountain** | Bidirectional | Tauri IPC + Events | Commands sent via Tauri invoke; updates received as Tauri events | |
| 116 | +| **Output** | Inbound | Static bundle | VSCode core UI components loaded from `@codeeditorland/output` | |
| 117 | +| **Worker** | Inbound | Web Worker API | Web workers for background processing imported from `@codeeditorland/worker` | |
| 118 | + |
| 119 | +--- |
| 120 | + |
| 121 | +## Configuration |
| 122 | + |
| 123 | +| Variable | Default | Description | |
| 124 | +| :--- | :--- | :--- | |
| 125 | +| `Mountain` | unset | Set to `true` to load the A2 Mountain workbench (recommended) | |
| 126 | +| `Electron` | unset | Set to `true` to load the A3 Electron workbench | |
| 127 | +| `BrowserProxy` | unset | Set to `true` to load the A1 BrowserProxy workbench | |
| 128 | +| `Browser` | unset | Set to `true` to load the A1 Browser workbench | |
| 129 | +| `NODE_ENV` | `production` | Controls source map generation and debug output | |
| 130 | + |
| 131 | +When no variant flag is set, `index.astro` loads `Workbench/Default.astro`. |
| 132 | +The recommended deployment always sets `Mountain=true`. |
| 133 | + |
| 134 | +**Astro configuration** (`astro.config.ts`) resolves Wind and other |
| 135 | +`@codeeditorland/*` packages through Vite aliases, sets `Source/` as the |
| 136 | +content root, and directs build output to `Target/`. |
0 commit comments