fix(desktop): stop folder import on cloud lookup errors#4547
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds handling in useFolderFirstImport for findByPath responses with zero candidates but non-empty cloudErrors: the hook reports the first cloud error via onError with a formatted message and returns null, skipping setup/create/finalize. Includes a test for this path. ChangesCloud Error Handling
sequenceDiagram
participant Hook
participant Query
participant ErrorCb
participant SetupSrv
participant CreateSrv
participant FinalizeSrv
Hook->>Query: findByPath.query(path)
Query-->>Hook: response (candidates[], cloudErrors[])
alt No candidates + cloudErrors
Hook->>ErrorCb: onError("Couldn't reach cloud: <url> — <message>")
Hook-->>Hook: return null
else Candidate found
Hook->>SetupSrv: setup(...)
Hook->>CreateSrv: create(...)
Hook->>FinalizeSrv: finalizeSetup(...)
end
🎯 3 (Moderate) | ⏱️ ~20 minutes
🚥 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. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add 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 |
Greptile SummaryThis PR adds an early-exit guard to
Confidence Score: 4/5The fix correctly stops the folder-import flow on cloud errors and is safe to merge. The only issue is the The implementation file's new guard block is the only area worth a second look, specifically the redundant ternary on
|
| Filename | Overview |
|---|---|
| apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/AddRepositoryModals/hooks/useFolderFirstImport/useFolderFirstImport.ts | Adds an early-exit guard when cloud lookup returns errors and no local candidates; logic is correct but the inner ternary on first is dead code since the array length is already checked. |
| apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/AddRepositoryModals/hooks/useFolderFirstImport/useFolderFirstImport.test.ts | New test file covering the two new cloud-error paths; baseline happy paths (no errors, single or multiple candidates) are not tested, leaving the pre-existing flow uncovered. |
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/AddRepositoryModals/hooks/useFolderFirstImport/useFolderFirstImport.ts:52-60
The `first` ternary guard is unreachable dead code. Because `response.cloudErrors.length > 0` is already asserted on the enclosing `if`, `response.cloudErrors[0]` is guaranteed to be a defined object — the fallback string `"Couldn't reach cloud"` can never execute.
Reviews (1): Last reviewed commit: "test(desktop): cover folder import cloud..." | Re-trigger Greptile
|
Ready to review this PR? Stage has broken it down into 2 individual chapters for you:
Chapters generated by Stage for commit 3a8c837 on May 17, 2026 10:48pm UTC. |
22e8ed6 to
a0477c4
Compare
|
Capy auto-review is paused for this organization because the monthly auto-review limit has been reached. Increase the limit or turn it off in billing settings to resume automatic reviews. |
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
* fix(desktop): stop folder import on cloud lookup errors * test(desktop): cover folder import cloud lookup errors * fix(desktop): remove unreachable cloud error fallback * test(desktop): trim folder import cloud error coverage
…4547) * fix(desktop): stop folder import on cloud lookup errors * test(desktop): cover folder import cloud lookup errors * fix(desktop): remove unreachable cloud error fallback * test(desktop): trim folder import cloud error coverage
Summary
Note
Duplicate GitHub remotes are still allowed. This only blocks the no-candidate + cloud-error fallback that could create an unintended new project when existing-project discovery failed.
QA
Summary by CodeRabbit
Bug Fixes
Tests