mirror of
https://github.com/patriceckhart/zot.git
synced 2026-06-26 21:36:31 +02:00
Previously the tui lazily flushed the agent messages to the session file only at exit via WriteNewTranscript, plus opt-in via /session export or /session tree. That meant a mid-session crash, kill -9, or power loss dropped the entire conversation from disk even though the summary was visible in the scrollback. Now the turn-drain goroutine in startTurn() calls FlushSession() right after i.agent.Prompt returns, while the turn memory is still hot. FlushSession is the same idempotent helper used by /session export and /session tree: it appends only the rows past the current baseline and advances the baseline, so double writes cant happen even if the exit-time flush also fires. Ordering in the goroutine: lock -> clear busy/streamOn/cancel -> read the flush callback -> unlock -> flush -> relock for the queue-drain and auto-compact decisions. The short unlocked window is safe because no other goroutine reads those fields at that moment (busy is already false). No new config hook; reuses the existing FlushSession the cli wires in. |
||
|---|---|---|
| .. | ||
| agent | ||
| assets | ||
| auth | ||
| core | ||
| extproto | ||
| provider | ||
| skills | ||
| tui | ||