Skip to content

fix(chat): stop the streaming transcript floor inventing scroll space - #6527

Merged
waleedlatif1 merged 2 commits into
stagingfrom
review/chat-composer-autosize
Aug 11, 2026
Merged

fix(chat): stop the streaming transcript floor inventing scroll space#6527
waleedlatif1 merged 2 commits into
stagingfrom
review/chat-composer-autosize

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • The transcript sizer floor was computed as the viewport's bottom edge (scrollTop + clientHeight), which exceeds the content height whenever the transcript is shorter than the viewport — early in a turn, or in any short chat. That invents scrollable space no content occupies.
  • It stays invisible until the scroll container shrinks mid-turn (composer growing, queued-message banner appearing, window or panel resize). Then the bottom-pin scrolls into the invented space and the transcript is displaced upward until the floor drains at the end of the turn.
  • Clamps the floor to the space content has actually held this turn — the max of the virtualizer's total size and the still-applied floor. Extracted to nextSizerFloor with unit tests.
  • The applied-floor term is load-bearing on its own: without it, a queued message re-engaging the floor mid-drain dumps the undrained debt in a single frame, which is the jump the eased drain exists to prevent.

Type of Change

  • Bug fix

Testing

Measured in Chromium against a harness rendering the real virtualizer, useAutoScroll, and the floor effect:

scenario before after
short transcript, composer grows mid-stream 72px upward displacement, reverts at end of turn 0px
short transcript, queued-message banner mid-stream same displacement 0px
tall transcript no phantom space identical
mid-stream row shrink floor holds, drains identical
drain interrupted by a new turn 3px eased release identical

509 home tests pass; typecheck and lint clean.

Note: verified in a harness that reconstructs the transcript with the real modules, not in the running app — worth a live spot-check on a short first reply.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Aug 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 11, 2026 3:41am

Request Review

@cursor

cursor Bot commented Aug 11, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches scroll pinning and virtualized transcript layout during streaming—user-visible and timing-sensitive—but logic is isolated with unit tests and preserves tall-transcript behavior.

Overview
Fixes phantom scroll space during streaming when the transcript is shorter than the viewport. The sizer min-height floor was tied to the viewport bottom (scrollTop + clientHeight), which can sit below real content height—so the floor invented empty scrollable area that only shows up when the scroll container shrinks mid-turn (composer growth, queued-message banner, resize), pulling the pinned transcript upward until end-of-turn drain.

nextSizerFloor centralizes the floor: a per-turn high-water mark (max of prior high water, virtualizer total size, and applied floor) caps the floor so it never exceeds space content has actually held. Mid-turn shrinks still hold via high water; undrained floor debt still carries when the floor re-engages mid-drain.

mothership-chat wires that helper, tracks high water in a ref, and resets floor state on chat switch (not when a pending chat gets its id) so a short chat doesn’t inherit another chat’s floor.

Reviewed by Cursor Bugbot for commit 0369620. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR prevents short streaming transcripts from creating phantom scroll space and adds explicit floor-state cleanup when switching chats.

  • Clamps the active sizer floor to the transcript’s retained high-water mark.
  • Preserves undrained floor debt when a new turn interrupts the drain.
  • Clears transcript-specific floor state on chat changes.
  • Adds focused unit coverage for floor bounds, shrinking content, fractional offsets, and interrupted drains.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/mothership-chat.tsx Integrates bounded floor computation, resets transcript-specific floor state on chat changes, and uses the required absolute import.
apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/sizer-floor.ts Encapsulates the floor and high-water calculation that prevents viewport extent from inventing content space.
apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/sizer-floor.test.ts Covers short transcripts, fractional and negative extents, content shrinkage, growth, and interrupted floor drains.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Transcript layout commit] --> B{Chat changed?}
  B -->|Yes, distinct chat| C[Cancel drain and clear floor state]
  B -->|No or pending chat persisted| D{Floor active?}
  C --> D
  D -->|Yes| E[Compute content high-water mark]
  E --> F[Clamp viewport extent to high-water mark]
  F --> G[Apply bounded min-height]
  D -->|No| H[Drain or clear applied floor]
Loading

Reviews (3): Last reviewed commit: "fix(chat): release the transcript floor ..." | Re-trigger Greptile

@greptile-apps

greptile-apps Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR extracts the transcript floor calculation and clamps it to content held during the active turn, with focused unit coverage.

  • Adds nextSizerFloor and tests for short transcripts, fractional extents, row shrinkage, growth, and interrupted drains.
  • Integrates a turn-level high-water mark into the streaming transcript floor and preserves undrained floor debt.
  • The high-water state currently lacks a reset at chat-identity boundaries.

Confidence Score: 4/5

The PR should not merge until the floor’s high-water state is reset when the active chat changes; the import-convention issue is non-blocking.

A retained component can apply the previous tall chat’s high-water mark to a newly selected short chat for at least one layout pass, recreating artificial scroll space that then drains visibly.

Files Needing Attention: apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/mothership-chat.tsx; apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/sizer-floor.test.ts

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/mothership-chat.tsx Integrates content-clamped floor tracking, but the new high-water ref can cross chat boundaries and recreate phantom space.
apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/sizer-floor.ts Provides a clear pure calculation that clamps viewport extent to content and applied-floor high-water state.
apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/sizer-floor.test.ts Covers the pure floor arithmetic well, but does not exercise the component-level transcript reset boundary.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Tall chat is streaming] --> B[heldHighWater records tall content]
  B --> C[User switches to cached short chat]
  C --> D[MothershipChat instance and refs persist]
  D --> E[Layout effect runs while lastRowAnimating is still true]
  E --> F[nextSizerFloor retains old high-water]
  F --> G[Short chat receives artificial min-height]
  G --> H[Floor drains over subsequent frames]
Loading

Reviews (1): Last reviewed commit: "fix(chat): stop the streaming transcript..." | Re-trigger Greptile

The sizer floor was the viewport's bottom edge (scrollTop + clientHeight),
which exceeds the content height whenever the transcript is shorter than the
viewport. That invents scrollable space no content occupies, and a mid-turn
container shrink turns it into real scroll room the bottom-pin scrolls into.

Clamp the floor to the space content has actually held this turn: the max of
the virtualizer's total size and the still-applied floor. The applied-floor
term keeps undrained debt across a turn boundary that interrupts the drain.
The high-water mark and applied floor are per-turn refs on a component that
survives a chat switch, so a tall chat's mark could size a newly opened short
one for as long as the outgoing turn kept the floor engaged. Release both
outright on a chat change — the switch re-lands the viewport, so there is no
eased settle to preserve — while treating a pending chat adopting its id as
the same conversation.

Also switch the sizer-floor import to the absolute path convention.
@waleedlatif1
waleedlatif1 force-pushed the review/chat-composer-autosize branch from 3c8ad63 to 0369620 Compare August 11, 2026 03:41
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor 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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 0369620. Configure here.

@waleedlatif1
waleedlatif1 merged commit 1a39e29 into staging Aug 11, 2026
30 checks passed
@waleedlatif1
waleedlatif1 deleted the review/chat-composer-autosize branch August 11, 2026 05:00
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

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