Skip to content

fix(editor): isolate restored PDF and media reading positions - #34941

Closed
OrcaWin wants to merge 2 commits into
mainfrom
OrcaWin/editor-pdf-owner-scroll
Closed

OrcaWin wants to merge 2 commits into
mainfrom
OrcaWin/editor-pdf-owner-scroll

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 28, 2026 •

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

Restored PDF tabs use the file path as their scroll-cache key, so two workspace owners of the same path inherit each other's reading position. The same default key also backs media playback progress. Explicit split-tab IDs already isolate newly created tabs; the bug is reachable through supported saved-session tabs whose view ID equals the file ID.

Use the existing file-view preference key for the default PDF/media position scope. It includes workspace, runtime environment, external SSH target, and path, so closing a raw-path tab and later reusing its ID in another workspace also stays separate. Keep explicit split-pane scopes unchanged. Position caches retain their existing bounds; no schema or transport changes are introduced.

Actual Linux Electron reproduction uses a local Git worktree and a local folder workspace reading the same on-disk PDF. Tabs are restored through the public session hydration actions, and each viewer is unmounted by selecting another text tab before returning:

Step Before After
Original worktree, page 2 1166 px 1166 px
Folder workspace, first open 1166 px (inherits page 2) 0 px (page 1)
Folder workspace, after page 3 scroll 2232 px 2232 px
Return to original worktree 2232 px (overwritten) 1166 px
Return to folder workspace 2232 px 2232 px

Before, folder workspace incorrectly opens on page 2:

Before: folder inherits the worktree reading position

After, folder workspace starts on page 1:

After: folder starts with an independent reading position

Validation:

  • Original actual-component regression: six failing ownership cases, two passing split controls. Final suite adds two cases for a legacy raw-path ID reused by a later workspace.
  • All 64 focused tests pass across the final ownership suite, PDF position controls, and viewer reload/recovery suite.
  • Three successful fixed fresh-app runs preserve the measured offsets. One additional initial attempt was interrupted when renderer/network processes exited; the fresh retry passed. The final version of the rendered test also passes after replacing fixed sleeps with render-frame progression.
  • A normal newly created-tab control passes on the original code, confirming the scope is restored/default view IDs.
  • The exact final commit passes all 22 changed-file checks (ORCA_BACKGROUND_LAUNCH=1 pnpm check:changed --maxWorkers=2, 717.8 s), including formatting, lint, typecheck, affected tests, and ratchets.

Apps remained hidden on an isolated display. This measures PDF behavior on Linux with local disk reads; media ownership and paired-runtime/workspace key cases are component-tested. Live SSH, macOS, Windows, mobile, and codec playback were not executed.

@OrcaWin

OrcaWin commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator Author

Closing after an adversarial review pass (correctness + value lenses, judged per cluster).

Folded into #34816. The bug is real but narrow: the default-pane PDF/media position key is ${filePath}:pdf when the tab id equals the file id, so same-path owners share it. The fix belongs next to #34816's matching one-line editorViewStateKey change, with one owner-scoping scheme (activeFile.id, as the diff and preview keys already use) rather than a second scheme based on preference keys. The PR also adds 351 lines of tests (a 225-line e2e spec and a 126-line component test that string-matches the lazy factory) for a two-line change. Closing comment: "Thanks. Folding the one-line pdfViewStateKey fix into #34816 so every default-pane view-state key in EditorContent uses the same owner-scoped id scheme. The e2e spec and the large component test are not being carried over."

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