okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-clean-3 (321794636): docs and history (cleanup step 3, items 3.0-3.10); release manifest and capability table with checks, history/ with pointers, link check, tools/ split, bench index; owner OK'd the wording 11-082b36e8a02

main
8.2 KiB143 linesraw

01 · Chat

Route #/chat — the landing screen · File src/screens/Chat.tsx (779 lines, the largest in the app)

Chat is where the product either holds up over a long session or does not. It is the only screen a user might sit in for hours, so it carries the strictest rules in the system: the reading measure, the follow-the-stream behaviour, focus mode, and the telemetry row.

What it is today

  • Header — title (editable inline), a subtitle carrying model · message count · token count, and two controls: a generating pill that appears only while working, and the context-rail toggle. The ··· overflow was removed last round.
  • Transcript — .chat__inner, 920 px max, centre-aligned. Assistant prose is capped at 56ch, measured at 68 characters at 10, 16 and 22 px. Code blocks and tables escape the cap and use the full bubble.
  • Tool cards — inline approval cards with Enter/Esc, a scope badge, a result line and a duration.
  • Composer — Do anything placeholder, keyboard hints as the box's second line, toolbar row, Send. Glass material at the regular tier.
  • Telemetry — three centred, clickable groups (turns/steps/tok/s, tokens/cache hit, context %) opening detail popovers.
  • Context rail — a grid track that animates 0 → 340 px, with a per-conversation breakdown.
  • Focus mode — ⌘⇧F withdraws the chrome to an ambient bar.
  • Scroll behaviour — follows the stream only when already at the bottom; per-conversation scroll memory; a scroll-driven reading-progress hairline.

Where it falls short

  1. The header subtitle is dense and low-value. Starter · 0.5B Q4_K_M · 2 messages · 244 tokens duplicates what the telemetry row and the sidebar engine chip already say. Three places report the same state.
  2. The header has no model identity while idle. The generating pill only exists mid-request, so at rest the bar says nothing about what is loaded.
  3. Assistant messages have no per-message time or cost. Checked and wrong. A two-turn conversation renders a footer under both assistant messages with identical structure (236 tokens · 56.6 tok/s · 4.2 s), because the done frame writes tokens, tps and durationMs onto every message and the footer renders whenever any of the three exists. The figures were always per-turn; only the actions below are missing.
  4. No way to retry or edit a turn. Fixed. Every assistant turn carries Ask again (retryLast) and every user turn carries Edit and ask again (rewindTo). Verified: retry drops the reply and replaces it without duplicating the turn; edit rewinds the transcript and refills the composer focused. Actions reveal on hover and on focus-within, so they are reachable by keyboard. Branch and Continue are now shipped — see below.
  5. Reasoning is a collapsed block with no affordance. The disclosure animates open but there is no indication of how long the model thought.
  6. The intro state is four static suggestion cards. They do not reflect the workspace, and they do not change with the loaded model.
  7. Nothing marks unread turns when a long generation finishes while the user is scrolled up.
  8. The transcript has no content-visibility. In a 200-turn conversation every message stays in layout, which is the one place the app can get slow.
  9. Focus mode dims earlier turns to 45% but offers no way to move between turns — no next/previous, no jump-to-latest.

The plan

Hierarchy — one hero, less restatement

  1. Strip the subtitle to the conversation only. 2 messages · 244 tokens moves entirely into the telemetry popover; the subtitle becomes the model name and nothing else, or disappears when the rail toggle is present.
  2. Add a persistent model chip to the header, left of the controls: the loaded model with its state dot. This is the DSH shape and it means the bar is informative at rest, not only mid-request.

Substance — make the transcript auditable

  1. Per-turn actions on the existing footer — retry, edit-and-resend, branch. The figures are already correct and per-turn; what the footer lacks is anything to do with a turn after reading it.

  2. Retry and edit-and-resend. Done. Both live in the store rather than the screen, because each has to touch the message list — doing it from a component ends up duplicating the stream handling that already lives there.

  3. Branch and continue. Done. Branch from here forks a session at any turn, leaving the original intact — verified: the branch carries only the turns up to that point, the original is byte-identical afterwards, and both are listed. Continue from here appears on the newest reply only, since an older one already has its answer beneath it, and is sent as an ordinary user turn rather than a hidden mode, because a continuation is a request and the transcript should show it.

    Branching exposed a real bug. Chat resolves its session as location.param ?? activeId, so the URL wins when it names a session. Every other path into a session navigates (newSession(); go('chat', id)); the first version of branchFrom only set activeSession, so the sidebar showed the new branch while the transcript kept showing the original indefinitely — a feature that looked broken while its data was correct. branchFrom now navigates, and the flow asserts the URL follows.

  4. Reasoning blocks show their duration (Thought for 4.2s) in the summary row, using the disclosure already built.

  5. content-visibility: auto on message blocks with contain-intrinsic-size so off-screen turns cost nothing. This is the single largest performance win available and it is invisible when it works.

