mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 10:07:19 +01:00
fix(daemon): delete stale /tmp/agent-current-prompt-<tab> in push loop
Companion to the UI staleness gate. Closes the leak at the source so
the sentinel doesn't keep getting re-pushed every 2s — fires the same
two checks the UI uses (session-mtime newer than prompt-start, OR
prompt older than 30min) inside _push_loop, deletes the file, and
clears cpk/cpl/cpsat so the JSON pushed to /api/control/runtime-state
carries nulls.
Verified against live state:
- OrangeCat: 3-day-old "echo ui-dispatch-test" prompt → cleared
after daemon restart (DB row's current_prompt_started_at went
null within one push interval).
- revamp-it: 30-min-old "Auto: next_best" → cleared on next push.
Companion to:
fix(control): stale "Working" defense — gate currentPrompt by
session signals + time
This commit is contained in:
1 file changed
+17
@@ -572,6 +572,23 @@ _build_state_json() {
|
||||
[[ "$mts" =~ ^[0-9]+$ ]] && sess_mtime="$mts"
|
||||
fi
|
||||
|
||||
# Stale-prompt cleanup: Codex has no Stop hook (interactive TUI), so
|
||||
# /tmp/agent-current-prompt-<tab> lingers indefinitely after the agent
|
||||
# returns to idle. Without this gate the control UI shows "Codex working
|
||||
# 61h" on dead tabs. Two signals fire the cleanup: (1) the session file
|
||||
# was rewritten after the prompt started — the agent wrote a handoff so
|
||||
# the cycle closed; (2) the prompt is older than 30 min (hard cap for
|
||||
# agents that never write a session file).
|
||||
if [ "$cpsat" != "null" ]; then
|
||||
local _now_s
|
||||
_now_s=$(date +%s)
|
||||
if { [ "$sess_mtime" != "null" ] && [ "$sess_mtime" -gt "$((cpsat + 5))" ]; } \
|
||||
|| [ "$((_now_s - cpsat))" -gt 1800 ]; then
|
||||
rm -f "$pf"
|
||||
cpk="" cpl="" cpsat="null"
|
||||
fi
|
||||
fi
|
||||
|
||||
local proj
|
||||
proj=$(jq -n \
|
||||
--arg tab "$tab" \
|
||||
|
||||
Reference in new issue
Block a user