From dc9c14a7fd65f00cbd9f444c3280885c309273b6 Mon Sep 17 00:00:00 2001 From: aihyo <1391830376@qq.com> Date: Mon, 1 Jun 2026 17:59:59 +0800 Subject: [PATCH] fix(tui-v2): preserve new conversation when switching with /continue --- frontends/continue_cmd.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/frontends/continue_cmd.py b/frontends/continue_cmd.py index 260a8c349..aad181132 100644 --- a/frontends/continue_cmd.py +++ b/frontends/continue_cmd.py @@ -322,9 +322,13 @@ def _current_log_path(pid=None): return os.path.join(_LOG_DIR, f'model_responses_{pid}.txt') -def _snapshot_current_log(pid=None): - """Persist current PID log as a standalone recoverable snapshot, then clear it.""" - path = _current_log_path(pid) +def _snapshot_current_log(pid=None, agent=None): + """Persist the active log as a recoverable snapshot, then clear it.""" + path = '' + if agent is not None: + path = getattr(agent, 'log_path', '') + if not path: + path = _current_log_path(pid) if not os.path.isfile(path): return None try: @@ -351,7 +355,7 @@ def reset_conversation(agent, message='🆕 已开启新对话,当前上下文 agent.abort() except Exception: pass - _snapshot_current_log() + _snapshot_current_log(agent=agent) if hasattr(agent, 'history'): agent.history = [] for client in _agent_clients(agent):