Use the dedicated TJWATER_AGENT_URL and Responses stream protocol. Keep running turns active while users steer or queue follow-ups and edit pending delivery. Refresh the model catalog before generation and preserve approval mode selection. Integrate scoped investigation messaging/presentation, geographic place selection, current Agent composer styles and supporting workbench contracts. Validation: 77 focused Vitest checks, 21 browser cases, lint, typecheck and production build. Preserve direct Server/Agent routing and project authentication.
26 lines
1.0 KiB
TypeScript
26 lines
1.0 KiB
TypeScript
import type { WorkbenchEvent } from "../api/workbench-sync-client";
|
|
|
|
export type WorkbenchStreamNotification =
|
|
| { type: "open" | "disconnect" | "reset" }
|
|
| { type: "events"; events: WorkbenchEvent[] };
|
|
|
|
/** Presentation observes wire events before business acknowledgements or snapshot filtering. */
|
|
export class WorkbenchEventChannel {
|
|
private listeners = new Set<(notification: WorkbenchStreamNotification) => void>();
|
|
private live = false;
|
|
|
|
subscribe = (listener: (notification: WorkbenchStreamNotification) => void) => {
|
|
this.listeners.add(listener);
|
|
listener({ type: this.live ? "open" : "disconnect" });
|
|
return () => { this.listeners.delete(listener); };
|
|
};
|
|
|
|
publish(notification: WorkbenchStreamNotification) {
|
|
if (notification.type !== "events") this.live = notification.type === "open";
|
|
for (const listener of this.listeners) {
|
|
// One presentation observer must not interrupt authoritative business synchronization.
|
|
try { listener(notification); } catch { /* Observers own their error presentation. */ }
|
|
}
|
|
}
|
|
}
|