Repository navigation
Conversation
|
Ready to review this PR? Stage has broken it down into 9 individual chapters for you: Chapters generated by Stage for commit 8814267 on Jun 22, 2026 7:44pm UTC. |
📝 WalkthroughWalkthroughThis PR introduces composite (executionHostId + repoId) repo identity and canonical host-qualified worktree IDs across the storage, runtime, and renderer layers. Same-id repos on different runtime hosts become distinct entries via composite identity keys in reconciliation, merging, reordering, and mutation paths. A new Worktree IDs shift from legacy 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Warning Tools execution failed with the following error: Failed to run tools: 8 RESOURCE_EXHAUSTED: Received message larger than max (324474373 vs 209715200) 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
src/renderer/src/store/slices/repo-identity-reconcile.ts (1)
47-49: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick winDocument the composite identity delimiter contract inline.
getRepoIdentityKeyon Line 47 encodes a non-obvious contract (host + "\0" + repo.id). Please add a short why-comment so future edits don’t accidentally drift from the cross-host identity rule.Suggested patch
function getRepoIdentityKey(repo: Repo): string { + // Why: repo ids can collide across execution hosts; keying by host + id + // keeps reconciliation stable for same-id repos across hosts. return `${getRepoExecutionHostId(repo)}\0${repo.id}` }As per coding guidelines, "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does."
Source: Coding guidelines
src/renderer/src/store/slices/repo-reorder-host-split.ts (1)
28-41: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick winAdd a short rationale comment for the per-id host queue behavior.
The queue-on-duplicate logic on Line 28 and Line 41 is core to same-id multi-host correctness but not obvious at a glance; please add a 1–2 line why-comment.
Suggested patch
const focusedHostId = getSettingsFocusedExecutionHostId(settings) + // Why: the same repo id can exist on multiple hosts; queue host ids so each + // ordered id occurrence is assigned to the next matching host instance. const hostIdsByRepoId = new Map<string, string[]>()As per coding guidelines, "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does."
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: a7ae1cc3-783c-4e61-8499-3ba4679dd0ff
📒 Files selected for processing (13)
src/renderer/src/lib/repo-runtime-owner.test.tssrc/renderer/src/lib/repo-runtime-owner.tssrc/renderer/src/store/slices/project-host-setup-compatibility-merge.test.tssrc/renderer/src/store/slices/project-host-setup-compatibility-merge.tssrc/renderer/src/store/slices/repo-host-refresh-merge.test.tssrc/renderer/src/store/slices/repo-host-refresh-merge.tssrc/renderer/src/store/slices/repo-identity-reconcile.test.tssrc/renderer/src/store/slices/repo-identity-reconcile.tssrc/renderer/src/store/slices/repo-reorder-host-split.test.tssrc/renderer/src/store/slices/repo-reorder-host-split.tssrc/renderer/src/store/slices/repos-multi-host-refresh.test.tssrc/renderer/src/store/slices/repos-same-id-host-mutations.test.tssrc/renderer/src/store/slices/repos.ts
| function reorderReposByIdPermutation(orderedIds: readonly string[], previous: readonly Repo[]) { | ||
| const reposById = queueReposById(previous) | ||
| const next: Repo[] = [] | ||
| for (const id of orderedIds) { | ||
| const repo = reposById.get(id)?.shift() | ||
| if (repo) { | ||
| next.push(repo) | ||
| } | ||
| } | ||
| return next.length === previous.length ? next : null | ||
| } |
There was a problem hiding this comment.
Reject non-permutations with extra IDs before optimistic reorder.
Line 247 only checks next.length === previous.length, so inputs with extra IDs can still pass. That contradicts the non-permutation guard used at Line 1924 and can hide malformed reorder payloads.
💡 Suggested fix
function reorderReposByIdPermutation(orderedIds: readonly string[], previous: readonly Repo[]) {
+ if (orderedIds.length !== previous.length) {
+ return null
+ }
const reposById = queueReposById(previous)
const next: Repo[] = []
for (const id of orderedIds) {| function getRepoMutationOwnerHostId( | ||
| repos: readonly Pick<Repo, 'id' | 'connectionId' | 'executionHostId'>[], | ||
| repoId: string, | ||
| targetHostId: string | ||
| ): string { | ||
| const candidates = repos.filter((repo) => repo.id === repoId) | ||
| const targetOwned = candidates.find( | ||
| (repo) => hasExplicitRepoOwner(repo) && getRepoExecutionHostId(repo) === targetHostId | ||
| ) | ||
| if (targetOwned) { | ||
| return targetHostId | ||
| } | ||
| const explicitOwner = candidates.find(hasExplicitRepoOwner) | ||
| return explicitOwner ? getRepoExecutionHostId(explicitOwner) : targetHostId | ||
| } |
There was a problem hiding this comment.
Align RPC mutation host with resolved mutation owner host.
Line 485 can resolve ownerHostId to a different host than targetHostId. But Line 1642 and Line 1858 still send RPC/IPC to target, while state mutation filters by ownerHostId. That can desynchronize backend vs in-memory state for mixed explicit/legacy ownership records.
💡 Suggested fix
+function runtimeTargetForExecutionHostId(hostId: string): ReturnType<typeof getActiveRuntimeTarget> {
+ const parsed = parseExecutionHostId(hostId)
+ return parsed?.kind === 'runtime'
+ ? ({ kind: 'environment', environmentId: parsed.environmentId } as const)
+ : ({ kind: 'local' } as const)
+}
...
-const target = getActiveRuntimeTarget(settingsForRepoOwner(get(), projectId))
-const targetHostId = getRuntimeTargetHostId(target)
+const initialTarget = getActiveRuntimeTarget(settingsForRepoOwner(get(), projectId))
+const targetHostId = getRuntimeTargetHostId(initialTarget)
const ownerHostId = getRepoMutationOwnerHostId(get().repos, projectId, targetHostId)
+const target = runtimeTargetForExecutionHostId(ownerHostId)Also applies to: 1637-1644, 1851-1854
|
Suggested reviewers: @Jinwoo-H for the Remote Orca Servers host model, and @brennanb2025 for project/folder workspace state and project host setup behavior. I tried to request reviews directly, but this fork account cannot call RequestReviewsByLogin on the upstream repo. |
Co-authored-by: Orca <[email protected]>
Co-authored-by: Orca <[email protected]>
Co-authored-by: Orca <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 6
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/main/memory/hydrate-local-pty-registry.ts (1)
78-90:⚠️ Potential issue | 🟠 Major | ⚡ Quick winRestrict alias hydration to local execution host repos.
This loop only excludes SSH repos. Repos on non-local execution hosts can still be indexed, which may register a local daemon session under the wrong canonical host key (or fail hydration while enumerating non-local paths).
💡 Suggested fix
+import { getRepoExecutionHostId } from '../../shared/execution-host' import { getRepoWorktreeIdAliases, makeRepoWorktreeKey } from '../../shared/worktree-id' for (const repo of repos) { const connectionId = repo.connectionId ?? null - if (connectionId) { + const repoHostId = getRepoExecutionHostId(repo) + if (connectionId || repoHostId !== 'local') { // Why: SSH PTYs are never registered for local process sampling, so - // avoid startup SSH/git enumeration for repos we will skip anyway. + // avoid startup SSH/git enumeration for repos we will skip anyway. + // Non-local execution hosts must also be skipped: this registry is local-only. continue } const worktrees = await listRepoWorktrees(repo)Also applies to: 119-126
src/renderer/src/hooks/useIpcEvents.ts (1)
771-787:⚠️ Potential issue | 🟠 Major | ⚡ Quick winFilter deletion diffs to the refreshed host before purging.
ownerHostIdscopes the fetch, butbefore/afterare still repo-wide. If another host’s detected list is missing or non-authoritative, a host-specific refresh can classify sibling-host worktrees as removed and purge their terminal/workspace state.🛡️ Suggested host-scoped diff shape
+ const belongsToRefreshHost = (worktree: { hostId?: ExecutionHostId }): boolean => + ownerHostId == null || worktree.hostId === ownerHostId + const authoritativeIdsForRefreshHost = ( + snapshot: ReturnType<typeof useAppStore.getState> + ): Set<string> | null => { + const detected = snapshot.detectedWorktreesByRepo[repoId] + if (!detected?.authoritative) { + return null + } + return new Set( + detected.worktrees.filter(belongsToRefreshHost).map((worktree) => worktree.id) + ) + } + const visibleIdsForRefreshHost = ( + snapshot: ReturnType<typeof useAppStore.getState> + ): Set<string> => + new Set( + (snapshot.worktreesByRepo[repoId] ?? []) + .filter(belongsToRefreshHost) + .map((worktree) => worktree.id) + ) const state = useAppStore.getState() const before = - getAuthoritativeDetectedWorktreeIds(state, repoId) ?? - getVisibleWorktreeIdsForRepo(state, repoId) + authoritativeIdsForRefreshHost(state) ?? visibleIdsForRefreshHost(state) await (ownerHostId ? state.fetchWorktrees(repoId, { ownerHostId }) : state.fetchWorktrees(repoId)) await useAppStore.getState().fetchWorktreeLineage() @@ } const afterState = useAppStore.getState() - const after = getAuthoritativeDetectedWorktreeIds(afterState, repoId) + const after = authoritativeIdsForRefreshHost(afterState) if (!after) { return }
🧹 Nitpick comments (4)
src/renderer/src/store/slices/repo-host-refresh-merge.ts (1)
10-16: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick winAdd a brief “why” comment for host-block anchoring behavior.
This merge strategy is non-obvious (replace one host block while preserving sibling host ordering); add a 1–2 line rationale above
firstHostIndex/insertAtto make the invariant explicit.Suggested patch
): Repo[] { + // Keep the refreshed host block anchored at its previous first position so + // sibling host ordering is preserved across host-scoped refreshes. const firstHostIndex = previous.findIndex((repo) => getRepoExecutionHostId(repo) === hostId) const preserved = previous.filter((repo) => getRepoExecutionHostId(repo) !== hostId)As per coding guidelines,
**/*.{ts,tsx,js,jsx}requires a short comment for non-obvious/design-driven behavior.Source: Coding guidelines
src/main/runtime/worktree-teardown.ts (1)
116-121: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick winDocument the legacy-ID fallback intent.
This canonical→legacy alias expansion is a migration-specific behavior and is non-obvious at a glance. Add a short “Why” comment here to preserve intent.
Suggested patch
function getTeardownWorktreeIds(worktreeId: string): Set<string> { const ids = new Set([worktreeId]) const parsed = splitWorktreeId(worktreeId) if (parsed) { + // Why: during canonical-ID rollout, some persisted PTY/session rows may + // still reference legacy repoId::path identifiers; sweep both forms. ids.add(makeLegacyWorktreeId(parsed.repoId, parsed.worktreePath)) } return ids }As per coding guidelines, "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does."
Source: Coding guidelines
src/main/memory/hydrate-local-pty-registry.test.ts (1)
224-233: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick winAdd a mixed-host hydration regression case.
Please add a case with same
repoId/pathonlocaland non-local execution hosts to assert hydration only registers the local canonical worktree ID. This guards alias-map regressions.src/shared/worktree-id.ts (1)
95-97: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick winDocument the strict query-parameter ordering contract.
This ordering check is a non-obvious compatibility rule. Add a short
Why:comment so future edits don’t loosen the canonical format unintentionally.Proposed patch
const keys = [...params.keys()] + // Why: canonical worktree IDs are a versioned wire format; strict field order + // prevents accepting ambiguously shaped or re-serialized query strings. if (keys.length !== 3 || keys[0] !== 'hostId' || keys[1] !== 'repoId' || keys[2] !== 'path') { return null }As per coding guidelines,
**/*.{ts,tsx,js,jsx}requires a short comment for non-obvious constraints.Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: f0454b31-cd32-4897-bbed-cfe73beb5cff
📒 Files selected for processing (43)
docs/worktree-host-identity-rollout-validation.mdsrc/main/daemon/pty-session-id.test.tssrc/main/ipc/remote-workspace.tssrc/main/ipc/repos.tssrc/main/ipc/workspace-cleanup.test.tssrc/main/ipc/workspace-cleanup.tssrc/main/ipc/worktree-metadata-merge.tssrc/main/ipc/worktree-remote.tssrc/main/ipc/worktrees.test.tssrc/main/ipc/worktrees.tssrc/main/memory/hydrate-local-pty-registry.test.tssrc/main/memory/hydrate-local-pty-registry.tssrc/main/persistence.test.tssrc/main/persistence.tssrc/main/runtime/orca-runtime.test.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/project-runtime-rpc-methods.tssrc/main/runtime/worktree-teardown.tssrc/main/usage-worktree-metadata.tssrc/main/workspace-space-analysis.tssrc/renderer/src/components/settings/McpConfigSection.tsxsrc/renderer/src/components/settings/RepositoryHostSetupsSection.test.tsxsrc/renderer/src/components/settings/RepositoryHostSetupsSection.tsxsrc/renderer/src/hooks/useIpcEvents.test.tssrc/renderer/src/hooks/useIpcEvents.tssrc/renderer/src/hooks/worktree-change-refresh-queue.tssrc/renderer/src/lib/project-host-workspace-target.test.tssrc/renderer/src/lib/project-host-workspace-target.tssrc/renderer/src/lib/worktree-runtime-owner.test.tssrc/renderer/src/lib/worktree-runtime-owner.tssrc/renderer/src/store/slices/repo-host-refresh-merge.test.tssrc/renderer/src/store/slices/repo-host-refresh-merge.tssrc/renderer/src/store/slices/repos-multi-host-refresh.test.tssrc/renderer/src/store/slices/repos-project-host-lifecycle.test.tssrc/renderer/src/store/slices/repos-same-id-host-mutations.test.tssrc/renderer/src/store/slices/repos.tssrc/renderer/src/store/slices/worktree-helpers.tssrc/renderer/src/store/slices/worktrees.test.tssrc/renderer/src/store/slices/worktrees.tssrc/shared/pty-session-id-format.tssrc/shared/types.tssrc/shared/worktree-id.test.tssrc/shared/worktree-id.ts
✅ Files skipped from review due to trivial changes (1)
- docs/worktree-host-identity-rollout-validation.md
🚧 Files skipped from review as they are similar to previous changes (1)
- src/renderer/src/store/slices/repos.ts
| function migrateLegacyFolderWorkspaceMetaIfSafe(store: Store, repo: Repo): void { | ||
| for (const [worktreeId, meta] of Object.entries(store.getAllWorktreeMeta())) { | ||
| if (!isLegacyFolderWorkspaceIdForRepo(repo, worktreeId)) { | ||
| continue | ||
| } | ||
| const repoHostId = getRepoExecutionHostId(repo) | ||
| if (meta.hostId !== undefined && meta.hostId !== repoHostId) { | ||
| continue | ||
| } | ||
| store.migrateWorktreeIdentity(worktreeId, getCanonicalFolderWorkspaceId(repo, worktreeId)) | ||
| } |
There was a problem hiding this comment.
Prevent legacy folder-meta migration from clobbering an existing canonical row.
migrateLegacyFolderWorkspaceMetaIfSafe migrates every legacy key without checking whether the canonical destination already exists. If both keys are present, this can overwrite newer canonical metadata during listing.
💡 Suggested fix
function migrateLegacyFolderWorkspaceMetaIfSafe(store: Store, repo: Repo): void {
for (const [worktreeId, meta] of Object.entries(store.getAllWorktreeMeta())) {
if (!isLegacyFolderWorkspaceIdForRepo(repo, worktreeId)) {
continue
}
+ const canonicalId = getCanonicalFolderWorkspaceId(repo, worktreeId)
+ if (canonicalId === worktreeId || store.getWorktreeMeta(canonicalId)) {
+ continue
+ }
const repoHostId = getRepoExecutionHostId(repo)
if (meta.hostId !== undefined && meta.hostId !== repoHostId) {
continue
}
- store.migrateWorktreeIdentity(worktreeId, getCanonicalFolderWorkspaceId(repo, worktreeId))
+ store.migrateWorktreeIdentity(worktreeId, canonicalId)
}
}| id: makeRepoWorktreeKey( | ||
| { | ||
| id: repo.id, | ||
| connectionId: repo.connectionId, | ||
| executionHostId: repo.executionHostId | ||
| }, | ||
| repo.path | ||
| ), | ||
| path: repo.path |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win
Add a short “why” comment for the host-qualified fallback worktree key.
This fallback now encodes host identity; please add a one-line rationale so future edits don’t regress cross-host disambiguation.
Suggested update
worktreesForRepo[0] ?? {
+ // Why: fallback IDs must stay host-qualified so same repo IDs across hosts don't collide.
id: makeRepoWorktreeKey(
{
id: repo.id,
connectionId: repo.connectionId,
executionHostId: repo.executionHostId
},
repo.path
),
path: repo.path
}As per coding guidelines, "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does."
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| id: makeRepoWorktreeKey( | |
| { | |
| id: repo.id, | |
| connectionId: repo.connectionId, | |
| executionHostId: repo.executionHostId | |
| }, | |
| repo.path | |
| ), | |
| path: repo.path | |
| id: makeRepoWorktreeKey( | |
| { | |
| id: repo.id, | |
| connectionId: repo.connectionId, | |
| executionHostId: repo.executionHostId | |
| }, | |
| repo.path | |
| ), | |
| path: repo.path |
| id: makeRepoWorktreeKey( | |
| { | |
| id: repo.id, | |
| connectionId: repo.connectionId, | |
| executionHostId: repo.executionHostId | |
| }, | |
| repo.path | |
| ), | |
| path: repo.path | |
| worktreesForRepo[0] ?? { | |
| // Why: fallback IDs must stay host-qualified so same repo IDs across hosts don't collide. | |
| id: makeRepoWorktreeKey( | |
| { | |
| id: repo.id, | |
| connectionId: repo.connectionId, | |
| executionHostId: repo.executionHostId | |
| }, | |
| repo.path | |
| ), | |
| path: repo.path |
Source: Coding guidelines
| function getProjectHostSetupKey(setup: Pick<ProjectHostSetup, 'hostId' | 'id'>): string { | ||
| return `${setup.hostId}\0${setup.id}` | ||
| } |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win
Document why the setup key uses a host-qualified composite format.
The \0 delimiter choice is non-obvious; add a brief why-comment to protect this disambiguation behavior during future refactors.
Suggested update
function getProjectHostSetupKey(setup: Pick<ProjectHostSetup, 'hostId' | 'id'>): string {
+ // Why: setup IDs can repeat across hosts, so key by host+id to keep selection/removal stable.
return `${setup.hostId}\0${setup.id}`
}As per coding guidelines, "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does."
Source: Coding guidelines
| setDeletingSetupKey(setupKey) | ||
| await deleteProjectHostSetup({ setupId: setup.id, hostId: setup.hostId }) | ||
| setDeletingSetupKey(null) |
There was a problem hiding this comment.
Always clear deletingSetupKey when deletion fails.
If deleteProjectHostSetup rejects, the current code skips reset and can leave the row permanently non-removable until remount.
Suggested update
onClick={async () => {
- setDeletingSetupKey(setupKey)
- await deleteProjectHostSetup({ setupId: setup.id, hostId: setup.hostId })
- setDeletingSetupKey(null)
+ setDeletingSetupKey(setupKey)
+ try {
+ await deleteProjectHostSetup({ setupId: setup.id, hostId: setup.hostId })
+ } finally {
+ setDeletingSetupKey(null)
+ }
}}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| setDeletingSetupKey(setupKey) | |
| await deleteProjectHostSetup({ setupId: setup.id, hostId: setup.hostId }) | |
| setDeletingSetupKey(null) | |
| setDeletingSetupKey(setupKey) | |
| try { | |
| await deleteProjectHostSetup({ setupId: setup.id, hostId: setup.hostId }) | |
| } finally { | |
| setDeletingSetupKey(null) | |
| } |
| type WorktreeChangeEvent = { | ||
| repoId: string | ||
| ownerHostId?: ExecutionHostId | ||
| renamed?: WorktreeRename | ||
| } | ||
|
|
||
| type WorktreeChangeRefreshHandler = (repoId: string, renamed?: WorktreeRename) => Promise<void> | ||
| type WorktreeChangeRefreshHandler = ( | ||
| repoId: string, | ||
| ownerHostId?: ExecutionHostId, | ||
| renamed?: WorktreeRename |
There was a problem hiding this comment.
Do not key queued refreshes to mutable focus.
The 'focused' fallback defers host selection until drain time. A local worktree event queued while local is active can drain after the user switches to a runtime host, causing the refresh to run against the wrong host.
🛡️ Suggested direction
type WorktreeChangeEvent = {
repoId: string
- ownerHostId?: ExecutionHostId
+ ownerHostId: ExecutionHostId
renamed?: WorktreeRename
}
type WorktreeChangeRefreshHandler = (
repoId: string,
- ownerHostId?: ExecutionHostId,
+ ownerHostId: ExecutionHostId,
renamed?: WorktreeRename
) => Promise<void>
@@
type RepoRefreshState = {
repoId: string
- ownerHostId?: ExecutionHostId
+ ownerHostId: ExecutionHostId
running: boolean
queue: QueuedWorktreeChange[]
}
@@
const getRefreshKey = (event: Pick<WorktreeChangeEvent, 'repoId' | 'ownerHostId'>) =>
- `${event.ownerHostId ?? 'focused'}\0${event.repoId}`
+ `${event.ownerHostId}\0${event.repoId}`Then pass the local owner explicitly at the local IPC enqueue site, e.g. { ...data, ownerHostId: LOCAL_EXECUTION_HOST_ID }.
Also applies to: 40-41, 64-70
| if ( | ||
| !detectedForHost.authoritative && | ||
| worktreesForHost.length === 0 && | ||
| currentForHost && | ||
| currentForHost.length > 0 | ||
| ) { | ||
| set((s) => ({ | ||
| detectedWorktreesByRepo: { ...s.detectedWorktreesByRepo, [repoId]: detected } | ||
| detectedWorktreesByRepo: { | ||
| ...s.detectedWorktreesByRepo, | ||
| [repoId]: mergeDetectedWorktreesForHost( | ||
| s.detectedWorktreesByRepo[repoId], | ||
| detectedForHost, | ||
| ownerHostId, | ||
| shouldTreatHostlessWorktreesAsLocal(s, repoId) | ||
| ) | ||
| } | ||
| })) |
There was a problem hiding this comment.
Preserve detected entries on transient empty host refreshes.
These stale-preservation branches keep worktreesByRepo, but still call mergeDetectedWorktreesForHost with an empty non-authoritative result. That splices out the current host’s detected entries, so later diffs/hidden-worktree metadata can behave as if those worktrees disappeared.
🛡️ Suggested preservation helper
+function preserveDetectedWorktreesAfterEmptyHostRefresh(
+ previous: DetectedWorktreeListResult | undefined,
+ fetched: DetectedWorktreeListResult
+): DetectedWorktreeListResult | undefined {
+ return previous
+ ? { ...previous, authoritative: false, source: fetched.source }
+ : previous
+}
+
@@
if (
!detectedForHost.authoritative &&
worktreesForHost.length === 0 &&
currentForHost &&
currentForHost.length > 0
) {
- set((s) => ({
- detectedWorktreesByRepo: {
- ...s.detectedWorktreesByRepo,
- [repoId]: mergeDetectedWorktreesForHost(
- s.detectedWorktreesByRepo[repoId],
- detectedForHost,
- ownerHostId,
- shouldTreatHostlessWorktreesAsLocal(s, repoId)
- )
- }
- }))
+ set((s) => {
+ const detected = preserveDetectedWorktreesAfterEmptyHostRefresh(
+ s.detectedWorktreesByRepo[repoId],
+ detectedForHost
+ )
+ return detected
+ ? { detectedWorktreesByRepo: { ...s.detectedWorktreesByRepo, [repoId]: detected } }
+ : s
+ })
return false
}Apply the same branch-specific preservation in fetchAllWorktrees instead of falling through to the empty-host merge.
Also applies to: 1737-1747
|
Closing as superseded, with thanks — #6136 (merged June 23) covers this PR's scope renderer-side, including the headline behavior: repoId-less setup rows fall back to setup id per host and survive sibling-host refreshes (main keys setup ownership by host + repoId-or-setup-id), plus host-scoped pruning and ownership rules. The branch now conflicts with main in 23 files. On the host-qualified worktree-identity commit: we reviewed it in depth, but it's a platform-scale ID migration (new persisted/wire format + lazy store migration) that needs its own design and a version-gated rollout rather than riding in a fix PR — the current head fails 60 of its own runtime tests, and in a real client↔server pairing the server's Remaining host-blind lookups our review found on main are tracked in #9783. |
Context
Tracking issue: #6032
This is the second PR in the Remote Orca Servers state stack. It should be reviewed after #6030. The branch includes #6030's commit until that PR lands because GitHub cannot use a fork-only branch as the base for an upstream PR.
Once repo refresh is host-aware, shared projects still have a second failure mode: project compatibility and
projectHostSetupscan be reconciled with bare repo ids. When the same project exists on a local host and a Remote Orca Server, refreshing one host can drop the other host from compatibility and setup state.Changed
projectHostSetupsfor sibling hosts during a host-specific refresh.repoIdby falling back to setup id on the same host, so empty setup rows do not collapse.Regression coverage
The new tests create a shared project with host-specific repo state, then refresh one host. On
main, the refresh drops the other host fromsourceRepoIdsor collapses setup rows. With this stack, both hosts keep their project state.Tests
pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/store/slices/repo-identity-reconcile.test.ts src/renderer/src/store/slices/repo-host-refresh-merge.test.ts src/renderer/src/store/slices/repos-multi-host-refresh.test.ts src/renderer/src/store/slices/repos-same-id-host-mutations.test.ts src/renderer/src/store/slices/repo-reorder-host-split.test.ts src/renderer/src/lib/repo-runtime-owner.test.ts src/renderer/src/store/slices/repos-update-serialization.test.ts src/renderer/src/store/slices/project-host-setup-compatibility-merge.test.tspnpm exec oxlint src/renderer/src/lib/repo-runtime-owner.ts src/renderer/src/lib/repo-runtime-owner.test.ts src/renderer/src/store/slices/repo-host-refresh-merge.ts src/renderer/src/store/slices/repo-host-refresh-merge.test.ts src/renderer/src/store/slices/repo-identity-reconcile.ts src/renderer/src/store/slices/repo-identity-reconcile.test.ts src/renderer/src/store/slices/repo-reorder-host-split.ts src/renderer/src/store/slices/repo-reorder-host-split.test.ts src/renderer/src/store/slices/repos.ts src/renderer/src/store/slices/repos-multi-host-refresh.test.ts src/renderer/src/store/slices/repos-same-id-host-mutations.test.ts src/renderer/src/store/slices/project-host-setup-compatibility-merge.ts src/renderer/src/store/slices/project-host-setup-compatibility-merge.test.tspnpm run typecheck:webStack