fix(desktop): scroll expanded diffs to the first change
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 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, cleanbun run lint, andbun run typecheckpassed. Typecheck completed 42/42 tasks.TERM=xterm-256color bun run test --continue=alwayscompleted 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 lintandbun run typecheckpass (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.
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.

