Repository navigation
fix(sessions): stop blaming the queue for every launch that is not up yet - #226
Conversation
… yet A session stays in `queued` from the moment its row is written until the container workflow's first activity starts it — right through dispatch. Two screens read that state as "no slot for you" and said so, so an authentication session that was granted its slot in one second spent its whole launch telling the user to wait for capacity, with the user's own limit nowhere near full. A launch that failed outright said the same thing, with the real reason recorded only in `last_error` where nobody could see it. SessionAdmission#launch_phase answers what the session is actually waiting on, the resource carries it plus the launch's own error, and shared/lib/launchStatus is the single place that turns either into words. Also: "Session admission is closed" is the queue refusing a permit, which is what a `finish` landing mid-launch looks like from inside an activity. It used to become both the session's error message and the reason it was marked failed — pressing Finish four seconds in reported a failed session in the queue's vocabulary. A requested finish now keeps only whatever real error it already had. Co-Authored-By: Claude Opus 5 <[email protected]> Signed-off-by: Artem Petrov <[email protected]>
The API has one action for both intents — every "Cancel session" button and every dialog close POSTs `finish` — so a session stopped while its container was still coming up was reported with the vocabulary of a completed run. `ready_at` separates them: the session was never usable, so the person cancelled it. Across three days of production, `finishing_at` without `ready_at` described exactly the two authentication sessions this is about and not one of 2,168 workflow steps. Co-Authored-By: Claude Opus 5 <[email protected]> Signed-off-by: Artem Petrov <[email protected]>
|
Correction to the story above: the person did not press a finish button — there isn't one on that screen. The API has a single action for both intents (
Added in d0738ba:
|
What a person actually saw
Production, 2026-09-09 15:09 UTC. Connecting Antigravity from the profile page showed, for the whole launch:
Neither sentence was true. The session was granted its slot one second in, the pool was
user:3with a limit of 2 and nothing else in it, and the pod pulled its image in 2.5 s and started. Then Finish was pressed four seconds in, before the launch reachedexec, and the session was reported as:Nothing had failed, and that string is the queue refusing a permit, not a diagnosis.
Why
queuedfrom the moment the row is written until the container workflow's first activity callsstart!— right through dispatch. BothSessionShowContentand the profile auth modal keyed their copy onstate === 'queued'alone, so that state's second meaning ("your slot is granted, the container is coming up") was rendered as a full pool. The same screen text covered a launch that had failed outright and would never come up at all.admission.last_error— the refused preflight, the failed Temporal dispatch, the capacity refusal — was never exposed, so the queue message was the only explanation a user ever got.finalize_sessiontookstate[:error]at face value. Afinishlanding mid-launch makes the next activity raiseStopped, whose message then became botherror_messageand the reason forfailed.What changed
SessionAdmission#launch_phase—queued_for_slot/starting/cluster_capacity/namespace_quota/running, derived fromadmitted_at,launch_stateandwait_reasontogether. Neither signal answers it alone:wait_reasonalso defaults toconcurrency_limitat insert, so it agrees with whichever reading you already had.TerminalSessionResourcecarrieslaunchPhaseandlaunchError.shared/lib/launchStatusis the single place that turns a phase into words, used by both screens; the launch's own error is rendered instead of silence.GENERIC_ERROR_MESSAGESgains"Session admission is closed", andfinalize_sessionno longer fails a session over a generic message when the finish was requested.Tests
test/resources/terminal_session_resource_test.rb(new, 7 cases): a session nobody has a slot for reportsqueued_for_slot; a granted slot reportsstartingwhile still inqueued; cluster capacity reports itself; the launch's own error reaches the payload; a session with no admission claims nothing.admitted_phase_activity_test.rb: a finish requested mid-launch finishes clean (fails without the fix:Expected "finished", Actual "failed"), and a real error still fails a session the user asked to finish.shared/lib/launchStatus.test.ts+ fourSessionShowContentcases for the copy each phase produces.make check_allgreen: brakeman, eslint, fe-test, fsd, rails-test, rubocop, system-test, typescript, vite-build.Not in this PR
The reason anything in project 27 is genuinely queued right now is 16 leaked reservations — that is #224.
🤖 Generated with Claude Code