fix(web): collapse thoughts within tool groups #12302
main fromrefs/pull/12302/head·merged by juliusmarminge View on GitHubopening a tool group currently reveals every reasoning trace. thoughts now stay collapsed independently, showing a truncated reasoning preview and a chevron; expanding a thought reveals its full text and restores the thought label. thought-only groups retain their existing single disclosure.
validation: web typecheck and 120 existing timeline tests passed on blacksmith; targeted lint completed with 20 warnings and no errors. verified collapse, expansion, and restored previews in the web client using a real Claude thread through the shared server.

model: gpt-6; harness: codex.
Spacing follow-up: collapsed thought headers now match the 24px tool rows, with no extra gaps between thought and tool sections. Verified expansion and collapse in an isolated web client with synthetic transcript data. Web typecheck and 173 focused timeline tests pass; targeted lint has warnings and no errors.
Before spacing fix:

After spacing fix:

Expanded thought:

Spacing follow-up model: GPT-6; harness: Codex.
Summary by CodeRabbit#
New Features
- Added expand/collapse controls for reasoning details within activity groups.
- Collapsed reasoning sections now show a preview of the first visible message.
- Expansion state is preserved when activity rows are recycled.
Style
- Updated spacing and header styling for expanded reasoning details.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- @@ -2714,7 +2717,9 @@27142717 return null;27152718 }27162719 const label = streaming ? "Thinking" : "Thought";2720+ const collapsedPreview = messages.find((message) => message.text.trim().length > 0)?.text.trim();2721+ const headerText = expanded ? label : (collapsedPreview ?? label);27172722 return (27182723 <div className="flex flex-col">27192724 {showHeader ? (2720- <div className="flex min-h-6 select-none items-center gap-1.5 px-0.5 py-0.5 text-sm leading-relaxed">2725+ <button
Shared primitives over custom controls: use the existing
Buttonprimitive instead of styling a raw<button>as this disclosure control.
Posted via Macroscope — UI Consistency- <button + <Button type="button" + variant="ghost" + size="xs" aria-expanded={expanded} onClick={() => ctx.onToggleReasoning(first.id, !expanded, anchorKey)} - className="flex min-h-6 cursor-pointer select-none items-center gap-1.5 rounded-md px-0.5 py-0.5 text-start text-sm leading-relaxed transition-colors hover:bg-accent/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/70" + className="w-full justify-start text-start font-normal" > ... - </button> + </Button>Note
Written by
gpt-6on behalf of Mariathis disclosure intentionally matches the adjacent ReasoningTimelineRow control, including its icon, spacing, focus ring, hover treatment, and chevron. the proposed ghost/xs button changes the existing timeline sizing and styling that maria asked us to preserve. keeping the matching disclosure control keeps this fix scoped; a shared timeline disclosure primitive would be a separate cleanup.
Correction to the inline review suggestion: the opening and closing tag edits belong to the same hunk; the intervening child markup should remain unchanged.
Posted via Macroscope — UI ConsistencyApprovability#
Verdict: Not approved
Macroscope's review found this PR not approvable — This focused web UI change introduces independent collapse controls and previews for reasoning traces, changing the default visibility of thoughts when a tool group is opened. The implementation is isolated, but the changed product default warrants human review.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
c0609b21-0ef7-4aaf-85d3-a7b6a75fc43c📥 Commits
Reviewing files that changed from the base of the PR and between a2957cc1fa34b465e29e6d08274b7875e2d7719f and fbe895baa3f1615e1cec1f7ca6b1da55d9e2a093.
📒 Files selected for processing (1)
apps/web/src/components/chat/MessagesTimeline.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- apps/web/src/components/chat/MessagesTimeline.tsx
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
Walkthrough#
The chat timeline adds expand/collapse behavior to reasoning traces. Collapsed traces show the first non-empty message as a preview. The disclosure state uses the activity row ID as its anchor.
Changes#
Reasoning trace disclosure
Layer / File(s) Summary Reasoning trace toggle and row anchoring
apps/web/src/components/chat/MessagesTimeline.tsxActivityGroupTimelineRowpassesrow.idasanchorKey.ReasoningTraceBlockreads and updates expanded state through the chat context. Its header toggles message visibility, shows a rotating chevron, displays a preview when collapsed, and adjusts the expanded details spacing.Priority: ⬇️ Low
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Sequence Diagram(s)#
sequenceDiagram participant User participant ReasoningTraceBlock participant ChatTimelineContext User->>ReasoningTraceBlock: Click reasoning trace header ReasoningTraceBlock->>ChatTimelineContext: Toggle message state with anchorKey ChatTimelineContext-->>ReasoningTraceBlock: Return updated expanded state ReasoningTraceBlock-->>User: Render messages or previewMerge Risk: ⚪ Minimal · up to
fbe89The disclosure behavior preserves independent collapsed reasoning traces without an identified merge-blocking risk.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
Check name Status Explanation Resolution Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold. ✅ Passed checks (4 passed)
Check name Status Explanation Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request. Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request. Title check ✅ Passed The title clearly and concisely describes the main change: collapsing thought traces within tool groups. Description check ✅ Passed The description explains the behavior change, the reason for it, UI interaction details, validation results, and includes screenshots and a video for the interaction change. It does not use the templa… - Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create a new PR
Comment `@coderabbitai help` to get the list of available commands.juliusmarminge merged this592021f
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed