fix(desktop): fall back to Windows primary when wsl-only but WSL unavailable
Parity with the #2353 fix for the "WSL off hides recovery control" report. resolvePrimary took the wsl-only primary path whenever wslOnly + wslBackendEnabled were persisted, without checking whether WSL is actually usable. If WSL became unavailable (wsl.exe removed, no distro), the primary looped on preflight failures while the Connections backend control is hidden, leaving no in-app way back to Windows. resolvePrimary now checks wslEnvironment.isAvailable and resolves the Windows primary (logging a warning) when wsl-only was requested but WSL isn't usable. Added a regression test asserting the Windows primary path under isAvailable: false.
This commit is contained in:
1 parent
3a5c7649fd
commit
defdf575f8
2 files changed
+52
-1
No files matched your search
@@ -280,4 +280,43 @@ describe("DesktopBackendConfiguration", () => {
|
||||
}
|
||||
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
|
||||
);
|
||||
|
||||
it.effect(
|
||||
"resolvePrimary falls back to the Windows primary when wsl-only but WSL is unavailable",
|
||||
() =>
|
||||
Effect.gen(function* () {
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const baseDir = yield* fileSystem.makeTempDirectoryScoped({
|
||||
prefix: "t3-desktop-backend-config-test-",
|
||||
});
|
||||
|
||||
yield* Effect.gen(function* () {
|
||||
const environment = yield* DesktopEnvironment.DesktopEnvironment;
|
||||
const configuration = yield* DesktopBackendConfiguration.DesktopBackendConfiguration;
|
||||
const config = yield* configuration.resolvePrimary;
|
||||
|
||||
// wsl-only is persisted but WSL is unavailable, so the primary must
|
||||
// not spawn wsl.exe (which would loop on preflight failures while the
|
||||
// Connections backend control is hidden). Resolve the Windows primary.
|
||||
assert.equal(config.executablePath, process.execPath);
|
||||
assert.equal(config.bootstrap.t3Home, environment.baseDir);
|
||||
assert.isTrue(Option.isNone(config.preflightFailure));
|
||||
}).pipe(
|
||||
Effect.provide(
|
||||
DesktopBackendConfiguration.layer.pipe(
|
||||
Layer.provideMerge(serverExposureLayer),
|
||||
Layer.provideMerge(
|
||||
DesktopAppSettings.layerTest({
|
||||
...DesktopAppSettings.DEFAULT_DESKTOP_SETTINGS,
|
||||
wslBackendEnabled: true,
|
||||
wslOnly: true,
|
||||
}),
|
||||
),
|
||||
Layer.provideMerge(DesktopWslEnvironment.layerTest({ isAvailable: false })),
|
||||
Layer.provideMerge(makeEnvironmentLayer(baseDir, { platform: "win32" })),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
|
||||
);
|
||||
});
|
||||
@@ -501,7 +501,19 @@ export const layer = Layer.effect(
|
||||
// configResolve fires each time the backend (re)starts.
|
||||
const persistedSettings = yield* settings.get;
|
||||
if (persistedSettings.wslOnly && persistedSettings.wslBackendEnabled) {
|
||||
return yield* buildWslPrimaryConfig;
|
||||
// Only honor wsl-only when WSL is actually usable. If the user
|
||||
// persisted wsl-only but WSL has since become unavailable (wsl.exe
|
||||
// removed, no distro), fall back to the Windows primary instead of
|
||||
// looping forever on preflight failures: the Connections backend
|
||||
// control is hidden while WSL is unavailable, so a stuck WSL
|
||||
// primary would otherwise leave no in-app way back to Windows.
|
||||
const wslAvailable = yield* wslEnvironment.isAvailable;
|
||||
if (wslAvailable) {
|
||||
return yield* buildWslPrimaryConfig;
|
||||
}
|
||||
yield* Effect.logWarning(
|
||||
"WSL-only backend requested but WSL is unavailable; starting the Windows primary instead.",
|
||||
);
|
||||
}
|
||||
return yield* buildWindowsPrimaryConfig;
|
||||
}).pipe(Effect.withSpan("desktop.backendConfiguration.resolvePrimary")),
|
||||
|
||||
Reference in new issue
Block a user