- Add paginated thread history with bounded snapshots and replay limits - Trim oversized wire payloads and support progressive mobile history loading
Showing the changes to apps/server/src/orchestration-v2/ShellStream.test.ts (1 of 43 files). Show all
Unified · Split
| @@ -5,6 +5,7 @@ import type { · 4 unmodified lines | ||
| 5 | 5 | OrchestrationV2StoredEvent, |
| 6 | 6 | OrchestrationV2ThreadShell, |
| 7 | 7 | } from "@t3tools/contracts"; |
| 8 | +import { ThreadId } from "@t3tools/contracts"; | |
| 8 | 9 | import * as Effect from "effect/Effect"; |
| 9 | 10 | import * as Stream from "effect/Stream"; |
| 10 | 11 | |
| @@ -16,6 +17,7 @@ import { · 5 unmodified lines | ||
| 16 | 17 | shellStreamItemFromEnrichmentRefresh, |
| 17 | 18 | shellStreamItemFromThreadShell, |
| 18 | 19 | shellStreamItemsFromInitialSnapshot, |
| 20 | + shellStreamItemsFromResumeSnapshot, | |
| 19 | 21 | } from "./ShellStream.ts"; |
| 20 | 22 | |
| 21 | 23 | function project(sequence: number, id: string): ApplicationStoredEvent { |
| @@ -198,6 +200,35 @@ describe("shellStreamItemFromEnrichmentRefresh", () => { · 176 unmodified lines | ||
| 198 | 200 | }); |
| 199 | 201 | |
| 200 | 202 | describe("shellStreamItemsFromInitialSnapshot", () => { |
| 203 | + it("keeps thread rows out of the metadata-only enrichment frame", () => { | |
| 204 | + const snapshot = { | |
| 205 | + ...emptyShellSnapshot, | |
| 206 | + projects: [ | |
| 207 | + { id: "project-a", workspaceRoot: "/workspace/a" }, | |
| 208 | + { id: "project-b", workspaceRoot: "/workspace/b" }, | |
| 209 | + ], | |
| 210 | + threads: [shellFixture({})], | |
| 211 | + archivedThreads: [shellFixture({ id: ThreadId.make("thread-archived"), archivedAt: null })], | |
| 212 | + } as unknown as OrchestrationV2ShellSnapshot; | |
| 213 | + | |
| 214 | + const items = shellStreamItemsFromInitialSnapshot({ | |
| 215 | + snapshot, | |
| 216 | + resolvedRepositoryIdentityRoots: ["/workspace/a"], | |
| 217 | + }); | |
| 218 | + | |
| 219 | + expect(items[0]).toEqual({ kind: "snapshot", snapshot }); | |
| 220 | + expect(items[1]).toMatchObject({ | |
| 221 | + kind: "snapshot", | |
| 222 | + snapshot: { | |
| 223 | + projects: [{ id: "project-a", workspaceRoot: "/workspace/a" }], | |
| 224 | + threads: [], | |
| 225 | + archivedThreads: [], | |
| 226 | + }, | |
| 227 | + resolvedRepositoryIdentityRoots: ["/workspace/a"], | |
| 228 | + }); | |
| 229 | + expect(JSON.stringify(items[1]).length).toBeLessThan(JSON.stringify(items[0]).length); | |
| 230 | + }); | |
| 231 | + | |
| 201 | 232 | it("emits unmarked authoritative then same-sequence marked enrichment when roots resolved", () => { |
| 202 | 233 | const snapshot = { |
| 203 | 234 | ...emptyShellSnapshot, |
| @@ -229,6 +260,20 @@ describe("shellStreamItemsFromInitialSnapshot", () => { · 25 unmodified lines | ||
| 229 | 260 | }); |
| 230 | 261 | }); |
| 231 | 262 | |
| 263 | +describe("shellStreamItemsFromResumeSnapshot", () => { | |
| 264 | + it("never repeats the authoritative shell snapshot", () => { | |
| 265 | + expect( | |
| 266 | + shellStreamItemsFromResumeSnapshot({ | |
| 267 | + snapshot: { | |
| 268 | + ...emptyShellSnapshot, | |
| 269 | + threads: [shellFixture({})], | |
| 270 | + }, | |
| 271 | + resolvedRepositoryIdentityRoots: [], | |
| 272 | + }), | |
| 273 | + ).toEqual([]); | |
| 274 | + }); | |
| 275 | +}); | |
| 276 | + | |
| 232 | 277 | describe("composeShellStreamWithEnrichment", () => { |
| 233 | 278 | it.effect( |
| 234 | 279 | "emits every initial item before enrichment even when enrichment is already ready", |