feat: add wsl-only mode + project icon dedup
Three things in one branch: * fix(web): drop the per-thread container icon when every thread in the project is already on WSL (a7a2e1bd, already pushed). * feat(web): confirm before disable / distro-switch when WSL has state (449e18f8, already pushed). * This commit: add a third backend mode where the WSL backend runs as the primary and the Windows backend isn't started. The mode lands as a new `wslOnly` setting on DesktopAppSettings, gated behind wslBackendEnabled. When both are true: - DesktopBackendConfiguration.resolvePrimary now dispatches at resolve time. The Windows path builds the same start config as before; the WSL path reuses resolveWslStartConfig with the primary port and the user's chosen distro, so the WSL backend binds where the Windows backend would have, the renderer loads from the same exposure endpoint, and cookie-auth keeps working. - DesktopBackendPool reads settings once at layer init to pick the primary's label ("Windows" vs "WSL (Ubuntu)"). The label is captured per process; flipping the mode requires a restart. - DesktopWslBackend.reconcile skips the parallel "wsl:<distro>" registration when wsl-only is on, otherwise we'd run two WSL processes on the same distro. - New IPC channel SET_WSL_ONLY_CHANNEL plus a setWslOnly handler. getWslState now includes the wslOnly flag, and the DesktopBridge contract gains setWslOnly(enabled). - Settings UI gets a third row ("Run WSL only") under the distro picker, visible when WSL is enabled. The confirmation dialog grows a third branch with restart-aware copy ("Save and restart later") since the primary spec is captured at layer init. Migration / defaults: wslOnly defaults to false. Existing setups stay on parallel mode unless the user explicitly turns this on. Tests: test bridges, settings mock, and IPC layerTest extended for the new field. Existing settings + backend + WSL test suites pass.
This commit is contained in:
1 parent
449e18f815
commit
e00ad61e45
13 files changed
+210
-18
No files matched your search
@@ -13,6 +13,7 @@ import * as DesktopBackendManager from "./DesktopBackendManager.ts";
|
||||
import * as DesktopEnvironment from "../app/DesktopEnvironment.ts";
|
||||
import * as DesktopObservability from "../app/DesktopObservability.ts";
|
||||
import * as DesktopServerExposure from "./DesktopServerExposure.ts";
|
||||
import * as DesktopAppSettings from "../settings/DesktopAppSettings.ts";
|
||||
import * as DesktopWslEnvironment from "../wsl/DesktopWslEnvironment.ts";
|
||||
|
||||
export interface DesktopBackendConfigurationShape {
|
||||
@@ -413,6 +414,7 @@ export const layer = Layer.effect(
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const serverExposure = yield* DesktopServerExposure.DesktopServerExposure;
|
||||
const wslEnvironment = yield* DesktopWslEnvironment.DesktopWslEnvironment;
|
||||
const settings = yield* DesktopAppSettings.DesktopAppSettings;
|
||||
const tokenRef = yield* Ref.make(Option.none<string>());
|
||||
|
||||
// Both resolvers share the same bootstrap token: the renderer holds a
|
||||
@@ -429,13 +431,47 @@ export const layer = Layer.effect(
|
||||
return { bootstrapToken, observabilitySettings } satisfies SharedBootstrapInput;
|
||||
});
|
||||
|
||||
const buildWslPrimaryConfig = Effect.gen(function* () {
|
||||
// wsl-only mode pipes the WSL backend through the same port the
|
||||
// Windows primary would normally take. That way the renderer
|
||||
// still loads from the local-only endpoint advertised by
|
||||
// DesktopServerExposure, and primary-aware code paths (cookie
|
||||
// auth, the env switcher's "primary" id) keep working without
|
||||
// a parallel "secondary" registration.
|
||||
const backendExposure = yield* serverExposure.backendConfig;
|
||||
const persistedSettings = yield* settings.get;
|
||||
const shared = yield* sharedInputs;
|
||||
return yield* resolveWslStartConfig({
|
||||
...shared,
|
||||
port: backendExposure.port,
|
||||
distro: persistedSettings.wslDistro,
|
||||
}).pipe(
|
||||
Effect.provideService(DesktopEnvironment.DesktopEnvironment, environment),
|
||||
Effect.provideService(DesktopWslEnvironment.DesktopWslEnvironment, wslEnvironment),
|
||||
Effect.provideService(FileSystem.FileSystem, fileSystem),
|
||||
);
|
||||
});
|
||||
|
||||
const buildWindowsPrimaryConfig = Effect.gen(function* () {
|
||||
const shared = yield* sharedInputs;
|
||||
return yield* resolvePrimaryStartConfig(shared).pipe(
|
||||
Effect.provideService(DesktopEnvironment.DesktopEnvironment, environment),
|
||||
Effect.provideService(DesktopServerExposure.DesktopServerExposure, serverExposure),
|
||||
);
|
||||
});
|
||||
|
||||
return DesktopBackendConfiguration.of({
|
||||
resolvePrimary: Effect.gen(function* () {
|
||||
const shared = yield* sharedInputs;
|
||||
return yield* resolvePrimaryStartConfig(shared).pipe(
|
||||
Effect.provideService(DesktopEnvironment.DesktopEnvironment, environment),
|
||||
Effect.provideService(DesktopServerExposure.DesktopServerExposure, serverExposure),
|
||||
);
|
||||
// Dispatch on the wsl-only setting at resolve time so the
|
||||
// user toggling the mode between restarts picks up the new
|
||||
// path on the next start cycle. The pool's primary
|
||||
// BackendInstance is created once at layer init, but its
|
||||
// configResolve fires each time the backend (re)starts.
|
||||
const persistedSettings = yield* settings.get;
|
||||
if (persistedSettings.wslOnly && persistedSettings.wslBackendEnabled) {
|
||||
return yield* buildWslPrimaryConfig;
|
||||
}
|
||||
return yield* buildWindowsPrimaryConfig;
|
||||
}).pipe(Effect.withSpan("desktop.backendConfiguration.resolvePrimary")),
|
||||
resolveWsl: (input) =>
|
||||
Effect.gen(function* () {
|
||||
|
||||
@@ -93,6 +93,7 @@ import { HttpClient } from "effect/unstable/http";
|
||||
import { ChildProcessSpawner } from "effect/unstable/process";
|
||||
|
||||
import * as DesktopBackendConfiguration from "./DesktopBackendConfiguration.ts";
|
||||
import * as DesktopAppSettings from "../settings/DesktopAppSettings.ts";
|
||||
import * as DesktopBackendManager from "./DesktopBackendManager.ts";
|
||||
import * as DesktopObservability from "../app/DesktopObservability.ts";
|
||||
import * as DesktopWindow from "../window/DesktopWindow.ts";
|
||||
@@ -185,6 +186,7 @@ export const layer = Layer.effect(
|
||||
Effect.gen(function* () {
|
||||
const configuration = yield* DesktopBackendConfiguration.DesktopBackendConfiguration;
|
||||
const desktopWindow = yield* DesktopWindow.DesktopWindow;
|
||||
const settings = yield* DesktopAppSettings.DesktopAppSettings;
|
||||
// Capture the services needed to build any future instance from the
|
||||
// pool's layer scope. register() runs `makeBackendInstance` against
|
||||
// a fresh child scope but reuses these services so the instance gets
|
||||
@@ -192,9 +194,23 @@ export const layer = Layer.effect(
|
||||
// primary instance uses.
|
||||
const factoryContext = yield* Effect.context<BackendInstanceFactoryRequirements>();
|
||||
|
||||
// Primary label is captured once per process. When wsl-only mode
|
||||
// is active, the primary's configResolve actually returns the WSL
|
||||
// backend config (see DesktopBackendConfiguration.resolvePrimary),
|
||||
// so the label needs to match. We don't try to react to runtime
|
||||
// setting changes here: the wsl-only switch requires an app
|
||||
// restart so the label reflects the mode the user is actually in.
|
||||
const initialSettings = yield* settings.get;
|
||||
const primaryLabel =
|
||||
initialSettings.wslOnly && initialSettings.wslBackendEnabled
|
||||
? initialSettings.wslDistro
|
||||
? `WSL (${initialSettings.wslDistro})`
|
||||
: "WSL"
|
||||
: "Windows";
|
||||
|
||||
const primary = yield* DesktopBackendManager.makeBackendInstance({
|
||||
id: DesktopBackendManager.PRIMARY_INSTANCE_ID,
|
||||
label: "Windows",
|
||||
label: primaryLabel,
|
||||
configResolve: configuration.resolvePrimary,
|
||||
// Window creation errors propagating out of handleBackendReady are
|
||||
// swallowed here on purpose: they're logged by the window service
|
||||
|
||||
@@ -41,7 +41,7 @@ import {
|
||||
setTheme,
|
||||
showContextMenu,
|
||||
} from "./methods/window.ts";
|
||||
import { getWslState, setWslBackendEnabled, setWslDistro } from "./methods/wsl.ts";
|
||||
import { getWslState, setWslBackendEnabled, setWslDistro, setWslOnly } from "./methods/wsl.ts";
|
||||
|
||||
export const installDesktopIpcHandlers = Effect.gen(function* () {
|
||||
const ipc = yield* DesktopIpc.DesktopIpc;
|
||||
@@ -74,6 +74,7 @@ export const installDesktopIpcHandlers = Effect.gen(function* () {
|
||||
yield* ipc.handle(getWslState);
|
||||
yield* ipc.handle(setWslBackendEnabled);
|
||||
yield* ipc.handle(setWslDistro);
|
||||
yield* ipc.handle(setWslOnly);
|
||||
|
||||
yield* ipc.handle(pickFolder);
|
||||
yield* ipc.handle(confirm);
|
||||
|
||||
@@ -35,4 +35,5 @@ export const GET_ADVERTISED_ENDPOINTS_CHANNEL = "desktop:get-advertised-endpoint
|
||||
export const GET_WSL_STATE_CHANNEL = "desktop:get-wsl-state";
|
||||
export const SET_WSL_BACKEND_ENABLED_CHANNEL = "desktop:set-wsl-backend-enabled";
|
||||
export const SET_WSL_DISTRO_CHANNEL = "desktop:set-wsl-distro";
|
||||
export const SET_WSL_ONLY_CHANNEL = "desktop:set-wsl-only";
|
||||
export const SSH_PASSWORD_PROMPT_CANCELLED_RESULT = "ssh-password-prompt-cancelled";
|
||||
@@ -24,6 +24,7 @@ const readWslState: Effect.Effect<
|
||||
enabled: settings.wslBackendEnabled,
|
||||
distro: settings.wslDistro,
|
||||
available,
|
||||
wslOnly: settings.wslOnly,
|
||||
distros,
|
||||
};
|
||||
});
|
||||
@@ -66,3 +67,19 @@ export const setWslDistro = makeIpcMethod({
|
||||
return yield* readWslState;
|
||||
}),
|
||||
});
|
||||
|
||||
export const setWslOnly = makeIpcMethod({
|
||||
channel: IpcChannels.SET_WSL_ONLY_CHANNEL,
|
||||
payload: Schema.Boolean,
|
||||
result: DesktopWslStateSchema,
|
||||
handler: Effect.fn("desktop.ipc.wsl.setOnly")(function* (enabled) {
|
||||
// wsl-only changes the pool's primary spec, which is captured
|
||||
// once at layer init. Persist the new setting here; the actual
|
||||
// mode flip lands on the next desktop launch. The renderer
|
||||
// surfaces "T3 Code will restart" in the confirmation dialog so
|
||||
// the user knows what to expect.
|
||||
const appSettings = yield* DesktopAppSettings.DesktopAppSettings;
|
||||
yield* appSettings.setWslOnly(enabled);
|
||||
return yield* readWslState;
|
||||
}),
|
||||
});
|
||||
@@ -91,6 +91,7 @@ contextBridge.exposeInMainWorld("desktopBridge", {
|
||||
setWslBackendEnabled: (enabled) =>
|
||||
ipcRenderer.invoke(IpcChannels.SET_WSL_BACKEND_ENABLED_CHANNEL, enabled),
|
||||
setWslDistro: (distro) => ipcRenderer.invoke(IpcChannels.SET_WSL_DISTRO_CHANNEL, distro),
|
||||
setWslOnly: (enabled) => ipcRenderer.invoke(IpcChannels.SET_WSL_ONLY_CHANNEL, enabled),
|
||||
pickFolder: (options) => ipcRenderer.invoke(IpcChannels.PICK_FOLDER_CHANNEL, options),
|
||||
confirm: (message) => ipcRenderer.invoke(IpcChannels.CONFIRM_CHANNEL, message),
|
||||
setTheme: (theme) => ipcRenderer.invoke(IpcChannels.SET_THEME_CHANNEL, theme),
|
||||
|
||||
@@ -99,6 +99,7 @@ describe("DesktopSettings", () => {
|
||||
updateChannel: "nightly",
|
||||
updateChannelConfiguredByUser: false,
|
||||
wslBackendEnabled: false,
|
||||
wslOnly: false,
|
||||
wslDistro: null,
|
||||
} satisfies DesktopSettingsValue);
|
||||
});
|
||||
@@ -122,6 +123,7 @@ describe("DesktopSettings", () => {
|
||||
updateChannel: "latest",
|
||||
updateChannelConfiguredByUser: true,
|
||||
wslBackendEnabled: false,
|
||||
wslOnly: false,
|
||||
wslDistro: null,
|
||||
} satisfies DesktopSettingsValue);
|
||||
|
||||
@@ -203,6 +205,7 @@ describe("DesktopSettings", () => {
|
||||
updateChannel: "latest",
|
||||
updateChannelConfiguredByUser: false,
|
||||
wslBackendEnabled: false,
|
||||
wslOnly: false,
|
||||
wslDistro: null,
|
||||
} satisfies DesktopSettingsValue);
|
||||
}),
|
||||
@@ -244,6 +247,7 @@ describe("DesktopSettings", () => {
|
||||
updateChannel: "nightly",
|
||||
updateChannelConfiguredByUser: false,
|
||||
wslBackendEnabled: false,
|
||||
wslOnly: false,
|
||||
wslDistro: null,
|
||||
} satisfies DesktopSettingsValue);
|
||||
}),
|
||||
@@ -268,6 +272,7 @@ describe("DesktopSettings", () => {
|
||||
updateChannel: "latest",
|
||||
updateChannelConfiguredByUser: true,
|
||||
wslBackendEnabled: false,
|
||||
wslOnly: false,
|
||||
wslDistro: null,
|
||||
} satisfies DesktopSettingsValue);
|
||||
}),
|
||||
@@ -291,6 +296,7 @@ describe("DesktopSettings", () => {
|
||||
updateChannel: "latest",
|
||||
updateChannelConfiguredByUser: false,
|
||||
wslBackendEnabled: false,
|
||||
wslOnly: false,
|
||||
wslDistro: null,
|
||||
} satisfies DesktopSettingsValue);
|
||||
}),
|
||||
|
||||
@@ -34,6 +34,14 @@ export interface DesktopSettings {
|
||||
// value are migrated to `wslBackendEnabled: true` on load.
|
||||
readonly wslBackendEnabled: boolean;
|
||||
readonly wslDistro: string | null;
|
||||
// When true (and wslBackendEnabled is also true) the desktop runs only
|
||||
// the WSL backend as the primary, and the Windows-side Node backend is
|
||||
// not started. Designed for users who develop entirely inside WSL and
|
||||
// don't want a second backend process running. Defaults to false so
|
||||
// existing setups stay on the parallel-backends behavior. Changing
|
||||
// this requires a desktop restart because the pool's primary spec is
|
||||
// chosen once at layer init.
|
||||
readonly wslOnly: boolean;
|
||||
}
|
||||
|
||||
export interface DesktopSettingsChange {
|
||||
@@ -51,6 +59,7 @@ export const DEFAULT_DESKTOP_SETTINGS: DesktopSettings = {
|
||||
updateChannelConfiguredByUser: false,
|
||||
wslBackendEnabled: false,
|
||||
wslDistro: null,
|
||||
wslOnly: false,
|
||||
};
|
||||
|
||||
const DesktopSettingsDocument = Schema.Struct({
|
||||
@@ -65,6 +74,7 @@ const DesktopSettingsDocument = Schema.Struct({
|
||||
wslBackendEnabled: Schema.optionalKey(Schema.Boolean),
|
||||
wslMode: Schema.optionalKey(Schema.Literals(["local", "wsl"])),
|
||||
wslDistro: Schema.optionalKey(Schema.NullOr(Schema.String)),
|
||||
wslOnly: Schema.optionalKey(Schema.Boolean),
|
||||
});
|
||||
|
||||
type DesktopSettingsDocument = typeof DesktopSettingsDocument.Type;
|
||||
@@ -106,6 +116,9 @@ export interface DesktopAppSettingsShape {
|
||||
readonly setWslDistro: (
|
||||
distro: string | null,
|
||||
) => Effect.Effect<DesktopSettingsChange, DesktopSettingsWriteError>;
|
||||
readonly setWslOnly: (
|
||||
enabled: boolean,
|
||||
) => Effect.Effect<DesktopSettingsChange, DesktopSettingsWriteError>;
|
||||
}
|
||||
|
||||
export class DesktopAppSettings extends Context.Service<
|
||||
@@ -159,6 +172,7 @@ function normalizeDesktopSettingsDocument(
|
||||
updateChannelConfiguredByUser,
|
||||
wslBackendEnabled,
|
||||
wslDistro: normalizeWslDistro(parsed.wslDistro),
|
||||
wslOnly: parsed.wslOnly === true,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -189,6 +203,9 @@ function toDesktopSettingsDocument(
|
||||
if (settings.wslDistro !== defaults.wslDistro) {
|
||||
document.wslDistro = settings.wslDistro;
|
||||
}
|
||||
if (settings.wslOnly !== defaults.wslOnly) {
|
||||
document.wslOnly = settings.wslOnly;
|
||||
}
|
||||
|
||||
return document;
|
||||
}
|
||||
@@ -254,6 +271,15 @@ function setWslDistro(settings: DesktopSettings, distro: string | null): Desktop
|
||||
};
|
||||
}
|
||||
|
||||
function setWslOnly(settings: DesktopSettings, enabled: boolean): DesktopSettings {
|
||||
return settings.wslOnly === enabled
|
||||
? settings
|
||||
: {
|
||||
...settings,
|
||||
wslOnly: enabled,
|
||||
};
|
||||
}
|
||||
|
||||
function readSettings(
|
||||
fileSystem: FileSystem.FileSystem,
|
||||
settingsPath: string,
|
||||
@@ -355,6 +381,10 @@ export const layer = Layer.effect(
|
||||
attributes: { distro: distro ?? null },
|
||||
}),
|
||||
),
|
||||
setWslOnly: (enabled) =>
|
||||
persist((settings) => setWslOnly(settings, enabled)).pipe(
|
||||
Effect.withSpan("desktop.settings.setWslOnly", { attributes: { enabled } }),
|
||||
),
|
||||
});
|
||||
}),
|
||||
);
|
||||
@@ -386,6 +416,7 @@ export const layerTest = (initialSettings: DesktopSettings = DEFAULT_DESKTOP_SET
|
||||
setWslBackendEnabled: (enabled) =>
|
||||
update((settings) => setWslBackendEnabled(settings, enabled)),
|
||||
setWslDistro: (distro) => update((settings) => setWslDistro(settings, distro)),
|
||||
setWslOnly: (enabled) => update((settings) => setWslOnly(settings, enabled)),
|
||||
});
|
||||
}),
|
||||
);
|
||||
@@ -161,7 +161,12 @@ export const layer = Layer.effect(
|
||||
const existing = yield* findExistingWslInstance;
|
||||
const existingId = Option.map(existing, (instance) => instance.id);
|
||||
|
||||
const shouldRun = settings.wslBackendEnabled && available;
|
||||
// In wsl-only mode the pool's primary IS the WSL backend (see
|
||||
// DesktopBackendConfiguration.resolvePrimary), so the
|
||||
// orchestrator skips registering a parallel "wsl:<distro>"
|
||||
// secondary. Without this skip we'd spin up two WSL processes
|
||||
// on the same distro for users who explicitly asked for one.
|
||||
const shouldRun = settings.wslBackendEnabled && available && !settings.wslOnly;
|
||||
const targetId = shouldRun
|
||||
? Option.some(resolveTargetInstanceId(settings.wslDistro))
|
||||
: Option.none<DesktopBackendPool.BackendInstanceId>();
|
||||
|
||||
@@ -1505,13 +1505,15 @@ export function ConnectionsSettings() {
|
||||
const [isUpdatingWslBackend, setIsUpdatingWslBackend] = useState(false);
|
||||
const [desktopWslError, setDesktopWslError] = useState<string | null>(null);
|
||||
// Pending WSL setting change waiting on user confirmation. Set when
|
||||
// the user tries a destructive change (disable, switch distro) while
|
||||
// the WSL backend has saved-env state on this machine. Confirming
|
||||
// applies the change; cancelling drops it without touching the
|
||||
// persisted setting. Null when nothing is pending.
|
||||
// the user tries a destructive change (disable, switch distro,
|
||||
// toggle wsl-only) while the WSL backend has saved-env state on this
|
||||
// machine. Confirming applies the change; cancelling drops it
|
||||
// without touching the persisted setting. Null when nothing is
|
||||
// pending.
|
||||
type PendingWslChange =
|
||||
| { readonly kind: "disable" }
|
||||
| { readonly kind: "distro"; readonly nextDistro: string | null };
|
||||
| { readonly kind: "distro"; readonly nextDistro: string | null }
|
||||
| { readonly kind: "wsl-only"; readonly nextValue: boolean };
|
||||
const [pendingWslChange, setPendingWslChange] = useState<PendingWslChange | null>(null);
|
||||
const isWslConfirmDialogOpen = pendingWslChange !== null;
|
||||
const [pendingTailscaleServeEndpoint, setPendingTailscaleServeEndpoint] =
|
||||
@@ -2459,6 +2461,20 @@ export function ConnectionsSettings() {
|
||||
[applyWslSettingChange, desktopBridge, desktopWslState, hasWslRegistrationToLose],
|
||||
);
|
||||
|
||||
const handleToggleWslOnly = useCallback(
|
||||
(enabled: boolean) => {
|
||||
if (!desktopBridge || !desktopWslState || desktopWslState.wslOnly === enabled) return;
|
||||
// wsl-only changes which backend the pool uses as "primary",
|
||||
// which is decided once at app launch. The desktop side persists
|
||||
// the setting immediately but doesn't tear down or restart
|
||||
// anything itself; the renderer warns the user to expect a
|
||||
// restart and (in a follow-up) can trigger it automatically.
|
||||
// Always prompt — even enabling is consequential here.
|
||||
setPendingWslChange({ kind: "wsl-only", nextValue: enabled });
|
||||
},
|
||||
[desktopBridge, desktopWslState],
|
||||
);
|
||||
|
||||
const handleConfirmWslChange = useCallback(() => {
|
||||
if (!desktopBridge || !pendingWslChange) return;
|
||||
const change = pendingWslChange;
|
||||
@@ -2467,7 +2483,11 @@ export function ConnectionsSettings() {
|
||||
void applyWslSettingChange(() => desktopBridge.setWslBackendEnabled(false));
|
||||
return;
|
||||
}
|
||||
void applyWslSettingChange(() => desktopBridge.setWslDistro(change.nextDistro));
|
||||
if (change.kind === "distro") {
|
||||
void applyWslSettingChange(() => desktopBridge.setWslDistro(change.nextDistro));
|
||||
return;
|
||||
}
|
||||
void applyWslSettingChange(() => desktopBridge.setWslOnly(change.nextValue));
|
||||
}, [applyWslSettingChange, desktopBridge, pendingWslChange]);
|
||||
|
||||
const renderWslRow = () => {
|
||||
@@ -2540,6 +2560,20 @@ export function ConnectionsSettings() {
|
||||
}
|
||||
/>
|
||||
) : null}
|
||||
{desktopWslState.enabled ? (
|
||||
<SettingsRow
|
||||
title="Run WSL only"
|
||||
description="Stop the Windows backend and run only the WSL backend. Useful if you develop entirely inside WSL and don't want a second backend process. Requires an app restart."
|
||||
control={
|
||||
<Switch
|
||||
checked={desktopWslState.wslOnly}
|
||||
disabled={isUpdatingWslBackend}
|
||||
onCheckedChange={(checked) => handleToggleWslOnly(checked)}
|
||||
aria-label="Run WSL only"
|
||||
/>
|
||||
}
|
||||
/>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -2765,12 +2799,20 @@ export function ConnectionsSettings() {
|
||||
<AlertDialogTitle>
|
||||
{pendingWslChange?.kind === "disable"
|
||||
? "Disable WSL backend?"
|
||||
: "Switch WSL distro?"}
|
||||
: pendingWslChange?.kind === "distro"
|
||||
? "Switch WSL distro?"
|
||||
: pendingWslChange?.nextValue
|
||||
? "Run only the WSL backend?"
|
||||
: "Re-enable the Windows backend?"}
|
||||
</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
{pendingWslChange?.kind === "disable"
|
||||
? "The WSL backend will stop. Threads and projects opened against WSL stay safe inside the distro, but they'll be unavailable in T3 Code until you re-enable WSL."
|
||||
: "T3 Code will restart the WSL backend on the new distro. Sessions still running on the current distro will be interrupted."}
|
||||
: pendingWslChange?.kind === "distro"
|
||||
? "T3 Code will restart the WSL backend on the new distro. Sessions still running on the current distro will be interrupted."
|
||||
: pendingWslChange?.nextValue
|
||||
? "T3 Code will save this preference and switch to running only the WSL backend on the next app launch. Your Windows-side projects won't be accessible until you turn this off again."
|
||||
: "T3 Code will save this preference and bring the Windows backend back up alongside WSL on the next app launch."}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
@@ -2781,7 +2823,12 @@ export function ConnectionsSettings() {
|
||||
Cancel
|
||||
</AlertDialogClose>
|
||||
<Button
|
||||
variant={pendingWslChange?.kind === "disable" ? "destructive" : "default"}
|
||||
variant={
|
||||
pendingWslChange?.kind === "disable" ||
|
||||
(pendingWslChange?.kind === "wsl-only" && pendingWslChange.nextValue)
|
||||
? "destructive"
|
||||
: "default"
|
||||
}
|
||||
onClick={handleConfirmWslChange}
|
||||
disabled={isUpdatingWslBackend}
|
||||
>
|
||||
@@ -2792,8 +2839,12 @@ export function ConnectionsSettings() {
|
||||
</>
|
||||
) : pendingWslChange?.kind === "disable" ? (
|
||||
"Disable WSL"
|
||||
) : (
|
||||
) : pendingWslChange?.kind === "distro" ? (
|
||||
"Switch distro"
|
||||
) : pendingWslChange?.nextValue ? (
|
||||
"Save and restart later"
|
||||
) : (
|
||||
"Save and restart later"
|
||||
)}
|
||||
</Button>
|
||||
</AlertDialogFooter>
|
||||
|
||||
@@ -451,18 +451,28 @@ const createDesktopBridgeStub = (overrides?: {
|
||||
enabled: false,
|
||||
distro: null,
|
||||
available: false,
|
||||
wslOnly: false,
|
||||
distros: [],
|
||||
}),
|
||||
setWslBackendEnabled: vi.fn().mockResolvedValue({
|
||||
enabled: false,
|
||||
distro: null,
|
||||
available: false,
|
||||
wslOnly: false,
|
||||
distros: [],
|
||||
}),
|
||||
setWslDistro: vi.fn().mockResolvedValue({
|
||||
enabled: false,
|
||||
distro: null,
|
||||
available: false,
|
||||
wslOnly: false,
|
||||
distros: [],
|
||||
}),
|
||||
setWslOnly: vi.fn().mockResolvedValue({
|
||||
enabled: false,
|
||||
distro: null,
|
||||
available: false,
|
||||
wslOnly: false,
|
||||
distros: [],
|
||||
}),
|
||||
pickFolder: vi.fn().mockResolvedValue(null),
|
||||
|
||||
@@ -224,18 +224,28 @@ function makeDesktopBridge(overrides: Partial<DesktopBridge> = {}): DesktopBridg
|
||||
enabled: false,
|
||||
distro: null,
|
||||
available: false,
|
||||
wslOnly: false,
|
||||
distros: [],
|
||||
}),
|
||||
setWslBackendEnabled: async () => ({
|
||||
enabled: false,
|
||||
distro: null,
|
||||
available: false,
|
||||
wslOnly: false,
|
||||
distros: [],
|
||||
}),
|
||||
setWslDistro: async () => ({
|
||||
enabled: false,
|
||||
distro: null,
|
||||
available: false,
|
||||
wslOnly: false,
|
||||
distros: [],
|
||||
}),
|
||||
setWslOnly: async () => ({
|
||||
enabled: false,
|
||||
distro: null,
|
||||
available: false,
|
||||
wslOnly: false,
|
||||
distros: [],
|
||||
}),
|
||||
pickFolder: async () => null,
|
||||
|
||||
@@ -407,6 +407,11 @@ export interface DesktopWslState {
|
||||
// null means "track the current WSL default distro".
|
||||
distro: string | null;
|
||||
available: boolean;
|
||||
// When true (and `enabled` is also true) the desktop runs only the
|
||||
// WSL backend as the primary; the Windows-side Node backend is not
|
||||
// started. Toggling this requires an app restart because the
|
||||
// primary backend's spec is captured once at layer init.
|
||||
wslOnly: boolean;
|
||||
distros: readonly DesktopWslDistro[];
|
||||
}
|
||||
|
||||
@@ -414,6 +419,7 @@ export const DesktopWslStateSchema = Schema.Struct({
|
||||
enabled: Schema.Boolean,
|
||||
distro: Schema.NullOr(Schema.String),
|
||||
available: Schema.Boolean,
|
||||
wslOnly: Schema.Boolean,
|
||||
distros: Schema.Array(DesktopWslDistroSchema),
|
||||
});
|
||||
|
||||
@@ -460,6 +466,7 @@ export interface DesktopBridge {
|
||||
getWslState: () => Promise<DesktopWslState>;
|
||||
setWslBackendEnabled: (enabled: boolean) => Promise<DesktopWslState>;
|
||||
setWslDistro: (distro: string | null) => Promise<DesktopWslState>;
|
||||
setWslOnly: (enabled: boolean) => Promise<DesktopWslState>;
|
||||
pickFolder: (options?: PickFolderOptions) => Promise<string | null>;
|
||||
confirm: (message: string) => Promise<boolean>;
|
||||
setTheme: (theme: DesktopTheme) => Promise<void>;
|
||||
|
||||
Reference in new issue
Block a user