Repository navigation
fix: avoid duplicate repository groups during catalog refresh - #19170
Conversation
📝 WalkthroughWalkthroughThe project group creation flow now compares group ID and owner host before inserting a group into state. Store tests cover refresh and creation races across local, remote, and SSH hosts. End-to-end tests cover ordinary and delayed creation timing, including group visibility, repository assignment, scrolling, refresh, collapse, and re-expansion. Priority: ➖ Normal — Impact reflects medium issue severity. Severity of issue fixed: Medium Merge Risk: 🟡 Moderate · up to The host-aware group insertion change addresses duplicate and disappearing sidebar groups, but the added race test has a TypeScript contract mismatch that can prevent validation from compiling until corrected. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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.
✅ No new issues found.
Reviewed changes
- Idempotent group insertion —
createProjectGroupnow skips the append when a group with the sameidand owning host is already present, closing the refresh-before-create-response race that produced duplicate UUIDs. - Host-scoped identity — the dedup uses
getProjectGroupHostId, so a different host's group with the same id is preserved. - Store regression tests — a new
repos-project-group-create-race.test.tscovers local and remote ordering plus metadata and host preservation. - Electron regression spec —
project-group-creation-visibility.spec.tsreproduces the virtualized-sidebar failure with 30 seeded repos and a deterministic IPC gate.
The fix targets the mutation boundary, matches the existing mergeFetchedProjectGroupsForHost identity ([host, id]), and keeps already-fetched metadata intact. Verified both new tests would fail against the pre-fix behavior (store: 3 vs 2 rows; E2E: 5 vs 1 group header).
ℹ️ E2E spec depends on Electron's private IPC registry
The deterministic response gate reaches into ipcMain._invokeHandlers plus removeHandler/handle to stall the create response. It's guarded with a loud runtime check, so nothing to change — just the brittlest seam in the new coverage if Electron's internal API shifts in a future upgrade.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
New visual proof — independent takeover validationFresh before/after captures from the review run, separate from the original contributor's screenshots. Both show the same sidebar area after adding 30 temporary Git repositories, grouping two, then expanding and scrolling through 10 unrelated repositories. Images are cropped identically; their content is otherwise unchanged.
Verified by DOM assertions: the original implementation failed with 3 group headers instead of 1. The fixed implementation passed the expansion, scrolling, catalog refresh, and collapse/reopen checks, with both member repositories visible. The adverse-order test deliberately holds the create response until the real catalog refresh inserts the group. Ordinary timing passed on both implementations; this proves the failure mechanism under that ordering, not how frequently it happens naturally. Captured in real hidden Electron on macOS with |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 527adbc0-3947-4734-a530-12ce1a3e7140
📒 Files selected for processing (3)
src/renderer/src/store/project-groups/project-group-mutations.tssrc/renderer/src/store/slices/repos-project-group-create-race.test.tstests/e2e/project-group-creation-visibility.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/renderer/src/store/project-groups/project-group-mutations.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review.
| if (compatibility) { | ||
| return compatibility | ||
| } | ||
| expect(request).toMatchObject({ selector: runtimeEnvironmentId }) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sed -n '1,80p' src/renderer/src/runtime/runtime-compatibility-test-fixture.ts
sed -n '35,65p' src/renderer/src/store/slices/repos-project-group-create-race.test.ts
rg -n -C 3 'RuntimeEnvironmentCallRequest|runtimeEnvironments.*call|selector' \
src/renderer/src/runtime src/renderer/src/storeRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- fixture ---'
rg -n -C 8 'export (type|interface) RuntimeEnvironmentCallRequest|RuntimeEnvironmentCallRequest' \
src/renderer/src/runtime/runtime-compatibility-test-fixture.ts
printf '%s\n' '--- reviewed test ---'
sed -n '1,75p' src/renderer/src/store/slices/repos-project-group-create-race.test.ts
printf '%s\n' '--- relevant call contract ---'
rg -n -C 6 'runtimeEnvironments.*call|RuntimeEnvironmentCallRequest' \
src/renderer/src/runtime/runtime-rpc-client.ts \
src/renderer/src/runtime/runtime-compatibility-test-fixture.ts \
src/renderer/src/store/slices/repos-project-group-create-race.test.tsRepository: stablyai/orca
Length of output: 11497
Add selector to RuntimeEnvironmentCallRequest.
The type declares only method and params, but the callback accesses request.selector. TypeScript reports an invalid property access at line 52.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Comment refined, no behavior change — the dedup branch now attributes the race to an overlapping catalog refresh rather than the change notification, matching the actual mechanism.
- Store regression coverage expanded —
repos-project-group-create-race.test.tsgrew from 2 to 10 cases: zero subscriber notifications on duplicate delivery, original-owner retention across a host switch, no-rollback on a lost create response, and SSH-vs-local identity isolation, plus explicit RPC selector assertions and realgetDefaultSettings. - Electron spec hardened —
project-group-creation-visibility.spec.tsnow drives both ordinary and forced-adverse ordering, restores the originalprojectGroups:createhandler on first use, releases the response gate infinally, re-fetches groups mid-test, and uses the Windows-saferunProcessfor git fixture commands.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏



