Skip to content

Reset explorer files when switching remote hosts at the same path - #26627

Merged
OrcaWin merged 1 commit into
mainfrom
nwparker/remote-explorer-host-cache
Oct 9, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
nwparker/remote-explorer-host-cache

Conversation

@nwparker

@nwparker nwparker commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​179 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​176
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​27 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​24

ELI5

Two remote machines can have the same folder ID and path. Switching machines now replaces the explorer's cached tree, so you see the selected machine's files.

What Changed

Before, clicking the other host's folder changed the active host and successful file reads, but Files kept the previous host's root and expanded directory contents. The existing reset checked only the absolute path.

The explorer now keys its existing component by the canonical operation owner. A host change replaces its cache, selection and watch lifetime. Retirement invalidates pending directory reads through the existing generation and load tokens, and initial loading handles React StrictMode replay. Hiding and reopening Files on the same host preserves its tree.

Why

Ownership already has a shared resolver. Using its identity for the component lifetime keeps all explorer state together, rather than adding separate host-reset rules to each cache and interaction hook. Existing path resets still handle workspace changes on the same host.

Linked Issue

Found during SSH → Remote consolidation testing; no existing issue.

Visual Proof

Two valid, independently converted Linux SSH hosts publish the same folder ID and path. The identical baseline switches host successfully and reads the new host's sentinel, but retains the old root and nested listing. Corrected runs display the new host's root and expanded nested files in both directions.

explorer-host-cache-a-to-b-before-final.png
explorer-host-cache-a-to-b-after-final.png
explorer-host-cache-b-to-a-before-final.png
explorer-host-cache-b-to-a-after-final.png
explorer-host-cache-runtime-red-final.log
explorer-host-cache-runtime-green-final.log

Testing

  • Hidden macOS Electron client, two owned Linux Docker SSH hosts and the installed production server template.
  • Added directory-read retirement, StrictMode replay and same-host hide/reopen controls; expanded the existing dedicated Docker journey and its CI routing.

Untouched parent baseline fails both switch directions in 29.5 / 29.4 s. Fresh corrected runs pass in 19.7 / 19.8 s (41.6 s total), including selected-host creation/deletion, actual sidebar switches, already-expanded nested directories, switching back, and hide/reopen.

The two new retirement regressions fail before the fix; StrictMode and hide/reopen controls already pass. All 230 tests / 19 files pass afterward. Full pnpm tc, pnpm lint, changed quality, standalone React Doctor, fresh E2E build and commit hooks pass.

Combined stack verification: C18–C21 rebased on #26637/#26645 preserves their renderer changes exactly. 547 tests / 49 files, full typecheck/lint, changed quality (including React Doctor/design-system checks), a fresh E2E build and both real-host switch directions pass. CI reruns on the new head; prior green results are not claimed for it.

Review

Stacked on #26616; merge #26637 → #26645 → #26616 first. Its selected-host watcher snapshot fix is required for this journey's creation/deletion controls. This PR isolates equal-path host-switch cache lifetime and cancellation.

Agent skill upstream boundary

  • Not applicable; no upstream skill-installer source or resources copied.

Notes

No server or wire change. Runtime coverage is macOS client / Linux SSH hosts; Windows was not exercised. All host writes target disposable fixtures. Shared watcher target selection and sidebar active highlighting are separate investigations.

Checklist

  • Small, focused change
  • ELI5, user-facing before/after, mechanism and approach explained
  • Before/after screenshot pairs and runtime logs attached
  • Self-reviewed for correctness, security and performance
  • Cross-platform, SSH ownership, folder workspaces and paths considered
  • Local lint, typechecks, affected tests and fresh build pass

@nwparker
nwparker force-pushed the nwparker/remote-explorer-selected-host branch from c06c5fb to d097934 Compare October 8, 2026 18:56
@nwparker
nwparker force-pushed the nwparker/remote-explorer-host-cache branch from e4d139a to a4d4c9f Compare October 8, 2026 18:56
@OrcaWin
OrcaWin force-pushed the nwparker/remote-explorer-selected-host branch from d097934 to e0d99fa Compare October 9, 2026 02:27
@OrcaWin
OrcaWin requested a review from brennanb2025 as a code owner October 9, 2026 02:27
@OrcaWin
OrcaWin force-pushed the nwparker/remote-explorer-host-cache branch from a4d4c9f to 40378b3 Compare October 9, 2026 02:27
@OrcaWin
OrcaWin force-pushed the nwparker/remote-explorer-selected-host branch from e0d99fa to 53d0e31 Compare October 9, 2026 06:03
@OrcaWin
OrcaWin force-pushed the nwparker/remote-explorer-host-cache branch 2 times, most recently from 804f466 to 3d577f3 Compare October 9, 2026 06:10
@OrcaWin
OrcaWin force-pushed the nwparker/remote-explorer-selected-host branch from 53d0e31 to 0f6dfc4 Compare October 9, 2026 06:10
@OrcaWin
OrcaWin force-pushed the nwparker/remote-explorer-host-cache branch from 3d577f3 to 4b49611 Compare October 9, 2026 09:18
@OrcaWin
OrcaWin force-pushed the nwparker/remote-explorer-selected-host branch 2 times, most recently from 16eb5c0 to 0bb7200 Compare October 9, 2026 11:44
@OrcaWin
OrcaWin changed the base branch from nwparker/remote-explorer-selected-host to main October 9, 2026 12:06
@OrcaWin
OrcaWin force-pushed the nwparker/remote-explorer-host-cache branch 2 times, most recently from 27abb81 to 8085a9e Compare October 9, 2026 12:06
@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 880ab904-3a8d-45cf-b016-13fca868c7c2

📥 Commits

Reviewing files that changed from the base of the PR and between 6c20143 and 8085a9e.


📒 Files selected for processing (7)
  • config/scripts/ci-e2e-job-selection.test.mjs
  • config/scripts/pr-e2e-source-routing.mjs
  • src/renderer/src/components/right-sidebar/FileExplorer.tsx
  • src/renderer/src/components/right-sidebar/use-file-explorer-tree-load-effects.ts
  • src/renderer/src/components/right-sidebar/useFileExplorerTree.lifecycle.test.tsx
  • src/renderer/src/components/right-sidebar/useFileExplorerTree.ts
  • tests/e2e/ssh-orcad-explorer-selected-host.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.



📝 Walkthrough

Walkthrough

The explorer subtree is now keyed by the active worktree’s operation owner. Tree cleanup resets its directory-load tracker and invalidates pending refreshes. New lifecycle tests cover unmounts, StrictMode, and sidebar reopening. The selected-host E2E test now checks nested files across host switches and sidebar reopening. E2E routing and its test include explorer source changes.


Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 8085a

The explorer changes and their selected-host test routing show no identified issue requiring a fix before merge.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check Warning The description is detailed and covers the change, rationale, testing, visual proof, compatibility notes, and checklist. However, the required Linked Issue section does not contain an actual issue lin… Add the actual issue link that this pull request fixes, or confirm that the author is a repository maintainer and the template exception applies.
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: resetting explorer state when switching remote hosts that use the same path.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

Full details: Description check

Explanation

The description is detailed and covers the change, rationale, testing, visual proof, compatibility notes, and checklist. However, the required Linked Issue section does not contain an actual issue link and instead states that no issue exists.



  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR


  • 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.

@OrcaWin
OrcaWin merged commit 941c8d8 into main Oct 9, 2026
39 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.

2 participants