Fluidity

  1. Jump-to-latest pill. Done — and it only appears once the newest message is genuinely off screen, so it does not sit over a short transcript with nothing to jump to. When scrolled up during or after a stream, a floating capsule appears above the composer with the count of new turns. Clicking scrolls smoothly; the pill fades on a token.

  2. Unread mark on the session row in the sidebar while the user is elsewhere.

  3. Turn navigation in focus mode. Done. Focus mode is for reading a long conversation, and reading needs a next. ⌥↑/⌥↓ step between your own turns and ⌘↓ returns to the latest; the focus bar teaches the keys, since that bar is the only chrome the mode keeps. Verified: five distinct stops going down, each press retreating on the way back, and ⌘↓ landing at gap 0.

    The first version stuck. It scrolled a turn to offsetTop − 16 and then tested offsetTop > scrollTop + 8 — which the turn it had just moved to still satisfied, so the second press did nothing. The tolerance has to exceed the offset the turn is positioned at.

Substance — the intro

  1. Suggestion cards become workspace-aware — derived from the actual file list rather than a fixed array, and one of them becomes "Continue where you left off" when a previous session exists.

Motion

InteractionSpec
Turn enteringst-enter, --st-t-local, 6 px lift — already correct
Jump-to-latest appearst-enter, --st-t-control, --st-from-y: 4px
Reasoning disclosureinterpolate-size on ::details-content, --st-t-local — built
Retry / branchNo transition; the transcript re-renders. Movement here would be noise
Rail open/closegrid track 0 ↔ 340 px, --st-t-surface — built

Everything is dropped to opacity-only under reduced motion, per rule 6.

Verification

  • The per-turn footer assertion is already satisfied and should be kept as a regression guard rather than written as a new check: every assistant message with a completed stream must render .st-msg__meta.
  • New assertion: with 100 seeded turns, paint time on scroll stays within 1.5× of a 10-turn conversation — the content-visibility proof.
  • npm run measure must still report 68 characters after any header or column change.
  • Focus-mode turn navigation added to the shortcut table and to flow focus.
