Files
kandev/apps
João Salavisa 2416b8dd49 fix(orchestrator): drain queued message on workflow transition to non-auto-start step (#726)
* fix(orchestrator): drain queued message on workflow transition to non-auto-start step

A workflow transition (e.g. In Progress → Review) made handleAgentReady
early-return before draining the message queue, on the assumption that
the new step's auto_start_agent would handle the next prompt (#677). For
steps without auto_start_agent (Review, etc.) nothing ever drained the
queue and user-queued messages stuck forever.

Add drainQueuedMessageAfterTransition and call it from the two
processOnEnter paths that don't auto-start the agent (no on_enter
actions, and the default switch case). Restores pre-#677 behavior for
non-auto-start transitions while keeping the deadlock fix for
auto-start steps intact.

Includes regression test covering the no-on_enter-actions case.

* fix(orchestrator): address PR review feedback on queue drain

- Log a Warn when drainQueuedMessageAfterTransition discards an empty
  queued message, matching handleAgentReady's behavior. (Claude)
- Fix data race on mockAgentManager.capturedPrompts surfaced by `-race`:
  PromptAgent now appends under the existing mu, and adds an opt-in
  promptDone channel so tests can wait deterministically. (Claude)
- Replace sleep-based polling in the new regression test with a select
  on promptDone — matches the project's no-time.Sleep guideline.
  (Claude, CodeRabbit)
- Drain the queue in the sessionSwitched + step.Prompt error handler
  goroutine in processOnEnter — same orphan-queue class of bug as the
  rest of this PR, just on a different no-auto-start path. (Greptile P1)

---------

Co-authored-by: Kandev Agent <agent@kandev.dev>
2026-04-28 15:40:32 +01:00
..
2026-04-27 19:44:04 +01:00
2026-02-26 23:08:15 +00:00