Skip to content

🐛 fix: defer scroll-to-user-message until spacer is mounted#13378

Open
Innei wants to merge 2 commits intocanaryfrom
claude/fix-scroll-padding-timing-1ktSD
Open

🐛 fix: defer scroll-to-user-message until spacer is mounted#13378
Innei wants to merge 2 commits intocanaryfrom
claude/fix-scroll-padding-timing-1ktSD

Conversation

@Innei
Copy link
Copy Markdown
Member

@Innei Innei commented Mar 29, 2026

The scroll that pins a user message to the top of the viewport was
racing with the conversation spacer mount. When the spacer hadn't
rendered yet, there wasn't enough scrollable height, so the scroll
had no effect.

Now useScrollToUserMessage accepts a spacerActive flag and
defers the scroll until the spacer is mounted, guaranteeing the
fill height is available before scrolling.

https://claude.ai/code/session_016GDASpf7Rh5yN7BJTdXYwT

The scroll that pins a user message to the top of the viewport was
racing with the conversation spacer mount. When the spacer hadn't
rendered yet, there wasn't enough scrollable height, so the scroll
had no effect.

Now `useScrollToUserMessage` accepts a `spacerActive` flag and
defers the scroll until the spacer is mounted, guaranteeing the
fill height is available before scrolling.

https://claude.ai/code/session_016GDASpf7Rh5yN7BJTdXYwT
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 29, 2026

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

Project Deployment Actions Updated (UTC)
lobehub Error Error Mar 29, 2026 11:05am

Request Review

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

We've reviewed this pull request using the Sourcery rules engine

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c6f626c3ef

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +94 to +96
} else {
// Defer scroll until spacer mounts and provides enough height
pendingScrollIndexRef.current = userMessageIndex;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Fall back to immediate scroll when spacer never mounts

Deferring to pendingScrollIndexRef whenever spacerActive is false causes auto-scroll to be skipped entirely when no spacer is needed. In useConversationSpacer, spacerActive is tied to mounted, which stays false when computed spacer height is 0 (the long user/assistant-content case), so this branch stores a pending index that is never executed. That regresses the previous behavior by preventing the user message from being pinned in conversations where the content already fills/exceeds the viewport.

Useful? React with 👍 / 👎.

The previous fix deferred scrolling entirely until spacerActive was
true. This regressed the no-spacer case (content fills viewport,
spacer height = 0, mounted stays false) — the scroll never fired.

Now the hook always scrolls immediately on message send (preserving
original behavior), and additionally fires a follow-up scroll when
spacerActive transitions to true. This covers both cases:
- Content fills viewport: immediate scroll works, no spacer needed
- Content is short: immediate scroll may under-scroll, but the
  follow-up scroll after spacer mounts corrects the position

https://claude.ai/code/session_016GDASpf7Rh5yN7BJTdXYwT
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.95%. Comparing base (966f943) to head (5c244b1).
⚠️ Report is 6 commits behind head on canary.

Additional details and impacted files
@@            Coverage Diff            @@
##           canary   #13378     +/-   ##
=========================================
  Coverage   66.94%   66.95%             
=========================================
  Files        1903     1903             
  Lines      153684   153701     +17     
  Branches    15534    18387   +2853     
=========================================
+ Hits       102889   102908     +19     
+ Misses      50675    50673      -2     
  Partials      120      120             
Flag Coverage Δ
app 58.53% <100.00%> (+<0.01%) ⬆️
database 96.66% <ø> (ø)
packages/agent-runtime 89.61% <ø> (ø)
packages/context-engine 86.47% <ø> (ø)
packages/conversation-flow 92.36% <ø> (ø)
packages/file-loaders 87.02% <ø> (ø)
packages/memory-user-memory 66.68% <ø> (ø)
packages/model-bank 99.85% <ø> (ø)
packages/model-runtime 84.44% <ø> (ø)
packages/prompts 67.76% <ø> (ø)
packages/python-interpreter 92.90% <ø> (ø)
packages/ssrf-safe-fetch 0.00% <ø> (ø)
packages/utils 90.41% <ø> (ø)
packages/web-crawler 88.82% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Store 67.29% <ø> (ø)
Services 49.30% <ø> (ø)
Server 67.27% <ø> (+<0.01%) ⬆️
Libs 51.03% <ø> (ø)
Utils 91.01% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

2 participants