Skip to content

fix(website): list a regenerated session-start turn once in the Context panel - #16680

Merged
iamwhatever merged 1 commit into
mainfrom
fix/context-breakdown-one-row-per-turn
Oct 4, 2026
Merged

iamwhatever merged 1 commit into
mainfrom
fix/context-breakdown-one-row-per-turn

Conversation

@chenmingwei23

Copy link
Copy Markdown
Contributor

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 rendered all.filter(t => t.isStart) directly.

Change: session-start rows now go through the same rule, so starts holds one entry per ordinal, newest attempt kept. Two uses follow:

  • The previous-turn sequence used for the delta holds only kept attempts, so the turn after a regenerated start compares against the attempt that was kept.
  • The earlier-turns count drops its own distinct-ordinal pass, because starts is 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

  • New vitest case lists a regenerated start turn once, from its newest attempt in website/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 --test and 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.

Before: Context panel on main lists Turn 41 session start twice

After (this branch): turn 41 is listed once, the newest attempt at 37,120 characters.

After: Context panel lists Turn 41 session start once, the newest attempt

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

  • At most two commits (one is the norm), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Fixes #16670

@chenmingwei23
chenmingwei23 requested a review from a team October 4, 2026 06:07
@chenmingwei23
chenmingwei23 requested a review from a team as a code owner October 4, 2026 06:07
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 4, 2026
@github-actions

github-actions Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 354024968aa1fcc55ed190f59f84b21d4e9e7791 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 354024968aa1fcc55ed190f59f84b21d4e9e7791 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

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 ships

Inventory (3 items) — 3 justified

Intent: 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.

  1. A start turn that was regenerated now shows once, as its newest attempt, not twice. — justified
  2. The size change ("delta") shown for the next turn is now measured against the start attempt that was kept. — justified
  3. The "earlier turns not shown" count now reads the deduplicated start list. It no longer runs its own distinct-ordinal pass, and its output is unchanged. — justified

[FIRST-PRINCIPLES-REVIEWED] 3540249

Description read

[DESCRIPTION-READ] 7a7289fe6e3c9ae6fb8a03abcf7882136903aef7060a5dd9812d8ed78dc689fe

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 354024968aa1fcc55ed190f59f84b21d4e9e7791 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 354024968aa1fcc55ed190f59f84b21d4e9e7791 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 3540249

Verdict parsed from the review's SHA-scoped output markers for commit 354024968aa1fcc55ed190f59f84b21d4e9e7791.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 354024968aa1fcc55ed190f59f84b21d4e9e7791: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 354024968aa1fcc55ed190f59f84b21d4e9e7791 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 3540249

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 354024968aa1fcc55ed190f59f84b21d4e9e7791: <one-sentence reason>

…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
@chenmingwei23
chenmingwei23 force-pushed the fix/context-breakdown-one-row-per-turn branch from 77678c9 to 3540249 Compare October 4, 2026 08:02
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 4, 2026
@iamwhatever
iamwhatever enabled auto-merge (squash) October 4, 2026 10:03

@iamwhatever iamwhatever left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@iamwhatever
iamwhatever merged commit 486c2fb into main Oct 4, 2026
98 checks passed
@iamwhatever
iamwhatever deleted the fix/context-breakdown-one-row-per-turn branch October 4, 2026 10:03
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 4, 2026
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.

Context panel lists a regenerated session-start turn twice

2 participants