Expand description
In-memory manager for pre-launch OAuth sessions.
See docs/specs/SPEC_PRE_LAUNCH_OAUTH_FLOW_2026_05_14.md §7.
Each session represents one user-initiated “Connect with OAuth”
attempt. The frontend creates a session via start_session,
polls via poll_session, optionally pastes a callback URL (the
auth.submitcallback handler forwards it via send_to_stdin),
and cancels via cancel_session.
PR A scope: the session-state machine + per-line stdout
interpretation + lifecycle (timeout, cancel, cleanup). The
actual CLI spawn lives in the handler (server/identity_auth_spawn.rs,
so it can use AppState’s CLI resolver) but emits frames into this
module via record_line / finish_success / finish_failure.
That keeps this module pure and testable.
Structs§
- Auth
Session Manager - Poll
Session Result - Snapshot returned by
poll_session. MirrorsAuthSessionStatusplus the provider id for renderer dispatch. - Process
Refs 🔒 - Per-session “process refs” — the join handle for the drain task
and the stdin sender for the callback-paste-back path. Held
outside the
sessionsMutex so cancellation can.abort()/ drop without holding the state lock across an await. - Session 🔒
- Start
Session Result - Public-facing handle returned by
start_session. The handler owns the spawned CLI’s child handle (so it can stdin-inject the pasted callback URL and kill on cancel); this manager owns the session state.
Enums§
Constants§
- FINISHED_
RETENTION_ 🔒SECS - How long a finished session stays pollable before
sweepdrops it. The UI stops polling once it sees the terminal state, so this only has to outlast one poll interval; it’s generous. - SESSION_
TIMEOUT_ 🔒SECS - Wall-clock cap on a single auth session. Past this, the session
transitions to
Failedand its CLI is killed, whether or not anyone is polling it (sweep). - SWEEP_
INTERVAL_ 🔒SECS - How often the sweeper runs (
spawn_sweeper).