zot/internal/agent
patriceckhart 9b063d871b fix(session): export the full running conversation, handle quoted paths
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.
2026-04-20 10:19:53 +02:00
..
extensions feat(ext): phase 4 - full-event interception, arg rewrites, /reload-ext 2026-04-19 17:02:04 +02:00
modes fix(session): export the full running conversation, handle quoted paths 2026-04-20 10:19:53 +02:00
tools feat(tui,bash): shell-log style bash results 2026-04-20 09:03:24 +02:00
args.go fix(no-yolo): don't auto-refuse tool calls in non-interactive modes 2026-04-19 19:17:05 +02:00
botcmd.go fix ci on windows: split detach helper into posix/windows variants 2026-04-18 10:58:10 +02:00
botcmd_unix.go fix ci on windows: split detach helper into posix/windows variants 2026-04-18 10:58:10 +02:00
botcmd_windows.go fix ci on windows: split detach helper into posix/windows variants 2026-04-18 10:58:10 +02:00
build.go rename: /lock -> /jail, /unlock -> /unjail 2026-04-20 08:57:40 +02:00
changelog.go feat(tui): show github release notes once after upgrading 2026-04-19 16:12:13 +02:00
cli.go fix(session): export the full running conversation, handle quoted paths 2026-04-20 10:19:53 +02:00
config.go feat(tui): show github release notes once after upgrading 2026-04-19 16:12:13 +02:00
extcmd.go feat: extension system (subprocess + json-rpc, any language) 2026-04-19 14:09:43 +02:00
modelsync.go initial commit 2026-04-17 20:36:38 +02:00
rpc.go fix(no-yolo): don't auto-refuse tool calls in non-interactive modes 2026-04-19 19:17:05 +02:00
systemprompt.go feat(auth,tui): dark login pages + /logout picker 2026-04-19 20:14:22 +02:00
update.go tui: show 'update available' banner at top of chat 2026-04-18 11:49:22 +02:00