Skip to content

fix(diff): keep scroll restore armed through layout shifts - #10615

Merged
AmethystLiang merged 2 commits into
mainfrom
fix-diff-scroll-restore
Jul 25, 2026
Merged

AmethystLiang merged 2 commits into
mainfrom
fix-diff-scroll-restore

Conversation

@AmethystLiang

Copy link
Copy Markdown
Contributor

Summary

  • Preserve the combined diff's within-section scroll position while a remounted viewer converges after tab switches.
  • Keep an in-flight anchor restore armed through measurement-driven viewport shifts; genuine unmarked user scrolls still disarm it through the scroll listener.
  • Add a revert-proven unit regression for the dropped retry.

Screenshots

No visual change to capture; this restores the existing scroll-position behavior.

Testing

  • npx oxfmt --check -c .oxfmtrc.json src/renderer/src/hooks/useVirtualizedScrollAnchor.ts src/renderer/src/hooks/useVirtualizedScrollAnchor.marks-restore-signal.test.ts
  • npx oxlint src/renderer/src/hooks/useVirtualizedScrollAnchor.ts src/renderer/src/hooks/useVirtualizedScrollAnchor.marks-restore-signal.test.ts
  • npx tsc --noEmit -p config/tsconfig.node.json --composite false
  • npx tsc --noEmit -p config/tsconfig.web.json --composite false
  • npx vitest run --config config/vitest.config.ts src/renderer/src/hooks src/renderer/src/components/sidebar --reporter=dot (2,036 tests)
  • npx electron-vite build --mode e2e
  • Combined diff scroll restore E2E on macOS: one normal run plus --repeat-each=3 (4/4 passed)
  • Added a regression test that fails against the previous condition (expected 1 to be greater than 1) and passes with the fix

AI Review Report

An independent read-only AI review found no issues. It checked the pending-restore state machine, verified that unmarked user input still wins through the listener disarm, confirmed marked restore and virtualizer writes remain programmatic, and confirmed WorktreeList is behaviorally unchanged because it does not pass restoreSignal.

Cross-platform review covered macOS, Linux, Windows, SSH, and folder workspaces. This renderer-local DOM state change touches no shortcuts, labels, paths, shell behavior, Git behavior, transport, or platform-specific Electron APIs.

Security Audit

No security-sensitive surface changed. The patch adds no input handling, command execution, path handling, authentication, secrets, dependencies, IPC, or network behavior.

Notes

  • Related to [Other]: main E2E has been red for 24 consecutive scheduled runs #10519.
  • WorktreeList remains on the legacy every-measurement restore path, so the one-shot signal consumption fixed here cannot strand the sidebar consumer.
  • The scheduled failure is timing-dependent on Linux CI. The macOS passes validate local behavior but cannot prove the Linux fix; CI remains the authoritative check.

@coderabbitai

coderabbitai Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c9ff0564-dde9-4ebb-be60-ab718594d739

📥 Commits

Reviewing files that changed from the base of the PR and between f13d22c and d2f3ed8.

📒 Files selected for processing (1)
  • src/renderer/src/hooks/useVirtualizedScrollAnchor.marks-restore-signal.test.ts

📝 Walkthrough

Walkthrough

Updated useVirtualizedScrollAnchor so viewport clamp handling is skipped while a restore is pending, allowing restoration to continue through layout-driven movement. Added a Vitest case that changes scrollTop during convergence and verifies additional restore and measurement attempts occur.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: keeping scroll restore armed through layout shifts.
Description check ✅ Passed The description includes all required sections and gives a clear summary, testing, AI review, security, and notes.
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

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 27fc413c-bd8b-4f6e-823f-4734f29a4174

📥 Commits

Reviewing files that changed from the base of the PR and between e564603 and f13d22c.

📒 Files selected for processing (2)
  • src/renderer/src/hooks/useVirtualizedScrollAnchor.marks-restore-signal.test.ts
  • src/renderer/src/hooks/useVirtualizedScrollAnchor.ts

Verify that a converging restore withstands layout shifts and continues
retrying, while unmarked user scroll disarms the restore attempt. Stabilize
marks and offset objects across renders to preserve the bookkeeping state
that guards restoration retries.
@AmethystLiang
AmethystLiang merged commit 97175ed into main Jul 25, 2026
1 check passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…10615)

* fix(diff): keep scroll restore armed through layout shifts

* test: add scroll-restore convergence and user-scroll disarm cases

Verify that a converging restore withstands layout shifts and continues
retrying, while unmarked user scroll disarms the restore attempt. Stabilize
marks and offset objects across renders to preserve the bookkeeping state
that guards restoration retries.
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