The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 23, 03:00 UTC
fix(desktop): unregistering a WSL backend now stops its supervisor (#18575)
Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com> Co-authored-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com>
Pujitha Paladugu committed
Oct 18, 2026 at 13:07 UTC
af134abf792b27074d60c6694188cb23f9490ee4
2 files changed
+51
-3
apps/desktop/src/backend/DesktopBackendPool.test.ts
+46
@@ -156,4 +156,50 @@ describe("DesktopBackendPool", () => {
156
}),
157
),
158
);
159
+
160
+ it.effect("unregister stops the registered instance", () =>
161
+ Effect.scoped(
162
+ Effect.gen(function* () {
163
+ const id = DesktopBackendPool.BackendInstanceId("wsl:Ubuntu");
164
+ const pool = yield* DesktopBackendPool.DesktopBackendPool;
165
+ const instance = yield* pool.register({
166
+ id,
167
+ label: Effect.succeed("WSL (Ubuntu)"),
168
+ // A transient preflight failure leaves a restart fiber scheduled
169
+ // without needing a real child process.
170
+ configResolve: Effect.succeed({
171
+ executablePath: "/electron",
172
+ args: [],
173
+ entryPath: "/server/bin.mjs",
174
+ cwd: "/server",
175
+ env: {},
176
+ bootstrap: {
177
+ mode: "desktop",
178
+ noBrowser: true,
179
+ port: 3774,
180
+ t3Home: "/tmp/t3",
181
+ host: "127.0.0.1",
182
+ desktopBootstrapToken: "token",
183
+ tailscaleServeEnabled: false,
184
+ tailscaleServePort: 443,
185
+ },
186
+ bootstrapDelivery: "fd3",
187
+ extendEnv: true,
188
+ httpBaseUrl: new URL("http://127.0.0.1:3774"),
189
+ captureOutput: false,
190
+ preflightFailure: Option.some({ reason: "WSL starting", fatal: false }),
191
+ } satisfies DesktopBackendStartConfig),
192
+ });
193
+ yield* instance.start;
194
+ assert.equal((yield* instance.snapshot).restartScheduled, true);
195
+
196
+ yield* pool.unregister(id);
197
+
198
+ const stopped = yield* instance.snapshot;
199
+ assert.equal(stopped.desiredRunning, false);
200
+ assert.equal(stopped.restartScheduled, false);
201
+ assert.equal(Option.isNone(yield* pool.get(id)), true);
202
+ }).pipe(Effect.provide(layerPool(Ref.makeUnsafe("Windows")))),
203
+ ),
204
+ );
205
});
apps/desktop/src/backend/DesktopBackendPool.ts
+5
-3
@@ -219,12 +219,14 @@ export const layer = Layer.effect(
219
] as const);
220
}
221
return Effect.gen(function* () {
222
- // Provide the captured factory services first, then the child scope
223
- // last so instance finalizers are owned by the unregisterable scope.
222
+ // Provide the child scope after the captured factory context. That
223
+ // context also holds the pool layer's Scope, so providing it last
224
+ // would let it shadow the child scope and leave the instance's
225
+ // stop finalizer and restart fibers running after unregister.
226
const instanceScope = yield* Scope.fork(layerScope, "sequential");
227
const instance = yield* DesktopBackendManager.makeBackendInstance(spec).pipe(
226
- Effect.provide(factoryContext),
228
Scope.provide(instanceScope),
229
+ Effect.provide(factoryContext),
230
);
231
const next = new Map(current);
232
next.set(spec.id, {