Skip to content

Commit 87ddf5b

Browse files
t3dotggclaude
andcommitted
test(shell): resume tests use the flags this server sends
Resume tests now include omitOlderSettled, and a completed resume reads the cached older settled counts once more. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 124f10b commit 87ddf5b

2 files changed

Lines changed: 35 additions & 3 deletions

File tree

‎packages/client-runtime/src/state/olderSettledThreads.test.ts‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,32 @@ describe("createOlderSettledThreadAtoms", () => {
428428
}),
429429
);
430430

431+
it.effect("a completed resume reads the cached counts once more", () =>
432+
Effect.gen(function* () {
433+
const { replies, requests, atoms, registry, setShell, until } = yield* makeAtoms();
434+
const olderAtom = atoms.olderSettledAtom(environmentId);
435+
const count = (value: OlderSettled | null) => value?.counts.get(project);
436+
registry.mount(olderAtom);
437+
438+
// A resume keeps the cached snapshot, whose cursor is past its counts.
439+
const cached = shellSnapshot({ sequence: 5, asOfSequence: 3, count: 5 });
440+
setShell({ snapshot: cached });
441+
expect(count(registry.get(olderAtom))).toBe(5);
442+
yield* Queue.offer(
443+
replies,
444+
Effect.succeed({
445+
snapshotSequence: 6,
446+
threads: [],
447+
counts: [{ projectId: project, count: 4 }],
448+
}),
449+
);
450+
setShell({ snapshot: cached, generation: 1 });
451+
yield* TestClock.adjust("500 millis");
452+
expect(count(yield* until(olderAtom, (value) => count(value) === 4))).toBe(4);
453+
expect(requests).toEqual([{ before: { settledAt: before }, limit: 0 }]);
454+
}),
455+
);
456+
431457
it.effect("reads pages in order until a short one, and retries a failed page", () =>
432458
Effect.gen(function* () {
433459
const { replies, requests, atoms, registry, setShell, until } = yield* makeAtoms();

‎packages/client-runtime/src/state/shell-sync.test.ts‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ const makePersistenceHarness = Effect.fn("test.makeShellPersistenceHarness")(fun
129129
const RESUMABLE_CONFIG = {
130130
shellResumeCompletionMarker: true,
131131
shellThreadFamilies: true,
132+
shellOlderSettled: true,
132133
shellResumeKey: "server-1",
133134
};
134135

@@ -230,7 +231,12 @@ const savedResumableShell = Effect.fn(function* () {
230231
return (yield* Ref.get(before.saved)).at(-1)!;
231232
});
232233

233-
const RESUMED_INPUT = { afterSequence: 10, omitIdleSubagents: true, requestCompletionMarker: true };
234+
const RESUMED_INPUT = {
235+
afterSequence: 10,
236+
omitIdleSubagents: true,
237+
omitOlderSettled: true,
238+
requestCompletionMarker: true,
239+
};
234240

235241
describe("environment shell synchronization", () => {
236242
it.effect("skips unchanged shell writes, persists resets and flushes changed rows", () =>
@@ -1050,8 +1056,8 @@ describe("environment shell synchronization", () => {
10501056
{ name: "another client build", build: "build-2" },
10511057
{ name: "other snapshot flags", config: { ...RESUMABLE_CONFIG, shellThreadFamilies: false } },
10521058
{
1053-
name: "older settled threads left out",
1054-
config: { ...RESUMABLE_CONFIG, shellOlderSettled: true },
1059+
name: "a server that keeps older settled threads",
1060+
config: { ...RESUMABLE_CONFIG, shellOlderSettled: false },
10551061
},
10561062
{
10571063
name: "a server without completion markers",

0 commit comments

Comments
 (0)