Skip to content

Collapse expanded reasoning and tool-call panels by clicking their body - #469

Merged
sysread merged 1 commit into
mainfrom
claude/message-card-collapse-29ho59
Aug 3, 2026
Merged

Collapse expanded reasoning and tool-call panels by clicking their body#469
sysread merged 1 commit into
mainfrom
claude/message-card-collapse-29ho59

Conversation

@sysread

@sysread sysread commented Aug 3, 2026

Copy link
Copy Markdown
Owner

SYNOPSIS

Clicking anywhere on an expanded reasoning trace or tool-call detail now collapses it.

PURPOSE

A long expanded panel pushes its header toggle far off-screen; collapsing currently means scrolling all the way back up to the tiny chevron. This is especially painful on mobile.

DESCRIPTION

Today the reasoning block quote (ReasoningPanel.svelte) and the tool-call detail (ToolCalls.svelte) each expand from a header/row button that is also the only way to close them.

This PR adds a shared guard, clickShouldCollapse (src/lib/ui/collapse-click.ts), and wires the expanded bodies to collapse on click. The guard excludes two click flavors:

  • clicks on interactive descendants (links in markdown-rendered results, the view-mode toggle) - matched via closest() so their own behavior wins
  • the click that ends a text drag-selection (any non-collapsed window.getSelection()), so copying a passage never snaps the panel shut

On the streaming reasoning panel, a body-collapse click fires onToggle so the parent latches manual control exactly like a header click. Both bodies get a pointer cursor + "Click to collapse" tooltip.

Notes:

  • the svelte-ignore a11y comments are intentional: the header/row buttons remain the accessible keyboard toggles; the body click is a pointer-only convenience (role/tabindex on a wall of text would be worse for keyboard users)
  • new jsdom test tests/collapse-click.test.ts is registered in environmentMatchGlobs (vite.config.ts)
  • docs updated in the same PR: docs/user/chat.md, docs/dev/components.md, docs/dev/chat.md, and QA use-case chat-reasoning-collapse.md (steps 8-10; logged as not executed - cloud session has no browser)

Generated by Claude Code

A long expanded reasoning trace or tool-call detail pushes the tiny
header toggle far off-screen, so closing the panel meant scrolling all
the way back up. Clicking anywhere on the expanded contents now
collapses the panel.

A shared guard (clickShouldCollapse in src/lib/ui/collapse-click.ts)
leaves clicks on links, buttons, and the view-mode toggle to their own
behavior, and skips the click that ends a text drag-selection so
copying a passage does not snap the panel shut. The header and row
buttons remain the accessible keyboard toggles; on the streaming
reasoning panel a body-collapse click fires onToggle so the parent
latches manual control the same way a header click does.
@sysread
sysread merged commit cba55cb into main Aug 3, 2026
1 check passed
@sysread
sysread deleted the claude/message-card-collapse-29ho59 branch August 3, 2026 01:35
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