You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(projects): register a folder once when two adds race on a server - #34303
If you added the same new folder to a paired Orca server twice at the same moment, the server could save it twice. It now checks again right before saving.
What Changed
Before: the server's repo.add looked for an existing project at the path, then waited on the realpath lookup and icon/upstream detection, then saved. Two adds of the same new folder could both pass the first check, so the folder was saved twice. This is easy to hit with WSL distro servers, where adding a project takes several requests.
After: right before saving, the server looks for the project again. If a concurrent add already saved it, that project is returned, with the same runtime-host adoption as the first check.
Mechanism: the desktop's local add (local-repo-registration.ts) already re-checks for a "race winner" after its awaits. The server's RuntimeRepositoryRegistrationController.add now does the same. The shared adopt-or-return logic moved into reuseExisting().
Why
This is the smallest fix that removes the duplicate save, and it reuses the pattern the desktop path already relies on. It covers every paired server, not just WSL.
What this doesn't cover: the other half of STA-12331, where a lost reply during nested import, or a retry of it, creates a second group. That needs an operation identity the server records with its result, gated on a capability so older servers keep today's behavior. It is a separate design change and isn't in this PR.
N/A. The server-side registration is deduplicated, and there is no UI change.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
New case in runtime-repository-registration-host-dedupe.test.ts: two concurrent add() calls for the same new folder produce one project, and both return the same id. It fails on main, where two rows are saved.
The existing registration controller tests pass.
Review
Codex review and an independent review against the pinned base.
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
Folder workspaces: covered, since it's the same code path.
SSH rows: still never match local rows (unchanged filter).
Mixed versions: no wire change.
Mobile: not affected.
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
A paired server's repo.add looked for an existing project, then awaited icon
and upstream detection before saving. Two adds of the same new folder both
passed the check and saved it twice. Re-check right before saving, as the
desktop's local add already does.
Part of STA-12331.
Review was skipped as selected files did not have any reviewable changes.
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 8103bb11-2b78-44c6-b03f-236cc2285b19
Commits
Reviewing files that changed from the base of the PR and between c77b837 and 3ab90d0.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
🔍 Trigger review
Walkthrough
The registration controller now checks for a matching repository both before and after repository detection. When it finds one, it reuses that repository and preserves runtime-host adoption behavior. A concurrency test verifies that simultaneous adds for the same folder return the same repository and register it only once.
Priority: Low
Severity of issue fixed: Low
Merge Risk: Minimal · previous review c77b8
The intended same-path deduplication is in place. The remaining symlink-alias case can be tracked separately and does not block this merge.
Pre-merge checks: 5
Check name
Status
Explanation
Title check
The title names the main change: a folder is registered once when two concurrent adds race on a server. It matches the raw summary, the PR objectives, and the description. It is specific and concise, …
Description check
The description follows the template and covers the key parts. It includes the ELI5, a before/after account with the mechanism, the reasoning for the approach and its limits, the linked issue (Refs ST…
Docstring Coverage
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within survi…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: a folder is registered once when two concurrent adds race on a server. It matches the raw summary, the PR objectives, and the description. It is specific and concise, and it has no file lists or vague terms.
Full details: Description check
Explanation
The description follows the template and covers the key parts. It includes the ELI5, a before/after account with the mechanism, the reasoning for the approach and its limits, the linked issue (Refs STA-12331, with the open half called out), N/A visual proof with reason, testing with a new regression test, and a completed checklist. The 'Fixes #' line in the template is replaced by a 'Refs' link, which is a deviation. The 'Testing' manual checkbox is unchecked, and the AI Disclosure section is absent. These are minor gaps, so the description is mostly complete.
Full details: Docstring Coverage
Explanation
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 2 files.
Finishing Touches: 💡 1
📝 Generate docstrings
Commit to this branch
Create a new PR
🛠️ Fix failing CI checks: 💡
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.
69-69: Trivial · Data Integrity & Integration · Heavy lift
Close the remaining real-path race or track it separately.
normalizeRuntimePathForComparison normalizes path syntax but does not resolve symlinks. Concurrent folder registrations through a symlink and its target can therefore pass the initial real-path lookup and miss the final findAtPath() check, allowing two records.
This window existed before the PR. The new check correctly closes the race for identical path strings, so this is not a major regression. If alias deduplication is part of this PR’s scope, retain the real-path identity from the async phase and use it in the synchronous check immediately before store.addRepo().
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: f45969a8-008f-4673-a8e0-dc5080cd1098
Commits
Reviewing files that changed from the base of the PR and between cbbaa2d and c77b837.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
If you added the same new folder to a paired Orca server twice at the same moment, the server could save it twice. It now checks again right before saving.
What Changed
repo.addlooked for an existing project at the path, then waited on the realpath lookup and icon/upstream detection, then saved. Two adds of the same new folder could both pass the first check, so the folder was saved twice. This is easy to hit with WSL distro servers, where adding a project takes several requests.local-repo-registration.ts) already re-checks for a "race winner" after its awaits. The server'sRuntimeRepositoryRegistrationController.addnow does the same. The shared adopt-or-return logic moved intoreuseExisting().Why
This is the smallest fix that removes the duplicate save, and it reuses the pattern the desktop path already relies on. It covers every paired server, not just WSL.
What this doesn't cover: the other half of STA-12331, where a lost reply during nested import, or a retry of it, creates a second group. That needs an operation identity the server records with its result, gated on a capability so older servers keep today's behavior. It is a separate design change and isn't in this PR.
Linked Issue
Refs STA-12331 (concurrent add half only; the lost-reply /
projectGroup.importNestedretry half stays open).Visual Proof
N/A. The server-side registration is deduplicated, and there is no UI change.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
New case in
runtime-repository-registration-host-dedupe.test.ts: two concurrentadd()calls for the same new folder produce one project, and both return the same id. It fails on main, where two rows are saved.The existing registration controller tests pass.
Review
Codex review and an independent review against the pinned base.
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)