fix(auth): `auth logout` removes the saved Altimate gateway key

SA
1h ago
+74-0

Problem

altimate-code auth logout → "altimate-backend" removed only the auth.json entry. Browser sign-in also saves the gateway key to ~/.altimate/altimate.json, and the provider loader and all workspace calls (api-client, state, identity, memory/skill sync, link, datamate) read that file first. After sign-out the key stayed on disk and still worked, so delegated runs (e.g. /altimate-code:altimate from Claude Code) kept sending requests as the signed-out user. On a shared machine, the next person's runs go out under the previous user's identity.

Fix

  • providers.ts: logging out of altimate-backend now calls AltimateApi.clearCredentials() (via cliTry, so a failed delete is reported rather than "Logout successful").
  • providers.ts: the logout picker lists altimate-backend when only altimate.json exists (credentials pasted in the TUI dialog). Before, the CLI reported "No credentials found" and gave no way to sign out.
  • provider-credentials.tsx: TUI /logout also removes the auth.json entry. A pasted url::instance::key there would otherwise keep the provider loader's fallback path working.

After sign-out, workspace calls hit NotConfiguredError ("Altimate credentials not configured — sign in first.").

Not in scope

The key is only removed locally; it is not revoked on the server. Revoking it at sign-out needs a backend endpoint.

Testing

  • New CLI test in test/cli/providers-logout.test.ts covers browser sign-in (both stores) and file-only credentials. It fails on main (altimate.json still present) and passes with this change.
  • bun test test/cli test/upstream/fork-feature-guards.test.ts: 1187 pass. 4 failures in test/cli/run/{json-output,budget-finalization}.test.ts also fail on main and are unrelated.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Logging out of the Altimate backend now removes its saved credentials, whether they’re stored in Altimate’s settings or the shared authentication store.
    • Logout works consistently from the command line and the interface, while leaving credentials for other providers unchanged.
  • Documentation
    • Added instructions for signing out of the Altimate LLM Gateway using the command line or the interface.