summaryrefslogtreecommitdiff
path: root/subagents/workflow.lua
diff options
context:
space:
mode:
authort <t@tjp.lol>2026-09-02 10:47:15 -0600
committert <t@tjp.lol>2026-09-02 10:47:37 -0600
commitb206f895d9d3e82fcd2dc028d993b66ab0734011 (patch)
treedf77a6a1c3667a088c6082eda1ad89ae70d0aeac /subagents/workflow.lua
parentfd2b3dfd85d8d87716481425216abc5e8cdd9c1b (diff)
Defer workflow completion wake until callback unwinds
Diffstat (limited to 'subagents/workflow.lua')
-rw-r--r--subagents/workflow.lua12
1 files changed, 11 insertions, 1 deletions
diff --git a/subagents/workflow.lua b/subagents/workflow.lua
index ff534cb..28a76a6 100644
--- a/subagents/workflow.lua
+++ b/subagents/workflow.lua
@@ -760,7 +760,17 @@ local function notify(record)
local submitted = pcall(primary.submit, primary, string.format(
"[subagents] Workflow %s %s. Inspect subagents.workflows[%q] with subagents.lua.",
record.id, record.status, record.id))
- if submitted then emit("agent_submission") end
+ if not submitted then return end
+
+ -- Completion runs inside a host callback. Let it unwind before asking the
+ -- TUI to drain the queued submission; synchronous dispatch can observe a
+ -- transient busy state and leave that submission parked until another turn.
+ local timer = uv.new_timer()
+ timer:start(0, 0, function()
+ timer:stop()
+ timer:close()
+ emit("agent_submission")
+ end)
end
local function finish_workflow(record, status, result, err)