Skip to content

fix(web): stop chat jitter when opening citations at the bottom#1406

Open
brendan-kellam wants to merge 3 commits into
mainfrom
brendan/sou-1486-chat-jitters-when-opening-citations-at-bottom-4767
Open

fix(web): stop chat jitter when opening citations at the bottom#1406
brendan-kellam wants to merge 3 commits into
mainfrom
brendan/sou-1486-chat-jitters-when-opening-citations-at-bottom-4767

Conversation

@brendan-kellam

@brendan-kellam brendan-kellam commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Fixes SOU-1486

Clicking a citation while scrolled to the bottom of a chat caused the view to jitter vertically (repeatedly, on every click).

The chat scroll container uses useStickToBottom. While the user is at (or within ~70px of) the bottom, the hook keeps the container anchored to the bottom and re-asserts that position whenever content resizes or scrolls. Selecting a citation kicks off a scrollIntoView (in chatThreadListItem.tsx) to reveal/center the reference, and useStickToBottom fights that scroll by yanking back to the bottom. The two compete for the scroll position for a frame or two on each click, which is the jitter. It only reproduces "at the bottom" because that's the only state where the stick-to-bottom lock is engaged.

Fix: release the stick-to-bottom lock (stopScroll()) when a citation reference is selected, so the reveal scroll can settle without a fight. This is the same state the hook enters when the user scrolls up manually, and it matches the intent of the interaction (you're now inspecting a citation, not following streaming output). Sending a new message re-engages auto-scroll as before.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed chat scrolling so it no longer jumps or feels jittery when opening a citation while you’re at the bottom of the conversation.
    • Citation selection now behaves more smoothly by releasing the auto-scroll lock before showing the reference.

When the chat is stuck to the bottom, selecting a citation triggers a
scroll-into-view that fights useStickToBottom's auto-scroll, causing the
view to jitter. Release the stick-to-bottom lock on citation selection so
the reveal scroll can settle.

Generated with [Linear](https://linear.app/sourcebot/issue/SOU-1486/chat-jitters-when-opening-citations-at-bottom#agent-session-fbed4bdc)

Co-authored-by: linear-code[bot] <222613912+linear-code[bot]@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c5c8b431-7aab-4837-8cbf-9197cda4bdeb

📥 Commits

Reviewing files that changed from the base of the PR and between 3a7bf2d and 53fba91.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • packages/web/src/ee/features/chat/components/chatThread/chatThread.tsx
  • packages/web/src/ee/features/chat/components/chatThread/chatThreadListItem.tsx

Walkthrough

Adds a stopScroll callback from useStickToBottom in ChatThread, passed as onStickToBottomRelease to ChatThreadListItem. That callback is invoked when a citation reference is selected, releasing the stick-to-bottom scroll lock. Includes a changelog entry.

Changes

Stick-to-bottom release fix

Layer / File(s) Summary
Citation selection releases scroll lock
packages/web/src/ee/features/chat/components/chatThread/chatThreadListItem.tsx
Adds optional onStickToBottomRelease prop, invokes it when a reference is selected, and updates memoization dependencies.
Wiring stopScroll from ChatThread
packages/web/src/ee/features/chat/components/chatThread/chatThread.tsx
Destructures stopScroll from useStickToBottom and passes it as onStickToBottomRelease to each ChatThreadListItem.
Changelog entry
CHANGELOG.md
Documents the fix for chat jittering when opening citations while scrolled to bottom.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ChatThread
  participant ChatThreadListItem
  participant useStickToBottom

  ChatThread->>useStickToBottom: destructure stopScroll
  ChatThread->>ChatThreadListItem: onStickToBottomRelease=stopScroll
  ChatThreadListItem->>ChatThreadListItem: setSelectedReference(reference)
  ChatThreadListItem->>useStickToBottom: onStickToBottomRelease() (stopScroll)
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main user-facing fix: preventing chat jitter when opening citations at the bottom.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch brendan/sou-1486-chat-jitters-when-opening-citations-at-bottom-4767

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@brendan-kellam brendan-kellam marked this pull request as ready for review July 1, 2026 19:56
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