Skip to content

Display SSH worktrees immediately using persisted metadata - #12646

Merged
AmethystLiang merged 2 commits into
mainfrom
show-worktree-hosts-always
Aug 5, 2026
Merged

AmethystLiang merged 2 commits into
mainfrom
show-worktree-hosts-always

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Problem

When SSH is connecting, worktrees aren't shown to the user even though metadata for them is already saved locally. Users see an empty state until the connection is fully established.

Solution

Add a new IPC handler that reads saved worktree metadata without waiting for the live SSH provider. This gets called when fetching worktrees on an SSH repo that's still connecting. The metadata-based worktrees are merged with any existing cached ones, marked as non-authoritative, and never replace richer cached data.

Details

  • New handler worktrees:listKnownForExecutionHost validates repo ownership and host type, then returns persisted metadata
  • Integrated into three fetch paths: single-repo, all-repos, and hydration-time fetches
  • Worktrees merged via appendMissingWorktreesForHost to prevent duplicates by ID
  • Marked with authoritative: false and source: 'metadata-fallback'

Testing

  • pnpm lint — ran oxlint and the max-lines ratchet (node config/scripts/check-max-lines-ratchet.mjs), both clean; the remaining pnpm lint audits (localization catalogs, skill bundles, reliability gates) were not re-run because nothing here touches them
  • pnpm typecheck — all three projects (tsconfig.node.json, tsconfig.tc.web.json, tsconfig.tc.cli.json)
  • pnpm test — full suite, 46,055 / 46,140 passing. None of the 5 failures touch this change: 2 in src/relay/agent-exec-handler.test.ts reproduce on the base commit, and 3 (updater, PowerShell relay upload staging) pass in isolation and only fail under full-parallel load. The suites that do cover this change — renderer worktrees.test.ts, main ipc/worktrees.test.ts, degraded-repo-hydration.test.ts, preload/ssh-authority-forwarding.test.ts — are green
  • pnpm build — not run: no bundler, packaging, or native-module changes
  • Added 5 tests: metadata listing without live access, ambiguous owner rejection, display during connection, merge without replacement, hydration-time fetch

Notes

SSH-only feature. No platform-specific code or cross-platform concerns.

The metadata read is not write-free — it converges to read-only rather than starting there, and it persists on the first call per repo:

  • Folder repos reach listFolderWorkspaces, which calls store.setWorktreeMeta(worktreeId, { instanceId, displayName, lastActivityAt }) for any workspace id lacking a persisted instanceId, and setWorktreeMeta schedules a save.
  • Git repos repair ownership in listDisconnectedSshWorktrees via getProjectHostSetupMetaUpdates (projectId / hostId / projectHostSetupId).

Both writes are idempotent rather than churning: getProjectHostSetupForRepo always synthesizes a setup, so projectHostSetupId is never undefined after the first write and the update object is empty on every later call. Store mutations still happen only after repo-ownership and host validation pass.

Users can now see known worktrees for SSH hosts without waiting for the
provider connection to establish. Worktrees are fetched from local metadata
and displayed as non-authoritative, then merged without replacing richer
live data once the provider becomes available.
@coderabbitai

coderabbitai Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

An error occurred during the review process. Please try again later.

📝 Walkthrough

Walkthrough

Added a host-qualified contract for listing known worktrees for an SSH execution host. Added the corresponding main-process IPC handler and preload bridge. The handler rejects invalid, non-SSH, mismatched, or ambiguous requests. The renderer now validates and merges persisted SSH worktrees when live provider authority is unavailable. Tests cover IPC behavior, preload forwarding, refresh paths, hydration, and preservation of richer cached rows.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the problem, solution, implementation, testing, and scope, but it omits the required Screenshots, AI Review Report, and Security Audit sections. Add the required Screenshots, AI Review Report, and Security Audit sections, and record the completed validation checks.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. 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 summarizes the primary user-visible change: displaying SSH worktrees from persisted metadata before connection completes.
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.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

Add safeguards for metadata fallback: track authoritatively removed
worktrees per host to prevent resurrection, position new rows within
the host block to avoid jumping on authoritative scan arrival, and
preserve co-owner detection status during merge. Coalesce concurrent
metadata fetches to dedupe overlapping queries.
@AmethystLiang
AmethystLiang merged commit 2ff2a1b into main Aug 5, 2026
43 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…12646)

* Display SSH worktrees immediately using persisted metadata

Users can now see known worktrees for SSH hosts without waiting for the
provider connection to establish. Worktrees are fetched from local metadata
and displayed as non-authoritative, then merged without replacing richer
live data once the provider becomes available.

* Show SSH folder workspaces immediately via persisted metadata

Add safeguards for metadata fallback: track authoritatively removed
worktrees per host to prevent resurrection, position new rows within
the host block to avoid jumping on authoritative scan arrival, and
preserve co-owner detection status during merge. Coalesce concurrent
metadata fetches to dedupe overlapping queries.
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