Tern is an invented chat assistant with three fictional models: Tern Glide for quick answers, Tern Soar for writing and code, and Tern Dive for hard problems. It has conversations, a history grouped by day with pinned chats, projects with instructions and files, a canvas beside the chat, read-only shared links, search and settings. The art direction is dusk violet on lavender greys, with a rounded face and a pill-shaped composer. Replies are canned: four topics with two variants each, chosen by the words a message uses.
What makes Tern worth reading is that a streamed reply is not a client-side stream at all. A send is an ordinary form post that works with JavaScript off. The server answers with the whole reply already rendered as HTML, and an island replays it word by word, with Stop, a thinking trace, and focus kept in the composer. Every screen renders on the server, and the app still moves like a single-page app.
The brief
Chat assistants have a recognisable shape, and several of their parts are hard to build well. The composer has to grow with its text, send on Enter, take a new line on Shift+Enter, and turn into Stop while a reply arrives. The reply has to appear progressively, with rich content (headings, lists, tables, code with copy) settling into place without layout jumps. The conversation has to scroll so that a new question sits at the top while its answer fills in below. And the shell around it, history, projects, a model picker, sharing, has to stay put while you move between chats.
Tern takes all of that on, with two constraints. The demo stores nothing on the server, so a conversation's state has to travel with the page. And everything has to work before script loads. The chat components it needs, Composer, ComposerSubmit, MessageScroller, Activity and the streamTarget mixin, live in @sdxc/ui/chat, and Tern is where they are proven.
A reply that streams from server HTML
When a visitor sends a message, the form posts the thread to the server, which picks a reply and renders it in full: headings, lists, tables, quotes and code blocks, set with Typeset's chat preset. The streamTarget mixin on the reply then replays that HTML word by word, revealing each block as it is reached. Stop freezes the reply where it is. Under reduced motion the reply appears at once, and with script off it simply arrives whole. A short CSS fallback paints the reply even if the script never runs.
Because the reply is real markup from the start, its code blocks are complete components. Each one is a CodeBlock headed by its file name, with syntax highlighting and a copy button, and nothing about it depends on the stream finishing.

Each turn sits in a MessageScroller. User turns are scroll anchors, so a new question lands at the top of the viewport and its answer fills the space below it, the way people expect from a chat app. User turns can carry attached files, and each turn offers copy, edit, regenerate and feedback. Copy is a CopyButton, and edit opens a Dialog with the message in a text area.
A thinking trace above each reply
Above each reply sits an Activity disclosure labelled "Thought for" and the number of seconds. Inside it are Tern's plan, then the files it read, the web searches it ran and the commands it ran. A command step opens onto its output.

The disclosure is a native <details> element, so it opens and closes without script. A newly sent message's reply opens it and replays the steps one at a time under a shimmering "Thinking", with the current step showing moving dots. Replies loaded from history keep it closed, so a long conversation reads as answers rather than process.
A composer that sends and stops
The input is a Composer: a text field that grows up to twelve lines with field-sizing, a toolbar, and a hint line that truncates on narrow screens and hides on touch. ComposerSubmit is the island behind the send button. Enter sends, Shift+Enter adds a new line, the field clears after a send, and Send turns into Stop while a reply streams. Escape stops too. Typing a colon suggests emoji shortcodes through @sdxc/emoji, and message text expands shortcodes such as :tada: when it is displayed.

A new chat opens on a greeting with four suggestions. Each suggestion is a button that submits itself, so tapping one starts a conversation with no extra step.
A conversation that carries its own state
The demo keeps nothing on the server. Every form on a chat page carries the thread back in one hidden field: the saved conversation, how many of its turns are kept, and the messages sent on top of it since. Sending, regenerating and editing all post that field. The server rebuilds the conversation from it, adds the new turn, and renders the next state. thread.ts describes the shape. It is a small idea that makes a multi-turn chat possible on top of stateless, cacheable pages.
The model picker in the top bar is a Menu opened through the Command Invoker API. On a saved chat each model is a ?model= link, so the choice is part of the address and survives a reload. A chat with unsaved turns posts the choice with its thread instead, so nothing typed is lost.

A canvas and a shell that stay in place
?canvas=open puts a canvas beside the chat in a SplitView, with a handle to resize the two. The canvas streams in as its own frame over a placeholder whose bars follow lines of code, so it lands at its final size. A project's files and the settings usage panel stream in the same way.

The sidebar stays mounted while only the main pane swaps between chats, projects, search and settings. Focus moves to the new screen's heading so a screen reader hears its name, and Back and Forward restore the pane and its scroll. Sending, regenerating and editing reload the pane in place without adding history entries. Pin, Delete with Undo, and every settings form post the same way and raise their Toasts message in place. ⌘K opens a CommandPalette that finds any chat or project. History and list links prefetch on intent, and every page is cached at the edge and kept out of search engines.
Share opens a dialog with the chat's public link and a CopyButton, plus a way to open the read-only view in a new tab. The shared view at share/<id> renders the conversation without the shell.

On a phone the sidebar becomes a drawer, and the new-chat screen stacks its suggestions above the composer. A browser test checks that no Tern screen scrolls sideways at 375 pixels.

Takes after
ChatGPT — a model picker in the top bar, a canvas beside the chat, projects, and shared read-only links. In Tern the model and the canvas are both part of the address.
Claude — a reasoning disclosure above each reply, and copy, edit and regenerate on every turn.
Where to start reading
tern/conversation.tsx— the thread, the composer and the streamed reply.tern/thread.ts— the hidden field that carries a conversation's state through every form.tern/activity.tsx— the thinking trace built onActivity.
