zot/internal/agent/modes
patriceckhart 616eed3bd6 fix(tui): persist transcript to session file after every turn
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.
2026-04-20 12:11:15 +02:00
..
telegram feat(telegram): mirror tui prompts into telegram thread 2026-04-20 09:33:03 +02:00
btw_dialog.go fix(tui): three cursor/alignment fixes in the editor and /help 2026-04-19 20:25:34 +02:00
changelog_dialog.go feat(tui): show github release notes once after upgrading 2026-04-19 16:12:13 +02:00
confirm_dialog.go fix(cli): load extensions in print and json modes too 2026-04-19 20:00:36 +02:00
dialog_frame.go fix(tui): cell-aware width math for dialog header rules + add /btw 2026-04-19 13:47:39 +02:00
help.go fix(tui): three cursor/alignment fixes in the editor and /help 2026-04-19 20:25:34 +02:00
interactive.go fix(tui): persist transcript to session file after every turn 2026-04-20 12:11:15 +02:00
json.go feat(tui): live-stream file body during write/edit tool calls 2026-04-20 08:37:14 +02:00
jump_dialog.go tui: /jump to scroll to past turns, render cache for long transcripts 2026-04-18 12:22:16 +02:00
login_dialog.go initial commit 2026-04-17 20:36:38 +02:00
logout_dialog.go feat(auth,tui): dark login pages + /logout picker 2026-04-19 20:14:22 +02:00
model_dialog.go add telegram bot bridge 2026-04-18 09:15:46 +02:00
print.go initial commit 2026-04-17 20:36:38 +02:00
session_dialog.go fix(tui): hide empty sessions from the /sessions picker 2026-04-19 17:16:45 +02:00
session_ops_dialog.go feat(session): /session export + import with portable .zotsession file 2026-04-20 10:04:33 +02:00
session_tree_dialog.go feat(session): /session fork + /session tree 2026-04-20 11:10:56 +02:00
skills_dialog.go feat: skills — reusable instructions discovered from SKILL.md files 2026-04-19 14:32:30 +02:00
slash_suggest.go chore(tui): reorder slash catalog 2026-04-20 11:41:45 +02:00
spinner.go fix(tui): cell-aware width math for dialog header rules + add /btw 2026-04-19 13:47:39 +02:00
telegram_dialog.go feat(tui): /telegram connect | disconnect | status 2026-04-20 09:18:04 +02:00
update_banner.go tui: show 'update available' banner at top of chat 2026-04-18 11:49:22 +02:00
welcome.go tui: show binary version in the welcome banner for 1 second 2026-04-19 13:22:10 +02:00