Skip to content

fix(desktop): scroll expanded diffs to the first change - #10014

Open
ViktorBystrov72 wants to merge 1 commit into
ParadevAI:mainfrom
ViktorBystrov72:fix/diff-first-change
Open

ViktorBystrov72 wants to merge 1 commit into
ParadevAI:mainfrom
ViktorBystrov72:fix/diff-first-change

Conversation

@ViktorBystrov72

@ViktorBystrov72 ViktorBystrov72 commented Nov 19, 2026 •

Copy link
Copy Markdown

What & why

Opening a long file from Changes can leave the diff at the file header when Show all lines is enabled. The first changed row can be far below the viewport.

A file click now targets the first changed row once its patch loads. A deletion-only hunk uses its deleted line. An explicit line target still takes precedence, and the folded view continues to start at the file header.

Refs #7978, which also reproduces in the current workspace Changes pane.

How I tested it

Automated CDP mouse input in an isolated macOS dev desktop with two 1,500-line files. With Show all lines enabled, clicking late-change.txt stayed on line 1 before the fix. After the fix, the same click showed the first change at line 1400.

Before After
The diff stays at line 1 The diff shows the changed row at line 1400

The dev run also verified a deletion-only file, wheel scrolling followed by a second click on the same file, and the folded view. No renderer console errors were recorded during the measured interactions. Deletion-only diff at line 1300

  • The new late-load and deletion regressions failed before the fix. All 69 DiffPane tests passed after the fix, including explicit line navigation.
  • bun run lint:fix, clean bun run lint, and bun run typecheck passed. Typecheck completed 42/42 tasks.
  • TERM=xterm-256color bun run test --continue=always completed 29/32 tasks, including all 9,109 desktop tests. The six host-service failures passed in a serial rerun. The shared BYHOUR timezone test and two agent-setup system-CLI fallback tests still fail locally.

Codex assisted with implementation and automated verification.

Checklist

  • PR title follows conventional commits (type(scope): subject)
  • bun run lint and bun run typecheck pass (CI fails on lint warnings too)
  • "Allow edits from maintainers" is checked on fork PRs
  • I have signed the CLA (the bot asks on your first PR)

Summary by cubic

Fixes diff scrolling so clicking a file with Show all lines enabled scrolls to the first changed row once its patch loads. Deletion-only hunks target the deleted line, explicit line targets keep precedence, and the folded view still starts at the file header. Refs #7978.

Written for commit 971e845. Summary will update on new commits.

View guided diff

Summary by CodeRabbit

  • Bug Fixes
    • Diff views with expanded unchanged sections now scroll to the first changed line when no specific line is selected.
    • Explicit line focus remains the priority, and scrolling waits until the relevant diff content is available.
    • File-level positioning is applied before scrolling to a specific line.

@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 46f412a2-4d5d-4e7f-b083-1be63155a573
Commits

Reviewing files that changed from the base of the PR and between c8fbbdf and 971e845.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The diff scroll hook now supports deriving a line target from the first changed line when unchanged regions are expanded. It queues the file target before the line target. Tests cover explicit focus, pending diff loading, deletion-only hunks, and folded unchanged lines.

Changes: Diff scroll targeting

Layer / File(s) Summary
Resolve and queue diff scroll targets
apps/desktop/src/renderer/routes/_authenticated/_dashboard/workspace/$workspaceId/hooks/usePaneRegistry/components/DiffPane/DiffPane.tsx, apps/desktop/src/renderer/routes/_authenticated/_dashboard/workspace/$workspaceId/hooks/usePaneRegistry/components/DiffPane/hooks/useDiffCodeViewScroll/*
The hook accepts expandUnchanged, derives a line target from the first hunk when applicable, and queues the file target before the line target. DiffPane passes the theme setting. Tests cover explicit focus, pending diff loading, deletion-only hunks, and folded unchanged lines.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: kitenite, saddlepaddle

Merge Risk: Minimal · previous review a0a26

Clicking a file in Changes with Show all lines enabled now scrolls to its first changed row. The change is small and localized to the diff scroll hook, and no merge-blocking issue was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(desktop): scroll expanded diffs to the first change" follows conventional commit format and matches the main change. With Show all lines enabled, clicking a file now scrolls to its firs…
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.
Description check Passed The description follows the repository template closely. It has the 'What & why' section, which explains the bug (diff stays at file header with Show all lines enabled), the fix (first changed row tar…
Full details: Title check

Explanation

The title "fix(desktop): scroll expanded diffs to the first change" follows conventional commit format and matches the main change. With Show all lines enabled, clicking a file now scrolls to its first changed row once the patch loads, and the diff hook and DiffPane changes implement this.

Full details: Description check

Explanation

The description follows the repository template closely. It has the 'What & why' section, which explains the bug (diff stays at file header with Show all lines enabled), the fix (first changed row targeted after patch loads, deletion-only hunks use deleted line, explicit line target precedence, folded view unchanged), and links issue #7978. It has the 'How I tested it' section with concrete steps (CDP mouse input on macOS dev desktop, two 1,500-line files), before/after screenshots, regression test results, lint/typecheck results, and full test-suite results with known local failures explained. The checklist is filled in. Minor gaps: the PR title is not shown in the description, and the checklist marks lint and typecheck as passing even though the author states the full test run had known local failures. These gaps are not critical.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ebea64a8-e499-4717-9c8e-98002cfb2574
Commits

Reviewing files that changed from the base of the PR and between f64e718 and a0a26d5.

Files selected for processing: 3

  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/workspace/$workspaceId/hooks/usePaneRegistry/components/DiffPane/DiffPane.tsx
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/workspace/$workspaceId/hooks/usePaneRegistry/components/DiffPane/hooks/useDiffCodeViewScroll/useDiffCodeViewScroll.test.ts
  • apps/desktop/src/renderer/routes/_authenticated/_dashboard/workspace/$workspaceId/hooks/usePaneRegistry/components/DiffPane/hooks/useDiffCodeViewScroll/useDiffCodeViewScroll.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

This branch has not been deployed

No deployments
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