- 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.ts (1 of 43 files). Show all
Unified · Split
| @@ -43,12 +43,20 @@ export function shellStreamItemFromEnrichmentRefresh(input: { · 42 unmodified lines | |||
| 43 | readonly snapshot: OrchestrationV2ShellSnapshot; | 43 | readonly snapshot: OrchestrationV2ShellSnapshot; |
| 44 | readonly changes: ReadonlyArray<{ readonly workspaceRoot: string }>; | 44 | readonly changes: ReadonlyArray<{ readonly workspaceRoot: string }>; |
| 45 | }): Extract<OrchestrationV2ShellStreamItem, { readonly kind: "snapshot" }> { | 45 | }): Extract<OrchestrationV2ShellStreamItem, { readonly kind: "snapshot" }> { |
| 46 | const resolvedRepositoryIdentityRoots = [ | ||
| 47 | ...new Set(input.changes.map((change) => change.workspaceRoot)), | ||
| 48 | ]; | ||
| 46 | return { | 49 | return { |
| 47 | kind: "snapshot", | 50 | kind: "snapshot", |
| 48 | snapshot: input.snapshot, | 51 | snapshot: { |
| 49 | resolvedRepositoryIdentityRoots: [ | 52 | ...input.snapshot, |
| 50 | ...new Set(input.changes.map((change) => change.workspaceRoot)), | 53 | projects: input.snapshot.projects.filter((project) => |
| 51 | ], | 54 | resolvedRepositoryIdentityRoots.includes(project.workspaceRoot), |
| 55 | ), | ||
| 56 | threads: [], | ||
| 57 | archivedThreads: [], | ||
| 58 | }, | ||
| 59 | resolvedRepositoryIdentityRoots, | ||
| 52 | }; | 60 | }; |
| 53 | } | 61 | } |
| 54 | 62 | ||
| @@ -71,12 +79,29 @@ export function shellStreamItemsFromInitialSnapshot(input: { · 16 unmodified lines | |||
| 71 | authoritative, | 79 | authoritative, |
| 72 | { | 80 | { |
| 73 | kind: "snapshot" as const, | 81 | kind: "snapshot" as const, |
| 74 | snapshot: input.snapshot, | 82 | snapshot: { |
| 83 | ...input.snapshot, | ||
| 84 | projects: input.snapshot.projects.filter((project) => | ||
| 85 | input.resolvedRepositoryIdentityRoots.includes(project.workspaceRoot), | ||
| 86 | ), | ||
| 87 | threads: [], | ||
| 88 | archivedThreads: [], | ||
| 89 | }, | ||
| 75 | resolvedRepositoryIdentityRoots: [...new Set(input.resolvedRepositoryIdentityRoots)], | 90 | resolvedRepositoryIdentityRoots: [...new Set(input.resolvedRepositoryIdentityRoots)], |
| 76 | }, | 91 | }, |
| 77 | ]; | 92 | ]; |
| 78 | } | 93 | } |
| 79 | 94 | ||
| 95 | /** Resume after HTTP/cache hydration with metadata only, never another full shell body. */ | ||
| 96 | export function shellStreamItemsFromResumeSnapshot(input: { | ||
| 97 | readonly snapshot: OrchestrationV2ShellSnapshot; | ||
| 98 | readonly resolvedRepositoryIdentityRoots: ReadonlyArray<string>; | ||
| 99 | }): ReadonlyArray<Extract<OrchestrationV2ShellStreamItem, { readonly kind: "snapshot" }>> { | ||
| 100 | return shellStreamItemsFromInitialSnapshot(input).filter( | ||
| 101 | (item) => item.resolvedRepositoryIdentityRoots !== undefined, | ||
| 102 | ); | ||
| 103 | } | ||
| 104 | |||
| 80 | /** Keep only the newest stored event per thread within a coalescing window. */ | 105 | /** Keep only the newest stored event per thread within a coalescing window. */ |
| 81 | export function coalesceStoredThreadEvents( | 106 | export function coalesceStoredThreadEvents( |
| 82 | events: ReadonlyArray<OrchestrationV2StoredEvent>, | 107 | events: ReadonlyArray<OrchestrationV2StoredEvent>, |