Notebook design: numbered In/Out cells, tool sub-cells and an input-cell composer

Adds the Notebook design (TranscriptStyle.cells, ComposerStyle.cell), a
white/charcoal IDE theme with light grey cells, hairlines and 5px corners.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 23:24:03 +00:00
parent 9436067bf2
commit 113063b040
21 changed files with 2202 additions and 33 deletions
+85
View File
@@ -0,0 +1,85 @@
# Notebook design
A notebook IDE look (Settings > Design > Notebook, id `notebook`): the chat
as numbered Jupyter-style In/Out cells with tool calls as collapsible
sub-cells, a white page (neutral charcoal in dark), light grey cells,
hairline borders, 5px corners, the device's interface sans for chrome and
the bundled RobotoMono for code, tool sub-cells and gutter labels.
## Tokens and modes
`notebookTheme()` (`lib/ui/theme/notebook_theme.dart`, palette and controls
beside it) sets:
- `transcript: TranscriptStyle.cells` (new). Other designs never take it.
- `composer: ComposerStyle.cell` (new): `composer_cell.dart`.
- `selectedRow: washed` (left accent bar plus a light fill), `radius: 5`,
`flat`, `frame: outlineVariant`, `panel`: white (raised grey in dark),
Notebook ANSI accents, `chatColorSaturation: 0.7`.
- `reading`: the interface sans at 15/16 of `bodyLarge`, line height 1.5.
Both new enum values are additions; every existing design keeps its own
value, so nothing else changes. Exhaustive switches on `TranscriptStyle`
gained a `cells` case (bubble, activity view, automated prompt).
## The cells transcript
`lib/features/chat/ui/transcript/notebook/`:
- `notebook_gutter.dart`: `NotebookGutterRow`, a fixed-width gutter (ten
monospace characters at 0.8 of the reading size, scaled with text, plus an
8px gap) holding the right-aligned label on the cell's first-line strut, so
it shares that line's baseline. Below 600px of row width (a phone) the label moves
inline above the cell. Rows that are not cells (shell runs, notices,
activity groups) get an empty gutter (`chat_thread_view.dart`), and a
`NotebookGutterScope` stops nested rows indenting twice.
- `notebook_input_cell.dart`: the operator's `In [n]:` cell (cell grey, 7%
of the chat colour, 3px bar in the chat colour, else the accent); the
scheduled cell for follow-ups, auto-continues (tag `scheduled`) and account
switches (tag `switched`) with an outline bar; `NotebookTag`.
- `notebook_tool_cells.dart` / `notebook_tool_cell.dart`: each tool call a
sub-cell: chevron, bold name and dim arguments, duration and a status icon
on the right; collapsed it previews the first 3 output lines and
"+N lines"; the header expands it in place (input and up to 400 output
lines, built only when open). The latest 8 calls show, earlier ones behind
"Show N earlier tool calls". The status line under them ("Used 6 tools ·
1 failed", or the live label and seconds) opens Activity details.
- `notebook_cell_frame.dart`: one `CustomPainter` per cell (fill, clipped
leading bar, 1px border), no layers.
Numbering: `chatCellNumbers()` (`domain/chat_cell_numbers.dart`) numbers
operator turns from 1 in transcript order and gives each following answer
its prompt's number. It is derived, not stored, so a reload numbers the same;
with older history not yet loaded, numbering starts at the oldest loaded
turn (the server sends no absolute turn index). Queued or unsent prompts read
`In [ ]:`. A running answer shows `[*]` under its `Out [n]:`. The thread view
passes the number into `ChatMessageView.cell` (and the row cache's deps),
only under the cells transcript.
Under cells, answers keep their Read aloud/Copy on the footer line (shown on
hover) rather than the left Copy gutter, so short Out cells keep the
In/Out rhythm: 10px above an In cell, 3px between In and Out.
## Composer
`ComposerCell`: `In [ ]:` in the same gutter, the field in a cell-grey frame
whose border and bar take the chat's accent on focus; a 2px running line at
its foot while a turn runs. Padding is the pill's 4px edge gap plus 3px, so
the usage ring (40px send button, 3px gap, following the 5px radius) clears
the cell's hairline. The send keys are unchanged.
## Still default
Markdown inside answers (headings, lists, code blocks) uses the standard
transcript styling in the interface font; chips, permission cards, task
cards, the chat stack discs and the graph follow the generic flat/radius/
panel/frame tokens with no Notebook-specific code. Typography is Material's
apart from semibold, tighter titles.
## Perf
No `saveLayer`, blur or clip layers: cells paint in one picture each; the
expanded output is built only when opened; a tool cell memoises its preview
so a running turn's one-second tick does not resplit outputs. The theme is
value-equal on rebuild (identity-compared resolvers and indicators cached
per colour). Run the design budget (tool/perf/README.md) after changes.