Skip to content

Collapse long turns + auto-follow + jump-to-error on RunDetail (BEN-48)#52

Merged
benSepanski merged 1 commit intomainfrom
claude/nifty-bardeen-LjhE2
May 4, 2026
Merged

Collapse long turns + auto-follow + jump-to-error on RunDetail (BEN-48)#52
benSepanski merged 1 commit intomainfrom
claude/nifty-bardeen-LjhE2

Conversation

@benSepanski
Copy link
Copy Markdown
Owner

Context

BEN-48: src/web/RunDetail.tsx rendered 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

  • New src/web/runDetailUtils.ts — pure helpers (turnLineCount, turnLineThreshold, shouldCollapseTurn, collapsedSummary, findErrorEvents, stepCursor, eventDomId). 20 unit tests in runDetailUtils.test.ts.
  • RunDetail.tsx::TurnCard — turn content collapses by default when over its role threshold (1 line for tool, 12 for assistant), shows a Show full turn (+N more lines) / Collapse turn (N lines) button.
  • RunDetail.tsx::TurnsSection — adds an Auto-follow pill (visible only on running runs). 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 / ↓ next buttons cycle a cursor and scrollIntoView the 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

  • DOM-measurement-based maxHeight with overflow gradient — rejected: requires a useLayoutEffect + ResizeObserver per turn and the line-count heuristic matches the ticket's Show full turn (X lines) wording directly.
  • IntersectionObserver on 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.
  • Server-driven "next error" navigation via the API — rejected: events are already in memory in RunDetail, so client-side cursor is one useState.

Test Plan

  • pnpm all — typecheck + fmt:check + lint + test + eval (140 unit + 5 eval, all green)
  • pnpm build:web — bundle builds (181ms)
  • New runDetailUtils.test.ts covers per-role thresholds, line counting, summary slicing, error-event filtering (case-insensitive), and cursor wrap-around.

Generated by Claude Code

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.
@benSepanski benSepanski merged commit f657677 into main May 4, 2026
2 checks passed
@benSepanski benSepanski deleted the claude/nifty-bardeen-LjhE2 branch May 4, 2026 13:05
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.

2 participants