Skip to content

fix: release Markdown document history across workspace visits - #25631

Open
nwparker wants to merge 2 commits into
nwparker/editor-mobile-import-cycle-lintfrom
nwparker/editor-markdown-document-retention
Open

nwparker wants to merge 2 commits into
nwparker/editor-mobile-import-cycle-lintfrom
nwparker/editor-markdown-document-retention

Conversation

@nwparker

@nwparker nwparker commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​212 $\color{#cf222e}{\Huge{\mathbf{−}}}$​9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​203
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​46 $\color{#cf222e}{\Huge{\mathbf{−}}}$​19 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​27

ELI5

A mounted Markdown editor now keeps the document list for its current workspace and host. Previously it retained lists from every workspace it had visited. This also prevents another host's old list from appearing while the current list loads.

What Changed

One current snapshot replaces the per-workspace map. Its identity reuses the existing document-request key, including the runtime owner and SSH connection. Delayed saves and scan results must still belong to the current committed route before they can refresh or replace that snapshot.

This changes one production file (+46/−19, net 27 lines), plus regression tests. No listing algorithm, completion-provider cache, protocol, dependency, or library file changes.

Why

The hook already refreshes when a workspace returns, so retaining its old lists indefinitely is unnecessary. This avoids introducing another cache, eviction policy, or refill mechanism. Same-owner refreshes retain the current list until the new scan finishes.

Cleanup uses the actual installed React/ReactDOM 19.2.8 lifecycle: a temporary Suspense hide removes layout effects while retaining passive effects. The committed key updates in a layout effect; passive unmount cleanup clears it. React's public Suspense contract describes that distinction. The public createRoot/Suspense regression reproduced a dropped response before this correction.

Linked Issue

Addresses only the renderer-history portion of Neil (@nwparker) and Orca's #10990, whose source and cache/refill proposal were reviewed. Its producer-budget problem remains open. The existing Monaco model-swap/unmount cleanup and VS Code's suggestion lifetime were checked before choosing this smaller change.

Visual Proof

N/A — this changes background retention and routing, without a layout or styling change. The real React hook GC check and compiled navigation checks provide behavior evidence.

Actual hook check Before After
Retained document arrays after 40 workspace visits and forced GC 40 At most 2 current/alternate React snapshots

Testing

  • 32 tests across four focused suites, using real React roots. Includes owner/SSH changes, revisit retention, forced GC, an old save finishing after a successor scan starts or finishes, permanent unmount, Strict Mode replay, and a scan resolving during Suspense.
  • Fresh compiled macOS Electron: all four relative/wiki, plain/anchored preview navigation flows pass. Apps ran hidden with ORCA_BACKGROUND_LAUNCH=1 and exited afterward.
  • Full node/web/CLI typecheck, full lint, changed-code quality, standalone React Doctor 0.9.14 and a fresh E2E build pass.

Review

Two independent source reviews caught and verified fixes for the delayed-save and Suspense regressions before publication. Tests exercise the hook and public React behavior rather than checking source text.

Agent skill upstream boundary

  • Not applicable; no upstream skill source copied or translated.

Notes

Risk is low for this renderer-history scope, pending combined-branch checks. Returning to an earlier workspace waits for its existing fresh scan instead of immediately showing its old index. A single large current listing is still unbounded; this PR does not solve producer memory limits. Native Windows/Linux, actual SSH UI and physical mobile devices were not exercised for this change. Folder-path discovery is unchanged.

Checklist

  • Focused change; production and test lines separated.
  • User behavior, mechanism and approach explained.
  • No visual layout change; behavior evidence above.
  • Self-reviewed and independently reviewed against source.
  • Platform, remote and folder-workspace limits stated.
  • Typecheck, lint, tests, quality gates and fresh build pass.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — two commits replacing the per-worktree Markdown document map with a single keyed snapshot in useMarkdownDocuments, plus regression tests.

  • Single keyed snapshot — src/renderer/src/components/editor/useMarkdownDocuments.ts holds one { requestKey, documents } snapshot instead of a Record<worktreeId, MarkdownDocument[]>; markdownDocuments returns it only when its key equals the current route's documentRequestKey.
  • Committed-route guard — currentRequestKeyRef (updated in a useLayoutEffect, cleared only by the passive unmount cleanup) gates both the pre-scan early return and the post-await commit, so a scan or save belonging to a superseded workspace cannot refresh the current view.
  • Regression tests — useMarkdownDocuments.navigation.test.ts adds owner/SSH key isolation, prior-workspace discard, StrictMode replay, permanent-unmount save, Suspense reveal, and a forced-GC retention bound.

Verified locally: the three related suites pass (22 + 2 + 12 tests), pnpm tc:web is clean, and the changed-code quality gate reports 0 new findings. A lifecycle review against React/react-dom 19.2.8 found no mounted-hook path that permanently blocks a legitimate refresh or drops a valid scan result; the layout-effect key update runs before the passive refresh effect on every commit, and a Suspense hide preserves passive effects while re-running layout effects on reveal.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

This branch has not been deployed

No deployments
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