Skip to content

fix(editor): isolate restored reading positions by file owner - #34816

Merged
OrcaWin merged 1 commit into
mainfrom
OrcaWin/editor-host-view-state
Oct 29, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
OrcaWin/editor-host-view-state

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​27 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​27
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 0

Problem

EditorContent keyed default-pane reading positions by filePath when the view-state scope equals the file id. Two open files with the same absolute path but different owners (different runtime hosts, or different worktrees using owned editor:<wt>:<runtime>:<path> ids) therefore shared one entry for Monaco cursor/scroll, the derived rich-markdown and notebook scroll keys, and PDF/media scroll/playback position. Switching between them restored the other owner's position.

This branch is only taken when the tab id equals the file id: legacy/restored tabs without an entityId (hydration falls back to tab.id) and the legacy no-layout editor surface. Normally created tabs have UUID ids and already use the per-tab ${filePath}::${tabId} key.

Fix

Key the default-pane editor and PDF/media view state by activeFile.id, matching the diff and markdown-preview keys that already do. Local files have id === filePath, so their keys are unchanged. These caches are in-memory only, so there is no migration or mixed-version concern. Folds in the PDF/media key change from #34941.

Test

  • Added a regression case in EditorContent.monaco-lifecycle.test.tsx: two owners of the same path get different view-state keys (fails on main).
  • pnpm check:changed --maxWorkers=2 passes.

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 7 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7fdecfcd-c56a-4e4c-9748-abcae7703ea1
Commits

Reviewing files that changed from the base of the PR and between b2feed0 and 93b3e6b.

Files selected for processing: 2
  • src/renderer/src/components/editor/EditorContent.monaco-lifecycle.test.tsx
  • src/renderer/src/components/editor/EditorContent.tsx
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

The PR separates restored reading positions for files that share a path but have different owners.

  • The editor keeps saved positions separate for same-path files owned by different hosts.

No actionable issues were found. Tests were not run during this review.

Reviews (2) · Last reviewed commit: "fix(editor): scope default-pane reading ..." · Reviewed by Greptile

Same-path files with different owners (runtime hosts or worktrees) shared
Monaco, rich-markdown, notebook, and PDF/media reading positions when the
tab id equals the file id. Key them by file id, matching the diff and
markdown preview keys.
@OrcaWin
OrcaWin force-pushed the OrcaWin/editor-host-view-state branch from 2eed67e to 93b3e6b Compare October 29, 2026 00:27
@OrcaWin
OrcaWin merged commit 3b81adb into main Oct 29, 2026
35 checks passed
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