The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(chat): restore missing chat surface handler for empty state
Steven Enamakel9d167e32e0f3
diff --git a/app/src/providers/chatSurfaceHandlers.ts b/app/src/providers/chatSurfaceHandlers.tsnew file mode 100644index 0000000000..1339db599e--- /dev/null+++ b/app/src/providers/chatSurfaceHandlers.ts@@ -0,0 +1,50 @@+/**+ * The seam between assistant-ui's runtime write API and the surface that+ * actually owns sending.+ *+ * `onNew`/`onCancel`/`onReload` cannot be reimplemented inside the adapter.+ * The real send path (`Conversations.tsx`) is ~200 lines of orchestration —+ * attachment upload, thread creation, queue modes, the 600s silence timer,+ * lifecycle dispatches, analytics — and a second copy of it inside the runtime+ * adapter would be a fork that drifts, which is the precise way "assistant-ui+ * becomes the store" happens in practice.+ *+ * So the runtime does not own sending; it forwards. The active chat surface+ * registers its handlers here on mount, and the external-store adapter calls+ * through. Redux stays the source of truth and the send path stays singular.+ *+ * Registration is keyed by thread so two surfaces (home chat and the flows+ * copilot, which run different transports) cannot capture each other's turns.+ */++export interface ChatSurfaceHandlers {+ /** Send a new user turn. Mirrors whatever the surface's composer does. */+ send: (text: string) => Promise<void>;+ /** Cancel the in-flight turn, if the surface supports it. */+ cancel?: () => Promise<void>;+ /** Re-run the last turn, if the surface supports it. */+ reload?: () => Promise<void>;+}++const registry = new Map<string, ChatSurfaceHandlers>();++/** Register the handlers for `threadId`; returns the unregister function. */+export function registerChatSurface(threadId: string, handlers: ChatSurfaceHandlers): () => void {+ registry.set(threadId, handlers);+ return () => {+ // Only clear if we still own the slot — a remount that re-registered first+ // must not be torn down by the outgoing instance's cleanup.+ if (registry.get(threadId) === handlers) registry.delete(threadId);+ };+}++/** The handlers registered for `threadId`, or `null` when no surface owns it. */+export function getChatSurface(threadId: string | null): ChatSurfaceHandlers | null {+ if (!threadId) return null;+ return registry.get(threadId) ?? null;+}++/** Test seam — drops every registration. */+export function __resetChatSurfaces(): void {+ registry.clear();+}