Chat

The parts of an AI conversation. They don't fetch anything: give them the messages from the AI SDK's Chat (or anything else), and they handle the streaming, scrolling and states.

Messages and markdown

The person's turn is a bubble; the assistant's is prose across the column. While an answer streams, new words fade in and an unfinished table or bold renders as if done, so nothing jumps into shape.

Which stations had low oxygen in October?

Bottom oxygen at B3 Indre fell to 4,9 mg/l, the lowest this year.

StationO₂ bottom
B3 Indre4,9 mg/l
B4 Straum5,6 mg/l

The thermocline settled at about 30 m, which cut off mixing below it.

<Conversation {stick} class="flex-1">
	<ChatMessage from="user">{question}</ChatMessage>
	<ChatMessage from="assistant">
		<ChatToolLine calls={toolCalls} />
		<ChatMarkdown content={text} streaming={!done} />
		<ChatStatus label={working} />
	</ChatMessage>
</Conversation>
<ChatComposer bind:value={draft} {busy} onSubmit={send} onStop={() => chat.stop()} />

ChatStatus

What it's doing right now, with a light sweeping across. Each label stays at least 700 ms, so the four below, sent 250 ms apart, still read one by one.

ChatToolLine

What it looked up, folded into one quiet line. Press it to see each call. A call that didn't work is said so, not left spinning.

ChatApproval

Before it changes anything. Decided, it shrinks to a line that keeps the record.

Add 3 stations to Starefoss ledning

B5, B6 and B7 from the October survey, at their surveyed depths.

Approved: Rename the figure to “Oxygen, inner basin”

Cancelled: Delete the draft report

ChatComposer

Grows with the text and shrinks once sent. Enter sends, Shift+Enter is a new line. While busy, Send turns into Stop.

Answers can be wrong. Check figures before sending them on.

Nothing sent yet.

This thread is shared with you to read.

ChatSuggestions

Starters for the empty state; a press sends.

People chat

The same Conversation and composer, for people on a plan rather than an assistant. ChatBubble puts yours on the right and others on the left with avatar and name; a run from one person runs together. ChatAck says who has seen a message; ChatDivider marks days and where the unread start.

Ola Berge
B1 to B3 done. Swell is picking up a bit.
Skipping C4 if it gets worse, ok?
Fine by me, log it as a deviation.
Not sent.

With several people, pins, edits and live replies: plan chat example.

Rules

  • One status line at a time, and none while words stream: the words are the progress.
  • Tool calls fold into one line in the past tense. What is running goes in the status line.
  • Ask before changing anything (ChatApproval). The decided card stays as a record.
  • Never smooth-scroll while streaming. StickToBottom jumps once per layout change, and lets go when the reader scrolls up.
  • Send turns into Stop while busy; the box stays writable for the next question.
  • Pass the answer to ChatMarkdown as it grows; set streaming to false once it is done, so it renders still.
  • In a people chat, put hover actions (Acknowledge before anyone has, the menu) beside the bubble, and the ack row under it only once someone has: a run of short messages stays tight.
  • Use continues() for runs: same person, within 5 minutes, no divider between.

All of it together: AI assistant example.