Lets the desktop app launch the local backend inside a WSL distro instead of natively on Windows. Adds: - Backend plumbing (apps/desktop/src/wsl): pure path parsing utilities, a DesktopWslEnvironment Effect service wrapping wsl.exe operations (listDistros, preWarm, windowsToWslPath, ensureNodePty, isAvailable), and an explicit preflight that checks for missing node / build tools before spawning so the failure message names the actual problem. - Spawn path: DesktopBackendConfiguration branches on the new wslMode setting and assembles "wsl.exe -d <distro> -- node <linux-entry> --bootstrap-fd 0" with the bootstrap envelope on stdin (wsl.exe drops additional file descriptors). Sensitive env vars forward via WSLENV; --dev-url is passed as a CLI flag so the WSL dev backend lands in dev/ instead of userdata/ deterministi- cally. The Windows-side T3CODE_HOME is scrubbed and extendEnv is disabled for WSL so the WSL backend cannot accidentally share a baseDir with the local backend via /mnt/c/... - Settings: wslMode + wslDistro on DesktopAppSettings, with validation that drops distro names containing control or shell meta characters. Contracts get DesktopWslMode / DesktopWslDistro / DesktopWslState schemas. - IPC: getWslState and setWslBackend on the desktop bridge. The setter pre-warms the WSL VM, persists settings, then drives an in-process backend stop + start with a 2-minute readiness wait and a rollback path that reverts to the previous mode if the new backend never reports ready. pickFolder defaults to the WSL home UNC path when wslMode is "wsl". - Web UI: backend-runtime selector in Connection Settings with a three-stage swap modal (restarting / re-establishing session / syncing) that suppresses the WS reconnect toast for the duration of the swap, waits for the new backend's welcome event before closing, and clears the previous env's store state so the side- bar does not render stale threads. New suppressReconnect helper on the connection-status atom plus exports for the descriptor refresh and reauth used by the swap flow.
22 lines
773 B
TypeScript
22 lines
773 B
TypeScript
import * as Schema from "effect/Schema";
|
|
|
|
import { PortSchema } from "./baseSchemas.ts";
|
|
|
|
export const DesktopBackendBootstrap = Schema.Struct({
|
|
mode: Schema.Literal("desktop"),
|
|
noBrowser: Schema.Boolean,
|
|
port: PortSchema,
|
|
// Omitted when the desktop launches the backend inside WSL, since the
|
|
// Windows-side baseDir maps to /mnt/c/... and the Linux side should use its
|
|
// own home directory instead.
|
|
t3Home: Schema.optional(Schema.String),
|
|
host: Schema.String,
|
|
desktopBootstrapToken: Schema.String,
|
|
tailscaleServeEnabled: Schema.Boolean,
|
|
tailscaleServePort: PortSchema,
|
|
otlpTracesUrl: Schema.optional(Schema.String),
|
|
otlpMetricsUrl: Schema.optional(Schema.String),
|
|
});
|
|
|
|
export type DesktopBackendBootstrap = typeof DesktopBackendBootstrap.Type;
|