Skip to content

feat(timeline): fold long plain messages, and long single lines - #286

Merged
tyreseluo merged 1 commit into
mainfrom
feat/fold-long-content
Jul 31, 2026
Merged

feat(timeline): fold long plain messages, and long single lines#286
tyreseluo merged 1 commit into
mainfrom
feat/fold-long-content

Conversation

@tyreseluo

Copy link
Copy Markdown

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

  • Both toggles share 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.
  • The bot branch hides the plain toggle unconditionally. Bot cards carry their own toggle in the card footer, and these item widgets are recycled — without the reset, a bot reply drawn into a slot that previously held a folded plain message would show two toggles. This shape of leak has been the cause of three separate bugs in this file already.
  • While folded, the preview renders 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.

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 more in 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

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
tyreseluo force-pushed the feat/fold-long-content branch from d2490db to 7689042 Compare July 31, 2026 11:34
@tyreseluo
tyreseluo merged commit e53cc59 into main Jul 31, 2026
12 checks passed
@tyreseluo
tyreseluo deleted the feat/fold-long-content branch July 31, 2026 11:52
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