diff --git a/apps/desktop/src/backend/DesktopBackendConfiguration.ts b/apps/desktop/src/backend/DesktopBackendConfiguration.ts index e77c5e8193..e447ca0090 100644 --- a/apps/desktop/src/backend/DesktopBackendConfiguration.ts +++ b/apps/desktop/src/backend/DesktopBackendConfiguration.ts @@ -49,15 +49,10 @@ const DESKTOP_BACKEND_ENV_NAMES = [ ] as const; // Sensitive env vars that the WSL backend needs but Windows process.env won't -// forward across the wsl.exe boundary without WSLENV. VITE_DEV_SERVER_URL is -// included so the WSL backend can tell it is running in dev mode and use the -// `dev/` subdir instead of `userdata/` for its state — otherwise the dev -// build collides with the user's daily-driver packaged WSL backend. -const WSL_FORWARDED_ENV_NAMES = [ - "OPENAI_API_KEY", - "ANTHROPIC_API_KEY", - "VITE_DEV_SERVER_URL", -] as const; +// forward across the wsl.exe boundary without WSLENV. The dev-server URL is +// handled separately via a `--dev-url` CLI flag because WSLENV translation of +// URL-shaped values (colons / slashes) is unreliable. +const WSL_FORWARDED_ENV_NAMES = ["OPENAI_API_KEY", "ANTHROPIC_API_KEY"] as const; const backendChildEnvPatch = (): Record => Object.fromEntries(DESKTOP_BACKEND_ENV_NAMES.map((name) => [name, undefined])); diff --git a/apps/web/src/components/settings/ConnectionsSettings.tsx b/apps/web/src/components/settings/ConnectionsSettings.tsx index 96538087ee..fccc2e68c3 100644 --- a/apps/web/src/components/settings/ConnectionsSettings.tsx +++ b/apps/web/src/components/settings/ConnectionsSettings.tsx @@ -108,6 +108,12 @@ import { useServerConfig } from "~/rpc/serverState"; const DEFAULT_TAILSCALE_SERVE_PORT = 443; +// Select-value sentinels for the backend-runtime dropdown. The colon is +// rejected by DISTRO_NAME_PATTERN (validated by the desktop side), so these +// values can never collide with a real WSL distro name. +const BACKEND_VALUE_LOCAL = "backend:local"; +const BACKEND_VALUE_DEFAULT_WSL = "backend:default-wsl"; + const accessTimestampFormatter = new Intl.DateTimeFormat(undefined, { dateStyle: "medium", timeStyle: "short", @@ -2362,9 +2368,12 @@ export function ConnectionsSettings() { (value: string) => { if (!desktopWslState) return; const target = - value === "__local__" + value === BACKEND_VALUE_LOCAL ? { mode: "local" as const, distro: null } - : { mode: "wsl" as const, distro: value === "__default__" ? null : value }; + : { + mode: "wsl" as const, + distro: value === BACKEND_VALUE_DEFAULT_WSL ? null : value, + }; if (target.mode === desktopWslState.mode && target.distro === desktopWslState.distro) { return; } @@ -2476,17 +2485,17 @@ export function ConnectionsSettings() { if (!desktopWslState || !desktopWslState.available) return null; // When distro is null ("track the WSL default"), map to the actual default // distro's name if we know one so the Select highlights a real option - // instead of an orphan "__default__" with no matching item. Falls back to - // "__default__" only when no distros are listed yet — in that case the - // dropdown renders a single placeholder option that matches. + // instead of an orphan default sentinel with no matching item. Falls back + // to BACKEND_VALUE_DEFAULT_WSL only when no distros are listed yet — in + // that case the dropdown renders a single placeholder option that matches. const defaultDistroName = desktopWslState.distros.find((distro) => distro.isDefault)?.name ?? null; - const wslSelectValue = desktopWslState.distro ?? defaultDistroName ?? "__default__"; - const currentValue = desktopWslState.mode === "wsl" ? wslSelectValue : "__local__"; + const wslSelectValue = desktopWslState.distro ?? defaultDistroName ?? BACKEND_VALUE_DEFAULT_WSL; + const currentValue = desktopWslState.mode === "wsl" ? wslSelectValue : BACKEND_VALUE_LOCAL; const currentLabel = - currentValue === "__local__" + currentValue === BACKEND_VALUE_LOCAL ? "Local (Windows)" - : currentValue === "__default__" + : currentValue === BACKEND_VALUE_DEFAULT_WSL ? "WSL: default distro" : `WSL: ${currentValue}`; const pendingTargetLabel = @@ -2528,11 +2537,11 @@ export function ConnectionsSettings() { {currentLabel} - + Local (Windows) {desktopWslState.distros.length === 0 ? ( - + WSL: default distro ) : (