The best way to control Claude Code, Codex and more from any computer or phone
fix(server): make stale CLI service recovery actionable (#23541)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 23, 2026 at 10:53 UTC
58a5d1df068413315301e45745ae8414d16f5d84
5 files changed
+71
-19
apps/server/src/cli/invocation.ts
+1
-1
@@ -48,7 +48,7 @@ const decodeInstallManifest = Schema.decodeUnknownEffect(Schema.fromJsonString(I
48
* counts only when its package is this exact version: a different `t3` run
49
* from an agent's shell must not claim to be the npm install.
50
*/
51
-const resolveEntryPath = Effect.gen(function* () {
51
+export const resolveEntryPath = Effect.gen(function* () {
52
const npmLauncher = (yield* HostProcess.Environment).T3CODE_NPM_LAUNCHER_PATH?.trim();
53
if (npmLauncher) {
54
const fs = yield* FileSystem.FileSystem;
apps/server/src/cli/service.test.ts
+39
@@ -7,6 +7,7 @@ import * as Effect from "effect/Effect";
7
import * as FileSystem from "effect/FileSystem";
8
import * as Layer from "effect/Layer";
9
import * as Terminal from "effect/Terminal";
10
+import * as TestConsole from "effect/testing/TestConsole";
11
import { Command } from "effect/cli";
12
import { afterEach, vi } from "vite-plus/test";
13
@@ -88,6 +89,44 @@ it.layer(Layer.mergeAll(NodeServices.layer, NetService.layer))("service commands
89
expect(installOptions).toEqual([]);
90
}),
91
);
92
+
93
+ // regression: #13239 a stale nvm-installed CLI reported "already using" its own version
94
+ it.effect.each(["install", "update"] as const)(
95
+ "%s names the CLI that found nothing to change",
96
+ (command) =>
97
+ Effect.gen(function* () {
98
+ const fs = yield* FileSystem.FileSystem;
99
+ const baseDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-service-cli-test-" });
100
+ const { service, installOptions } = makeTestService(status);
101
+ vi.spyOn(BootService, "layer").mockReturnValue(
102
+ Layer.succeed(BootService.BootService, service),
103
+ );
104
+ const node = "/home/me/.nvm/versions/node/v26.8.2/bin/node";
105
+ const script = "/home/me/.nvm/versions/node/v26.8.2/lib/node_modules/t3/dist/bin.mjs";
106
+
107
+ const output = yield* Command.runWith(serviceCommand, { version: packageJson.version })([
108
+ command,
109
+ "--base-dir",
110
+ baseDir,
111
+ ]).pipe(
112
+ Effect.andThen(TestConsole.logLines),
113
+ Effect.map((lines) => lines.join("\n")),
114
+ Effect.provideService(HostProcess.Environment, {}),
115
+ Effect.provideService(HostProcess.IsExecutable, false),
116
+ Effect.provideService(HostProcess.ExecutablePath, node),
117
+ Effect.provideService(HostProcess.Arguments, [node, script, "service", command]),
118
+ Effect.provide(
119
+ Layer.mergeAll(
120
+ ConfigProvider.layer(ConfigProvider.fromEnv({ env: {} })),
121
+ Layer.fresh(TestConsole.layer),
122
+ ),
123
+ ),
124
+ );
125
+ expect(output).toContain(`t3@${packageJson.version}`);
126
+ expect(output).toContain(script);
127
+ expect(installOptions).toEqual([]);
128
+ }),
129
+ );
130
});
131
132
it.effect("leaves a newer service unchanged during onboarding without prompting", () =>
apps/server/src/cli/service.ts
+7
-4
@@ -12,6 +12,7 @@ import { compareExactServiceVersions } from "../cloud/serviceProtocol.ts";
12
import type * as ServerConfig from "../config.ts";
13
import * as ProcessRunner from "../processRunner.ts";
14
import { projectLocationFlags, resolveCliAuthConfig } from "./config.ts";
15
+import { resolveEntryPath } from "./invocation.ts";
16
17
export const layer = (config: ServerConfig.ServerConfig["Service"]) =>
18
BootService.layer({
@@ -102,9 +103,9 @@ function formatServiceStatus(status: BootService.BootServiceStatus, cliVersion:
103
].join("\n");
104
}
105
105
-const runServiceCommand = Effect.fn("cli.service.run")(function* <A, E>(
106
+const runServiceCommand = Effect.fn("cli.service.run")(function* <A, E, R>(
107
flags: { readonly baseDir: Parameters<typeof resolveCliAuthConfig>[0]["baseDir"] },
107
- run: Effect.Effect<A, E, BootService.BootService>,
108
+ run: Effect.Effect<A, E, R>,
109
) {
110
const logLevel = yield* GlobalFlag.LogLevel;
111
const config = yield* resolveCliAuthConfig(flags, logLevel);
@@ -128,7 +129,7 @@ const serviceInstallCommand = Command.make("install", serviceReconcileFlags).pip
129
const result = yield* reconcileService({ allowDowngrade: flags.allowDowngrade });
130
if (!result.changed) {
131
yield* Console.log(
131
- `T3 Code service is already installed with t3@${packageJson.version}.`,
132
+ `T3 Code service is already installed with t3@${packageJson.version} (${yield* resolveEntryPath}).`,
133
);
134
return;
135
}
@@ -150,7 +151,9 @@ const serviceUpdateCommand = Command.make("update", serviceReconcileFlags).pipe(
151
);
152
const result = yield* reconcileService({ allowDowngrade: flags.allowDowngrade });
153
if (!result.changed) {
153
- yield* Console.log(`T3 Code service is already using t3@${packageJson.version}.`);
154
+ yield* Console.log(
155
+ `T3 Code service is already using t3@${packageJson.version} (${yield* resolveEntryPath}).`,
156
+ );
157
return;
158
}
159
yield* Console.log(formatServiceChange(result));
apps/server/src/cloud/servicePreflight.test.ts
+16
-12
@@ -1,18 +1,22 @@
1
import { expect, it } from "@effect/vitest";
2
3
import { runServicePreflight } from "./servicePreflight.ts";
4
+import { SERVICE_LAUNCHER_PROTOCOL } from "./serviceProtocol.ts";
5
5
-it.each([1])("blocks legacy launcher protocol %i", (launcherProtocol) => {
6
- expect(
7
- runServicePreflight({
8
- databasePath: "/missing/state.sqlite",
9
- launcherProtocol,
10
- version: "1.2.3",
11
- }),
12
- ).toEqual({
13
- status: "blocked",
14
- version: "1.2.3",
15
- reason:
16
- "This release requires a newer T3 Code service launcher. Update it on the server machine.",
6
+// regression: #13239 a stale CLI shadowing the updated one kept "updating" to itself
7
+it.each([1])("blocks legacy launcher protocol %i with exact recovery steps", (launcherProtocol) => {
8
+ const result = runServicePreflight({
9
+ databasePath: "/missing/state.sqlite",
10
+ launcherProtocol,
11
+ version: "9.8.7",
12
});
13
+
14
+ expect(result).toMatchObject({ status: "blocked", version: "9.8.7" });
15
+ const reason = result.status === "blocked" ? result.reason : "";
16
+ expect(reason).toMatch(new RegExp(`\\b${launcherProtocol}\\b`));
17
+ expect(reason).toMatch(new RegExp(`\\b${SERVICE_LAUNCHER_PROTOCOL}\\b`));
18
+ expect(reason).toContain("curl -fsSL https://t3.codes/install.sh | T3CODE_VERSION=9.8.7 sh");
19
+ expect(reason).toContain("~/.local/bin/t3 service install");
20
+ expect(reason).toContain("t3 --version");
21
+ expect(reason).toContain("which -a t3");
22
});
apps/server/src/cloud/servicePreflight.ts
+8
-2
@@ -23,8 +23,14 @@ export function runServicePreflight(input: {
23
return {
24
status: "blocked",
25
version,
26
- reason:
27
- "This release requires a newer T3 Code service launcher. Update it on the server machine.",
26
+ // A stale `t3` earlier on PATH (an old npm/nvm global) makes `t3 service install`
27
+ // reinstall itself and report success, so name the exact install and the path check.
28
+ reason: [
29
+ `The installed service launcher speaks protocol ${input.launcherProtocol}, but t3@${version} requires protocol ${SERVICE_LAUNCHER_PROTOCOL}.`,
30
+ `On the server machine, install this exact CLI: \`curl -fsSL https://t3.codes/install.sh | T3CODE_VERSION=${version} sh\`.`,
31
+ `Check that \`t3 --version\` prints ${version} and that \`which -a t3\` lists no older t3 (such as an npm or nvm install) first, then run \`~/.local/bin/t3 service install\` (the installer's default path).`,
32
+ "Updating the desktop app does not update this CLI, and `t3 service update` only repairs the service with whichever CLI runs it.",
33
+ ].join(" "),
34
};
35
}
36