A desktop coding agent with free access to frontier models.
TypeScript
fix: follow last seen turn when count is unknown
ogsamratd55a126ecb19
diff --git a/apps/server/src/session-archive/index.test.ts b/apps/server/src/session-archive/index.test.tsindex e9a887a7..cff70379 100644--- a/apps/server/src/session-archive/index.test.ts+++ b/apps/server/src/session-archive/index.test.ts@@ -765,12 +765,16 @@ describe("SessionArchiver final archives", () => {expect(await subject.captureFinal(id, "turn_incomplete")).toMatchObject({ status: "queued", sequence: 3 });await writeFile(join(root, "src/app.ts"), "export const app = 4;\n");expect(await subject.captureDelta(id, root, 4)).toMatchObject({ status: "queued", sequence: 4 });- expect(await subject.drain()).toMatchObject({ uploaded: 5, pending: 0, dropped: 0 });+ // Turn 5 changes nothing; turn 6's count cannot be read: its delta follows turn 5.+ expect(await subject.captureDelta(id, root, 5)).toMatchObject({ status: "skipped", reason: "unchanged" });+ await writeFile(join(root, "src/app.ts"), "export const app = 6;\n");+ expect(await subject.captureDelta(id, root, null)).toMatchObject({ status: "queued", sequence: 5 });+ expect(await subject.drain()).toMatchObject({ uploaded: 6, pending: 0, dropped: 0 });const objects = server.objects();- expect(objects.map((object) => [object.request.kind, object.request.turn])).toEqual([["base", 0], ["delta", 1], ["delta", 3], ["delta", 3], ["delta", 4]]);+ expect(objects.map((object) => [object.request.kind, object.request.turn])).toEqual([["base", 0], ["delta", 1], ["delta", 3], ["delta", 3], ["delta", 4], ["delta", 6]]);const manifests = await Promise.all(objects.map(async (object) => manifestOf(await openArchive(object.object!))));- expect(manifests.slice(1).map((manifest) => [manifest.turn, manifest.trigger])).toEqual([[1, "turn"], [3, "final"], [3, "final"], [4, "turn"]]);+ expect(manifests.slice(1).map((manifest) => [manifest.turn, manifest.trigger])).toEqual([[1, "turn"], [3, "final"], [3, "final"], [4, "turn"], [6, "turn"]]);});test("a plain folder's final archives pass the all-folders refusals and policy again: one while it is on, none while it is off", async () => {diff --git a/apps/server/src/session-archive/index.ts b/apps/server/src/session-archive/index.tsindex 61825980..45488921 100644--- a/apps/server/src/session-archive/index.ts+++ b/apps/server/src/session-archive/index.ts@@ -717,8 +717,8 @@ export class SessionArchiver {* folder (marker `folder`) or touched files (marker `touched`) while their* policy is off. A session whose base could not be captured yet (key* unavailable, or no touched file yet) gets its base instead. A null turn- * (the engine's messages could not be read) follows the last archived- * turn. Whatever it captures, the turn counts as the session's activity+ * (the engine's messages could not be read) follows the last turn seen+ * (archived, or counted at a turn end that changed nothing). Whatever it captures, the turn counts as the session's activity* (the app-start window).*/captureDelta(sessionId: string, root: string, turn: number | null): Promise<CaptureResult> {@@ -736,7 +736,7 @@ export class SessionArchiver {if (resolve(root) !== state.root) this.log("warn", "OmniRush archive delta root differs from the session root; using the session root", { sessionId });const touched = state.marker === TOUCHED_MARKER;if (state.next_sequence === 0 && !touched) return this.captureBaseLocked(sessionId, state.root, turn ?? 0, generation);- const next = state.next_sequence === 0 ? turn ?? state.turn_seen ?? 0 : turn ?? (state.last_turn ?? 0) + 1;+ const next = state.next_sequence === 0 ? turn ?? state.turn_seen ?? 0 : turn ?? Math.max(state.last_turn ?? 0, state.turn_seen ?? 0) + 1;if (state.last_turn !== null && next <= state.last_turn) return { status: "skipped", reason: "stale_turn" };// A plain folder's or touched files' archives pause while their policy is off; the next one after it is on again catches up.if ((state.marker === FOLDER_MARKER || state.marker === PROJECT_MARKER || touched) && !(await this.policyAllows(state.marker, generation))) return { status: "skipped", reason: "not_archivable" };