mirror of
https://github.com/patriceckhart/zot.git
synced 2026-06-26 21:36:31 +02:00
Two bugs in yesterday's /session export + import: 1. Quoted / tilde paths weren't normalised. Drag-drop paste in the tui auto-quotes dropped file paths so the shell-style `/session import 'foo bar.zotsession'` stays well-formed. But the /session handler's expandTilde checked for a leading '~' and the string's first char was a literal quote, so the tilde never expanded and stat failed with "no such file or directory". unquotePath helper now strips a matching pair of surrounding single or double quotes before expandTilde runs. Applies to both export (dst) and import (src). 2. Export was writing only the meta row when called mid-session. The tui's default persistence strategy writes agent messages to the session file lazily: WriteNewTranscript runs once when the tui exits, NOT after every turn. Meanwhile the running agent's messages live in a sync.Mutex-guarded slice in core.Agent.messages. /session export was reading the file bytes off disk, which at that point only contained the meta row plus whatever was there on startup. New FlushSession hook on InteractiveConfig: the cli wires it to WriteNewTranscript against the current agent, then advances sessBaselineMsgs so the tui's own exit-time flush doesn't double-write. /session export calls the hook right before ExportSession, so the file on disk reflects the full running transcript at the moment the user hit enter. Tests: - internal/core/session_portable_test.go was already exercising ExportSession/ImportSession against on-disk files; this fix lives in the cli/modes glue, not in core. - internal/agent/modes ad-hoc TestUnquotePathThenExpandTilde (run locally, not committed) covered the 8 tilde+quote combinations. Verified: create a fresh session, type "hello", reply, "foo", reply, run /session export. Exported .zotsession now contains the meta row + 2 user + 2 assistant + 1 usage row. Re-import into a different cwd via /session import <path>, /sessions to confirm it lands as a resumable entry. |
||
|---|---|---|
| .. | ||
| agent | ||
| assets | ||
| auth | ||
| core | ||
| extproto | ||
| provider | ||
| skills | ||
| tui | ||