# Chat turn visual specification

| Part | Code |
| --- | --- |
| Components | `apps/web/components/chat/messages/` |
| Styles | `apps/web/app/styles/chat/`; step colours in `apps/web/app/styles/tool-tones.css` |
| Summary sentence | [Tool group summary](https://fzkuji.github.io/OpenProgram/docs/reference/design/ui/chat/tool-group-summary.html) |
| File attribution, Undo, recovery | [File changes, Review and recovery](https://fzkuji.github.io/OpenProgram/docs/reference/design/runtime/operations/file-management.html) |

## Message surfaces

No avatars and no speaker line. The text column lines up with the composer's edges.

| Surface | Look | Behaviour |
| --- | --- | --- |
| User bubble | Right-aligned, content width up to 75% (88% narrow and in split panes). 16px corners, 10px 16px padding, no border. Fill `--user-msg-bg` (= `--bg-input`), `--composer-shadow`. | Hover deepens to `--composer-shadow-focus`. Code blocks and collapsed pastes inside use a `--bg-primary` inset. The message that set a Goal (`startsGoal`) opens with the target icon (16) and “Goal” in `--accent-blue`, weight 500, on the first line of its text. |
| Assistant reply | Flat on the page. Blocks are separated by one `--reply-gap` of 22px; a heading gets half a gap more above and a third less below. | No token or service-tier footer. |
| Queued row | Bubble surface, 10px corners, above the composer | A user message not yet sent |
| Pending send | Bubble at 60% opacity | A send that never reached the server says so on a line under the bubble. |
| Edit box | Full column, `--bg-input`, 23px corners, composer shadow, deeper on hover and focus | Kept attachments (each removable), new-attachment strip, composer input row with @ file mentions. Bottom row: paperclip (ghost round `icon-sm`, “Add images or files”), then Cancel (elevated sm) and Save & resend (primary sm). Esc cancels, ⌘/Ctrl+Enter saves, files can be dropped. Action row hidden. |

Two marks are not avatars: a compact 18px identity line above a reply from a named non-main agent in multi-agent sessions, and the ƒ marker of a manual function run.

### Action row

| Aspect | Rule |
| --- | --- |
| Place | Under every message: right under a user bubble, left under a reply at `--reply-gap` − 3px. Height stays 24px. |
| Order | Timestamp, Copy, Regenerate and Pin as chapter (assistant), Edit (user), Rewind to here (user, when later replies changed files), ‹ N / M › for sibling versions |
| Buttons | Ghost round `icon-xs` (24px), 16px animated line icon, muted ink at rest, primary ink and round muted fill on hover. Hover and keyboard focus drive the icon. |
| Labels | `HoverTip` + `TipBody` after 1.5s, never a native title; same text as `aria-label` |
| Visibility | Transparent until the message is hovered or holds focus. Always visible on touch and on a pinned chapter. |
| Busy, copied | Disabled at 40% opacity. Copy shows a green check for 1.2s. |

**Time contract**

| Item | Records |
| --- | --- |
| User message | Local time on successful send |
| Agent reply, independent function or runtime message | Start time, when its first visible state is created |
| Thinking and tool steps inside an Agent | That Agent message's start time. Independent runtime and sub-agent messages keep their own. |
| Later updates | Streaming, terminal updates and hierarchy moves preserve the time; after reload persisted time wins. |
| Before the first reply content | One temporary row, start time right after the status text, no normal footer |

## Execution timeline

### Summary row

- One plain-text row plus ›, no outer frame or button background, aligned to the body column. 28px tall; hover only brightens the text.
- Sentence, then any live retry state, red “· N failed”, Stopped or Interrupted tag, and the +N −M pill. The sentence truncates to one line.
- Reply text is always visible.

| Transcript view | Tool groups | Steps |
| --- | --- | --- |
| `normal` (default) | Collapsed | Collapsed |
| `thinking` | Open | Thinking steps open |
| `verbose` | Open | All open |

Per-browser preference, one default plus one choice per conversation. A manual click wins over the view and over later streaming and terminal updates.

### Step rows

|  | Main row | Nested row |
| --- | --- | --- |
| Minimum height | 30px | 26px |
| Left padding | 34px | 30px, indented 6px |
| Icon box | 24px | 20px |
| Rail, 1px | At 11.5px, fades over first and last 12px | At 9.5px |

- Text: verb title (Ran, Edited, Searched the web…) at weight 500, identifying argument as a chip, first result line in muted text. No raw JSON; the side panel keeps full parameters and output.
- The icon is the Solar Bold Duotone glyph alone, in the step's tone, on the page colour so the rail stops behind it.
- Nesting recurses with no depth limit.

| Tone | Steps |
| --- | --- |
| Green | Commands, sub-agents |
| Amber | File edits |
| Blue | Reads |
| Cyan | Searches, LLM |
| Indigo | Web and browser |
| Purple, fuchsia | Thinking; memory |
| Slate, rose, stone | Planning; media; system |
| Orange | Other functions |

| State or target | Result |
| --- | --- |
| Running | Normal glyph, conic sweep orbiting it (1.1s); thinking notes show the latest line |
| Failed | Red warning triangle, red title |
| Underlined title | Opens details in the right panel |
| Icon, summary, row whitespace | Only expands or collapses; a chevron marks expandable rows. Leaf rows do nothing. |
| Inline body | Thinking text and a sub-agent's own transcript open in the row, aligned to the title, one light fill |
| Actions | Copy on every row, Open and Cancel execution on sub-agents. Only on the hovered row (`:hover` on the head, so a child never reveals its ancestors) or `:focus-visible`; always on touch. |

**Motion**

| Element | Transition |
| --- | --- |
| Whole strip | Grid 0fr↔1fr, 160ms, expanding downward only. Children unmount 220ms after collapse. |
| Step body and child timeline | Height and −3px→0 over 240ms, opacity 160ms |
| New step | 0.22s fade and slide |
| Chevrons | Rotate 90° over 160ms |
| Running summary | Text shimmer, 1.8s |
| Viewport | Must not jump: scroll anchoring is off in chat, and bottom following pauses 600ms after a click |

### Lifecycle and ownership

- Streaming, completed and restored messages use the same `ExecutionStrip`, `ThinkingStep` and `FunctionStep`; completion never switches to a boxed table.
- Without ordered blocks, stored thinking and tool records are shown in stored order. Missing interleaving is not reconstructed and no tool record is invented. Results, errors, identifiers and full-output references stay.
- Functions started by an Agent reply belong only to that reply's timeline. Only user-invoked functions are independent runtime messages.
- Work the agent named with a task is drawn as a [task block](https://fzkuji.github.io/OpenProgram/docs/reference/design/ui/chat/task-blocks.html): its steps one indent in, and under a step the reader opens the same step rows, one indent further. A reply that names no task is unchanged.

## Manual function runs

The form and an exact function expression are two editors for one `FunctionInvocation { name, kwargs }`, sharing one converter and one HTTP submitter. Neither creates a user bubble or Agent text turn.

| Input | Classified as | Result |
| --- | --- | --- |
| `gui_agent(task="…", surface="browser")` | Exact whole input, registered function, named literals | `POST /api/function/gui_agent`, one ProgramRun |
| Function form | Schema produces the same typed kwargs | Same |
| `Please explain gui_agent(...)`, `` `gui_agent(...)` `` | Not a complete expression | Ordinary user message to the Agent |
| Missing or mistyped required argument | Recognized, invalid | Draft kept, form opens with errors; no fallback to chat |

| Aspect | Rule |
| --- | --- |
| Recognizer | Runs no JavaScript or Python. Strings, numbers, booleans, null and flat named arguments only; no positional arguments, attributes, variables or expressions. |
| Submission | Recognition does not call `sendChatMessage` or write pending user text. Attachments, queuing and system decisions never become parameters. Placeholders, Project, channel, navigation and rollback stay in the shared submitter. |
| Layout | 28px ƒ marker, unframed timeline. Collapsed title, Conclusion and footer share one left edge. Footer 14px below, left-aligned, same buttons as chat, version navigation by `.message-nav` (◀ N/M ▶). |
| Expanded | Direct root children only; deeper levels open one at a time |
| Copy | The root call's result (error ?? output), not the argument JSON |
| Retry | Sibling branch with the same arguments |
| Edit | Prefills the form; sibling branch with edited arguments (`fork_of_node` anchors to the original call's predecessor) |
| Branches | Replace the displayed run in place; never appended at the end of the conversation |
| Running, nested | One breathing-dot row. Nested runs have no footer. |

## Sub-agents

### Live display

| Moment | Timeline |
| --- | --- |
| Parent running | Execution follows the transcript view; streaming does not decide it |
| Sub-agent starts | A running record is added; an open timeline shows the new row |
| Sub-agent finishes | The row with the same stable `card_id` updates in place, never duplicated or deleted |
| Parent terminal | The manual choice stands; only the activity indicator and step status change |
| Expanded later | Still the same timeline row, with Open on hover or focus |

| Call path | Live data | Row |
| --- | --- | --- |
| In chat, `agent()` | `sub_agent` events by `card_id` into `attachCards` | `SubAgentStep` |
| `report_workflow` role call | `tree_update` into `contextTree` | `TreeStep` child |

### Parent and child navigation

1. **Call site** parent branch, `callerId`
2. Open
3. **Sub-agent** child branch, `attach.head_id` Switch returns to the call site
4. Back to main conversation
5. **Latest position** parent branch, `backTarget`

| Control | Lands |
| --- | --- |
| Open, on the row | The sub-agent's newest reply. While the conversation runs its head cannot move, so the agent opens in the row instead. |
| Back to main conversation, top banner | Parent's latest position; after reload, the originating turn with its execution expanded and the row highlighted |
| Switch, on the “Spawned from” card before the first message | `callerId`; later parent messages are hidden |

All three switch the active HEAD in one session and reload the transcript; no new tab. The backend refuses HEAD moves during execution. A legacy cross-session AttachCard only opens the target session. A `report_workflow` `TreeStep` without an attach pointer opens right-panel details only.

## Message navigation

| Aspect | Rule |
| --- | --- |
| Marks | One per user message, 9px at rest, 10px apart, the visible one brighter. Only a chapter's mark is longer: a second length for turns with tasks read as an unexplained difference. The rail scrolls internally when long and shows no scrollbar, the app's floating thumb included: the marks are the position, and the end with hidden marks fades. |
| Colour | A mark's colour is its place in the conversation: the wordmark's gradient runs down the whole rail, blue at the first turn and purple at the last, so the two ends are told apart. The visible and the pointed-at mark are the bright text colour; a chapter is solid purple and thicker |
| Position | Left edge of the chat area beside the sidebar divider, using `100cqw` of the inline-size container |
| Pointer | Y maps to the nearest mark, which grows up to 36px; a preview card (truncated text, attachment chips) opens beside it. Never a full list. |
| Click, Enter | Smooth scroll to the message and a brief highlight |
| Preview content | User text and assistant summaries are untrusted Markdown: raw HTML and HTML-like math stay literal, links follow the document URL policy, attachment extraction and secret masking run first |

### Chapters

| Aspect | Rule |
| --- | --- |
| Control | Pin as chapter or Unpin chapter on a reply. While pinned the bookmark is filled purple on the pressed fill and that action row stays shown. |
| Stored | `metadata.chapter = {"pinned_at": <epoch seconds>}` on the turn's user node; `None` or missing means unpinned. Follows the node through every branch and returns from `load_session` as `chapter`. |
| Protocol | `set_message_chapter {session_id, message_id, pinned}` accepts only a user message of that session and broadcasts `message_chapter_updated {session_id, message_id, chapter}`. The server patches its mirror; a read takes the pin from the stored row. |
| Mark | `--accent-purple`, 4px thick instead of 2.5px, 18px at rest (`CHAPTER_W`), never shorter on hover, full purple while the rail dims |
| Selector | One more scalar in `packRailRow`, so rows still compare as flat strings |

## File-change card

Reports only exact changes from this turn. How a change is attributed: [the file-management page](https://fzkuji.github.io/OpenProgram/docs/reference/design/runtime/operations/file-management.html).

| Part | Rule |
| --- | --- |
| Surface | `--bg-input`, 2xl corners, 6px padding, `--composer-shadow`, deeper on hover. Product sans throughout. |
| Header | 30px minimum, 20px pen icon, “N files changed” at weight 600, tinted +N −M pill (— when unknown), then actions pushed right. At card width ≤420px: “N files”, gaps 6px and 5px. |
| Actions | Elevated xs buttons. The one executable action of Undo, Revert, Redo, Reapply, then Review. Redo reverses Undo, Reapply reverses Revert. |
| Unavailable | The action stays focusable with `aria-disabled` at 50%; its hover tip says why (edited afterwards, not recoverable, inactive branch, agent or run active, already in progress) |
| File list | Inset well: `--bg-primary`, lg corners, 3px padding |
| Rows | 30px, 10px side padding. `FileTypeIcon` (16px box, light and dark palettes), muted folder, bright name, bare green and red counts, or “renamed” / “deleted”. Hover adds `--bg-hover`; the whole row opens Review at that file. |
| Overflow | Three rows, then “Show N more files” up to 20 loaded, then Collapse. Counted but unlisted files end in one “and N more files — open Review” row. The header count is `file_count`. A summary counting more than it lists loads the full list through `review_scope`. |
| Reverted | List at 55% opacity, names struck through, “Historical original diff. These changes are no longer active.” |

| Turn | Shows |
| --- | --- |
| Persisted file records, or a direct file-writing tool | Card mounts |
| No records | No card, no Review |
| Older turn, loading on entering the viewport | Invisible probe; empty results stay hidden |
| Read failed | Nothing changes; the read is asked again with backoff |
| All writes failed | “File changes in this turn did not go through.” |

### Review tab

| Scope | Source | Contains | Undo |
| --- | --- | --- | --- |
| This turn | Mutation journal of the turn | Primary change set; linked child sets grouped by actual producer | When every record is recoverable and unchanged since |
| Unstaged | Git working tree against the index, and `ls-files --others --exclude-standard` | Changes not yet staged, untracked files included, respecting `.gitignore`; non-Git shows unavailable | None; Stage |
| Staged | Git index against HEAD | Changes staged for the next commit | None; Unstage |
| Branch | Mutation projection of the active lineage | Completed turns and explicit reverts, restores and reapplies; no sibling branches, ordinary Bash or external writes | From a specific turn or checkpoint only |

| Action or state | Result | Boundary |
| --- | --- | --- |
| Review, file row | Opens one deterministic `r:<sessionId>:<assistantMsgId>` center tab; a row also selects its path | No inline chat diff; repeated clicks only focus or update selection |
| Placement | Without a split, to the chat's right in the existing group; with a full split, a normal active tab | No replaced peers, third pane or second tab store |
| Header | One row: the scope menu with its totals; a … menu with Review with agent and File type (All, Code, Tests, Docs, Large). See [Review pane](https://fzkuji.github.io/OpenProgram/docs/reference/design/ui/workspace/review-pane.html#header) | Page colour, hairline separators |
| Below 900px pane width | File list folds into the selected file's header: full name, folder, actor, producing turn, line counts, *n / N* menu | From 900px: a 260px list, name over folder |
| Diff | No file headers; hunks labelled by line range; long lines wrap; added or deleted files show one number column; paging below | One bounded diff mounted at a time |
| Preview | Rendered current Markdown, image or PDF | Reads the file as it is now; none for deleted files |
| Line comments, staging, Review with agent | See [Review pane](https://fzkuji.github.io/OpenProgram/docs/reference/design/ui/workspace/review-pane.html) | Comments never edit files; findings never claim a fix |
| Large, binary | Statistics, reason, Open file | No full rendering |
| Undo conflict | Review locates conflicting files | No force shortcut |

**Where this comes from: peer systems**

| System | Turn or checkpoint | Review | Undo or rewind |
| --- | --- | --- | --- |
| [Codex](https://github.com/openai/codex/blob/main/codex-rs/core/src/turn_diff_tracker.rs) | `TurnDiffTracker` uses only committed `apply_patch` deltas; inexact deltas clear the turn diff | [`/diff`](https://github.com/openai/codex/blob/main/codex-rs/tui/src/get_git_diff.rs) uses Git: `git diff` and `git ls-files --others --exclude-standard` | [`thread/revert`](https://github.com/openai/codex/blob/main/codex-rs/app-server-protocol/src/protocol/v2/thread.rs) restores conversation history only; App file Undo is not in the open-source repository |
| [Claude Code](https://code.claude.com/docs/en/checkpointing) | A checkpoint per prompt, direct edit tools only, latest 100 kept | [Desktop](https://code.claude.com/docs/en/desktop) and [Web](https://code.claude.com/docs/en/web-quickstart): session totals, file navigation, single-file diff, line comments | Code and conversation restore separately. Bash, background sub-agents, external changes and links are not guaranteed. |

| Item | OpenProgram |
| --- | --- |
| Exact attribution | As Codex: turn statistics come only from committed mutations |
| Separate review surface | As both: chat holds summaries, Review holds navigation, content and comments |
| Session and repository diffs | Four scopes in one tab |
| Checkpoint recovery | Turn-level Undo with full preflight, recorded as a new journal transaction |
| Not done | No directory-scan attribution around Bash, no approximate turn diffs, no silent partial recovery |

**Implementation map**

| Scope | Location | Excluded |
| --- | --- | --- |
| Mutations and recovery | `programs/tools/files/`, `state/store/snapshot/checkpoint/`, turn finalize, `runtime/conversation/rewinds/revert.py` | Bash directory watchers, changing user Git, inferring a turn from disk |
| Review protocol | `interfaces/server/ws_actions/turn_files/`, message metadata, Git helpers | Unbounded strings, approximate fallback |
| Review tab | `center-tab-ids.ts`, `center-tabs-store.ts`, `center-tab-groups.ts`, `components/center-tabs/review/` | New windows, modals, a third pane |
| Chat card | `turn-files-chips.tsx`, `turn-files-card.css` | Inline diff, file-row arrows, hover action groups |

## Chat math

- Complete `$$`, `$`, `\[` and `\(` blocks are stashed before `marked` and restored as escaped text after sanitizing. `MarkdownText` typesets after paint; the chat-area pin path calls `typesetMath` on the observed column.
- Unclosed streaming math waits for the next paint with a closer. Prose without math and incomplete openers do not typeset. Invalid math does not throw.

## Waiting for a reply

An empty reply shows one static “Thinking…” row with the summary row's shimmer, no › (a green raining label in the code rain style). The spinning activity mark lives on the sidebar row. Approval and terminal states suppress it; timeline, footers and pane titles add no mark.

## Automatic retries

| Aspect | Rule |
| --- | --- |
| Place | After the sentence of the reply's last tool group, joined like “· N failed”. A reply ending in text or with no group gets its own collapsed row, no leading dot. |
| Text | “Server busy, retrying in 3s · 2/5”, “Offline, checking again in 20s”, “Reply came back incomplete, retrying 2/3” |
| Cause | 429: Rate limited. 5xx or overload: Server busy. Timeout: Timed out. Otherwise: Connection lost. |
| Colour | Orange while answering a failure. “Hit the output limit, continuing” keeps the row's colour. Shimmer stops while waiting. |
| Seconds | Count down from the notice, tabular figures |
| Opened | Timeline ends with a retry row (plug glyph, system tone, running), same sentence as title, failure in one line such as `ReadTimeout: …` |
| Event | `attempt`, `max_attempts`, `reason`, `delay_ms`, `error` (`retry_error_text`, at most 300 characters). Sent by the OpenAI-compatible and Codex adapters; shown by `retry-status.tsx`. |
| Lifetime | Live only. The next streamed content clears it, so a recovered reply looks like one that never failed. |

## Failed replies

- The partial answer and ordered trace stay. One terminal notice follows them, before message actions: a localized headline, technical details on request as plain text. No automatic retry is added.
- The notice is drawn until the reader sends a newer message. After that it is left out, and a reply that is nothing but its error leaves no row: an error already answered asks nothing of the reader, and three failed tries read as three alarms above the message that went through.
- Partial blocks and failure detail are separate fields. Node output keeps the error text for model context and non-Web consumers; the Web mapper restores the answer from ordered text blocks.
- The node persists detail, reason, retryability and retry delay before the final failure event, so history restores the same notice. Older error output is recognized without rewriting history and does not repeat the answer.
- Cancellation, approval, nested details, retry and branch semantics and Goal reports are unchanged. Provider taxonomy stays authoritative; no second error store.

**Acceptance**

- A public turn emits text and tools, then fails: live and cold history show answer, trace and one notice.
- Empty and older failed replies stay visible until a newer message follows them. Successful and cancelled replies gain no notice. Details work narrow and dark.
- Regression also covers browser permission inheritance and high-level delegation. Bound-page tests supply an explicit binding and expect the stop after three failed attempts on one observation, with the concrete reason.

## Transcript update ownership

| Part | Owner and rule |
| --- | --- |
| Rows | The server owns every row. A read draws a window, numbered `transcript_update` changes keep it current, and text frames add text to a block by offset. One reducer, `apply-transcript-update.ts`, applies all three, so a row drawn live is the row a reload draws. |
| Local rows | The browser adds only what the server has not named yet. A pending send, a function placeholder or a notice is a typed local row, and goes when a read or update names its `clientRequestId`. |
| Fields ahead of the server | A field shown ahead of the server (Stop, a version switch, a chapter pin, a file undo, a goal result) is an overlay that ends on a stated event and never changes the row under it. |
| Execution trees | Execution trees supplement the owning reply: a model-issued function's tree is an item of the reply's `callRoots`, a function run's tree a field of its row. A tree or frame for a row the view does not hold creates nothing. |
| Missed update | A missed update or a lost text frame makes the view read once at its anchor. A read during a stream neither loops nor shortens the reply, because the server parks that view's frames until the read's reply has gone. A branch move or structural change reads again. |
| Execution roots | Each execution root keeps its persisted path. Repeated calls stay distinct; a root is consumed once across text-separated groups. A completed function stays in its summary; direct runs stay standalone. |

Acceptance replays recorded chats through production reducers and components and requires live to equal cold at every checkpoint: stream, partial history, completion, late trees, steers, errors, cancellation, reconnect and reload.

## Queue and current-turn input

| Case | Rule |
| --- | --- |
| Send preparation | Reserved per draft owner across composers. A repeat with the same pending signature is ignored; a changed draft stays editable with a not-sent notice; another conversation prepares independently. |
| Signature | Draft text, attachment id, order and `sourcePath`, and `thinking`, `toolsEnabled`, `toolsProfile`, `webSearchEnabled`, `fastEnabled`, `fastSupported`. Not attachment base64 or focused/bound presentation. Permission, model, project and channel still bind late in `sendChatMessage`. |
| File mentions | One 15-second batch deadline including response bodies; unresolved mentions keep their text |
| Release | After transport handoff or failure. Completion clears only an unchanged captured draft. |
| Queued | Dispatched in order after the current turn. Session queues and editing order are independent; attachments use ordinary queue delivery. |
| Consumed steering | Shown between the reply content around it. Its user node stays independent; the reply stores an ordered boundary shared by streaming, cancellation and history. Older records use predecessor edges, never a guessed offset. |
| Delivery | The same command is asked about again when its execution or the session's run changes, or the socket reopens, without changing the waiting label, and works while the provider is silent. Pending or uncertain items cannot be resent, edited or removed. Definitive rejection keeps the queued draft; transport failure stays uncertain and is never resent. |
| Streaming steer | Accepted text interrupts active text or reasoning, keeps emitted content, closes the request and applies the durable command before the next model request. Tool-call arguments, running tools and structured output wait for their safe point; no tool is replayed or cancelled. |
| Stop during pending steer | Keeps the partial reply and its history position. A command rejected by cancellation stays an unsent draft with Send, never a new turn automatically. Projection may advance only the exact top-level turn from its user node to its assistant node by compare-and-set. |

## Sensitive text in previews

- Known token formats and complete private-key blocks are masked in passive display; pasted previews mask before truncating.
- Reveal is scoped to the source message, conversation and rendered prose, and never moves to another value. Explicit edit, copy and model payloads keep the original.
- Display masking only: not password recognition or data removal.

Acceptance uses the real `UserBubble` with synthetic secrets: long key preview, paste expansion after reveal, content and session changes, show and hide, unchanged source.

## Bounded transcript history

| Layer | Bound |
| --- | --- |
| Server | One branch view per session, shared by every connection, at most 16 in the process, rebuilt when the store says the branch moved. A view holds row ids grouped by turn, not bodies. A page projects only its selected whole turns from the store, so a row that changed after open reads fresh: a prompt and everything it owns, with tool descendants and compaction rows in place. |
| Cursor off the branch | Answers `cursor_not_on_branch`; the client reads the chat again |
| Rollback | Read version 2 keeps its per-connection snapshots |
| Browser cache | Four conversations; displayed panes and in-flight requests may exceed it briefly |
| One transcript | Six ordinary pages, 8 MiB, with one indivisible page allowed for a large turn |
| Eviction | Opposite the reading position, never persisted records; active updates stay; scrolling back refetches |
| Rows | Measured rows outside the viewport unmount and keep their height; evicted rows lose it |
| Requests | One at a time; prefetch distance follows scroll direction and speed, bounded; exponential backoff; hidden panes stop; stale responses cannot overwrite a newer generation |
| Anchor | Insertion and eviction restore the visible message and offset before paint, by message ID. Jump to latest fetches the latest window directly. |
| Markdown cache | 256-entry LRU, 8 MiB from UTF-16 source and sanitized output; an oversized entry renders but is not kept. Never bypasses sanitizing. |
| Graph | A version 3 read sends no graph: covering and spawn origins arrive on the rows. Ordinary branch metadata omits bodies. Opening the DAG requests its layout. |
| Cold load | Building a view reads and enriches the branch once, linear in stored nodes; page reads fetch only their turns' rows |

**Interaction contract**

- The bottom of an intermediate window is not the latest position. Main and split panes share following, adaptive rendering and jump.
- Jump stays available while newer history exists and after a failed request; repeated clicks share one pending intent.
- Wheel, pointer and keyboard cancel a pending jump or restoration before the window changes. Ordinary paging still compensates for inserted rows.
- Pane teardown saves the final anchor. Reconnecting resumes loading without an old retry delay.

**Modules**

| Module | Responsibility |
| --- | --- |
| `message-list.tsx` | Composition and measured rows |
| `use-chat-area-stick`, `use-message-viewport`, `use-history-window` | Following, viewport measurement, history lifecycle |
| `history-window`, `history-viewport` | Bounded pages and anchors |
| `session-history-loader` | Requests, generation checks, state |
| `interfaces/server/transcript/` | Projection, turn index, bounded reads and Find |
| `transcript/reader.py` | Page limits and the reads by turn |

**Acceptance**

- A synthetic source of 300,000 one-row turns: repeated bidirectional paging keeps pages, rows and measurements bounded; rapid reversals under latency keep a visible message; stale replies, reconnect, branch changes and live updates cannot corrupt the window.
- Backend page reads do not scan or parse the whole branch once the view is built.
- Browser tests cover an intermediate-window bottom, failed and repeated jumps, interrupted restoration, independent split panes, unmount and remount, and the saved anchor across queued animation frames.
- Regression asserts skipped work, semantic equivalence, cache eviction and bounded retention, not timing. Timing and heap figures are synthetic and do not establish latency for large real attachments or tool output.

## Implementation status

| Area | Open |
| --- | --- |
| Transcript update ownership | Verification pending |
| Sensitive text in previews | Installed-App acceptance pending |
| Send preparation | Installed-App acceptance pending |

Everything else on this page is implemented.
