- 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 | OrchestrationV2StoredEvent, | 5 | OrchestrationV2StoredEvent, |
| 6 | OrchestrationV2ThreadShell, | 6 | OrchestrationV2ThreadShell, |
| 7 | } from "@t3tools/contracts"; | 7 | } from "@t3tools/contracts"; |
| 8 | import { ThreadId } from "@t3tools/contracts"; | ||
| 8 | import * as Effect from "effect/Effect"; | 9 | import * as Effect from "effect/Effect"; |
| 9 | import * as Stream from "effect/Stream"; | 10 | import * as Stream from "effect/Stream"; |
| 10 | 11 | ||
| @@ -16,6 +17,7 @@ import { · 5 unmodified lines | |||
| 16 | shellStreamItemFromEnrichmentRefresh, | 17 | shellStreamItemFromEnrichmentRefresh, |
| 17 | shellStreamItemFromThreadShell, | 18 | shellStreamItemFromThreadShell, |
| 18 | shellStreamItemsFromInitialSnapshot, | 19 | shellStreamItemsFromInitialSnapshot, |
| 20 | shellStreamItemsFromResumeSnapshot, | ||
| 19 | } from "./ShellStream.ts"; | 21 | } from "./ShellStream.ts"; |
| 20 | 22 | ||
| 21 | function project(sequence: number, id: string): ApplicationStoredEvent { | 23 | function project(sequence: number, id: string): ApplicationStoredEvent { |
| @@ -198,6 +200,35 @@ describe("shellStreamItemFromEnrichmentRefresh", () => { · 176 unmodified lines | |||
| 198 | }); | 200 | }); |
| 199 | 201 | ||
| 200 | describe("shellStreamItemsFromInitialSnapshot", () => { | 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 | it("emits unmarked authoritative then same-sequence marked enrichment when roots resolved", () => { | 232 | it("emits unmarked authoritative then same-sequence marked enrichment when roots resolved", () => { |
| 202 | const snapshot = { | 233 | const snapshot = { |
| 203 | ...emptyShellSnapshot, | 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 | describe("composeShellStreamWithEnrichment", () => { | 277 | describe("composeShellStreamWithEnrichment", () => { |
| 233 | it.effect( | 278 | it.effect( |
| 234 | "emits every initial item before enrichment even when enrichment is already ready", | 279 | "emits every initial item before enrichment even when enrichment is already ready", |