Skip to content

fix(code): collapse long queued messages instead of filling the viewport#3223

Merged
jonathanlab merged 5 commits into
mainfrom
posthog-code/collapse-queued-messages
Jul 7, 2026
Merged

fix(code): collapse long queued messages instead of filling the viewport#3223
jonathanlab merged 5 commits into
mainfrom
posthog-code/collapse-queued-messages

Conversation

@vdekrijger

@vdekrijger vdekrijger commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Why

Queued messages render their full content in the conversation list. A couple of queued messages with large pasted code blocks consume the entire viewport, making the conversation unreadable (see Before below).

What

  • Extracted UserMessage's existing measured collapse pattern (160px cap, scrollHeight measurement on mount, fade gradient, Show more/less toggle) into a shared CollapsibleMessageContent component.
  • QueuedMessageView now uses it, so queued messages collapse exactly like regular user messages instead of growing unbounded.
  • UserMessage migrated to the shared component — behavior unchanged (same 160px threshold, gradient, and toggle).
  • Per repo convention, the new wrapper component accepts both className and style props.

Before / After

Before / after: two queued messages with large pasted code, uncollapsed vs collapsed at 160px

(mock-up rendered with the component's exact styles — current rounded-card queued design: same two queued messages, same 620px viewport; before overflows it, after fits both with room to spare)

Test plan

  • pnpm typecheck green across all 23 packages (re-run after rebasing onto the packages/ui split).
  • pnpm --filter @posthog/ui test — 1290 tests pass (no tests exist for these presentational components; behavior is unchanged for UserMessage and purely additive for queued messages).
  • Reviewed via /simplify + review swarm (4 reviewers): grade A, no findings above LOW; the one convention finding (missing style prop) is fixed in this diff.
  • Manual: queue several messages with large pasted code — each caps at 160px with a fade and Show more/less; expanding re-measures the virtualized row correctly (virtua ResizeObserver).

Created with PostHog Code

@trunk-io

trunk-io Bot commented Jul 7, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Queued messages with large pasted content (code blocks etc.) previously
rendered at full height, so a couple of queued messages could consume the
entire conversation viewport. Extract UserMessage's existing measured
collapse pattern (160px cap, fade gradient, Show more/less toggle) into a
shared CollapsibleMessageContent component and use it for queued messages
too, so both message types share one overflow affordance.

Generated-By: PostHog Code
Task-Id: 93b789ce-d9c1-434c-909e-ebfc4cbd1f46
Removed again in the next commit; referenced by SHA from the PR body.

Generated-By: PostHog Code
Task-Id: 93b789ce-d9c1-434c-909e-ebfc4cbd1f46
The image stays fetchable via the previous commit's SHA.

Generated-By: PostHog Code
Task-Id: 93b789ce-d9c1-434c-909e-ebfc4cbd1f46
@vdekrijger vdekrijger force-pushed the posthog-code/collapse-queued-messages branch from 2977e0a to aa232fa Compare July 7, 2026 12:33
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

React Doctor found 1 issue in 1 file · 1 warning.

1 warning

src/features/sessions/components/session-update/CollapsibleMessageContent.tsx

Reviewed by React Doctor for commit 5f32c6f.

Removed again in the next commit; referenced by SHA from the PR body.

Generated-By: PostHog Code
Task-Id: 93b789ce-d9c1-434c-909e-ebfc4cbd1f46
The image stays fetchable via the previous commit's SHA.

Generated-By: PostHog Code
Task-Id: 93b789ce-d9c1-434c-909e-ebfc4cbd1f46
@vdekrijger vdekrijger marked this pull request as ready for review July 7, 2026 12:58
@vdekrijger vdekrijger added the Stamphog This will request an autostamp by stamphog on small changes label Jul 7, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Mechanical UI refactor — extracts existing collapsible logic into a reusable component and applies it to a second call site. No logic changes, no API/data-model impact, no security surface.

@greptile-apps

greptile-apps Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "chore: remove temporary PR asset" | Re-trigger Greptile

@jonathanlab jonathanlab merged commit 8dcfcb1 into main Jul 7, 2026
32 checks passed
@jonathanlab jonathanlab deleted the posthog-code/collapse-queued-messages branch July 7, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Stamphog This will request an autostamp by stamphog on small changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants