#6059: fix #6044
commands
Fixes #6044
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR fixes an interactive CLI edge case in `models auth add` where cancelling a `@clack/prompts` select (ESC) returns `undefined` and previously flowed into provider/method handling. The command now detects cancellation for both the provider and method selects and exits early with a `Cancelled.` log, preventing downstream errors.
It also adds a small Vitest regression test that mocks `@clack/prompts` to verify the command resolves without throwing when the provider select or method select is cancelled.
<h3>Confidence Score: 4/5</h3>
- This PR is safe to merge and addresses a clear cancellation crash path in an interactive command.
- The behavior change is narrow (early returns on `undefined` selections) and covered by a focused regression test. The only nits are test robustness/type-safety improvements; no functional regressions were identified in the modified command logic.
- src/commands/models/models-auth.add.test.ts
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#15852: fix: pass agentId when resolving IRC session paths
by MisterGuy420 · 2026-02-14
78.3%
#8546: Fix/config UI improvements
by RandomRaine · 2026-02-04
77.8%
#6110: refactor: simplify boolean logic using nullish coalescing
by T1mn · 2026-02-01
77.3%
#9739: #9291 fix(models): preserve existing models in models.json when mer...
by ximzzzzz · 2026-02-05
77.3%
#7316: fix: /chat dashboard performance
by felipcsousa · 2026-02-02
77.2%
#13318: fix(agents): prevent sanitizeUserFacingText from rewriting conversa...
by hleliofficiel · 2026-02-10
77.0%
#11048: fix: address repository issues (env, author, CI comments, security ...
by cavula · 2026-02-07
76.8%
#3335: Fixes cron jobs
by hkirat · 2026-01-28
76.6%
#17647: fix: Display error messages instead of (no output) for non-Claude m...
by MisterGuy420 · 2026-02-16
76.2%
#12974: fix: intermittent (no output) reported by users
by vincentkoc · 2026-02-10
76.1%