Files
npub1ty04d6th3jzvggd25za6xmqrh99g42kvkvqsmf7ydv793fgyxa3s3t2lw7andBradley Axen b76292d457 fix(desktop): auto-restart setup-mode agents when an edit satisfies readiness
A harness spawned with BUZZ_ACP_SETUP_PAYLOAD runs as a nudge-only setup
listener and never re-evaluates its config — readiness is only computed at
spawn. Fixing the missing model/provider in Edit Agent therefore changed
nothing: the stale setup-mode process stayed connected to the relay and kept
replying "needs configuration" to every mention, with no hint that a restart
was required.

Stamp was-spawned-in-setup-mode on the in-memory ManagedAgentProcess at spawn
time (runtime-only, never persisted), and in update_managed_agent stop +
respawn the process when the edit makes the record pass readiness — inside
the same store-lock section the save already holds, reusing
stop_managed_agent_process / start_managed_agent_process. The respawn is
best-effort: a failure is surfaced via record.last_error and never fails the
save itself. Healthy (non-setup-mode) processes keep the existing
"takes effect on next spawn" contract and the needs_restart badge.

The readiness gate lives in setup_mode_now_ready, which mirrors the
spawn-time computation (effective harness resolution + effective env), with
unit tests covering fixed config, still-missing model, still-missing
credential, and the non-setup-mode no-op.

Co-authored-by: Bradley Axen <baxen@squareup.com>
Signed-off-by: Bradley Axen <baxen@squareup.com>
2026-07-07 20:22:03 -07:00
..