@devries-cameron20 / t3code Mirror · read-only / commits / e1931b5689
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 23, 01:45 UTC

fix(server): keep a failed service start out of the current state (#12199)

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>

Vitaly Iegorov committed Oct 19, 2026 at 22:25 UTC e1931b56896a56484028c5ff2828687fc1c2d3cc
2 files changed +28 -6
apps/server/src/cloud/bootService.test.ts
+26
@@ -858,6 +858,32 @@ it.layer(NodeServices.layer)("boot service install", (it) => {
858 }),
859 );
860
861 + it.effect("keeps failed launch agent installs pending until activation succeeds", () =>
862 + Effect.gen(function* () {
863 + const { service, fs, statePath, commands, control } = yield* makeHarness("darwin");
864 + const path = yield* Path.Path;
865 + const plan = yield* service.install();
866 + const markerPath = path.join(path.dirname(statePath), SERVICE_RESTART_PENDING_FILE);
867 + const bootstrap = `launchctl bootstrap gui/501 ${plan.unitPath}`;
868 + control.failCommand = bootstrap;
869 +
870 + expect((yield* service.install().pipe(Effect.flip))._tag).toBe("BootServiceCommandError");
871 + expect(yield* service.status).toMatchObject({
872 + current: false,
873 + problems: ["restart-pending"],
874 + });
875 + expect(yield* fs.readFileString(markerPath)).toBe("1.2.3\n");
876 +
877 + control.failCommand = undefined;
878 + commands.length = 0;
879 + yield* service.install();
880 +
881 + expect(commands).toContain(bootstrap);
882 + expect(yield* fs.exists(markerPath)).toBe(false);
883 + expect((yield* service.status).current).toBe(true);
884 + }),
885 + );
886 +
887 it.effect("restarts without overwriting a pending remote update on macOS", () =>
888 Effect.gen(function* () {
889 const { service, fs, statePath, commands } = yield* makeHarness("darwin");
apps/server/src/cloud/bootService.ts
+2 -6
@@ -810,12 +810,8 @@ export const make = Effect.fn("cloud.boot_service.make")(function* (input: {
810 yield* fs
811 .makeDirectory(path.dirname(unitPath), { recursive: true })
812 .pipe(Effect.mapError((cause) => new BootServiceInstallError({ cause })));
813 - if (!start && installed) {
814 - // Written first: once the files below name the new version, the running
815 - // service is behind them, and a failure between the two writes must not
816 - // leave it looking current.
817 - yield* fs.writeFileString(restartPendingPath, `${input.cliVersion}\n`, { mode: 0o600 });
818 - }
813 + // Files can match the new version even when activation fails; keep that install retryable.
814 + yield* fs.writeFileString(restartPendingPath, `${input.cliVersion}\n`, { mode: 0o600 });
815 yield* writeDurably(
816 statePath,
817 // @effect-diagnostics-next-line preferSchemaOverJson:off - fixed launcher-owned document.