1# 01 · Chat
2
3**Route** `#/chat` — the landing screen · **File** `src/screens/Chat.tsx` (779 lines, the largest in the app)
4
5Chat is where the product either holds up over a long session or does not. It is
6the only screen a user might sit in for hours, so it carries the strictest rules
7in the system: the reading measure, the follow-the-stream behaviour, focus mode,
8and the telemetry row.
9
10## What it is today
11
12- **Header** — title (editable inline), a subtitle carrying model · message count ·
13  token count, and two controls: a generating pill that appears only while
14  working, and the context-rail toggle. The `···` overflow was removed last round.
15- **Transcript** — `.chat__inner`, 920 px max, centre-aligned. Assistant prose is
16  capped at **56ch**, measured at **68 characters** at 10, 16 and 22 px. Code
17  blocks and tables escape the cap and use the full bubble.
18- **Tool cards** — inline approval cards with Enter/Esc, a scope badge, a result
19  line and a duration.
20- **Composer** — `Do anything` placeholder, keyboard hints as the box's second
21  line, toolbar row, Send. Glass material at the regular tier.
22- **Telemetry** — three centred, clickable groups (turns/steps/tok/s, tokens/cache
23  hit, context %) opening detail popovers.
24- **Context rail** — a grid track that animates 0 → 340 px, with a per-conversation
25  breakdown.
26- **Focus mode** — `⌘⇧F` withdraws the chrome to an ambient bar.
27- **Scroll behaviour** — follows the stream only when already at the bottom;
28  per-conversation scroll memory; a scroll-driven reading-progress hairline.
29
30## Where it falls short
31
321. **The header subtitle is dense and low-value.** `Starter · 0.5B Q4_K_M · 2
33   messages · 244 tokens` duplicates what the telemetry row and the sidebar
34   engine chip already say. Three places report the same state.
352. **The header has no model identity while idle.** The generating pill only
36   exists mid-request, so at rest the bar says nothing about what is loaded.
373. ~~Assistant messages have no per-message time or cost.~~ **Checked and
38   wrong.** A two-turn conversation renders a footer under *both* assistant
39   messages with identical structure (`236 tokens · 56.6 tok/s · 4.2 s`), because
40   the `done` frame writes `tokens`, `tps` and `durationMs` onto every message and
41   the footer renders whenever any of the three exists. The figures were always
42   per-turn; only the *actions* below are missing.
434. ~~No way to retry or edit a turn.~~ **Fixed.** Every assistant turn carries
44   *Ask again* (`retryLast`) and every user turn carries *Edit and ask again*
45   (`rewindTo`). Verified: retry drops the reply and replaces it without
46   duplicating the turn; edit rewinds the transcript and refills the composer
47   focused. Actions reveal on hover and on focus-within, so they are reachable by
48   keyboard. *Branch* and *Continue* are now shipped — see below.
495. **Reasoning is a collapsed block with no affordance.** The disclosure animates
50   open but there is no indication of how long the model thought.
516. **The intro state is four static suggestion cards.** They do not reflect the
52   workspace, and they do not change with the loaded model.
537. **Nothing marks unread turns** when a long generation finishes while the user
54   is scrolled up.
558. **The transcript has no `content-visibility`.** In a 200-turn conversation
56   every message stays in layout, which is the one place the app can get slow.
579. **Focus mode dims earlier turns to 45% but offers no way to move between
58   turns** — no next/previous, no jump-to-latest.
59
60## The plan
61
62### Hierarchy — one hero, less restatement
631. **Strip the subtitle to the conversation only.** `2 messages · 244 tokens`
64   moves entirely into the telemetry popover; the subtitle becomes the model name
65   and nothing else, or disappears when the rail toggle is present.
662. **Add a persistent model chip to the header**, left of the controls: the
67   loaded model with its state dot. This is the DSH shape and it means the bar is
68   informative at rest, not only mid-request.
69
70### Substance — make the transcript auditable
713. **Per-turn actions on the existing footer** — retry, edit-and-resend, branch.
72   The figures are already correct and per-turn; what the footer lacks is
73   anything to *do* with a turn after reading it.
744. ~~Retry and edit-and-resend.~~ **Done.** Both live in the store rather than
75   the screen, because each has to touch the message list — doing it from a
76   component ends up duplicating the stream handling that already lives there.
77
785. ~~Branch and continue.~~ **Done.** *Branch from here* forks a session at any
79   turn, leaving the original intact — verified: the branch carries only the
80   turns up to that point, the original is byte-identical afterwards, and both
81   are listed. *Continue from here* appears on the newest reply only, since an
82   older one already has its answer beneath it, and is sent as an ordinary user
83   turn rather than a hidden mode, because a continuation *is* a request and the
84   transcript should show it.
85
86   **Branching exposed a real bug.** `Chat` resolves its session as
87   `location.param ?? activeId`, so the URL wins when it names a session. Every
88   other path into a session navigates (`newSession(); go('chat', id)`); the
89   first version of `branchFrom` only set `activeSession`, so the sidebar showed
90   the new branch while the transcript kept showing the original *indefinitely* —
91   a feature that looked broken while its data was correct. `branchFrom` now
92   navigates, and the flow asserts the URL follows.
935. **Reasoning blocks show their duration** (`Thought for 4.2s`) in the summary
94   row, using the disclosure already built.
956. **`content-visibility: auto` on message blocks** with `contain-intrinsic-size`
96   so off-screen turns cost nothing. This is the single largest performance win
97   available and it is invisible when it works.
98
99### Fluidity
1007. ~~Jump-to-latest pill.~~ **Done** — and it only appears once the newest
101   message is genuinely off screen, so it does not sit over a short transcript
102   with nothing to jump to. When scrolled up during or after a stream, a floating
103   capsule appears above the composer with the count of new turns. Clicking scrolls
104   smoothly; the pill fades on a token.
1058. **Unread mark on the session row** in the sidebar while the user is elsewhere.
1069. ~~Turn navigation in focus mode.~~ **Done.** Focus mode is for reading a long
107   conversation, and reading needs a next. `⌥↑`/`⌥↓` step between your own turns
108   and `⌘↓` returns to the latest; the focus bar teaches the keys, since that bar
109   is the only chrome the mode keeps. Verified: five distinct stops going down,
110   each press retreating on the way back, and `⌘↓` landing at gap 0.
111
112   **The first version stuck.** It scrolled a turn to `offsetTop − 16` and then
113   tested `offsetTop > scrollTop + 8` — which the turn it had just moved to still
114   satisfied, so the second press did nothing. The tolerance has to exceed the
115   offset the turn is positioned at.
116
117### Substance — the intro
11810. **Suggestion cards become workspace-aware** — derived from the actual file
119    list rather than a fixed array, and one of them becomes "Continue where you
120    left off" when a previous session exists.
121
122## Motion
123
124| Interaction | Spec |
125|---|---|
126| Turn entering | `st-enter`, `--st-t-local`, 6 px lift — already correct |
127| Jump-to-latest appear | `st-enter`, `--st-t-control`, `--st-from-y: 4px` |
128| Reasoning disclosure | `interpolate-size` on `::details-content`, `--st-t-local` — built |
129| Retry / branch | No transition; the transcript re-renders. Movement here would be noise |
130| Rail open/close | grid track 0 ↔ 340 px, `--st-t-surface` — built |
131
132Everything is dropped to opacity-only under reduced motion, per rule 6.
133
134## Verification
135
136- The per-turn footer assertion is **already satisfied** and should be kept as a
137  regression guard rather than written as a new check: every assistant message
138  with a completed stream must render `.st-msg__meta`.
139- New assertion: with 100 seeded turns, **paint time on scroll stays within 1.5×
140  of a 10-turn conversation** — the `content-visibility` proof.
141- `npm run measure` must still report 68 characters after any header or column
142  change.
143- Focus-mode turn navigation added to the shortcut table and to `flow focus`.