Skip to content

[codex] Fix changes pane scroll to file headers#4615

Merged
Kitenite merged 1 commit into
mainfrom
changes-pane-scroll-heade
May 16, 2026
Merged

[codex] Fix changes pane scroll to file headers#4615
Kitenite merged 1 commit into
mainfrom
changes-pane-scroll-heade

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented May 16, 2026

Summary

  • Scroll changes-pane file jumps to the diff entry header anchor instead of the whole entry wrapper.
  • Keep the file header rendered by DiffFileEntry even before the lazy diff body mounts.
  • Simplify WorkspaceDiff so it only owns the diff body and comment annotations.

Root Cause

The changes pane click path selected the file entry wrapper as the scroll target. When comment annotations or lazy-mounted diff content changed the entry layout, the jump could land relative to the comment/body area instead of consistently landing on the file entry header.

Impact

Clicking a file in the changes pane now consistently lands at that file's header. Comment-focused jumps still use the entry root for line lookup after the header jump.

Validation

  • bunx biome check on the touched diff-pane files
  • bun run --cwd apps/desktop typecheck
  • bun run lint:fix
  • bun run lint

Open in Stage

Summary by cubic

Scroll jumps from the changes pane now land on each file’s header for stable positioning, even when diff content or comments mount later. The file header always renders; WorkspaceDiff now only renders the diff body and annotations.

  • Bug Fixes

    • Use the header element ([data-diff-entry-header-path]) as the scroll target instead of the entry wrapper.
    • After snapping to the header, focus-on-line still centers the target line to keep comment jumps working.
  • Refactors

    • Render DiffFileHeader unconditionally in DiffFileEntry; lazy‑mount only the diff body.
    • Remove header-related props and rendering from WorkspaceDiff.

Written for commit 4bdc0ed. Summary will update on new commits. Review in cubic

Summary by CodeRabbit

  • Bug Fixes

    • Improved scroll-to-file behavior and line-focusing alignment in the diff viewer to correctly target the appropriate DOM elements within virtualized diffs.
  • Refactor

    • Restructured the diff display architecture to improve separation of concerns between headers and content rendering.

Review Change Stack

@capy-ai
Copy link
Copy Markdown

capy-ai Bot commented May 16, 2026

Capy auto-review is paused for this organization because the monthly auto-review limit has been reached. Increase the limit or turn it off in billing settings to resume automatic reviews.

@stage-review
Copy link
Copy Markdown

stage-review Bot commented May 16, 2026

Ready to review this PR? Stage has broken it down into 3 individual chapters for you:

Title
1 Add anchor attribute to DiffFileHeader
2 Move DiffFileHeader rendering to DiffFileEntry
3 Update scroll logic to target file headers
Open in Stage

Chapters generated by Stage for commit 4bdc0ed on May 16, 2026 12:33am UTC.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 16, 2026

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dbeb8c57-6adf-43d8-9040-53afaf704b9b

📥 Commits

Reviewing files that changed from the base of the PR and between da0282c and 4bdc0ed.

📒 Files selected for processing (4)
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/DiffPane/DiffPane.tsx
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/DiffPane/components/DiffFileEntry/DiffFileEntry.tsx
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/DiffPane/components/DiffFileHeader/DiffFileHeader.tsx
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/DiffPane/components/WorkspaceDiff/WorkspaceDiff.tsx
💤 Files with no reviewable changes (1)
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/DiffPane/components/WorkspaceDiff/WorkspaceDiff.tsx

📝 Walkthrough

Walkthrough

The diff pane component hierarchy is refactored to separate header rendering from diff content. WorkspaceDiff's public contract is narrowed to accept source and viewer state instead of metadata and handlers. DiffFileEntry now manages the header separately, passing reduced props to WorkspaceDiff. DOM attributes and scroll logic are updated to align with this structure.

Changes

Diff Component Header Extraction and Scrolling

Layer / File(s) Summary
WorkspaceDiff contract simplification
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/DiffPane/components/WorkspaceDiff/WorkspaceDiff.tsx
WorkspaceDiffProps interface is reduced to accept source, diffStyle, expandUnchanged, collapsed, and optional focus coordinates, dropping status/additions/deletions and all handlers. Component no longer renders DiffFileHeader and configures MultiFileDiff with disableFileHeader: true.
DiffFileEntry header extraction and prop reduction
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/DiffPane/components/DiffFileEntry/DiffFileEntry.tsx
DiffFileEntry builds header element once with DiffFileHeader, all metadata, and interaction callbacks. Header renders unconditionally; WorkspaceDiff receives reduced prop set with only diff-specific data.
DOM attributes and scroll logic alignment
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/DiffPane/components/DiffFileHeader/DiffFileHeader.tsx, apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/DiffPane/DiffPane.tsx
DiffFileHeader adds data-diff-entry-header-path attribute. ScrollToFile queries both entry and header elements separately, using header for offset calculation and entry for line focusing.

