Skip to content

Show session peak context, and keep a Thinking pair's tokens out of the next row - #439

Merged
daaain merged 5 commits into
mainfrom
token-figures-follow-up
Dec 5, 2026
Merged

daaain merged 5 commits into
mainfrom
token-figures-follow-up

Conversation

@daaain-bot

@daaain-bot daaain-bot Bot commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #414 (refs #405), covering the points left open in its review.

Peak context instead of summed "in"

Session and page totals in the minimal theme now read 183k peak · 283k new · 155k out instead of X in · Y out. The old "in" summed every turn's cache read, which counts the same context again on each turn, so it grew with how long a session ran rather than how full it got.

  • Peak is the largest context a single main-thread turn sent (input + cache creation + cache read). Sub-agent turns aren't counted; they have their own windows.
  • New is uncached input plus cache creation: what the conversation actually added.
  • The transcript header and each session row on the index show all three. Project and archive lines show new · out. Tooltips keep the full breakdown.
  • The index's session rows never showed tokens before: none of the four builders (cached, archived, fallback, date window) passed them. They, and the Codex walker, now pass numeric fields, and the minimal helpers read numbers instead of parsing token strings.

Cache: migration 019 adds sessions.peak_context_tokens. Like 016, it also zeroes each project's message total, so the next run refreshes every project in full from the cached entries (no JSONL re-parse) and fills the column for sessions whose files never change again. On a copy of a real 16-session cache that run took 0.6s. NULL means unknown (Codex reports only cumulative totals; archived sessions have no source) and isn't shown.

Gutter fixes

  • Thinking pairs no longer overlap the next row. A pair's first-half gutter hangs into its last half. With Distinguish cached and new input tokens in minimal gutter #414's two token lines a Thinking + Assistant gutter is four lines, and on a short pair the output figure printed over the next row's time. The renderer now hands the first half's usage to the last half (TemplateMessage.pair_token_usage), and the wide layout shows the figures in the last half's gutter one line down, growing that row if needed, as P7c does for the lane tag. A redacted (empty) thought keeps one line of gutter height so the figures clear its own role.
  • Phone width: the two figures share a line there, and the output gets its · back (98k+20k · 364).
  • Paginated pages: page_stats labelled cache creation Cache Create:, which the minimal header didn't recognise. It's now Cache Creation: like every other summary. This changes the classic theme's paginated page header text; no message markup moves and no classic snapshot changes.
  • Tidy-ups: the unused mn_compact_tokens global and one-line compact_token_usage are gone; the tooltip is computed once per message (via a minimal-only macro, so classic markup is byte-identical); the tokens.css comment keeps its role-icon note; a turn that only read the cache shows 98k+0 instead of a bare number that looked uncached.

Upgrading

Existing session pages keep their old header until they're re-rendered. A release bumps the library version, which re-renders everything; running from source with an unchanged version, delete the pages (or change the source) to see it.

Not in this PR

  • Peak for Codex sessions (needs per-turn usage from the provider).
  • From the Distinguish cache read / cache creation #405 thread: the token tooltip on paired Thinking + Assistant cards, and the classic theme's labels for those pairs.

Tests

  • New: peak computation (renderer and cache agree, sub-agents excluded, dedup by request), the pair hand-off, page_stats peak and label, migration 019 filling an old cache without a re-parse, index session rows, and a browser test of a short and a redacted Thinking pair at wide and phone widths (both fail without their fix).
  • Snapshots regenerated with just update-snapshot; only minimal blocks changed.
  • just ci passes.

Docs: dev-docs/css-classes.md, the migration list in dev-docs/application_model.md, and a token-figures section in docs/themes.md.

🤖 Generated with Claude Code

…he next row

Follow-up to #414.

Session and page totals in the minimal theme now read
`183k peak · 283k new · 155k out` instead of `X in · Y out`. The old "in"
summed every turn's cache read, which counts the same context again on each
turn, so it grew with how long a session ran rather than how full it got.
Peak is the largest context one main-thread turn sent (sub-agents have
their own windows); new is uncached input plus cache creation. The
transcript header and the index's session rows show all three; project and
archive lines show new · out.

- Peak is computed beside the totals in compute_session_data and
  _collect_session_info, and persisted in a new sessions column (migration
  019). The migration also zeroes every project's message total, so the
  next run refreshes each project in full from the cached entries (no
  re-parse) and fills the column; on a real 16-session archive that run
  took 0.6s. NULL means unknown (Codex, which reports only cumulative
  totals, or an archived session) and isn't shown.
