Repository navigation
fix(website): list a regenerated session-start turn once in the Context panel - #16680
Conversation
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing to check. [DESIGN-REVIEWED] 3540249 Description read[DESCRIPTION-READ] 381f918845d9462e89c80eee9df3af4226803c0bae6d4bd41df5e57a22c3841e That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS One check before merge: confirm that the newest attempt kept for a start turn (a turn that opens a session) is the attempt that actually ran, and not the one the replay threw away. What this change shipsInventory (3 items) — 3 justifiedIntent: Make the Context panel show each session-start turn once, even when it was regenerated. This is a FIX. #16670 records the defect, and the new test fails on base.
[FIRST-PRINCIPLES-REVIEWED] 3540249 Description read[DESCRIPTION-READ] 7a7289fe6e3c9ae6fb8a03abcf7882136903aef7060a5dd9812d8ed78dc689fe That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Check that the session-start note still appears on main: the "before" screenshot doesn't show it, and this diff doesn't change the condition that controls it. [UX-REVIEWED] 3540249 Description read[DESCRIPTION-READ] 3db03e20de93f78a2ee6a48f85434b9a613ab0ad7a050c0ec140ea367cd47cfa That sha256 names everything this verdict read: the PR description, plus the 5 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
23b97f2 to
77678c9
Compare
…xt panel A replay that regenerates a turn writes a second session-start row with the same ordinal. The start list rendered one row per row; it now keeps the newest attempt per ordinal, the same rule the chart already uses, and the previous-turn delta compares against that kept attempt. Fixes #16670
77678c9 to
3540249
Compare
iamwhatever
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: fix (2 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, SAST annotations clean, security checklist all-NO, AI reviewers green. Category: ContextBreakdownPanel deduplicates session-start turns by ordinal like regular turns, so a replay-regenerated start turn is listed once (newest attempt) instead of twice; one regression test. Semgrep's single annotation is the GitHub platform notice (ubuntu-latest migration), not a finding; CodeQL success with 0 PR alerts.
Problem / Motivation
Goal: The Context breakdown panel lists each session-start turn once, even when that turn was regenerated.
The panel lists session-start turns above its chart. It drew one row per trace row, not one per turn. When a turn is regenerated, for example a replay after a provider switch, the backend writes a second session-start composition that carries the same ordinal. The panel then showed two "Turn 41 - session start" rows for one turn.
Why it matters
The panel disagreed with itself. The "earlier turns not shown" line already counted turn 41 once, while the list above it showed turn 41 twice with two different sizes. A reader cannot tell which row is the turn that actually ran, and the delta shown for the next turn could be measured against the attempt that was thrown away.
Not a goal
What changed (motivation -> approach -> change)
Symptom: two start rows for one turn in
website/src/pages/ContextBreakdownPanel.tsx.Root cause: the chart already kept one column per turn. It groups rows by
displayN(the turn's true ordinal) and keeps the newest attempt. The start-row list skipped that step and renderedall.filter(t => t.isStart)directly.Change: session-start rows now go through the same rule, so
startsholds one entry per ordinal, newest attempt kept. Two uses follow:startsis already one entry per turn. Its output is unchanged and still covered by the existing "counts a regenerated turn once" test.Backwards compatibility
Compatible: frontend rendering only; the trace payload and its readers are unchanged.
Removes nothing: the dropped rows are earlier attempts of a turn that is still listed, and the chart already dropped earlier attempts of regular turns the same way.
Tests
lists a regenerated start turn once, from its newest attemptinwebsite/src/test/ContextBreakdownPanel.test.tsx. It asserts one[data-start-row], that it is the newest attempt (window-local index 2, 31,120 characters), and that the next turn's delta is measured against it. It fails on main (2 rows found) and passes here.vitest run src/test/ContextBreakdownPanel.test.tsx: 36 passed.tsc --noEmit: exit 0.scripts/check_comment_history.py --testand the diff-scoped run: pass. No Python changed.Manual verification
Built the SPA from this worktree, ran it in a pod, opened the Context breakdown tab with the trace endpoint stubbed to five rows: two session-start rows at ordinal 41, then turns 42 to 44. Rebuilt with main's version of the panel file and repeated for the before shot.
Screenshots / video
Before (main): turn 41 is listed twice, at 36,120 and 37,120 characters.
After (this branch): turn 41 is listed once, the newest attempt at 37,120 characters.
Related Issues
Found by an Opus review finding on #15367.
Pattern harvest
Not generalizable: the panel has exactly two row lists, and both now go through the same per-ordinal map.
Checklist
Fixes #16670