feat(arcade-cli): remember login host for subsequent commands#847
feat(arcade-cli): remember login host for subsequent commands#847EricGustin wants to merge 4 commits into
Conversation
Persist the Coordinator and Engine URLs after `arcade login` so every follow-up CLI command targets the same environment without repeating the `-h` flag. Resolution order is explicit flags > saved URL > production default. - Add `engine_url` field to `Config` (saved alongside `coordinator_url`) - Add `derive_engine_url_from_coordinator` for the `cloud.X` -> `api.X` convention (plus localhost mapping) - Add `resolve_engine_url` / `resolve_coordinator_url` helpers used by every command callback - `arcade login` derives and persists the Engine URL; banner shows both - `arcade whoami` prints both URLs (non-prod highlighted) - `server`, `secret`, `show`, `deploy`, `dashboard`, `org`, `project` default their `-h` flag to None and resolve through the saved URL
Previously, passing only --port, --tls, or --no-tls (without -h) made the resolver fall back to the production host and drop the host saved at login. A user logged into a non-prod environment who ran `arcade server list --no-tls` would silently hit the production engine. Now: -h is a clean override (saved host ignored); --port / --tls / --no-tls layer on top of the saved host so the connection stays in the same environment. The saved scheme and port are preserved unless explicitly overridden.
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 dd97fb4. Configure here.
…olver URL resolution now runs on every CLI command, so a corrupted credentials.yaml (malformed YAML, unreadable file) must not crash unrelated commands. Widen the catch to include yaml.YAMLError and OSError, log a warning so the cause is discoverable, and fall back to production defaults.
The `arcade whoami` command goes through main_callback, which uses the CREDENTIALS_FILE_PATH constant baked at module import time. Pre-existing constants in arcade_core.constants do not honor ARCADE_WORK_DIR after import, so the test passed locally only because the user already had a real ~/.arcade/credentials.yaml. Patch the imported constant in the fixture to point at the same file Config writes to.
|
This pull request has been automatically marked as stale because it has had no activity for 14 days. It will be closed in 14 days if no further activity occurs. If this is still relevant, please leave a comment or remove the stale label. |
|
This pull request has been automatically marked as stale because it has had no activity for 14 days. It will be closed in 14 days if no further activity occurs. If this is still relevant, please leave a comment or remove the stale label. |
|
This pull request has been closed due to inactivity. Feel free to reopen it if it is still relevant. |

Summary
arcade login -h cloud.X.devnow persists the matching Engine URL so every subsequent CLI command (engine-side and coordinator-side) targets that environment by default. Today, users who log into a non-prod host have to repeat-hon every command, and confusingly some commands expect the Coordinator host (cloud.X.dev) while others expect the Engine host (api.X.dev).Resolution order is now: explicit flags > saved URL > production default.
Resolves:
Design decisions
coordinator_urlwas already persisted but never used as a default; this PR addsengine_urlnext to it. Storing both is simpler and clearer than recomputing the engine URL on every command.derive_engine_url_from_coordinatorswaps thecloud.prefix forapi.and preserves the port; localhost getslocalhost:9099. Unknown hostnames returnNoneso the caller falls back to prod, matching today's behavior. This avoids inventing a parallel--engine-hostflag at login time for the 99% case while leaving a clean follow-up if a non-conventional env ever needs it.resolve_engine_url,resolve_coordinator_url) instead of magic inside each callback. Each typer.Option-hdefault flips fromPROD_*_HOSTtoNone, and the callback body becomes a one-liner.credentials.yamlfiles don't haveengine_urlset; commands fall back toapi.arcade.devexactly as before. Logged-out users see no behavior change.whoamisurfaces both URLs, with non-prod URLs highlighted in yellow so a glance confirms which environment is active. Login banner shows them too.Scope
In scope:
-hflag resolves through the saved URLwhoamisurfaces both URLsNot in scope (handled separately):
arcade env use staging) — bigger feature that can build on top of this--engine-hostflag onarcade loginfor non-conventional hosts — small follow-up if a real env stops following thecloud.X/api.XconventionTest plan
make check(ruff + mypy) cleanmake test— 3605 passed, 1 skipped (evals)whoamioutputcredentials.yamlwith non-prod URLs to a tmpARCADE_WORK_DIR, confirmedresolve_engine_url/resolve_coordinator_urlreturn the saved URLs, and that explicit flags still overridearcade login -h <non-prod-coordinator>thenarcade server list/arcade secret list/arcade org listwith no-hand confirm each hits the right hostRisk note
Touches the CLI surface every internal user relies on. Blast radius:
test_*_no_creds_falls_back_to_prodtests.engine_urlisNoneuntil they re-log in, so commands fall back to prod. Same behavior as today. No migration required.arcade login, commands stop needing-h. If derivation fails for some reason,engine_urlstaysNoneand they get the same behavior as today.-h/-p/--tls/--no-tlsalways wins, so the escape hatch is preserved.Author checklist
make checkandmake testgreen locally; CI is expected to passNote
Medium Risk
Touches host/URL selection logic across many CLI commands and changes default targeting behavior after login, so regressions could misroute requests to the wrong environment. Risk is mitigated by centralized resolution helpers plus extensive new unit tests and safe fallbacks to prod when credentials are missing or unreadable.
Overview
After
arcade login, the CLI now persists both Coordinator and Engine base URLs (newConfig.engine_url) so subsequent commands default to the same environment without repeatedly passing-h/--host.Adds centralized URL resolution (
resolve_engine_url,resolve_coordinator_url) that applies explicit flags > saved URL > prod defaults, including layering--port/--tls/--no-tlson top of the saved host when--hostisn’t provided, and falling back safely ifcredentials.yamlis missing/corrupted.Updates engine- and coordinator-backed commands (e.g.,
server,secret,org,project,show,deploy,dashboard) to use the new resolvers and makes--hostoptional, whileloginderives and saves the matching engine URL andwhoaminow prints both URLs (highlighting non-prod). Extensive new tests cover persistence, derivation, resolution precedence, and callbacks using saved defaults.Reviewed by Cursor Bugbot for commit 0aa63d3. Bugbot is set up for automated code reviews on this repo. Configure here.