The best way to control Claude Code, Codex and more from any computer or phone
fix(server): t3 service uninstall leaves another T3 home's service alone (#29872)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Alex Southwell committed
Nov 3, 2026 at 23:38 UTC
99ccd4785af939aa771d882c68cb42485411285a
2 files changed
+66
-2
apps/server/src/cli/service.test.ts
+50
-2
@@ -32,6 +32,7 @@ function makeTestService(
32
) {
33
const installOptions: Array<Parameters<BootService.BootService["Service"]["install"]>[0]> = [];
34
const restarts: Array<true> = [];
35
+ const uninstalls: Array<true> = [];
36
const service = BootService.BootService.of({
37
status: Effect.succeed(serviceStatus),
38
withStopped: (operation) => operation,
@@ -49,9 +50,12 @@ function makeTestService(
50
logPath: serviceStatus.logPath,
51
};
52
}),
52
- uninstall: Effect.succeed(false),
53
+ uninstall: Effect.sync(() => {
54
+ uninstalls.push(true);
55
+ return serviceStatus.installed;
56
+ }),
57
});
54
- return { service, installOptions, restarts };
58
+ return { service, installOptions, restarts, uninstalls };
59
}
60
61
it.layer(Layer.mergeAll(NodeServices.layer, NetService.layer))("service commands", (it) => {
@@ -194,4 +198,48 @@ it.layer(Layer.mergeAll(NodeServices.layer, NetService.layer))("service commands
198
expect(installOptions).toEqual([]);
199
}),
200
);
201
+
202
+ it.effect.each([
203
+ { label: "this home's service", otherHome: false, unreadable: false, removed: [true] },
204
+ { label: "another home's service", otherHome: true, unreadable: false, removed: [] },
205
+ { label: "an unreadable service", otherHome: false, unreadable: true, removed: [true] },
206
+ ])("uninstall removes only $label", (input) =>
207
+ Effect.gen(function* () {
208
+ const fs = yield* FileSystem.FileSystem;
209
+ const baseDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-service-cli-test-" });
210
+ const { service, uninstalls } = makeTestService({
211
+ ...status,
212
+ installedBaseDir: input.otherHome ? "/home/me/.t3" : baseDir,
213
+ });
214
+ vi.spyOn(BootService, "layer").mockReturnValue(
215
+ Layer.succeed(
216
+ BootService.BootService,
217
+ input.unreadable
218
+ ? {
219
+ ...service,
220
+ status: Effect.fail(new BootService.BootServiceInstallError({ cause: "EACCES" })),
221
+ }
222
+ : service,
223
+ ),
224
+ );
225
+
226
+ const output = yield* Command.runWith(serviceCommand, { version: packageJson.version })([
227
+ "uninstall",
228
+ "--base-dir",
229
+ baseDir,
230
+ ]).pipe(
231
+ Effect.andThen(TestConsole.logLines),
232
+ Effect.map((lines) => lines.join("\n")),
233
+ Effect.provideService(HostProcess.Environment, {}),
234
+ Effect.provide(
235
+ Layer.mergeAll(
236
+ ConfigProvider.layer(ConfigProvider.fromEnv({ env: {} })),
237
+ Layer.fresh(TestConsole.layer),
238
+ ),
239
+ ),
240
+ );
241
+ expect(uninstalls).toEqual(input.removed);
242
+ expect(output).toContain(input.otherHome ? "another T3 home" : "Removed");
243
+ }),
244
+ );
245
});
apps/server/src/cli/service.ts
+16
@@ -278,6 +278,22 @@ const serviceUninstallCommand = Command.make("uninstall", projectLocationFlags).
278
flags,
279
Effect.gen(function* () {
280
const service = yield* BootService.BootService;
281
+ const path = yield* Path.Path;
282
+ const { baseDir } = yield* ServerConfig.ServerConfig;
283
+ // An unreadable unit stays removable; only a unit known to serve another home is kept.
284
+ const installedBaseDir = yield* service.status.pipe(
285
+ Effect.map((status) => status.installedBaseDir),
286
+ Effect.orElseSucceed(() => undefined),
287
+ );
288
+ if (
289
+ installedBaseDir !== undefined &&
290
+ path.resolve(installedBaseDir) !== path.resolve(baseDir)
291
+ ) {
292
+ yield* Console.log(
293
+ "The installed service runs another T3 home, so it was not removed. Pass its --base-dir.",
294
+ );
295
+ return;
296
+ }
297
const removed = yield* service.uninstall;
298
yield* Console.log(
299
removed ? "Removed the T3 Code service." : "T3 Code service is not installed.",