Skip to content

Commit 7e14d16

Browse files
Yuruzuuclaude
andcommitted
test(server): live project mutations skip the offline runtime import
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 1b88bb7 commit 7e14d16

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

‎apps/server/src/cli/deferredImports.test.ts‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,53 @@ it.layer(NodeServices.layer)("CLI deferred imports", (it) => {
9898
}),
9999
);
100100

101+
it.effect("forwards live project mutations without importing the offline runtime", () =>
102+
Effect.gen(function* () {
103+
const fs = yield* FileSystem.FileSystem;
104+
const root = yield* fs.makeTempDirectoryScoped({ prefix: "t3-deferred-live-project-" });
105+
const baseDir = NodePath.join(root, "state");
106+
const workspaceRoot = NodePath.join(root, "workspace");
107+
yield* fs.makeDirectory(workspaceRoot);
108+
yield* persistServerRuntimeState({
109+
path: NodePath.join(baseDir, "userdata", "server-runtime.json"),
110+
state: yield* makePersistedServerRuntimeState({
111+
config: { host: "127.0.0.1", devUrl: undefined },
112+
port: 3_773,
113+
}),
114+
});
115+
116+
hooks.importsAttempted.length = 0;
117+
let mutations = 0;
118+
const fetch: typeof globalThis.fetch = async (_input, init) => {
119+
const isMutation = init?.method === "POST";
120+
if (isMutation) mutations++;
121+
return Response.json(
122+
isMutation
123+
? {
124+
id: "live-project",
125+
title: NodePath.basename(workspaceRoot),
126+
workspaceRoot,
127+
defaultModelSelection: null,
128+
scripts: [],
129+
createdAt: "2026-01-01T00:00:00.000Z",
130+
updatedAt: "2026-01-01T00:00:00.000Z",
131+
deletedAt: null,
132+
}
133+
: { projects: [], updatedAt: "2026-01-01T00:00:00.000Z" },
134+
);
135+
};
136+
137+
const exit = yield* runCli(["project", "add", workspaceRoot, "--base-dir", baseDir]).pipe(
138+
Effect.provideService(FetchHttpClient.Fetch, fetch),
139+
Effect.exit,
140+
);
141+
142+
assert.isFalse(Exit.hasDies(exit));
143+
assert.equal(mutations, 1);
144+
assert.deepEqual(hooks.importsAttempted, []);
145+
}),
146+
);
147+
101148
it.effect("never starts the history worker after an interrupted import", () =>
102149
Effect.gen(function* () {
103150
const history = yield* runCli(["__claude-history", "getSessionMessages", "session"]).pipe(

0 commit comments

Comments
 (0)