Problem and fix
A create response and an overlapping catalog refresh can each insert the same repository group into renderer state. Later catalog merges preserve those duplicate entries, and the sidebar gives them identical React/virtualizer keys. Expanding and scrolling unrelated repositories then exposes repeated empty group headers and missing or obscured member rows.
Make the create continuation insert only when the same normalized owning host + group ID is absent. Keep an already-fetched row intact, including newer metadata, and return the existing state without notifying subscribers. This prevents the duplicate at the insertion boundary; no extra fetch, rendering workaround, or persistence migration is needed.
Fixes #19168.
Root-cause evidence and its limit
The main handler emits
repos:changedbefore returning, but its notification starts another IPC roundtrip. That fact alone does not establish that this particular refresh normally beats the create response.An independent before/after run of the improved real-Electron regression found:
The response gate deliberately forces the adverse ordering. It proves the corruption mechanism and the fix, not the natural frequency or exclusive cause of every disappearing-sidebar report. Both original store race regressions also failed before the fix.
Takeover improvements
finally.Validation
--testTimeout=120000; imports/execution took about 56 seconds on this machine. Initial default 30-second timeout failures are acknowledged.pnpm tc, targeted Oxlint, formatting, and whitespace checks passed.ORCA_CODE_QUALITY_BASE=2e8fa3fe9b5(the actual PR parent; the current checkout'sorigin/mainhas no merge base).typecheck:e2ereports 190 diagnostics in 96 other files, none in this spec. The complete test suite was not rerun during takeover. The contributor's earlier full run also reported unrelated failures; this PR does not claim full-suite green.All automated app launches use
ORCA_BACKGROUND_LAUNCH=1; no test window was revealed or focused.Readiness review
No remaining candidate findings in the final diff; findings-severity counsel skipped under the checklist's zero-candidate rule. Reviewed ownership/concurrency, failure and cleanup, bounded work, security/supply chain, persistence and wire compatibility, platform behavior, and module organization.
Production adds one short-circuit linear lookup per create, with no polling, listeners, timers, extra requests, or retained cache. No schema, dependency, binary, RPC, protocol, or UI style changes. No mobile-facing surface touched. Group insertion is independent of Git vs folder workspaces and GitHub vs GitLab.
Actual rendered validation was macOS only. Runtime ownership and response-loss cases use unit mocks; live SSH disconnect/reconnect, Windows/Linux, and mobile were not exercised. Host-scoped store identity tests do not claim full UI support for cloned catalogs with identical UUIDs. Existing in-memory corruption is not migrated; a fresh renderer reloads the persisted catalog.
Original contributor visual proof
These attachments are from the contributor's initial run; takeover verification independently reproduced the same failure class, with three rather than five rendered headers.
Attribution
Original implementation and reproduction by @kiendle, AI-assisted. Maintainer-requested takeover review, stronger tests, harness cleanup, and independent before/after verification were AI-assisted with Codex.
Checklist