MCPcopy
hub / github.com/coder/mux / getOrCreateAggregator

Method getOrCreateAggregator

src/browser/stores/WorkspaceStore.ts:3980–4002  ·  view source on GitHub ↗

* 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
  )

Source from the content-addressed store, hash-verified

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)) {

Callers 1

addWorkspaceMethod · 0.95

Calls 4

setMethod · 0.80
setUnarchivedAtMethod · 0.80
getMethod · 0.65
hasMethod · 0.45

Tested by

no test coverage detected