Skip to content

fix(mothership): keep chat pinned to bottom across multi-line input resizes#5711

Merged
TheodoreSpeaks merged 1 commit into
stagingfrom
fix/scroll-error
Jul 16, 2026
Merged

fix(mothership): keep chat pinned to bottom across multi-line input resizes#5711
TheodoreSpeaks merged 1 commit into
stagingfrom
fix/scroll-error

Conversation

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator

Summary

  • A bottom-pinned mothership chat silently unpinned whenever a newline was added or removed in a multi-line input draft
  • Root cause: the prompt editor's autosize (height:'auto' → read scrollHeight → set px) forces a synchronous layout with the textarea collapsed; during that transient layout the chat scroll container grows and the browser natively clamps the pinned scrollTop down by the input's grown height (no JS write, invisible to ResizeObserver since the net size change is zero)
  • Fix 1: lock the prompt-editor scroller's box during the autosize measurement so the transient collapse never leaks into ancestor layout
  • Fix 2: re-pin the transcript to the bottom when the scroll container genuinely resizes (input growing/shrinking below its cap, panel/window resizes) — pinned-ness is sampled on scroll events, so a user who scrolled up is never yanked down

Type of Change

  • Bug fix

Testing

Reproduced and verified in the running app with instrumented scroll tracing (chrome-devtools MCP): add newline at input max height, remove newlines, and grow below the cap all stay pinned (dist ≈ 0); a user scrolled up 400px is untouched. bun run lint and bun run check:api-validation:strict pass.

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)

🤖 Generated with Claude Code

https://claude.ai/code/session_01QtgAAuHzbSoS4FEYZnHdAJ

@vercel

vercel Bot commented Jul 16, 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 Jul 16, 2026 6:18pm

Request Review

@cursor

cursor Bot commented Jul 16, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Localized UI scroll/autosize behavior in mothership chat and prompt editor with no auth, API, or data-path changes.

Overview
Fixes a bug where a bottom-pinned mothership chat drifted off the latest message when the prompt grew or shrank across multiple lines.

Prompt editor: During autosize, the scroller’s height is frozen at its current pixel size while the textarea briefly collapses to height: auto for scrollHeight measurement, then restored. That stops the transient layout from resizing ancestor chat scroll areas and letting the browser clamp a pinned scrollTop upward.

Mothership chat: Adds a PIN_THRESHOLD (2px) and a ResizeObserver on the transcript scroll container. Scroll events track whether the user was at the bottom; on real container resizes (input cap changes, panel/window size), the view re-scrolls to bottom only if they were already pinned—users who scrolled up are left alone.

Reviewed by Cursor Bugbot for commit 56574c8. Bugbot is set up for automated code reviews on this repo. Configure here.

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator Author

@greptile review

@greptile-apps

greptile-apps Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR keeps the mothership chat pinned during input and container resizing. The main changes are:

  • Locks the prompt editor scroller during textarea autosize measurement.
  • Tracks whether the transcript is at the bottom.
  • Restores the bottom position after genuine container resizes.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/mothership-chat.tsx Adds pinned-state tracking and resize-driven bottom restoration with proper observer and listener cleanup.
apps/sim/app/workspace/[workspaceId]/home/components/user-input/components/prompt-editor/prompt-editor.tsx Locks the scroller box while synchronously measuring and updating the textarea height.

Reviews (1): Last reviewed commit: "fix(mothership): keep chat pinned to bot..." | Re-trigger Greptile

@TheodoreSpeaks
TheodoreSpeaks merged commit b5196a4 into staging Jul 16, 2026
20 checks passed
@TheodoreSpeaks
TheodoreSpeaks deleted the fix/scroll-error branch July 16, 2026 18:41
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