feat(timeline): fold long plain messages, and long single lines - #286
Merged
Conversation
Folding covered one shape of "too long" and one kind of sender. Two ways past it remained, and both are ordinary traffic in a working room. **One enormous line.** Length was measured in lines only, so a minified payload or a pasted JSON dump — frequently a single line — reported nothing to fold while wrapping to fill the viewport. Length is now measured both ways, and the preview itself is capped at 400 characters as well as 3 lines, since three lines of a dump can still be a screenful. The cap slices on a character boundary; a byte offset would panic on multi-byte text, which is exactly how the link-preview truncation broke. **Only bot replies folded.** A pasted log from a person crowds the timeline just as badly. Plain messages now fold too, with the toggle in the meta band — every message template already instantiates that, so this needed no new slot in any of the four. Both toggles share `expanded_bot_body_event_ids`: each means "this event is unfolded", and a message is only ever one of the two. The bot branch hides the plain toggle unconditionally, because bot cards carry their own in the card footer and these item widgets are recycled — otherwise a bot reply drawn into a slot that previously held a folded plain message would show two. While folded, the preview is rendered without the message's `formatted_body` and without link previews: the HTML describes the full text rather than this slice, and the links belong to content the user has not asked to see yet. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
tyreseluo
force-pushed
the
feat/fold-long-content
branch
from
July 31, 2026 11:34
d2490db to
7689042
Compare
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.
Folding covered one shape of "too long" and one kind of sender. Two ways past it remained, and both are ordinary traffic in a working room.
One enormous line
Length was measured in lines only, so a minified payload or a pasted JSON dump — frequently a single line — reported nothing to fold while wrapping to fill the viewport.
Length is now measured both ways, and the preview itself is capped at 400 characters as well as 3 lines, since three lines of a dump can still be a screenful.
The cap slices on a character boundary. A byte offset would panic on multi-byte text — precisely how the link-preview truncation broke (#281), so there is a test asserting the CJK case.
Only bot replies folded
A pasted log from a person crowds the timeline just as badly as an agent report. Plain messages now fold too, with the toggle in the meta band — every message template already instantiates that, so this needed no new slot in any of the four (
Message,CondensedMessage,ImageMessage,CondensedImageMessage, which re-declare their subtrees and cannot inherit).Details worth a reviewer's eye
expanded_bot_body_event_ids. Each means "this event is unfolded", and a message is only ever one of the two, so a second set would just be two ways to say the same thing.formatted_bodyand without link previews: the HTML describes the full text rather than this slice, and the links belong to content the user has not asked to see yet.Testing
cargo test --lib --features agent_chat— 593 pass, 4 new: a single over-long line folds, the preview is capped by characters as well as lines, the cap is UTF-8 safe, and a body short on both counts still shows no toggle.typos src/clean.Ran the app: a long paste folds to three lines with a
Show morein the meta band, expand/collapse survives scrolling away and back, bot replies still use their own footer toggle with nothing extra in the meta band, and short messages are untouched.🤖 Generated with Claude Code