- The index's session rows never showed tokens: none of the builders
  passed them. All four (cached, archived, fallback, date window) and the
  Codex walker now pass numeric fields; minimal helpers read numbers
  instead of parsing token strings.
- page_stats labelled cache creation `Cache Create:`, which the minimal
  header's parser didn't recognise. It now says `Cache Creation:` like
  every other summary. This changes the classic theme's paginated page
  header text; no classic snapshot covers it and no message markup moves.

Gutter fixes:

- A pair's first-half gutter hangs into its last half. With #414's two
  token lines a Thinking + Assistant pair's gutter is four lines, and on
  a short pair the output figure printed over the next row's time (237
  overlaps on a real archive, against 20 near-misses on main before #414).
  The renderer now hands the first half's token usage to the last half
  (TemplateMessage.pair_token_usage), and the wide layout shows the
  figures in the last half's gutter, one line down, growing that row if
  needed, as P7c does for the lane tag. A redacted (empty) thought keeps
  one line of gutter height so the figures clear its role. The same
  archive now sweeps clean at both widths in all three branch modes.
- At phone width the two figures sit on one line; the output gets its
  `·` back.
- Tidy-ups: the unused mn_compact_tokens global and one-line
  compact_token_usage are gone, the tooltip is computed once per message
  (a minimal-only macro, so classic markup is untouched), the tokens.css
  comment keeps its role-icon note, and a turn that only read the cache
  shows `98k+0` rather than a bare total that looked uncached.

Docs: css-classes.md, the migration list in application_model.md, and a
token-figures section in docs/themes.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 491b1c55-1d00-4934-8be0-3574a3c1d7a8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

github-actions Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  claude_code_log
  cache.py
  converter.py 2613
  renderer.py
  utils.py
  claude_code_log/html
  minimal_theme.py
  utils.py
Project Total  

This report was generated by python-coverage-comment-action

@daaain-bot

daaain-bot Bot commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

1 similar comment
@daaain

daaain commented Dec 5, 2026

Copy link
Copy Markdown
Owner

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Action not completed

Review skipped.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@daaain-bot daaain-bot Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review pass by a fresh Claude Opus agent (no context from the conversation that wrote this PR), at the maintainer's request after CodeRabbit didn't run.

Classic snapshots are byte-identical (only TestMinimalThemeHTMLSnapshots.* blocks change), the minimal-only template additions are glued inside {% if minimal %}, and the PR's own tests pass. Findings are inline, most severe first: two bugs, one stale dev-doc, one test gap, one comment nit. Each one was reproduced before it was posted. Fixes follow in a separate commit.

-- (source gone) keep NULL.

ALTER TABLE sessions ADD COLUMN peak_context_tokens INTEGER;
UPDATE projects SET total_message_count = 0;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: archived projects show 0 messages for good after the upgrade.

