From 3c82c95b318bee063eeb76a5efec437f867673ea Mon Sep 17 00:00:00 2001 From: Josh Gratton Date: Mon, 18 May 2026 11:01:55 -0400 Subject: [PATCH] feat: auto-restart on wsl-only toggle Persisting the wsl-only setting and waiting for the next launch was clunky: the user had to confirm a dialog and then close + reopen the app for the toggle to take effect. The pool captures the primary choice once at layer init, so the relaunch is unavoidable, but we can do it for them. Same pattern the network-access toggle already uses. --- apps/desktop/src/ipc/methods/wsl.ts | 20 ++++++++++++------- .../settings/ConnectionsSettings.tsx | 10 +++++----- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/apps/desktop/src/ipc/methods/wsl.ts b/apps/desktop/src/ipc/methods/wsl.ts index 5135a46919..75a103d0ef 100644 --- a/apps/desktop/src/ipc/methods/wsl.ts +++ b/apps/desktop/src/ipc/methods/wsl.ts @@ -2,6 +2,7 @@ import { DesktopWslStateSchema, type DesktopWslState } from "@t3tools/contracts" import * as Effect from "effect/Effect"; import * as Schema from "effect/Schema"; +import * as DesktopLifecycle from "../../app/DesktopLifecycle.ts"; import * as DesktopAppSettings from "../../settings/DesktopAppSettings.ts"; import * as DesktopWslBackend from "../../wsl/DesktopWslBackend.ts"; import * as DesktopWslEnvironment from "../../wsl/DesktopWslEnvironment.ts"; @@ -73,13 +74,18 @@ export const setWslOnly = makeIpcMethod({ 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. + // wsl-only decides which backend the pool spins up as "primary", + // and that decision is captured once at layer init. After + // persisting the new value we relaunch so the user lands in the + // mode they just picked instead of having to close + reopen + // themselves. Same pattern as the server-exposure-mode change. const appSettings = yield* DesktopAppSettings.DesktopAppSettings; - yield* appSettings.setWslOnly(enabled); - return yield* readWslState; + const lifecycle = yield* DesktopLifecycle.DesktopLifecycle; + const change = yield* appSettings.setWslOnly(enabled); + const state = yield* readWslState; + if (change.changed) { + yield* lifecycle.relaunch(`wslOnly=${enabled}`); + } + return state; }), }); diff --git a/apps/web/src/components/settings/ConnectionsSettings.tsx b/apps/web/src/components/settings/ConnectionsSettings.tsx index 77d2c92ecd..bb07d42b3a 100644 --- a/apps/web/src/components/settings/ConnectionsSettings.tsx +++ b/apps/web/src/components/settings/ConnectionsSettings.tsx @@ -2563,7 +2563,7 @@ export function ConnectionsSettings() { {desktopWslState.enabled ? ( @@ -2842,9 +2842,9 @@ export function ConnectionsSettings() { ) : pendingWslChange?.kind === "distro" ? ( "Switch distro" ) : pendingWslChange?.nextValue ? ( - "Save and restart later" + "Restart and enable" ) : ( - "Save and restart later" + "Restart and disable" )}