Collapse long turns + auto-follow + jump-to-error on RunDetail (BEN-48)#52
Merged
benSepanski merged 1 commit intomainfrom May 4, 2026
Merged
Collapse long turns + auto-follow + jump-to-error on RunDetail (BEN-48)#52benSepanski merged 1 commit intomainfrom
benSepanski merged 1 commit intomainfrom
Conversation
A run with 50 turns no longer renders a several-thousand-pixel scroll: tool turns collapse to a one-line preview by default, assistant turns above 12 lines clip to a "Show full turn (+N more lines)" toggle, and ToolCalls JSON defaults closed when long. For live runs, an Auto-follow pill keeps the viewport pinned to the newest turn as the SSE stream appends; manual upward scroll silently flips the toggle off. When error events are present, prev/next buttons jump between them by scrolling each into view in the events list. Pure helpers (line-count thresholds, summary slicing, error filter, cursor stepping) live in runDetailUtils.ts with 20 unit tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
BEN-48:
src/web/RunDetail.tsxrendered every turn in a<pre>with no max height. A run with 30+ turns or a turn carrying a large tool output became a several-thousand-pixel scroll, and live runs appended new turns below the fold with no way to follow.TL;DR
Collapse tool turns to one-line previews and assistant turns above 12 lines to a "Show full turn" toggle, add an Auto-follow pill that pins the viewport to the newest turn on live runs, and add prev/next jump buttons over error events.
Summary
src/web/runDetailUtils.ts— pure helpers (turnLineCount,turnLineThreshold,shouldCollapseTurn,collapsedSummary,findErrorEvents,stepCursor,eventDomId). 20 unit tests inrunDetailUtils.test.ts.RunDetail.tsx::TurnCard— turn content collapses by default when over its role threshold (1 line fortool, 12 forassistant), shows aShow full turn (+N more lines)/Collapse turn (N lines)button.RunDetail.tsx::TurnsSection— adds anAuto-followpill (visible only onrunningruns). When on, the section's tail sentinel is scrolled into view on each new turn; a manual upward scroll silently flips it off (programmatic-scroll grace window suppresses self-cancel).RunDetail.tsx::TurnsSection— when any error event exists,↑ prev/↓ nextbuttons cycle a cursor andscrollIntoViewthe matching<li id="event-…">. Error rows in the events list are now tinted rose.ToolCalls<details>defaults closed when the JSON exceeds the assistant threshold; the rendered prompt<details>is unchanged.Demo
n/a — automated cron run; no browser MCP in this environment. Manual smoke-test path:
pnpm dev WORKFLOW.md --mock, open a long run, verify (a) tool turns show "first line + N more lines" with a Show-full toggle, (b) on a live run the Auto-follow pill keeps new turns visible and disables itself when you scroll up, (c) prev/next error buttons appear when errors are present and scroll to each event row.Alternatives
useLayoutEffect+ResizeObserverper turn and the line-count heuristic matches the ticket'sShow full turn (X lines)wording directly.IntersectionObserveron the tail sentinel for auto-disable — rejected: programmatic smooth-scroll briefly hides the sentinel, which would falsely cancel auto-follow. The scroll-direction + grace-window approach avoids that race.RunDetail, so client-side cursor is oneuseState.Test Plan
pnpm all— typecheck + fmt:check + lint + test + eval (140 unit + 5 eval, all green)pnpm build:web— bundle builds (181ms)runDetailUtils.test.tscovers per-role thresholds, line counting, summary slicing, error-event filtering (case-insensitive), and cursor wrap-around.Generated by Claude Code