feat(tui): `/logout` signs out of the provider behind the current model
Merged
SA
3d ago+422+422+012345678901234567890123456789-9-9-0123456789
What
/logout signed out of the Altimate LLM Gateway only. Anyone signed in with ChatGPT, Claude or an API key had to leave the TUI and run altimate auth logout <provider>, and a running TUI kept showing the provider until it reloaded.
/logout now signs out of the provider behind the current model, and its title names it:
| Current model's provider | /logout title | What it does |
|---|---|---|
| Altimate LLM Gateway | Log out of Altimate LLM Gateway | Existing gateway sign-out (key file, MCP servers, skills) |
| Altimate Base | Log out of Altimate Base | FreeTier.logout(), as altimate auth logout altimate-free does |
| Saved API key | Log out of OpenAI (API key) | auth.remove, then reload |
| Saved subscription sign-in | Log out of OpenAI (ChatGPT subscription) | auth.remove, then reload |
| Claude Agent | Log out of Claude Agent (Claude Code connection) | Removes the /connect marker; the Claude Code sign-in stays with claude |
| OpenCode free models | OpenCode free models need no login | Toast: nothing to log out of |
| Set by an env var | OpenAI is set by OPENAI_API_KEY | Toast: unset it and restart |
| Set in config / by another tool | … is set in your config / connected outside Altimate Code | Toast explaining where to remove it |
After confirming:
- the provider list reloads, and the toast names the model now in use;
- if an env key or config entry keeps the provider connected, a warning says so;
- if nothing is left,
/connectopens; - if the reload hasn't landed after 10 s, a warning says to run
/logoutagain or restart.
How
- Server:
Provider.Infogains an optionalauth: "api" | "oauth" | "wellknown", the saved login type.sourcecan't carry this: a config entry or env key overrides it, and a subscription loads ascustom. The SDK type is edited by hand (one line), because a full regen pulls in ~18k lines of unrelated drift that CI regenerates at release anyway. - TUI:
packages/tui/src/util/logout-target.tspicks the target and title.app.tsxruns it. The gateway and Base sign-outs stay in the opencode-side plugin (provider-credentials.tsx), because they needAltimateApi/FreeTier. - Docs: new "Signing out of a provider" section in
configure/providers.md.
Testing
- Unit:
packages/tui/test/util/logout-target.test.ts(15 cases, including several saved logins where only the current model's provider is picked). Three server cases intest/provider/provider.test.ts: a saved key reportsauth: "api"under a config entry, a saved sign-in reportsauth: "oauth", and an env-only provider has noauth. bun testinpackages/tui(379 pass),test/provider(887 pass), typecheck fortuiandopencode, the marker guard, and markers checked by hand inapp.tsxandprovider.ts.- Mutations: picking the first saved provider instead of the current model's, and a server that reports only API keys, each fail a test.
- E2E: the real TUI in tmux with isolated
XDG_*/OPENCODE_TEST_HOME:- Saved OpenAI API key: title "Log out of OpenAI (API key)"; confirming empties
auth.jsonand the toast says "Now using Tidepool Alpha Free". - ChatGPT OAuth login: title "Log out of OpenAI (ChatGPT subscription)"; confirming removes it.
- Saved key plus
OPENAI_API_KEY: after logout the warning reads "Removed the saved login. OpenAI is set by OPENAI_API_KEY…", and the title changes to "OpenAI is set by OPENAI_API_KEY". Running it shows the hint with no confirm dialog. - Gateway (fake key file): title "Log out of Altimate LLM Gateway"; confirming deletes
~/.altimate/altimate.json, shows "Signed out of Altimate LLM Gateway", and falls back to another model.
- Saved OpenAI API key: title "Log out of OpenAI (API key)"; confirming empties
- Review follow-ups (second commit), E2E again with isolated
HOMEand fake credentials:- Claude Agent plus a saved OpenAI key, Claude Agent current: title "Log out of Claude Agent (Claude Code connection)"; confirming removes only
claude-agentfromauth.json, and the toast says "Now using GPT-5.6 Terra". - Free model current: title "OpenCode free models need no login"; running it shows the hint and removes nothing.
- Saved OpenAI key, saved key plus
OPENAI_API_KEY, and the gateway: same results as above.
- Claude Agent plus a saved OpenAI key, Claude Agent current: title "Log out of Claude Agent (Claude Code connection)"; confirming removes only
- Not exercised E2E: the 10 s reload warning (the reload took about 8 s each time), and Altimate Base, because registering needs the live service. Its path is the same steps as the CLI's
altimate auth logout altimate-free.
🤖 Generated with Claude Code
https://claude.ai/code/session_01XM3J9koiiw5bTqfbB6xaMU
Summary by cubic
Makes /logout in the TUI sign out of the provider behind the current model. Previously it only signed out of the Altimate LLM Gateway; ChatGPT, Claude, and API-key logins had to be removed with altimate auth logout from a terminal.
- The
/logouttitle names the provider and sign-in type, e.g. "Log out of OpenAI (ChatGPT subscription)". - Providers set by an environment variable, config, or another tool show an explanation instead of a confirm dialog.
- After logout, the provider list reloads; the toast names the model now in use, warns when an env key keeps the provider connected, and reopens
/connectwhen nothing is left. - Gateway and Altimate Base keep their own opencode-side sign-outs; other saved logins go through
auth.remove. Provider.Infogains an optionalauthfield so the TUI can tell an API key from a subscription; the SDK type is edited by hand to avoid unrelated regeneration drift.- Docs: new "Signing out of a provider" section in
configure/providers.md.
Summary by CodeRabbit
- New Features
- Added
/logoutfor the provider associated with the current model. Saved credentials require confirmation, and the app reports the logout status. - Added logout support for Altimate Base. For externally managed connections, including Claude Agent, the app explains that they must be disconnected elsewhere.
- After logout, the app can switch to another connected model or open the provider picker when none is available.
- Added
- Documentation
- Clarified that
/logoutremoves the Altimate gateway credential only when a gateway model is selected. Documented provider logout behavior, cases where a connection cannot be removed, and terminal logout with an optional provider name.
- Clarified that