You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(playground): migrate useAgentStream to wrap useAgentChat
Reviewer agentic finding #21: dev-playground reimplemented the same
SSE parsing the template did, creating two divergent implementations
of one concern. The new `useAgentChat` hook in @databricks/appkit-ui
already owns the fetch + frame parsing + state plumbing; the
playground hook is now a thin wrapper that adds the two playground-
specific concerns and re-exports the legacy API surface.
The wrapper keeps two layers on top of the shared hook:
1. `contextPrefix` on send() — the Smart Dashboard injects active
filter / highlight state into the user message so the agent sees
the UI state on every turn. Composed in this wrapper rather than
polluting the shared hook surface.
2. Stream-inspector wiring — every send opens a `StreamRecord` via
`beginStreamRun` and forwards every event to `recordStreamEvent`
so the inspector drawer can render the timeline. The inspector
is a dev-playground feature, not a shared concern.
API stays drop-in compatible: `agentName` (not `agent`), `isLoading`
(not `isStreaming`), `send(message, { contextPrefix })`. `SSEEvent` is
re-exported as a type alias for `AgentChatEvent` so
`use-stream-inspector.ts` and other consumers don't need to be
touched. `routes/smart-dashboard.route.tsx`, `agent-sidebar.tsx`, and
`quick-actions-bar.tsx` work unchanged.
Error handling preserves the prior UX: fetch-level failures now
project from `useAgentChat.error` into the streamed `content` as
`"Error: ..."`, matching the dashboard's assistant-message rendering
of the previous hook's `setContent('Error: ...')` path.
Net: 159 -> ~100 lines on the playground hook, zero duplicated SSE
parsing across consumers, single source of truth in
`@databricks/appkit-ui/react`. Workspace tests: 2310 pass unchanged.
Signed-off-by: MarioCadenas <MarioCadenas@users.noreply.github.com>
0 commit comments