Skip to content

feat(app): fold long user messages - #59435

Merged
kitlangton merged 5 commits into
devfrom
fold-user-messages
Oct 28, 2026
Merged

kitlangton merged 5 commits into
devfrom
fold-user-messages

Conversation

@kitlangton

@kitlangton kitlangton commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Long messages you sent now fold to their first 8 lines in the timeline, with a Read more button to open them.
A pasted log or a long dictated prompt no longer fills the screen every time you scroll past it. It's the same rule the iOS app uses. Short messages and replies don't change.

💡 Why
You know what you said. A 40-line paste between two short replies makes the thread hard to scan.

🆕 Now you can

  • See a message longer than 12 lines as its first 8, fading out, with Read more under it.
  • Click Read more to open it in place. It opens downward, so the top of the message stays where it was. Show less folds it again.
  • Scroll it out of view and back, and it stays open.
  • Copy or select all and still get the whole message.
  • Find a word hidden in a folded message, and it opens to show it.
- user message: always laid out in full
+ user message past 12 lines: show 8 lines, fade the last ones, then a "Read more" button
+ open/closed lives with the timeline's other expand state, so it survives rows unmounting while you scroll

📊 Proof

❌ Before ✅ After
Before: a 40-line pasted log fills the screen After: the log and a code paste fold to 8 lines with Read more

The new e2e test checks that 12 lines stay open and 13 fold to 8, that the whole text stays selectable, that opening keeps the top in place and the row height updates, and that an opened message is still open after scrolling far enough to unmount it and back. It fails without the change, since there's no button. 6 of 6 passed (3 repeats each, with the neighbouring diff-anchor test).

👀 Read: UserMessageFold in message-content.tsx. It measures the text's own height to count lines, and closing a message taller than the screen scrolls by the amount the button moved, so the button stays under the pointer. Opening and closing also stop the timeline following its end, so an opened message near the bottom doesn't scroll its top away. Find skips the Read more button and opens a folded message when a match is hidden in it. A message in a hidden, cached tab keeps its fold instead of measuring 0 lines. The existing diff-anchor test used a long user message for overflow, so that filler is now assistant text. The rest is routine.

Visual

<svg xmlns="http://www.w3.org/2000/svg" width="240" height="72" viewBox="0 0 240 72" fill="currentColor">
  <g opacity=".25"><rect x="8" y="12" width="72" height="3" rx="1.5"/><rect x="8" y="19" width="60" height="3" rx="1.5"/><rect x="8" y="26" width="66" height="3" rx="1.5"/></g>
  <rect x="100" y="4" width="132" height="40" rx="8" opacity=".12"><animate attributeName="height" values="40;62" keyTimes="0;.5" dur="4s" calcMode="discrete" repeatCount="indefinite"/></rect>
  <g opacity=".6">
    <rect x="110" y="12" width="104" height="3" rx="1.5"/>
    <rect x="110" y="19" width="92" height="3" rx="1.5"/>
    <rect x="110" y="26" width="100" height="3" rx="1.5" opacity=".35"><animate attributeName="opacity" values=".35;1" keyTimes="0;.5" dur="4s" calcMode="discrete" repeatCount="indefinite"/></rect>
    <g opacity="0"><animate attributeName="opacity" values="0;1" keyTimes="0;.5" dur="4s" calcMode="discrete" repeatCount="indefinite"/>
      <rect x="110" y="33" width="84" height="3" rx="1.5"/><rect x="110" y="40" width="108" height="3" rx="1.5"/><rect x="110" y="47" width="70" height="3" rx="1.5"/>
    </g>
  </g>
  <rect x="110" y="35" width="30" height="3" rx="1.5" opacity=".4"><animate attributeName="y" values="35;57" keyTimes="0;.5" dur="4s" calcMode="discrete" repeatCount="indefinite"/></rect>
</svg>

Picked from four prototyped options · no user reports · stills from the components lab story, rendered headless

Checks run
  • bun typecheck in packages/session-ui and packages/app: no errors
  • bun run typecheck:e2e: no new errors (the existing ones are unchanged)
  • bun run test in packages/session-ui: 327 pass; packages/app src/session unit tests: 122 pass
  • bun run test:e2e:built -- e2e/regression/timeline-geometry.spec.ts -g "folds a prompt|keeps a file diff anchored" --retries=0 --repeat-each=3: 6 passed

Folding is behind Settings → Experimental → Fold long messages, off by default. With it off, user messages render as on dev (no fold DOM, no measuring).

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks sound from reading the code. I couldn't run it: Playwright's Chromium won't start in my environment because a system library is missing, so the e2e spec didn't run. tsc passes for packages/app and packages/session-ui.

The fold is laid out whole and clipped, so copy and select-all still get the full text. The open state lives in the timeline's disclosure store, so it survives row recycling. The scroll correction on collapse shouldn't clash with the virtualizer's own adjustment, which only applies to rows before the rendered range.

Public API is unchanged. The two new i18n keys are English-only and fall back to English in other locales.

This is a visible web UI change and I couldn't capture it, so before/after screenshots or a short clip of folding and unfolding a long prompt would help.

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I re-checked the new commit by reading it and running tsc (clean in packages/session-ui and packages/app). I still couldn't run the web UI or the e2e spec here because Playwright's browser fails to start. No earlier threads were open, and the public API is unchanged.

The follow-ups look right. Long messages now fold on first render, measuring is skipped while the timeline is detached, and the max-height uses 8lh. The collapse correction only runs when the message's top is above the screen, and unpin only happens on open. In Find, the toggle label is skipped and a match hidden in the fold opens the message. Opening clears the folded state, so the retry can't loop.

One thing worth doing: the fold e2e test is now about 150 lines in one block, covering edge cases, selection, the detached-tab case, opening, remount, closing and Find. The detached-tab step removes and re-inserts the bubble by hand, which doesn't match how a cached tab is really hidden. Could you trim it to the core fold/open/Find checks, or split it into a few smaller tests, so a failure points at one behaviour?

@thdxr
thdxr changed the base branch from beta to dev October 27, 2026 16:37
@kitlangton
kitlangton merged commit 651032b into dev Oct 28, 2026
20 checks passed
@kitlangton
kitlangton deleted the fold-user-messages branch October 28, 2026 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant