Skip to content

fix(web): fix scroll position for references further down in a file#1036

Merged
brendan-kellam merged 2 commits intomainfrom
brendan/fix-chat-reference-scroll
Mar 24, 2026
Merged

fix(web): fix scroll position for references further down in a file#1036
brendan-kellam merged 2 commits intomainfrom
brendan/fix-chat-reference-scroll

Conversation

@brendan-kellam
Copy link
Contributor

@brendan-kellam brendan-kellam commented Mar 24, 2026

Summary

  • Replaces coordsAtPos() with view.lineBlockAt() to get line positions from CodeMirror's internal height map
  • Also uses codeMirrorRect for coordinate calculation instead of relying on coords.top from the potentially-unrendered line
  • Fixes scrolling to references in lines that haven't been rendered yet by CodeMirror's virtualizer

Test plan

  • Open a chat and select a file reference that points to a line near the top of a file — scroll position should be correct
  • Select a file reference that points to a line further down in a large file — scroll position should now correctly land on the target line

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Fixed scroll positioning in the chat interface when selecting references that target lines located further down in a file. The viewport now correctly centers the referenced line for improved visibility and navigation.

Uses lineBlockAt() instead of coordsAtPos() to get line positions from
CodeMirror's internal height map, which works correctly for virtualized
lines that haven't been rendered yet.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

This comment has been minimized.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 24, 2026

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: d24635cc-bd96-4c5f-9d6c-4b6f5bae2ffd

📥 Commits

Reviewing files that changed from the base of the PR and between c7ee456 and 67e3ca1.

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

Walkthrough

This pull request fixes scroll positioning in the chat UI when selecting chat references that target lines located further down in a file. The CHANGELOG documents the fix. The implementation replaces scroll coordinate calculation in referencedSourcesListView.tsx to use CodeMirror's document layout API instead of the previous coordinate method.

Changes

Cohort / File(s) Summary
Documentation
CHANGELOG.md
Added Unreleased → Fixed entry documenting scroll position fix for chat reference selection (#1036).
Chat Reference Scroll Logic
packages/web/src/features/chat/components/chatThread/referencedSourcesListView.tsx
Replaced scroll positioning mechanism to use CodeMirror document layout (lineBlockAt().top) and DOM bounding rectangles instead of coordsAtPos(), computing scroll position to center the target line.

Possibly related PRs

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: fixing scroll position for chat references pointing to lines further down in files, which matches the core bug fix implemented in the pull request.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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/fix-chat-reference-scroll

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 and usage tips.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@brendan-kellam brendan-kellam merged commit 1ea2898 into main Mar 24, 2026
8 checks passed
@brendan-kellam brendan-kellam deleted the brendan/fix-chat-reference-scroll branch March 24, 2026 05:02
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