refactor(init): reuse resolveOrCreateTeam for wizard team resolution#679
refactor(init): reuse resolveOrCreateTeam for wizard team resolution#679
Conversation
The init wizard had ~55 lines of inline team resolution that duplicated the shared resolveOrCreateTeam logic. Both did: list teams → 0 (create) → 1 (auto-select) → N (filter by membership → pick). Adds an onAmbiguous callback to resolveOrCreateTeam so the wizard can present a clack select() prompt when multiple teams match, instead of throwing ContextError. Also fixes a silent error-swallowing catch that let team resolution failures pass through unnoticed, causing confusing errors later when project creation needed a team. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Bug Fixes 🐛Init
Other
Internal Changes 🔧Init
Other
Other
🤖 This preview updates automatically when you update the PR. |
Codecov Results 📊✅ 134 passed | Total: 134 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ✅ Patch coverage is 100.00%. Project has 1460 uncovered lines. Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
- Coverage 95.51% 95.50% -0.01%
==========================================
Files 223 223 —
Lines 32424 32425 +1
Branches 0 0 —
==========================================
+ Hits 30968 30965 -3
- Misses 1456 1460 +4
- Partials 0 0 —Generated by Codecov Action |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 67f963c. Configure here.
WizardError defaults rendered=true, so the framework error handler suppresses output. Every other throw site calls log.error() + cancel() first to display the message. The new catch block was missing this, which would silently swallow the error. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Summary
The init wizard had ~55 lines of inline team resolution that duplicated
resolveOrCreateTeamfromresolve-team.ts. Both implementations did the same thing: list teams → 0 teams (auto-create) → 1 team (auto-select) → N teams (filter by membership → pick).Adds an
onAmbiguouscallback toResolveTeamOptionsso the wizard can present a clackselect()prompt when multiple teams match, instead of the shared function throwingContextError.Also fixes a silent error-swallowing catch (
captureException+ continue) that let team resolution failures pass through unnoticed — the wizard would continue without a team and fail later when project creation needed one.Changes
resolve-team.ts: Added optionalonAmbiguouscallback toResolveTeamOptions. When provided, it's called with the candidate teams instead of throwingContextError. Non-breaking — existing callers are unaffected.wizard-runner.ts: Replaced inline team resolution with a call toresolveOrCreateTeam. Errors now surface properly instead of being silently swallowed. Removed unused imports (createTeam,listTeams,getSentryBaseUrl).Test plan
npx tsc --noEmitpassesnpx biome checkpasses on changed filessentry initagainst an org with 0, 1, and multiple teamssentry init --yesagainst an org with multiple teams (should auto-pick first)