mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-03 05:59:43 +02:00
fix(custom-model): wait for a freshly launched session to go idle before applying
Root cause of every 'Session is busy' apply failure reported from live
testing: a just-launched CLI reports itself 'busy' for its own startup
(boot spinner, workspace-trust check) well before runCustomModelEntry's
apply call could reach it, and the apply route's isBusy() guard correctly
cannot tell that apart from a real turn in progress — it exists precisely
to refuse restarting a session mid-turn, and a fresh boot looks exactly
like one from the outside. Confirmed live: replaying the identical apply
call by hand against the same session, once it had settled, succeeded
immediately.
Fixed by waiting on the session's own readiness signal before applying:
GET /api/sessions/:id/wait?until=idle&timeout=20000, one GET already built
for exactly this ('Agent wait primitives', CLAUDE.md) rather than inventing
a client-side poll loop. A timeout there is a normal 200 per that
endpoint's own contract, never an error, so a session still busy after 20s
just reaches the apply call anyway and gets the route's own honest error —
now visible, since the previous commit made error toasts sticky and
stopped discarding the real error text.
Tests: new case in custom-model-run-menu-ui.test.ts pins the ordering (the
wait call happens, and strictly before the apply call) and its exact query
string.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RqZeHrRS6DYcGcGX2p9EwG
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
409a6e65f9
commit
5c25a52f95
@@ -721,6 +721,19 @@ Object.assign(CodemanApp.prototype, {
|
||||
const sessionId = this.activeSessionId;
|
||||
if (!sessionId || sessionId === before) return;
|
||||
|
||||
// A freshly launched CLI reports its OWN startup as 'busy' (spinner, the
|
||||
// workspace-trust check, whatever else it does before its first prompt) —
|
||||
// measured landing well before this line reliably reaches it — and the
|
||||
// apply route's isBusy() guard correctly refuses to restart a session
|
||||
// mid-turn, "mid-turn" included, which this fresh boot looks exactly
|
||||
// like from the outside. Give it a bounded chance to settle first rather
|
||||
// than raising a false "Session is busy" on every single launch. Per the
|
||||
// wait contract a timeout here is a normal 200, never an error — a
|
||||
// session still busy after 20s just reaches the apply call below and
|
||||
// gets the route's own honest, now-visible SESSION_BUSY error instead of
|
||||
// this guessing about it.
|
||||
await this._apiJson(`/api/sessions/${sessionId}/wait?until=idle&timeout=20000`);
|
||||
|
||||
// _apiJson() (used everywhere else in this file) unwraps a success body to
|
||||
// its `data`, but on failure it swallows the response entirely and returns
|
||||
// null — exactly the `error` text a caller needs to tell "the endpoint is
|
||||
|
||||
Reference in New Issue
Block a user