Chat UI
The AI chat interface ships as the ai collection in the @netscript/fresh-ui copy registry: a
composer, a message thread, tool-call cards, a model picker and a generative-UI block renderer.
alpha
Install it with netscript ui:add ai. The CLI copies each item into your app, where you own it like
any other source file: edit it, restyle it or delete what you do not need. An update is a new copy,
not a version bump. The collection is not a package import: the published @netscript/fresh-ui
subpaths (., ./primitives, ./interactive, ./registry) carry no chat symbols, and there is
no @netscript/fresh-ui/chat subpath. Fresh UI & design describes the
copy-source model.
The ai collection
| Item | Role |
|---|---|
prompt-input | Chat composer: auto-grow textarea plus a toolbar (research / grounding pills, model picker, attach / screenshot / voice, send). |
message | A chat message: author + time, inline-markup body (bold / code / [n] citations), tool-call and chart / code blocks, follow-up chips, typing indicator. Exports renderInline and TypingIndicator. |
markdown | Sanitized streaming-markdown component plus its rendering pipeline. |
chat-render | The generative-UI block parser (a lib item): copies parse-blocks.ts into your app. |
tool-call-card | Tool-call disclosure card for an agent tool invocation. |
model-selector | Model picker used by the composer. |
citation-chip | Grounded-agent citation chip. |
code-block | Rendered code block. |
chart-block | Rendered chart block (a target of the generative-UI renderer). |
avatar | Author avatar. |
command-palette | Command palette surface. |
search | Search surface. |
theme-seed | Theme token seed for the chat surface. |
The generative-UI renderer
The chat-render item copies parse-blocks.ts into your app as @lib/chat/parse-blocks.ts. It
turns streamed markdown into typed blocks, so an agent can emit a chart or a table inside its
answer.
parseBlocks(input: string): RenderPart[]turns markdown into typed parts. It never throws: an unrecognized fenced block falls through to a verbatimtextpart.blockToText(part: RenderPart): stringis the exact inverse projection, to canonical markdown or plain text.parseBlocksis a boundary-stable fixed point, which keeps the transcript identical after a reload.
The presentation RenderPart
The renderer's RenderPart is a rich presentation union. It is separate from the transport
RenderPart of durable chat, which is only
text | tool: the transport part describes how a chunk streams, and the presentation part
describes how a block is drawn.
| Name · Type | Description |
|---|---|
chartChartRenderPart |
A chart block (payload ChartDatum[]). |
donutDonutRenderPart |
A donut block (payload DonutDatum[]). |
tableTableRenderPart |
A table block (TableColumn / TableRow, with TableAlign). |
statsStatsRenderPart |
A stats grid (payload StatsEntry[]). |
lineLineRenderPart |
A line chart (payload LinePoint[]). |
textTextRenderPart |
Verbatim text — the fallback for any unrecognized fence. |
The fenced-block grammar
parseBlocks reads the fenced-code info strings chart, donut, table, stats and line. Each
accepts canonical JSON or a minimal DSL (label: value @tone, plus markdown pipe tables), and a
RenderTone colors a value. A fence with any other info string stays a verbatim text part, so
ordinary code blocks pass through untouched.
```chart
[{ "label": "Q1", "value": 42 }, { "label": "Q2", "value": 58 }]
```
```stats
Revenue: 1.2M @positive
Churn: 3% @negative
```
parse-blocks.ts is self-contained and does not import @netscript/fresh/ai.
Streaming markdown and the composer
markdown renders sanitized streaming markdown, so you can feed it partial assistant text as
chunks arrive. prompt-input is the composer: a textarea that grows with its input, plus the
toolbar described in the table above.
Next steps
Copy the collection and adapt it with Customize Fresh UI.
- Durable chat produces the transcript these components render.
- The AI Chat tutorial builds a complete chat end to end.
- The
@netscript/fresh-uireference covers the copy-registry manifest.