You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Validate interactive startup API keys before entering signed-in state (#14615)
## Description
Interactive desktop and Warp Agent CLI startup API keys could previously
enter shared `AuthState` before the server had validated them or
returned the associated user. Credential presence made
`AuthState::is_logged_in()` true and allowed interactive UI
initialization to treat the process as authenticated while identity
loading was still pending. If validation then failed, the TUI could
create a terminal and render a bare **Signed in** state with no
validated identity; the desktop app could similarly create its workspace
before validation completed.
This change fixes both parts of that lifecycle:
- `LaunchMode` now owns startup API-key extraction and
eager-versus-deferred policy;
- desktop app and interactive TUI startup keys remain pending outside
shared `AuthState`;
- the pending key is used only by
`AuthClient::fetch_user(LoginToken::ApiKey(...), false)`, after staging
IAP access is ready;
- successful validation atomically promotes the returned credentials and
user through the existing authentication-completion path;
- failed validation leaves shared auth state with neither credentials
nor a user and keeps interactive clients in their signed-out
authentication UI;
- an explicitly supplied interactive key still takes precedence over
persisted identity without exposing the unvalidated key to other
clients;
- command-line SDK behavior remains eager because it refreshes through
shared credentials and has an explicit `AuthComplete` barrier before
command dispatch;
- the TUI requires credentials plus a fetched user ID before entering
its logged-in phase or creating a terminal; and
- account labels fall back through email, username, and stable user ID,
otherwise reporting **Not signed in** instead of bare **Signed in**.
The SSH environment exposed the partial state but was not the root
cause. API keys are not persisted by Warp; a key present at startup
comes from the launch arguments or `WARP_API_KEY` environment inherited
by that process.
## Linked Issue
N/A — this was identified from logs for an SSH-launched Warp Agent CLI
session.
- [ ] The linked issue is labeled `ready-to-spec` or
`ready-to-implement`.
- [ ] Where appropriate, screenshots or a short video of the
implementation are included below (especially for user-visible or UI
changes).
## Testing
Added regression coverage for:
- desktop app and interactive TUI deferred startup-key policy;
- pending API-key normalization and validation with `for_refresh =
false`;
- failed validation emitting `AuthFailed` while leaving shared auth
state fully logged out;
- successful promotion installing the API-key credentials together with
the fetched user;
- credential-only startup, validated identity startup, zero-state
labels, stable user-ID fallback, and `/status` identity resolution.
Manual full-terminal validation:
- Ran `WARP_API_KEY=wk-invalid-pending-key ./script/run-tui` in a real
PTY.
- The TUI built and launched successfully.
- The invalid key was rejected and displayed the login failure/retry
flow.
- The TUI never entered a signed-in state and did not create a shell
terminal.
Previously completed for the original TUI state-gating patch:
- App TUI authentication module: 17 tests passed.
- Full `warp_tui` suite: 966 tests passed.
- `./script/format` passed.
- Relevant workspace, app, and completer Clippy commands passed.
No additional automated suite, Clippy, presubmit, or formatting run was
performed after the pending-key lifecycle follow-up; validation of that
follow-up used the real TUI terminal flow above.
No process-level integration test was added because the headless TUI
does not use the GUI integration harness; state-transition and
render-to-lines unit tests cover the regression directly.
- [ ] I have manually tested my changes locally with `./script/run`
## Agent Mode
- [x] Warp Agent Mode - This PR was created via Warp's AI Agent Mode
- Agent conversation:
https://staging.warp.dev/conversation/f0184211-8c6c-4695-8ca1-6b0972449c78
CHANGELOG-BUG-FIX: Fixed interactive Warp clients treating startup API
keys as authenticated before validation completed.
Co-Authored-By: Oz <oz-agent@warp.dev>
---------
Co-authored-by: Oz <oz-agent@warp.dev>
0 commit comments