UPDATE projects SET total_message_count = 0 also hits archived projects (they're in the cache but have no JSONL left). The fill-in counts on the next run refreshing each project in full, but an archived project is never refreshed, so its total stays at 0. The archived index builder reads that number as-is (converter.py ~8152).

Reproduced: two projects, one pass, then one project's JSONL deleted, the cache rolled back to before 019, and the migrations re-run. After two more passes the archived project still had total_message_count 0 (it was 4). Its index row read 2 sessions · 0 msgs, while each of its session rows said 2 msgs.

Suggested fix: fill the column in SQL from messages instead of zeroing anything. The table already has session_id, _is_sidechain, type and the flattened token columns, and that covers archived sessions too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 6f06a59, the way you suggested. The migration no longer touches projects: it fills peak_context_tokens straight from messages (the largest input + cache creation + cache read over a session's non-sidechain assistant rows, NULLIF(…, 0) to match the Python's "no usage → NULL"). Repeats of a request carry the same usage, so MAX needs no dedup.

To check the SQL against the Python rule, I ran a full pass and then re-ran the migration over 41 sessions: the agent, teammate, dedup, sidechain and real-project fixtures. It gave every session the same value the refresh had written. The real archive (16 sessions) also matched exactly. The migration test now builds an archived project and asserts that peaks and message totals are both unchanged after re-migrating. It fails against the old migration.

instead, one line down — under the time and role hanging into it —
and that row grows to fit them if it must (as the lane tag does in
dag.css). */
.theme-minimal #transcript .message.pair_first > .header > .header-info > .mn-tok {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: on a wide page, a Thinking pair's tokens disappear when the reply is hidden.

Above 640px this rule hides the first half's figures without checking that the last half is shown, and the last half now holds the only visible copy. Turn off the Assistant filter with Thinking left on, or search for a word that only the thought contains: the Thinking card then shows no token figures at all. On main it shows 98k+20k / 364.

Reproduced: in Playwright, with the PR's _short_thinking_pair_jsonl fixture, at both commits.

Suggested fix: hide the first half's copy only while its partner is visible, apply the same condition to the 1.85em height rule, and add a filter case to the browser test.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 6f06a59. The first half's figures are hidden only while the next .message-node holds a pair_last that relays them and isn't filtered-hidden / search-hidden (pair halves are adjacent .message-node siblings). When the reply is hidden, the thought keeps its figures, and its gutter takes its own height (height: auto) instead of hanging four lines over the next row. The new browser test test_a_thought_shown_without_its_reply_keeps_its_tokens[filter|search] checks that both figures show on the Thinking card and end above the next row. It fails without the fix.

"""``["1.2M in", "48k out"]``: context consumed (input + cache) and output,
as the transcript header's meta line counts them (``page_meta``)."""
total_in = int(input_tokens or 0) + int(cache_creation or 0) + int(cache_read or 0)
def token_totals(peak: Optional[int], new_input: int, output: int) -> list[str]:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rule (dev-docs in sync): dev-docs/minimal-theme.md is out of date on index tokens.

Its Index paragraph (around lines 893–901, which this diff doesn't touch) still says project rows show "tokens in / out (token_totals, the transcript header's split)", and that session rows end in id · msgs. With this PR, project rows show new · out and session rows show id · msgs · peak · new · out. css-classes.md and docs/themes.md were updated; this page was missed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 6f06a59. The Index paragraph now describes project rows as new · out (with why cache reads are left to the tooltip), session rows as id · msgs · peak · new · out, and the header line as summing the archive like a project row. While in there I also corrected the 019 entry in application_model.md.

"message_count": session_data.message_count,
"first_user_message": session_data.first_user_message
or "[No user message found in session.]",
**session_token_fields(session_data),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test gap: three of the four index builders aren't tested for the token fields.

The cached, archived, fallback (_collect_project_sessions, line 5288) and date-window (_project_window_view, line 5442) builders all pass token fields now. Only the cached one is pinned, and only indirectly, through the Codex key-equality drift test. test_index_session_rows_show_peak_new_and_out gives index_sessions hand-built dicts. So removing **session_token_fields(...) from the archived, fallback or window builder fails no test.

Suggested fix: an end-to-end process_projects_hierarchy(theme="minimal") test that asserts peak / new appear in an index.html session row on each route.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 6f06a59. test_every_index_builder_gives_session_rows_their_token_figures runs process_projects_hierarchy(theme="minimal") four ways: cached, use_cache=False (the _collect_project_sessions fallback), from_date (the window view), and archived. Each time it asserts that every index.html session row has peak, new and out. I mutation-checked it by blanking **session_token_fields(...) in each builder in turn, and each blank fails exactly its own case.

}

