summaryrefslogtreecommitdiff
path: root/panto-herdr
diff options
context:
space:
mode:
authort <t@tjp.lol>2026-09-01 12:00:53 -0600
committert <t@tjp.lol>2026-09-02 08:29:54 -0600
commit04791c3273ab7076cc53f146d7751670d86c5c9b (patch)
treee8eba4e49fa5ea1de7f75b70f064c864158ce5d0 /panto-herdr
parent11aa2e9d8a8016eee008a8a043501aae96c873d4 (diff)
Keep Herdr reports current across Panto sessions
Use wall-clock-based report sequences so restarted processes supersede stale state, adopt the current message flag, restore idle state after replay, and release the agent report when a session ends.
Diffstat (limited to 'panto-herdr')
-rw-r--r--panto-herdr/init.lua35
1 files changed, 27 insertions, 8 deletions
diff --git a/panto-herdr/init.lua b/panto-herdr/init.lua
index dffef51..cc0b527 100644
--- a/panto-herdr/init.lua
+++ b/panto-herdr/init.lua
@@ -11,10 +11,22 @@ return {
local panto = require("panto")
local uv = require("luv")
- local seq = 0
+ -- Herdr orders reports by source and sequence. Seed each process from
+ -- wall time so a restarted panto cannot be shadowed by the prior
+ -- process's larger sequence numbers.
+ local seq = os.time() * 1000000
local last_state
local last_status
+ local function spawn(args)
+ local handle
+ pcall(function()
+ handle = uv.spawn("herdr", { args = args, stdio = { nil, nil, nil } }, function()
+ if handle then handle:close() end
+ end)
+ end)
+ end
+
local function report(state, status)
if state == last_state and status == last_status then return end
last_state, last_status = state, status
@@ -28,19 +40,25 @@ return {
"--seq", tostring(seq),
}
if status then
- args[#args + 1] = "--custom-status"
+ args[#args + 1] = "--message"
args[#args + 1] = status
end
- local handle
- pcall(function()
- handle = uv.spawn("herdr", { args = args, stdio = { nil, nil, nil } }, function()
- if handle then handle:close() end
- end)
- end)
+ spawn(args)
+ end
+
+ local function release()
+ seq = seq + 1
+ spawn({
+ "pane", "release-agent", pane_id,
+ "--source", "panto:extension",
+ "--agent", "panto",
+ "--seq", tostring(seq),
+ })
end
panto.ext.on("session_start", function() report("idle") end)
+ panto.ext.on("session_ready", function() report("idle") end)
panto.ext.on("user_message", function() report("working", "thinking") end)
panto.ext.on("thinking", function() report("working", "thinking") end)
panto.ext.on("compaction", function() report("working", "compacting") end)
@@ -49,5 +67,6 @@ return {
end)
panto.ext.on("assistant_text", function() report("working", "responding") end)
panto.ext.on("assistant_text_complete", function() report("idle") end)
+ panto.ext.on("session_end", release)
end,
}