@devries-cameron20 / t3code-1 / commits / 8f341f20c9
Fork 0

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

test(server): use the launcher state writer in release tests

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Theo Browne committed Aug 5, 2026 at 22:35 UTC 8f341f20c91e708de1dab949dbd723e86f2ff328
1 file changed +25 -14
apps/server/src/cloud/http.test.ts
+25 -14
@@ -1,7 +1,7 @@
1 import * as NodeServices from "@effect/platform-node/NodeServices";
2 import { describe, expect, it } from "@effect/vitest";
3 import * as Effect from "effect/Effect";
4 -import * as FileSystem from "effect/FileSystem";
4 +import * as Layer from "effect/Layer";
5 import * as Option from "effect/Option";
6 import * as Path from "effect/Path";
7 import * as PlatformError from "effect/PlatformError";
@@ -18,6 +18,12 @@ import { RelayClientTracer } from "@t3tools/shared/relayTracing";
18 import * as EnvironmentAuth from "../auth/EnvironmentAuth.ts";
19 import * as ServerSecretStore from "../auth/ServerSecretStore.ts";
20 import * as ServerConfigModule from "../config.ts";
21 +import { writeServiceState } from "../serviceLauncher.ts";
22 +import {
23 + SERVICE_LAUNCHER_PROTOCOL,
24 + SERVICE_STATE_FILE,
25 + type ServiceUpdateRecord,
26 +} from "./serviceProtocol.ts";
27 import * as ServerEnvironment from "../environment/ServerEnvironment.ts";
28 import { CLOUD_CLI_DESIRED_LINK_SECRET } from "./CliState.ts";
29 import * as CliTokenManager from "./CliTokenManager.ts";
@@ -259,18 +265,20 @@ describe("releaseManagedTunnelOnShutdown", () => {
265 readonly respond?: () => Response;
266 }
267
262 - // Writes the launcher's durable state file into this test's baseDir; the
263 - // release reads it to detect an in-flight update handoff.
264 - const writeServiceState = (update: Record<string, unknown>) =>
268 + // Writes the launcher's durable state file into this test's baseDir with
269 + // the launcher's own writer; the release reads it to detect an in-flight
270 + // update handoff.
271 + const writeLauncherState = (update: ServiceUpdateRecord) =>
272 Effect.gen(function* () {
266 - const fs = yield* FileSystem.FileSystem;
273 const path = yield* Path.Path;
274 const config = yield* ServerConfigModule.ServerConfig;
269 - const statePath = path.join(config.baseDir, "runtime", "service-state.json");
270 - yield* fs.makeDirectory(path.dirname(statePath), { recursive: true });
271 - yield* fs.writeFileString(
272 - statePath,
273 - JSON.stringify({ version: 1, activeVersion: "0.0.30", update }),
275 + const statePath = path.join(config.baseDir, "runtime", SERVICE_STATE_FILE);
276 + yield* Effect.promise(() =>
277 + writeServiceState(statePath, {
278 + protocol: SERVICE_LAUNCHER_PROTOCOL,
279 + activeVersion: "0.0.30",
280 + update,
281 + }),
282 );
283 });
284
@@ -326,8 +334,11 @@ describe("releaseManagedTunnelOnShutdown", () => {
334 ),
335 // The release consults the launcher state file under the configured
336 // baseDir, so every harness run gets a scoped temp baseDir.
329 - Effect.provide(ServerConfigModule.layerTest("/", { prefix: "t3-http-release-test-" })),
330 - Effect.provide(NodeServices.layer),
337 + Effect.provide(
338 + ServerConfigModule.layerTest("/", { prefix: "t3-http-release-test-" }).pipe(
339 + Layer.provideMerge(NodeServices.layer),
340 + ),
341 + ),
342 Effect.scoped,
343 );
344
@@ -419,7 +430,7 @@ describe("releaseManagedTunnelOnShutdown", () => {
430 const requests: Array<HttpClientRequest.HttpClientRequest> = [];
431
432 return Effect.gen(function* () {
422 - yield* writeServiceState({
433 + yield* writeLauncherState({
434 id: "update-1",
435 fromVersion: "0.0.30",
436 targetVersion: "0.0.31",
@@ -446,7 +457,7 @@ describe("releaseManagedTunnelOnShutdown", () => {
457 const requests: Array<HttpClientRequest.HttpClientRequest> = [];
458
459 return Effect.gen(function* () {
449 - yield* writeServiceState({
460 + yield* writeLauncherState({
461 id: "update-1",
462 fromVersion: "0.0.30",
463 targetVersion: "0.0.31",