StatsHub Docs

Assistant

A chat over the same data, streaming from the app's one route handler — and the sixteen console.logs that came out of it.

/experimental-ui/assistant · src/composed/experimental-ui/assistant · src/lib/ai

A chat that answers over the same data the boards render.

The one route handler

/api/agent is the only route handler in this app, and it is there because it streams. Everything else this app needs is an HTTP call to the API; a streaming response is the case Next.js has to serve itself.

The transport is the data layer

useChat attaches the Supabase session and the debug flag to every request, so it belongs on the state side of the boundary along with the send and retry handlers — not in the view.

What came out in the move

Four useEffects. Three had bodies that were entirely console.log, and the fourth logged errors the view already renders. Another twelve log calls came out of the suggestion extraction, which is now extractSuggestions in state.ts and can be tested without a chat session.

Worth naming because it is the usual shape of accreted debugging: an effect that only logs is not doing anything, and a function that can only be exercised by holding a conversation with a model is a function nobody will ever change confidently.

The tools

src/lib/ai/tools is what the agent can call, and bun run chat:eval is the eval suite over it. bun run chat drives the same agent from a terminal, which is the fastest way to change a prompt and see the effect.

On this page