desktop: surface preflight-pending WSL backends as Connecting

getLocalEnvironmentBootstraps dropped secondary (WSL) instances whose
config carried a preflightFailure (or had no config yet), so the sidebar
"Connecting..." indicator -- which is driven by the bootstrap list --
never appeared while a dual-mode WSL backend was retrying transient
preflight.

Emit such secondaries as pending bootstraps with null endpoints (and no
token) instead of dropping them. The renderer surfaces them as
"Connecting..." (the Sidebar bootstrap-list banner) and, because the
endpoints are null, never dials the dead port -- so the
/api/auth/bootstrap/bearer error cycles the drop avoided stay avoided.
The primary instance is still skipped while not ready: it is same-origin
with no connecting affordance to surface.

Addresses the Cursor "WSL sidebar misses preflight boot" finding.
This commit is contained in:
Josh Gratton committed 2026-06-21 12:46:42 -04:00
1 parent 206feb75de
commit 6ac6dcc1c8
1 file changed
+22 -11
+22 -11
View File
@@ -63,18 +63,29 @@ export const getLocalEnvironmentBootstraps = DesktopIpc.makeSyncIpcMethod({
const instances = yield* pool.list;
const bootstraps: DesktopEnvironmentBootstrap[] = [];
for (const instance of instances) {
const isPrimary = instance.id === PRIMARY_LOCAL_ENVIRONMENT_ID;
const config = yield* instance.currentConfig;
// Skip instances that haven't produced a config yet (e.g. WSL
// backend mid-registration, before its first start cycle). They'll
// appear on the next IPC call once they've started.
if (Option.isNone(config)) continue;
// Skip instances whose preflight failed (e.g. WSL distro
// missing node, the linux server entry was never built). The
// backend manager schedules a restart instead of actually
// listening, so exposing the bootstrap would point the renderer
// at a port nothing is bound to and trigger needless
// /api/auth/bootstrap/bearer error cycles.
if (Option.isSome(config.value.preflightFailure)) continue;
// A secondary backend (e.g. a parallel WSL backend) that hasn't produced
// a config yet (mid-registration, before its first start cycle) OR whose
// preflight failed (e.g. WSL distro missing node, the linux server entry
// was never built) is not listening on a port. We still surface it as a
// *pending* bootstrap (null endpoints, no token) so the renderer can show
// a "Connecting…" indicator while it retries — but with null endpoints
// the renderer will not dial the dead port, avoiding the needless
// /api/auth/bootstrap/bearer error cycles that a real endpoint would
// trigger. The primary stays skipped while not ready: it is same-origin
// and has no "connecting" affordance to surface, so exposing it half-built
// would only confuse the same-origin bootstrap path.
if (Option.isNone(config) || Option.isSome(config.value.preflightFailure)) {
if (isPrimary) continue;
bootstraps.push({
id: instance.id,
label: yield* instance.label,
httpBaseUrl: null,
wsBaseUrl: null,
});
continue;
}
const { bootstrap, httpBaseUrl } = config.value;
bootstraps.push({
id: instance.id,