Repository navigation
feat: preserve scroll, cursor, and undo across tab switches - #421
Merged
Merged
Conversation
…witches
Monaco editors now save and restore scroll position, cursor position,
and undo history when switching between tabs, instead of resetting to
the top of the file each time.
Changes:
- Add cursorPositionCache alongside existing scrollTopCache (LRU, 20 entries)
- Save cursor on every cursor move and snapshot scroll+cursor on unmount
via useLayoutEffect cleanup (runs before editor disposal)
- Restore scroll+cursor on mount via requestAnimationFrame (after layout)
- Add keepCurrentModel to MonacoEditor so undo history survives unmount
- Add keepCurrentOriginalModel/keepCurrentModifiedModel + scroll
save/restore to DiffViewer
- Add key={activeFile.id} on DiffViewer to force unmount/remount on
tab switch (triggers save/restore lifecycle)
- Dispose kept-alive models and clear caches when tabs are closed
(EditorPanel cleanup effect)
The revert in 94ac805 removed a guard that prevented scrollTop=0 from clobbering valid cached positions during React StrictMode double-mount. Restore the guard in useEditorScrollRestore and MarkdownPreview, and clean up :rich/:preview scoped cache keys on tab close.
brennanb2025
force-pushed
the
brennanb2025/preserve-scroll-position
branch
from
April 13, 2026 22:09
6370531 to
fa50532
Compare
enrick-dev
pushed a commit
to enrick-dev/orca
that referenced
this pull request
Oct 15, 2026
Thundernerd
added a commit
to Thundernerd/orca
that referenced
this pull request
Nov 18, 2026
… of tickets Each implemented ticket handed over one to three findings in the area it had just touched, and each of those did the same, so the tracker filled with narrowing variations on one theme (on Cronk: stablyai#421 → stablyai#430 → stablyai#442/stablyai#443 → stablyai#448/stablyai#454 → stablyai#460/stablyai#461, and similar chains for closing, query binding and From Transcript kinds). Some were review points on code still on the unmerged branch (stablyai#450, stablyai#453) or /code-review judgement calls (stablyai#467). - The implementing brief, local and cloud, now counts only real bugs and gaps as findings. Problems in code the branch adds are fixed in its PR; judgement calls, tidy-ups and further passes over freshly reworked code are left with a reason in the report instead of handed over. - The finding check also searches tickets closed in the last two weeks and the findings already filed up the "Found while implementing" chain, and files nothing for code that exists only on the origin's branch. - A finding whose title is already recorded on its origin is not filed again, which is how stablyai#431 duplicated stablyai#430. - The filed body no longer repeats "Found while implementing" and the triage line when the agent's draft already opens with them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cursorPositionCachealongside existingscrollTopCache(module-scoped Maps with LRU eviction at 20 entries)keepCurrentModel/keepCurrentOriginalModel/keepCurrentModifiedModelto retain Monaco models (and their undo stacks) across unmount/remountChanges
scroll-cache.tscursorPositionCachemapMonacoEditor.tsxuseLayoutEffect), restore both on mount (requestAnimationFrame), addkeepCurrentModelDiffViewer.tsxfilePathprop, throttled scroll save/restore,useLayoutEffectunmount snapshot,keepCurrentOriginalModel/keepCurrentModifiedModel, stable model pathsEditorContent.tsxkey={activeFile.id}andfilePathon<DiffViewer>to force unmount/remount on tab switchEditorPanel.tsxTest plan
Verified via Electron CDP automation (Chrome DevTools Protocol against the running app) — 9/9 tests passed:
pushEditOperationsmodel.undo()reverts the insertmodel.undo()still works after switching tabs and back (keepCurrentModelpreserves undo stack)