fix: confirm kebab resource name + improve Fly.io sandbox auth (#1525)

shared/common.sh — prompt_spawn_name():
  Replace log_info with safe_read so user confirms (or overrides) the
  derived kebab-case resource name before it's used for any cloud resource:
    Spawn name (e.g. "My Dev Box"): My Claude Box
    Resource name [my-claude-box]: ⏎   ← press Enter to accept

fly/lib/common.sh — _try_fly_browser_auth():
  - Print auth URL prominently on its own line (not just as a warning)
    so sandbox users can copy-paste it into their local browser
  - Suppress open_browser errors (|| true) so the script doesn't abort
    if no browser is available
  - Add explicit sandbox hint while polling
  - After 120s timeout: offer manual API token entry as a last resort
    with a direct link to fly.io/dashboard → Tokens

Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
L 2026-02-20 10:12:49 -05:00 committed by GitHub
parent f2df9bffa5
commit be176e4cdb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 5 deletions

View file

@ -168,9 +168,13 @@ _try_fly_browser_auth() {
return 1
fi
log_info "Opening browser for Fly.io login..."
log_warn "If the browser doesn't open, visit: $auth_url"
open_browser "$auth_url"
# Show the URL prominently so sandbox users can copy it
log_step "Fly.io login required. Open this URL in your browser:"
printf '\n %s\n\n' "$auth_url" >&2
open_browser "$auth_url" 2>/dev/null || true
log_info "Waiting for browser authentication (up to 120s)..."
log_warn "Running in a sandbox? Copy the URL above into your local browser."
# Poll for the access token (max 120 seconds, 2s intervals)
local attempt=0
@ -191,7 +195,16 @@ _try_fly_browser_auth() {
fi
done
log_warn "Browser login timed out after 120 seconds"
# Polling timed out — offer manual token entry as last resort
log_warn "Browser login timed out. You can paste a token manually."
log_warn "Generate one at: https://fly.io/dashboard → Tokens → Create token"
local manual_token
manual_token=$(safe_read "Paste Fly.io API token (or press Enter to skip): ") || return 1
if [[ -n "${manual_token}" ]]; then
echo "${manual_token}"
return 0
fi
return 1
}

View file

@ -546,9 +546,17 @@ prompt_spawn_name() {
kebab=$(_to_kebab_case "${display_name}")
[[ -z "${kebab}" ]] && kebab="spawn"
# Confirm the kebab-case resource name — user can press Enter to accept or type a custom value
local confirmed
confirmed=$(safe_read "Resource name [${kebab}]: ") || confirmed=""
if [[ -n "${confirmed}" ]]; then
kebab=$(_to_kebab_case "${confirmed}")
[[ -z "${kebab}" ]] && kebab="spawn"
fi
export SPAWN_NAME_DISPLAY="${display_name}"
export SPAWN_NAME_KEBAB="${kebab}"
log_info "Resource name: ${kebab}"
log_info "Using resource name: ${kebab}"
}
# Generic function to get resource name from environment or prompt