🎯 3 (Moderate) | ⏱️ ~25 minutes

🐰 Headers hop away to their own layer,
Props shrink down, the diff viewer lighter,
Scroll finds its path through DOM's bright data,
Structure aligns, components tighter,
This refactor makes the diff pane brighter! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly addresses the main change: improving scroll behavior to target file headers in the changes pane.
Description check ✅ Passed The description provides clear context with summary, root cause, impact, and validation steps, mostly following the template structure despite some auto-generated content.
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.

✏️ 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 changes-pane-scroll-heade

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 16, 2026

Greptile Summary

This PR fixes scroll-to-file in the changes pane by lifting DiffFileHeader out of WorkspaceDiff (which was lazily mounted) into DiffFileEntry (always rendered), and by adding a dedicated data-diff-entry-header-path attribute on the header div that ScrollToFile now uses as the scroll target instead of the full entry wrapper.

  • DiffFileEntry now owns and unconditionally renders DiffFileHeader, so the header is present in the DOM even before the lazy diff body mounts; WorkspaceDiff is simplified to only the diff body and comment annotations.
  • DiffPane / ScrollToFile queries both the entry element (used for subsequent line-focus retry logic) and the new header attribute (used for the initial scroll offset), and early-exits only when either is absent.
  • DiffFileHeader gains a single data-diff-entry-header-path attribute; because the attribute lives on the component itself, the deferred-placeholder code path also picks it up automatically.

Confidence Score: 5/5

Safe to merge — the change is a targeted refactoring that moves header rendering out of the lazily-mounted WorkspaceDiff into DiffFileEntry, with no logic changes to data fetching or state management.

The scroll fix is mechanically sound: the new header attribute is emitted by every render of DiffFileHeader (including the DeferredDiffPlaceholder path), so ScrollToFile will always find both query targets when a file entry is in the DOM. State (collapsed, viewed, expandUnchanged) flows correctly through the lifted header. WorkspaceDiff is only trimmed of props it no longer needs.

No files require special attention.

Important Files Changed

Filename Overview
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/DiffPane/DiffPane.tsx ScrollToFile now queries a dedicated header attribute for the scroll offset and falls back to the entry wrapper only for line-element lookup; logic is correct and handles both deferred and normal paths.
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/DiffPane/components/DiffFileEntry/DiffFileEntry.tsx Header lifted out of WorkspaceDiff; rendered unconditionally before the lazy shouldMount guard, ensuring it's always in the DOM. DeferredDiffPlaceholder retains its own DiffFileHeader call and inherits the new attribute automatically.
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/DiffPane/components/DiffFileHeader/DiffFileHeader.tsx Minimal change: adds data-diff-entry-header-path attribute to the root div; no logic changes.
apps/desktop/src/renderer/routes/_authenticated/_dashboard/v2-workspace/$workspaceId/hooks/usePaneRegistry/components/DiffPane/components/WorkspaceDiff/WorkspaceDiff.tsx DiffFileHeader and all its related props removed; component now only manages diff body and comment annotations.

Sequence Diagram

sequenceDiagram
    participant CP as Changes Pane
    participant SF as ScrollToFile
    participant DOM as DOM
    participant DFE as DiffFileEntry
    participant DFH as DiffFileHeader
    participant WD as WorkspaceDiff

    CP->>SF: path change / focusTick change
    SF->>DOM: querySelector([data-diff-path])
    DOM-->>SF: entry element
    SF->>DOM: querySelector([data-diff-entry-header-path])
    DOM-->>SF: header element
    Note over SF: Abort if either missing
    SF->>SF: getOffsetInScrollContainer(header)
    SF->>DOM: scrollTo(headerOffset)
    Note over SF: focusLine + tickChanged?
    SF->>SF: findLineElement(entry, focusLine)
    SF->>DOM: lineEl.scrollIntoView(center)

    Note over DFE,WD: Render path (after this PR)
    DFE->>DFH: always render header (data-diff-entry-header-path)
    DFE->>WD: "render only when shouldMount=true"
    WD-->>DFE: diff body + comment annotations
Loading

Reviews (1): Last reviewed commit: "fix(desktop): scroll changes pane to fil..." | Re-trigger Greptile

@Kitenite Kitenite merged commit 76242e6 into main May 16, 2026
9 of 10 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ✅ Neon database branch

Thank you for your contribution! 🎉

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