@devries-cameron20 / t3code-1 / commits / 2b37449c85
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(cli): t3 update no longer says a service awaiting restart runs the new version (#29901)

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

Alex Southwell committed Nov 3, 2026 at 23:41 UTC 2b37449c85557e1dfdc28b88fa8f666b69ba7f78
2 files changed +104 -2
apps/server/src/cli/update.test.ts
+96 -1
@@ -10,12 +10,14 @@ import * as Layer from "effect/Layer";
10 import * as Option from "effect/Option";
11 import * as Path from "effect/Path";
12 import * as TestClock from "effect/testing/TestClock";
13 +import * as TestConsole from "effect/testing/TestConsole";
14 import { HttpClient, HttpClientResponse } from "effect/http";
15 import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
16 import { afterEach, vi } from "vite-plus/test";
17
18 +import packageJson from "../../package.json" with { type: "json" };
19 import * as BootService from "../cloud/bootService.ts";
18 -import { prunePinnedRuntimes } from "../cloud/pinnedRuntime.ts";
20 +import { pinnedRuntimePaths, prunePinnedRuntimes } from "../cloud/pinnedRuntime.ts";
21 import * as ManagedPolicy from "../policy/ManagedPolicy.ts";
22 import * as ProcessRunner from "../processRunner.ts";
23 import {
@@ -434,3 +436,96 @@ it.layer(NodeServices.layer)("t3 update launcher", (it) => {
436 }).pipe(Effect.scoped, Effect.provideService(HostProcess.Platform, "linux")),
437 );
438 });
439 +
440 +// Without terminals, update skips its restart prompt whatever runs the test.
441 +const withoutTerminals = Effect.acquireRelease(
442 + Effect.sync(() =>
443 + [process.stdin, process.stdout].map((stream) => {
444 + const descriptor = Object.getOwnPropertyDescriptor(stream, "isTTY");
445 + Object.defineProperty(stream, "isTTY", { configurable: true, value: false });
446 + return { stream, descriptor };
447 + }),
448 + ),
449 + (saved) =>
450 + Effect.sync(() => {
451 + for (const { stream, descriptor } of saved) {
452 + if (descriptor === undefined) Reflect.deleteProperty(stream, "isTTY");
453 + else Object.defineProperty(stream, "isTTY", descriptor);
454 + }
455 + }),
456 +);
457 +
458 +it.layer(NodeServices.layer)("t3 update with a background service", (it) => {
459 + it.effect("names the version a service with a pending restart still runs", () =>
460 + Effect.gen(function* () {
461 + yield* withoutTerminals;
462 + const fs = yield* FileSystem.FileSystem;
463 + const path = yield* Path.Path;
464 + const baseDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-update-" });
465 + const version = packageJson.version;
466 + const runtime = pinnedRuntimePaths(path, baseDir, version, "linux");
467 + yield* fs.makeDirectory(runtime.versionDir, { recursive: true });
468 + yield* fs.writeFileString(runtime.entryPath, "");
469 + yield* fs.writeFileString(runtime.sentinelPath, `${version}\n`);
470 + const unitPath = path.join(baseDir, "t3code.service");
471 + const logPath = path.join(baseDir, "boot-service.log");
472 + // An earlier `t3 update` pointed the service at this version without restarting it.
473 + const service = Layer.mock(BootService.BootService, {
474 + status: Effect.succeed<BootService.BootServiceStatus>({
475 + supported: true,
476 + installed: true,
477 + current: false,
478 + installedVersion: version,
479 + installedBaseDir: baseDir,
480 + problems: ["restart-pending"],
481 + unitPath,
482 + logPath,
483 + }),
484 + install: () => Effect.succeed({ program: [runtime.entryPath], baseDir, unitPath, logPath }),
485 + });
486 + vi.spyOn(BootService, "layer").mockReturnValue(service);
487 + const runner = ProcessRunner.ProcessRunner.of({
488 + run: (input) =>
489 + input.args?.includes("--version") === true
490 + ? unrelatedLsof
491 + .run(input)
492 + .pipe(Effect.map((result) => ({ ...result, stdout: `t3 v${version}\n` })))
493 + : unrelatedLsof.run(input),
494 + });
495 +
496 + const output = yield* runUpdate({
497 + baseDir,
498 + logsDir: baseDir,
499 + serverRuntimeStatePath: path.join(baseDir, "server-runtime.json"),
500 + channel: undefined,
501 + requestedVersion: version,
502 + allowDowngrade: false,
503 + assumeYes: false,
504 + }).pipe(
505 + Effect.andThen(TestConsole.logLines),
506 + Effect.map((lines) => lines.join("\n")),
507 + Effect.provide(
508 + Layer.mergeAll(
509 + service,
510 + Layer.succeed(ProcessRunner.ProcessRunner, runner),
511 + ManagedPolicy.layerTest(),
512 + Layer.succeed(
513 + HttpClient.HttpClient,
514 + HttpClient.make(() => Effect.die("unexpected release lookup")),
515 + ),
516 + Layer.fresh(TestConsole.layer),
517 + ),
518 + ),
519 + );
520 +
521 + assert.include(
522 + output,
523 + `Background service still running the version before ${version}. Run \`t3 service restart\` when you are ready to switch it to ${version}.`,
524 + );
525 + }).pipe(
526 + Effect.scoped,
527 + Effect.provideService(HostProcess.Platform, "linux"),
528 + Effect.provideService(HostProcess.Environment, { PATH: "" }),
529 + ),
530 + );
531 +});
apps/server/src/cli/update.ts
+8 -1
@@ -603,8 +603,15 @@ export const runUpdate = Effect.fn("cli.update.run")(function* (input: {
603 } else if (serviceInstalled && serviceCurrent) {
604 yield* Console.log(` Background service already on ${targetVersion}`);
605 } else if (serviceInstalled) {
606 + // A pending restart means the service already points at serviceVersion but runs an older one.
607 + const running =
608 + serviceVersion === undefined
609 + ? "an unknown version"
610 + : restartPending
611 + ? `the version before ${serviceVersion}`
612 + : serviceVersion;
613 yield* Console.log(
607 - ` Background service still running ${serviceVersion ?? "an unknown version"}. Run \`t3 service restart\` when you are ready to switch it to ${targetVersion}.`,
614 + ` Background service still running ${running}. Run \`t3 service restart\` when you are ready to switch it to ${targetVersion}.`,
615 );
616 } else if (status.installed && !servesThisHome) {
617 yield* Console.log(