Skip to content

Commit 8b13183

Browse files
committed
fix(tui-v2): preserve new conversation when switching with /continue
1 parent e87f9e7 commit 8b13183

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

frontends/continue_cmd.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,17 @@ def _current_log_path(pid=None):
322322
return os.path.join(_LOG_DIR, f'model_responses_{pid}.txt')
323323

324324

325-
def _snapshot_current_log(pid=None):
326-
"""Persist current PID log as a standalone recoverable snapshot, then clear it."""
327-
path = _current_log_path(pid)
325+
def _log_path_for_agent(agent=None, pid=None):
326+
if agent is not None:
327+
path = getattr(agent, 'log_path', '') or getattr(getattr(agent, 'llmclient', None), 'log_path', '')
328+
if path:
329+
return path
330+
return _current_log_path(pid)
331+
332+
333+
def _snapshot_current_log(agent=None, pid=None):
334+
"""Persist the agent's active log as a recoverable snapshot, then clear it."""
335+
path = _log_path_for_agent(agent, pid)
328336
if not os.path.isfile(path):
329337
return None
330338
try:
@@ -351,7 +359,7 @@ def reset_conversation(agent, message='🆕 已开启新对话,当前上下文
351359
agent.abort()
352360
except Exception:
353361
pass
354-
_snapshot_current_log()
362+
_snapshot_current_log(agent)
355363
if hasattr(agent, 'history'):
356364
agent.history = []
357365
for client in _agent_clients(agent):

0 commit comments

Comments
 (0)