Repository navigation
fix(editor): preserve combined diff scroll on line focus - #23735
Conversation
|
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughThe diff editor options now disable Monaco’s native EditContext behavior. The end-to-end test helper now checks each diff line’s visible intersection and skips points obscured by another element. It returns Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to This change switches combined diff editors to Monaco's textarea input backend so clicking a line no longer scrolls the outer view. No concrete regression was found. Merge readiness is good once the pending CI checks pass. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
There was a problem hiding this comment.
Important
Forcing editContext: false moves the editable combined-diff sections onto Monaco's legacy textarea input path, which carries confirmed upstream input regressions (dropped first keystroke over a backward selection; lost Japanese IME reconversion). Details inline — worth confirming this tradeoff is intended.
Reviewed changes
- Scroll jump fix:
DiffSectionBody.tsxnow setseditContext: false, so focusing a diff line uses Monaco's textarea backend instead of focusing the hidden nativeEditContextnode that scrolls the shared.combined-diff-scroll-containerinto view. - Test hardening:
clickVisibleDiffLinein the combined-diff scroll spec now clips each.view-linerect to the scroll container and hit-tests it withdocument.elementFromPoint, so a sticky header or toolbar can no longer absorb the click and let the scroll assertion pass without ever focusing the editor.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
| keepCurrentModifiedModel | ||
| options={{ | ||
| // Native EditContext focus scrolls its hidden input into the combined viewport. | ||
| editContext: false, |
There was a problem hiding this comment.
Forcing editContext: false fixes the scroll jump, but it also drops every combined diff — including the editable unstaged sections this new test exercises — onto Monaco's legacy textarea input path. On Chromium (this app's Electron runtime) that path has an open upstream bug where the first keystroke over a backward (Shift+Left) selection is swallowed, and it loses EditContext-based Japanese IME reconversion. Please confirm the tradeoff is intended for the editable sections, or consider keeping native EditContext and restoring the container's scrollTop around focus instead.
Technical details
# `editContext: false` regresses input on the editable combined diff
## Affected sites
- `src/renderer/src/components/editor/DiffSectionBody.tsx:170` — sets `editContext: false` for every `DiffSectionBody` editor.
- `src/renderer/src/components/editor/DiffSectionItem.tsx:67` — `isEditable = section.area === 'unstaged'`; `readOnly: !isEditable` (`DiffSectionBody.tsx:171`), so the modified side of an unstaged combined diff is editable.
- `tests/e2e/combined-diff-scroll-restore.spec.ts` — `openCombinedDiff` selects the `unstaged` area, i.e. the editable path, so the spec exercises the affected configuration.
## Why this is introduced here
- monaco-editor 0.55.1 defaults `editContext` to `true` and enables it on Chromium (`node_modules/monaco-editor/esm/vs/editor/common/config/editorOptions.js:3135`, `included: isChrome || isEdge || isNative`), so before this change these editors used the native EditContext backend and these textarea-path defects did not apply.
## Evidence (upstream, against the pinned 0.55.1)
- microsoft/monaco-editor#5448 — typing over a backward selection requires two keypresses on the textarea path; explicit note that "forcing the same path in Chromium with `editContext: false` reproduces it there too".
- microsoft/monaco-editor#5207 — repro is literally `editContext: false`; first keypress is ignored over a backward/RTL selection.
- microsoft/vscode#238643 — turning EditContext off stops reconversion of a selected run of Japanese text via the conversion key.
## Required outcome
- The scroll fix must hold for editable sections while not regressing text input. Either accept the backend tradeoff explicitly, or keep EditContext and neutralise the focus-induced scroll (e.g. save/restore `.combined-diff-scroll-container` `scrollTop` across the focus event).
## Open questions for the human
- Are users expected to actually type into the editable `unstaged` combined diff (vs. read-only branch review), which would make the dropped-keystroke regression user-visible?
ELI5
Clicking a line in a combined diff should keep the code you were reading in place.
What Changed
Combined diff editors use Monaco's textarea input backend. Its focus handling preserves parent scroll positions; native EditContext focuses a hidden input and can scroll the outer combined view to that input.
The scroll-restoration test now clips its click point to the viewport and verifies that it hits the rendered line. Previously it could click a toolbar or sticky header instead, missing the real focus bug.
Why
With the corrected click, the existing scroll assertion failed three consecutive runs using native EditContext, then passed three consecutive runs with the textarea backend. A separate before/after capture reproduced a 1,238-pixel jump before the fix. Switching the supported input backend is narrower than changing scroll restoration or overriding browser focus methods.
Linked Issue
CI failure: https://github.com/stablyai/orca/actions/runs/36497243185/job/109179890307
Visual Proof
Before: clicking after restoring the deep scroll position jumps back to earlier files.
After: clicking preserves the section being read.
Testing
Review
Uses a supported Monaco backend for both editable and read-only combined diffs. Standalone editors, remote protocols, file contents, and test timeouts are unchanged. Combined review surfaces share this editor component.
Agent skill upstream boundary
Checklist