* Get or create aggregator for a workspace. * * REQUIRES: createdAt must be provided for new aggregators. * Backend guarantees every workspace has createdAt via config.ts. * * If aggregator already exists, createdAt is optional (it was already set during creation).
(
workspaceId: string,
createdAt: string,
unarchivedAt?: string
)
| 3978 | * If aggregator already exists, createdAt is optional (it was already set during creation). |
| 3979 | */ |
| 3980 | private getOrCreateAggregator( |
| 3981 | workspaceId: string, |
| 3982 | createdAt: string, |
| 3983 | unarchivedAt?: string |
| 3984 | ): StreamingMessageAggregator { |
| 3985 | if (!this.aggregators.has(workspaceId)) { |
| 3986 | // Create new aggregator with required createdAt and workspaceId for localStorage persistence |
| 3987 | const aggregator = new StreamingMessageAggregator(createdAt, workspaceId, unarchivedAt); |
| 3988 | // Wire up navigation callback for notification clicks |
| 3989 | if (this.navigateToWorkspaceCallback) { |
| 3990 | aggregator.onNavigateToWorkspace = this.navigateToWorkspaceCallback; |
| 3991 | } |
| 3992 | // Wire up response-complete forwarding for the "notify on response" feature. |
| 3993 | aggregator.onResponseComplete = this.forwardResponseComplete; |
| 3994 | this.aggregators.set(workspaceId, aggregator); |
| 3995 | this.workspaceCreatedAt.set(workspaceId, createdAt); |
| 3996 | } else if (unarchivedAt) { |
| 3997 | // Update unarchivedAt on existing aggregator (e.g., after restore from archive) |
| 3998 | this.aggregators.get(workspaceId)!.setUnarchivedAt(unarchivedAt); |
| 3999 | } |
| 4000 | |
| 4001 | return this.aggregators.get(workspaceId)!; |
| 4002 | } |
| 4003 | |
| 4004 | private shouldBumpStateForBufferedStreamFallback(data: WorkspaceChatMessage): boolean { |
| 4005 | if (!("type" in data)) { |
no test coverage detected