Skip to content

Collapse sequential Read tool uses into a "Read N files" card#105

Open
mcintyre94 wants to merge 1 commit intomainfrom
suggest-read-n-files-feature-612e54f4
Open

Collapse sequential Read tool uses into a "Read N files" card#105
mcintyre94 wants to merge 1 commit intomainfrom
suggest-read-n-files-feature-612e54f4

Conversation

@mcintyre94
Copy link
Owner

Summary

  • When Claude reads multiple files back-to-back, the individual tool cards are now grouped into a single compact "Read N files" row — reducing chat noise for read-heavy sessions
  • Tapping the row opens a sheet listing each file in a DisclosureGroup, with the file content expandable inline
  • The card updates live during streaming: when a second Read arrives, the first single-file card is upgraded to the group in place
  • Single reads continue to behave exactly as before

Implementation notes

  • New ReadGroupCard model (@Observable) holds an array of ToolUseCards and exposes allComplete / elapsedString
  • ChatContent gains a .readGroup(ReadGroupCard) case; PersistedChatContent gains a matching .readGroup([PersistedToolUse]) case for round-trip persistence
  • A single static func groupReadCard(_:into:) helper owns the grouping logic (searches backwards past interleaved .toolResult items); used by live streaming, replay buffer, and parseSessionJSONL
  • activeToolLabel, rebuildToolUseIndex, and result-linking all updated to look inside readGroup cards

Test plan

  • Chat where Claude reads a single file — card renders as before (ToolStepRow, taps to ToolDetailSheet)
  • Chat where Claude reads 2+ files sequentially — cards collapse to "Read N files" row with correct elapsed time
  • Tap "Read N files" row — sheet opens showing all files; each expands to show content
  • During streaming: first read shows normally; second read causes live upgrade to group card; shimmer still shows for the active read
  • Interrupt mid-read-group — muted strikethrough row shown
  • Persist and reload — group survives round-trip (reloaded as ReadGroupCard via .readGroup persistence case)
  • Session JSONL load (resume from remote session) — reads grouped correctly via parseSessionJSONL

🤖 Generated with Claude Code

When Claude reads multiple files in a row, the individual cards are now
grouped into one compact "Read N files" row that taps to open an accordion
sheet listing each file with its content expandable inline.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant