@devries-cameron20 / t3code Mirror · read-only / commits / cfe2e97ac4
Fork 0

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 22, 07:00 UTC

fix(desktop): bound the Linux xdg-mime registration like its sibling helpers (#28368)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Victor Vogel committed Nov 1, 2026 at 16:05 UTC cfe2e97ac4264d729cb9261c02051d2582894a07
2 files changed +66 -63
apps/desktop/src/app/DesktopLinuxUrlHandler.test.ts
+62 -60
@@ -366,68 +366,70 @@ describe("DesktopLinuxUrlHandler", () => {
366 });
367 });
368
369 - it.effect.skipIf(HostProcess.Platform.defaultValue() !== "linux")(
370 - "continues registration after a timed-out cache helper ignores SIGTERM",
371 - () =>
372 - Effect.gen(function* () {
373 - const realSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
374 - const nodeExecutable = yield* HostProcess.ExecutablePath;
375 - const recorded = emptyRecording();
376 - const spawned = yield* Deferred.make<ChildProcessSpawner.ChildProcessHandle>();
377 - const ready = yield* Deferred.make<void>();
378 - const processSpawner = ChildProcessSpawner.make((command) =>
379 - Effect.gen(function* () {
380 - if (!ChildProcess.isStandardCommand(command)) {
381 - return yield* Effect.die("expected a single registration command");
382 - }
383 - recorded.commands.push({ command: command.command, args: command.args });
384 - if (command.command !== "update-desktop-database") return mockProcess(0);
385 - const child = yield* realSpawner.spawn(
386 - ChildProcess.make(
387 - nodeExecutable,
388 - [
389 - "-e",
390 - // The watchdog makes the unfixed case exit with a distinguishable code.
391 - "process.on('SIGTERM', () => setTimeout(() => process.exit(99), 5000));" +
392 - "process.stdout.write('ready\\n'); setInterval(() => {}, 2147483647);",
393 - ],
394 - { ...command.options, stdout: "pipe" },
369 + for (const stalledHelper of ["update-desktop-database", "xdg-mime"] as const) {
370 + it.effect.skipIf(HostProcess.Platform.defaultValue() !== "linux")(
371 + `finishes registration after a timed-out ${stalledHelper} ignores SIGTERM`,
372 + () =>
373 + Effect.gen(function* () {
374 + const realSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
375 + const nodeExecutable = yield* HostProcess.ExecutablePath;
376 + const recorded = emptyRecording();
377 + const spawned = yield* Deferred.make<ChildProcessSpawner.ChildProcessHandle>();
378 + const ready = yield* Deferred.make<void>();
379 + const processSpawner = ChildProcessSpawner.make((command) =>
380 + Effect.gen(function* () {
381 + if (!ChildProcess.isStandardCommand(command)) {
382 + return yield* Effect.die("expected a single registration command");
383 + }
384 + recorded.commands.push({ command: command.command, args: command.args });
385 + if (command.command !== stalledHelper) return mockProcess(0);
386 + const child = yield* realSpawner.spawn(
387 + ChildProcess.make(
388 + nodeExecutable,
389 + [
390 + "-e",
391 + // The watchdog makes the unfixed case exit with a distinguishable code.
392 + "process.on('SIGTERM', () => setTimeout(() => process.exit(99), 5000));" +
393 + "process.stdout.write('ready\\n'); setInterval(() => {}, 2147483647);",
394 + ],
395 + { ...command.options, stdout: "pipe" },
396 + ),
397 + );
398 + yield* Deferred.succeed(spawned, child);
399 + yield* Stream.runHead(child.stdout);
400 + yield* Deferred.succeed(ready, undefined);
401 + return child;
402 + }),
403 + );
404 + const registration = yield* runRegister(recorded, { processSpawner }).pipe(
405 + Effect.forkScoped,
406 + );
407 + const child = yield* Deferred.await(spawned);
408 + yield* Effect.addFinalizer(() =>
409 + child.isRunning.pipe(
410 + Effect.flatMap((running) =>
411 + running ? child.kill({ killSignal: "SIGKILL" }) : Effect.void,
412 ),
396 - );
397 - yield* Deferred.succeed(spawned, child);
398 - yield* Stream.runHead(child.stdout);
399 - yield* Deferred.succeed(ready, undefined);
400 - return child;
401 - }),
402 - );
403 - const registration = yield* runRegister(recorded, { processSpawner }).pipe(
404 - Effect.forkScoped,
405 - );
406 - const child = yield* Deferred.await(spawned);
407 - yield* Effect.addFinalizer(() =>
408 - child.isRunning.pipe(
409 - Effect.flatMap((running) =>
410 - running ? child.kill({ killSignal: "SIGKILL" }) : Effect.void,
413 + Effect.ignore,
414 ),
412 - Effect.ignore,
413 - ),
414 - );
415 - yield* Deferred.await(ready);
416 - yield* TestClock.adjust("5 seconds");
417 - yield* Fiber.join(registration);
418 -
419 - const exit = yield* Effect.exit(child.exitCode);
420 - if (Exit.isFailure(exit)) {
421 - assert.include(Cause.pretty(exit.cause), "SIGKILL");
422 - } else {
423 - assert.fail(`cache helper exited with ${exit.value} instead of being force-killed`);
424 - }
425 - assert.deepEqual(
426 - recorded.commands.map(({ command }) => command),
427 - ["update-desktop-database", "xdg-mime"],
428 - );
429 - }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
430 - );
415 + );
416 + yield* Deferred.await(ready);
417 + yield* TestClock.adjust("5 seconds");
418 + yield* Fiber.join(registration);
419 +
420 + const exit = yield* Effect.exit(child.exitCode);
421 + if (Exit.isFailure(exit)) {
422 + assert.include(Cause.pretty(exit.cause), "SIGKILL");
423 + } else {
424 + assert.fail(`${stalledHelper} exited with ${exit.value} instead of being force-killed`);
425 + }
426 + assert.deepEqual(
427 + recorded.commands.map(({ command }) => command),
428 + ["update-desktop-database", "xdg-mime"],
429 + );
430 + }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
431 + );
432 + }
433 });
434
435 interface ThemeIconRun {
apps/desktop/src/app/DesktopLinuxUrlHandler.ts
+4 -3
@@ -261,15 +261,16 @@ export const make = Effect.gen(function* () {
261 stdin: "ignore",
262 stdout: "ignore",
263 stderr: "ignore",
264 + forceKillAfter: "1 second",
265 },
266 );
267 const handle = yield* spawner.spawn(command);
267 - const exitCode = yield* handle.exitCode;
268 - if ((exitCode as unknown as number) !== 0) {
268 + const exitCode = yield* handle.exitCode.pipe(Effect.timeout("5 seconds"));
269 + if (exitCode !== 0) {
270 return yield* new DesktopLinuxUrlHandlerRegistrationError({
271 step: "set-default-handler",
272 scheme,
272 - exitCode: Number(exitCode),
273 + exitCode,
274 });
275 }
276 }),