/* A pair's token figures, repeated in its last half's gutter for the wide
layout (below). Hidden everywhere else — on a phone, and on a card whose

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the comment describes a case the CSS doesn't handle.

The comment says the pair copy is hidden "on a card whose pairing was undone", but none of the new rules exclude .dag-split. Adding dag-split to both halves by hand left the reply showing only the tokens, with its own time and role hidden. The DAG engine only splits a pair whose closing half has data-merges, so this doesn't happen today. Either reword the comment or add :not(.dag-split).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 6f06a59, with both suggestions. The relay rules (hiding the first half's copy, the 1.85em hanging height, and showing .mn-tok-pair on the last half) now all carry :not(.dag-split), so a split pair keeps each half's own gutter. The comment now names the three cases where the copy stays hidden: a phone, a split pair, and the thought shown alone.

daaain and others added 2 commits December 5, 2026 16:58
…ply is hidden

Review follow-ups on the session peak and the Thinking pair's tokens:

- Migration 019 no longer zeroes every project's message total to force
  a full refresh. An archived project (sources gone) is never refreshed
  again, so it read "0 msgs" for good. The migration now fills
  peak_context_tokens from the cached messages by compute_session_data's
  rule, archived sessions included; a test checks the SQL gives every
  session the value a refresh wrote, over the agent, teammate, dedup and
  real-project fixtures.
- On a wide page the Thinking card hid its own token figures even while
  its reply was hidden (Assistant filter off, or a search missing the
  reply), so neither card showed them. The figures move to the reply's
  gutter only while the reply is shown; alone, the thought keeps them in
  a gutter of its own height. A split pair (dag-split) keeps its own.
- An end-to-end test covers the index's session rows from each of the
  four builders (cached, uncached, date window, archived).
- dev-docs/minimal-theme.md describes the index's new token figures.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Second review round:

- The two rules that kept a Thinking card's token figures when its reply
  was hidden read the next node's filtered-hidden / search-hidden classes
  through a sibling :has(), so every filter toggle and search keystroke
  restyled the previous node's subtree: an Assistant toggle on a
  1,134-card page went from ~96ms (main) to ~181ms. The DAG engine, which
  reads those classes on every such change anyway, now marks the shown
  half of a token-relaying pair `dag-alone`, and the CSS keys on that
  (~109ms).
- With the Thinking filter off (or a search missing the thought), the
  reply now carries the pair's figures at every width, as a row of its
  own; on a phone the turn showed none. The P7c lane-tag rules leave a
  half shown alone its own gutter.
- The browser test covers both halves hidden by the filter and by a
  search, wide and phone, in all three branch modes.
- SessionCacheData's peak comment matches what migration 019 now does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@daaain-bot daaain-bot Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Second review pass, run on the whole PR (fe9cbb2c..6f06a598) by a fresh Claude Opus agent with no context from earlier rounds.

It found nothing against the project's hard rules: classic snapshot blocks are untouched, the minimal-only additions are glued inline, and the schema change goes through migration 019. The dev-docs match the code except for one comment. The unit suite passes. It also confirmed:

  • 019's SQL matches compute_session_data on the sidechain, dedup and agent fixtures;
  • all four index builders and the Codex path pass the token fields;
  • the dag.css :not(.mn-tok-pair) change is right.

Findings are inline, most severe first. Each one was reproduced before posting.

hides the reply leaves the thought with its own figures. */
.theme-minimal
#transcript
.message-node:has(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Performance: the two sibling :has() rules make the Assistant filter toggle about 3x slower.

This rule and the one at line 514 read the next node's filtered-hidden / search-hidden classes. So whenever either class flips on a card, Chromium re-checks the previous .message-node and restyles its whole subtree, and filter toggles and search keystrokes flip them across the page.

On the coderabbit-review-helper real project (1134 cards, wide layout), median of 90 toggles with a forced layout after each:

Toggle main PR PR without the two rules
Assistant 75 ms 217 ms 79 ms
Tool 109 ms 128 ms 92 ms

Suggested fix: have JS write a class on the half whose partner is hidden, and key the CSS on that. The filter and search already visit every card, and minimal_dag.js:562 already reads both classes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 21353851, with the JS class as you suggested. On every filter and search change the DAG engine already rebuilds its model, which records whether each card is hidden. It now marks the shown half of a token-relaying pair dag-alone (only for pairs whose last half carries .mn-tok-pair, so tool pairs are untouched), and both sibling :has() rules are gone. The remaining :has() rules look only inside their own card's subtree.

Same page, same toggle loop, but timed through two animation frames so the engine's relayout counts too:

Toggle main 6f06a59 21353851
Assistant 96 ms 181 ms 109 ms
Thinking 112 ms 177 ms 103 ms
Tool 136 ms 212 ms 131 ms

-- gone), which no refresh ever visits again; a session whose files change
-- later is recomputed from its entries as usual.

ALTER TABLE sessions ADD COLUMN peak_context_tokens INTEGER;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caches that already ran b6930210's migration 019 are never repaired (narrow).

The runner applies migrations by number only, so a cache already at schema 19 from the first commit never runs the new fill. That first version set every projects.total_message_count to 0. Live projects heal on their next full refresh, but archived ones keep reading "0 msgs" with no peak.

Reproduced: the old migration's effects applied, then two runs of 6f06a598; the archived project stayed at (0, None). Only local caches that ran this branch are affected.

Suggested fix: reset or hand-patch those caches, or add a 020 that re-runs the fill and restores the zeroed totals of archived projects.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declining, since the branch is unreleased. No released version ever ran the first 019, so the only affected caches are ones a developer pointed at this branch between the two commits. A 020 would ship forever to repair a state no user can reach. I checked the caches in the dev box: none ran it (the only schema-19 cache with zeroed totals holds test-run temp projects).

