Merge branch 'worktree-simplify-agent-stop' into worktree-simplify-trace-events

This commit is contained in:
Tianyi Cui
2026-06-21 18:38:29 +08:00
9 changed files with 43 additions and 43 deletions

View File

@@ -253,12 +253,15 @@ interface Agent {
/**
* Resolve once the agent has reached quiescence after settling out of
* `running`, or immediately if it is already idle with no queued work. The
* quiescence signal a teardown awaits: a lifecycle owner disposes the agent
* through its `AgentHandle` (which aborts in-flight work then awaits this), so
* the caller proceeds only after queued/running work has fully stopped (a
* closing ACP connection, a disposing UI plugin) rather than returning while
* the driver is still streaming or about to start a queued turn.
* `running`, or immediately if it is already idle with no queued work. A
* non-owner's quiescence-observation hook: a consumer that does NOT own the
* agent's lifecycle awaits this to proceed only after queued/running work has
* fully stopped, rather than returning while the driver is still streaming or
* about to start a queued turn — without itself tearing the agent down. (A
* lifecycle OWNER does not need it: `AgentHandle.dispose()` already awaits the
* loop-exit promise directly as part of stopping and unregistering. So this is
* for a non-owning observer — e.g. a test awaiting a turn to settle, or a
* monitor — that wants the settle signal but must not dispose the agent.)
*
* "Quiescence", not merely "status changed": a disposed agent emits
* `agent/status('disposed')` from inside its disposer, BEFORE the driver loop
@@ -266,10 +269,6 @@ interface Agent {
* to actually exit (the implementation chains the loop-exit promise), not just
* observe the status flip. A mid-step disposal that never reaches `idle` still
* unblocks the await this way.
*
* Distinct from disposal: `whenIdle()` observes the transition WITHOUT tearing
* the agent down. A consumer that owns the agent's lifecycle disposes it
* separately.
*/
whenIdle(): Promise<void>