Uh oh!
There was an error while loading. Please reload this page.
feat: prioritize clouds with detected credentials in interactive mode - #752
Conversation
When running `spawn` interactively, clouds where the user already has auth env vars set (e.g. HCLOUD_TOKEN, DO_API_TOKEN) now appear first in the cloud selection list with a "credentials detected" hint. This reduces friction by surfacing the most likely-to-succeed options. Fixes#685 Agent: ux-engineer
la14-1
left a comment
There was a problem hiding this comment.
Self-review (Agent: ux-engineer):
Changes look good. The implementation is minimal and focused:
hasCloudCredentials(auth)- New 5-line helper that reuses the existingparseAuthEnvVars()to check if all required env vars are set. Returnsfalsefor CLI-based auth (sprite login, gcloud auth login, etc.) since those don't use env vars, which is the correct behavior.cmdInteractive()changes - Partitions clouds into "with credentials" and "without", concatenates them so credentialed clouds appear first. Adds a "credentials detected" prefix to the hint. Shows a count message before the picker. No changes to the agent selection flow.mapToSelectOptions()enhancement - Added an optionalhintOverridesparameter. Uses nullish coalescing (??) so existing callers are unaffected.Tests - 12 tests covering single vars, multiple vars, partial vars, CLI auth, empty strings, and edge cases. Proper env cleanup in afterEach.
Version bump - 0.2.64 -> 0.2.65 (patch for minor feature).
No concerns with this diff.
louisgv
left a comment
There was a problem hiding this comment.
Security Review
Verdict: APPROVED
Findings
No security issues found.
The hasCloudCredentials() function safely reads env vars using names validated by the existing parseAuthEnvVars() regex (/^[A-Z][A-Z0-9_]{3,}$/). Credential values are never logged or exposed — only their presence is checked via !!process.env[v]. The hint text displays "credentials detected" without revealing actual values. The hintOverrides dictionary is populated from manifest data and rendered in a terminal UI picker, not executed.
Tests
- bash -n: N/A (no .sh files changed)
- bun test: PASS (12/12 new tests pass)
- curl|bash pattern: N/A (no shell scripts changed)
- macOS compat: N/A (no shell scripts changed)
Automated security review by spawn security team
Uh oh!
There was an error while loading. Please reload this page.
Tests cover parseAuthEnvVars, hasCloudCredentials, cloud sorting by detected credentials, mapToSelectOptions with hintOverrides, getAuthHint, getImplementedClouds, and the full interactive picker prioritization flow. Agent: test-engineer Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
#758) Tests cover parseAuthEnvVars, hasCloudCredentials, cloud sorting by detected credentials, mapToSelectOptions with hintOverrides, getAuthHint, getImplementedClouds, and the full interactive picker prioritization flow. Agent: test-engineer Co-authored-by: A <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
Summary
spawninteractively, clouds with detected auth credentials are now prioritized (moved to the top) in the cloud selection pickerhasCloudCredentials()helper that checks if all required auth env vars for a cloud are setFixes#685
How it works
The
parseAuthEnvVars()function (already existing) extracts env var names from a cloud'sauthfield. The newhasCloudCredentials()checks if all extracted vars are present and non-empty inprocess.env. IncmdInteractive(), clouds are partitioned into "with credentials" and "without", then concatenated so credentialed clouds appear first.Test plan
hasCloudCredentials()covering single vars, multiple vars, missing vars, CLI-based auth, empty stringsHCLOUD_TOKEN=xand runspawninteractively -- Hetzner should appear first with "credentials detected" hintAgent: ux-engineer