Repository navigation
Conversation
|
Ready to review this PR? Stage has broken it down into 6 individual chapters for you: Chapters generated by Stage for commit f573e3f on Jun 22, 2026 2:12am UTC. |
📝 WalkthroughWalkthroughThis PR makes repo operations host-aware throughout the renderer store so that the same repo 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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: 1
🧹 Nitpick comments (1)
src/renderer/src/store/slices/repo-reorder-host-split.ts (1)
28-41: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick winAdd a brief “why” comment for the per-id host queue logic.
This
hostIdsByRepoId+.shift()strategy is non-obvious; a one-line rationale here would reduce regression risk during future refactors.Proposed diff
const hostIdsByRepoId = new Map<string, string[]>() for (const repo of repos) { const hasExplicitOwner = Boolean(repo.executionHostId?.trim() || repo.connectionId?.trim()) const hostId = hasExplicitOwner ? getRepoExecutionHostId(repo) : focusedHostId const existing = hostIdsByRepoId.get(repo.id) if (existing) { existing.push(hostId) } else { hostIdsByRepoId.set(repo.id, [hostId]) } } const groups = new Map<string, string[]>() + // Why: duplicate repo IDs can exist on different hosts; consume host IDs in + // order so each repeated ID is assigned to the correct host-specific group. for (const id of orderedIds) { const hostId = hostIdsByRepoId.get(id)?.shift()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: afb261ca-6154-4ab3-9b75-a9733a6a4881
📒 Files selected for processing (11)
src/renderer/src/lib/repo-runtime-owner.test.tssrc/renderer/src/lib/repo-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/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 overlong reorder payloads before optimistic apply.
reorderReposByIdPermutation can return non-null when orderedIds contains extra IDs (e.g., extra duplicates), because it only compares next.length with previous.length. That violates the permutation contract and can let malformed input pass optimistic validation.
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) {
const repo = reposById.get(id)?.shift()
if (repo) {
next.push(repo)
}
}
return next.length === previous.length ? next : 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.
| 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 | |
| } | |
| 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) { | |
| const repo = reposById.get(id)?.shift() | |
| if (repo) { | |
| next.push(repo) | |
| } | |
| } | |
| return next.length === previous.length ? next : null | |
| } |
|
Thanks for this stack and the sharp analysis in #6032 — the failure class was real. Closing as superseded: #6136 (merged June 23) landed host-scoped repo identity for the refresh/update/remove/reorder/runtime-owner paths this PR covers, with regression coverage in |
Context
Tracking issue: #6032
Remote Orca Servers can report repositories that share the same repo id across different hosts. The store had several paths that treated
repo.idas globally unique. Refreshing or mutating one host could replace, remove, or reorder the row for another host with the same id. That breaks the SSH and remote-server case where two machines have independent checkouts of the same project.Changed
updateRepo,removeProject, and repo reorder operations to the matching host row.Regression coverage
The tests model two hosts that expose the same repo id, then exercise refresh, update, removal, reorder, and runtime-owner lookup. These fail on
mainbecause the old store collapses rows by barerepo.id.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