Repository navigation
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
Included review availability: Your plan includes up to 10 reviews per rolling hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe change adds a ProseMirror selection cache for rich Markdown editors. The editor saves selections during cleanup and restores clamped ranges after remounts. Ordinary autofocus preserves restored text selections, while forced handoffs and non-text selections focus at the document start. Closed edit tabs remove their related cache entries. Tests cover caching, restoration, autofocus, cleanup, and tab switching. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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.
🧹 Nitpick comments (1)
src/renderer/src/components/editor/rich-markdown-auto-focus.ts (1)
38-44: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCondense the new focus comment.
Use one concise comment for the selection rule. Remove the standalone
//marker.Proposed cleanup
- // Why: a freshly-created empty document has an AllSelection, so focus it at - // the start to render a normal caret. Ordinary remounts may already have a - // restored TextSelection, which null preserves instead of resetting it. - // Explicit handoffs still start at position 1. + // Preserve restored TextSelection unless a forced or non-text selection needs 'start'. const focusPosition = force || !(nextEditor.state.selection instanceof TextSelection) ? 'start' : null - //As per coding guidelines, “Comments must be concise, non-obvious, and brief—prefer one line.”
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: e8c06bf3-a8c1-40ad-9c4c-b4dcdbf59540
📒 Files selected for processing (8)
src/renderer/src/components/editor/rich-markdown-auto-focus.test.tssrc/renderer/src/components/editor/rich-markdown-auto-focus.tssrc/renderer/src/components/editor/useClosedEditorTabCleanup.test.tsxsrc/renderer/src/components/editor/useClosedEditorTabCleanup.tssrc/renderer/src/components/editor/useEditorScrollRestore.test.tsxsrc/renderer/src/components/editor/useEditorScrollRestore.tssrc/renderer/src/lib/scroll-cache.test.tssrc/renderer/src/lib/scroll-cache.ts
Included review availability: Your plan includes up to 10 reviews per rolling hour; 9 remain after this review.
ELI5
Switching away from a rich Markdown file and back now returns the caret and selection to the same place instead of resetting them to the start.
What Changed
Why
Monaco already snapshots scroll and cursor state synchronously, and the rich editor already restores scroll state. The missing piece was ProseMirror selection state. A restored selection also had to be coordinated with the existing deferred autofocus; otherwise the next animation frame moved it back to the document start.
Windows Electron validation caught one additional focus handoff: after clicking the original tab, the restored ProseMirror selection was correct internally but the tab element still owned DOM focus, so no native selection was visible. Commit
4bf7e1e54allows that specific tab-to-editor handoff and adds E2E coverage for it.This keeps the existing pane-scoped key design, so two panes showing the same file retain independent view state.
Linked Issue
Fixes #14800
Visual Proof
Windows Electron, rich Markdown editor, A → B → A:
The final capture shows the same native blue highlight after the original editor was unmounted and remounted.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Windows Electron Playwright E2E: 1 passed; native
window.getSelection()restored after A → B → A.Windows Electron E2E build: passed.
Focused Vitest: 2 files, 13 tests passed on Windows and in the remote Linux container.
Oxfmt check: changed files passed.
Native-plugin and type-aware Oxlint: 0 warnings, 0 errors on Windows and remote Linux.
Remote Linux container: Node 24, pnpm 10.24.0, offline cached install.
Full renderer typecheck was attempted previously in a 2.2 GiB container but did not complete because the compiler entered sustained memory pressure; CI/full-suite checks remain pending.
AI Disclosure
OpenAI Codex (GPT-5) was used for repository inspection, implementation, test development, and code review. The submitted diff was independently reviewed twice, and the author remains responsible for the changes.
Review
Checklist
Author