If a real archive did run it, this restores it in place (total_message_count is the sum of the sessions' counts for a project with no sources left; live projects are refreshed anyway):

UPDATE sessions SET peak_context_tokens = (SELECT NULLIF(MAX(COALESCE(m.input_tokens,0)+COALESCE(m.cache_creation_tokens,0)+COALESCE(m.cache_read_tokens,0)),0) FROM messages m WHERE m.project_id=sessions.project_id AND m.session_id=sessions.session_id AND m.type='assistant' AND COALESCE(m._is_sidechain,0)=0) WHERE peak_context_tokens IS NULL;
UPDATE projects SET total_message_count = (SELECT COALESCE(SUM(message_count),0) FROM sessions WHERE project_id=projects.id) WHERE total_message_count = 0;

layout (below). Hidden everywhere else — on a phone, on a pair split
apart (dag-split), and while the first half shows alone — where the
first half's own copy shows. */
.theme-minimal #transcript .mn-tok-pair {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a phone, a pair's token figures vanish when the Thinking filter is off.

The comment says the first half's copy shows wherever .mn-tok-pair is hidden, but that doesn't hold when the first half is itself filtered out. With Thinking off, the reply shows the figures on a wide page; at 400px the reply's copy is display:none and the thought is hidden, so the turn shows none.

Reproduced: a Playwright sweep found this on all eight real projects, in all three branch modes (for example, 77 pairs in coderabbit-review-helper). Main loses these on a phone too, but now wide and phone disagree.

Suggested fix: show .mn-tok-pair on a phone when the first half is hidden, ideally keyed on the same JS-set class as the performance finding.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 21353851, by the same dag-alone mark. A last half shown alone (the Thinking filter off, or a search that misses the thought) becomes a row of its own at every width, showing its time, role, dot and the relayed figures. So wide and phone now agree, and a phone shows the figures where main showed none. A first half shown alone keeps its own figures in a gutter of its own height. The P7c lane-tag rules in dag.css also skip a half shown alone, so a sub-agent lane's lone half keeps its own gutter and tag. I updated the comment to match.

Comment thread claude_code_log/cache.py
total_output_tokens: int = 0
total_cache_creation_tokens: int = 0
total_cache_read_tokens: int = 0
# Migration 019: the largest context one main-thread turn sent (input +

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: stale comment.

It says None covers "a row written before the migration, an archived session whose source is gone". Since 6f06a598 the migration fills both from messages, so None now means only a Codex session or a session with no usage, as application_model.md already says.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 2135385: the comment now says the migration fills the column for every cached session, and that None means a session with no usage or a Codex session.

assert boxes[0] <= boxes[1]

# A redacted thought has no text at all: its card is ~3px tall.
@pytest.mark.parametrize("thought", ["short", ""])

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test gap: token placement isn't checked across branch modes.

The new browser tests open in the default main branch mode only, and test_minimal_parity_browser.py, which sweeps all three modes, never looks at .mn-tok / .mn-tok-pair.

A sweep of all three modes, both widths and three filter states found nothing apart from the phone finding. The remaining wide overlaps were 4 thoughts with no token usage of their own, which main has too (145 overlaps there).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 21353851. The browser test is now test_a_half_shown_alone_keeps_its_pairs_tokens, covering:

  • either half hidden, by the filter or by a search;
  • wide and phone;
  • all three branch modes (main, interleaved, columns).

That's 24 cases, and each asserts that the shown half carries both figures with its role and doesn't overlap the next row. All 24 fail without the fix. I also re-ran your sweep against the new build: the only reports left are the 4 thoughts without token usage of their own, the pre-existing case main has 145 of.

The engine's `dag-alone` mark covered only pairs that relay token figures,
so a pair without them kept the old behaviour when the filter or a search
hid one half: a first half's gutter (time over role) hung into the hidden
half's and over the next row (with the Assistant filter off, a thought
with no figures of its own put "Thinking" on the next turn's time), and a
last half shown alone had no time, role or dot. The mark now covers every
two-card pair, and the rules that leave a result half without its own
hairline or move an error pill down (P7c) skip it, as they skip a split
pair. Triples are unchanged.

A browser test hides either half of a tool pair by a search, wide and on
a phone. A sweep of the real-project fixtures (three branch modes, both
widths, three filter states) finds no overlap or missing figures left.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@daaain-bot daaain-bot Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Third review pass, by a fresh Claude Opus agent with no context from the earlier rounds, over the whole PR (fe9cbb2c..d99bac29).

No correctness bugs found. What it checked and found sound:

  • Migration 019 is safe on an existing cache, uses the existing session index, and agrees with compute_session_data.
  • Classic snapshots are unchanged; only minimal-theme blocks moved.
  • All four index builders and the Codex walker pass the new fields.
  • Only Thinking + Assistant pairs ever relay token figures.
  • dag-alone is cleared by the engine's generic dag-* class diff, and the new loop is O(n) on relayouts that already happen.
  • The dev-docs match the code.

One repo-hygiene problem (file-level, so it's here and not inline): commit 21353851 adds claude-code-log-cache.db-shm (32 KB) and claude-code-log-cache.db-wal (empty) at the repo root. These are the SQLite sidecar files a local run leaves next to the cache. .gitignore ignores claude-code-log-cache.db but not its -wal / -shm siblings, so git add -A picked them up. Suggested fix: git rm --cached both, and ignore claude-code-log-cache.db*.

Two smaller findings are inline.

assert phone["dot"] == '"· "'

@pytest.mark.parametrize("branches", ["main", "interleaved", "columns"])
@pytest.mark.parametrize("width", [1200, 400])

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test gap: the dag-alone change to the sub-agent lane rules has no test.

dag.css (the P7c rules, lines 294–326) now leaves a lone half its own gutter, but nothing exercises that. This test runs in all three branch modes, but its fixture has no sub-agent, so every mode renders the same main-lane layout. The tool-pair test uses representative_messages, which is also main lane only.

A Playwright sweep found nothing wrong today. It hid each half of every adjacent pair in nested_agents, async_agents and -experiments-worktrees, in all three modes, at 1300px and at 400px. So the code works; nothing guards it.

Suggested fix: add a parametrized case that hides each half of a tool pair inside a .dag-in lane (interleaved) and inside a .dag-col column. Assert dag-alone, a visible role, time and dot, and no overlap with the next row.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b37cb3c2. test_a_tool_pair_half_shown_alone_is_a_row_of_its_own is now parametrized over where the pair sits:

  • the main line;
  • a pair inside a sub-agent lane interleaved with it (.dag-in, nested_agents, interleaved), which exercises the P7c exemptions;
  • a pair in a sub-agent's column (.dag-col, columns);
  • an error result.

Each runs with either half hidden, at wide and phone widths: 16 cases. Each asserts dag-alone, a visible role, time and dot, and no overlap with the next row in the same column (columns sit side by side, so the check only looks below the card).

.theme-minimal
#transcript
.message.tool_result.error:is(.pair_middle, .pair_last):not(.dag-split)
.message.tool_result.error:is(.pair_middle, .pair_last):not(.dag-split, .dag-alone)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: an error result shown alone has no time.

The commit says a last half shown alone gets "time, role, dot". For a tool_result.error, though, the unchanged rule just above (lines 463–469) still hides everything in the gutter except .mn-role.

Reproduced with edge_cases.jsonl (FailingTool): adding search-hidden to the call made the result dag-alone, and its only visible gutter child was the pill, at both 1200px and 400px. A dag-split error result does the same, so this may be intended.

Suggested fix: either let .timestamp-row through on .dag-alone / .dag-split error halves, or document that error halves show only the pill.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b37cb3c2. The rule that hides all but the pill now skips .dag-split and .dag-alone error halves, so a failed result that is a row of its own shows its time over the pill, like any other row. A failed result tucked under its call keeps the pill alone. I updated the comment there and the error-pill paragraph in dev-docs/css-classes.md. The error case of the new test fails without the change (first-1200-error, first-400-error).

…s time

Third review round:

- 2135385 committed the -wal / -shm files SQLite leaves beside
  claude-code-log-cache.db at the repo root; .gitignore ignored the cache
  but not them. Both are untracked and the ignore entry covers them.
- An error result that is a row of its own (dag-alone, or dag-split) kept
  only its pill in the gutter: the rule that hides the rest, for a result
  tucked under its call, now skips those, so it shows its time over the
  pill like any other row.
- The tool-pair browser test also hides either half of a pair inside an
  interleaved sub-agent lane (dag-in), inside a sub-agent's column
  (dag-col), and of an error result, wide and on a phone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@daaain-bot

daaain-bot Bot commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Re the stray SQLite sidecars in the third review: fixed in b37cb3c. Both files are untracked, and .gitignore now ignores claude-code-log-cache.db*. They came from my opening that cache read-only during the second round (SQLite still creates the sidecars for a WAL database), followed by a git add -A. I now stage paths explicitly.

@daaain
daaain merged commit 51ed56e into main Dec 5, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant