From b4356c7262d95c223cd6dce1ff49b091f536f8c8 Mon Sep 17 00:00:00 2001 From: nianyucatfish <156216359+nianyucatfish@users.noreply.github.com> Date: Mon, 15 Jun 2026 08:59:37 +0800 Subject: [PATCH] =?UTF-8?q?fix(tui-v3):=20/continue=20=E6=81=A2=E5=A4=8D?= =?UTF-8?q?=E5=90=8E=E9=95=9C=E5=83=8F=E6=BA=90=E6=97=A5=E5=BF=97=EF=BC=8C?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E7=BB=AD=E8=81=8A=E4=B8=A2=E5=A4=B1=E6=97=A7?= =?UTF-8?q?=E5=8E=86=E5=8F=B2=20(#612)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit v3 的 _do_restore 此前只把历史载入内存 backend.history,不碰当前进程日志。native 后端逐轮只把新增消息 append 到 model_responses_{pid}.txt,恢复出的旧历史从不写入当前日志——续聊只追加增量,下次 /continue 扫到的本进程文件就只剩续聊部分,旧历史丢失。 对齐 v2 _do_continue_restore:恢复前 reset_conversation(快照+清空当前日志),恢复后 copyfile(源日志 → 当前日志),续聊便接在完整历史之后。 --- frontends/tui_v3.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/frontends/tui_v3.py b/frontends/tui_v3.py index c9ab20df..4acec2e4 100644 --- a/frontends/tui_v3.py +++ b/frontends/tui_v3.py @@ -4483,7 +4483,16 @@ class SB: self.commit([_DIM + _t('msg.no_history') + _RST]); return def _do_restore(path: str) -> None: + continue_cmd.reset_conversation(ag, message=None) # 快照+清空当前进程日志 msg, _ = continue_cmd.restore(ag, path) + # 镜像源日志进当前进程日志,否则续聊只 append 增量,下次 /continue 丢旧历史。 + # 对齐 v2 _do_continue_restore(tuiapp_v2.py:5285)。 + current_log = getattr(ag, 'log_path', '') or '' + if current_log and path != current_log: + try: + shutil.copyfile(path, current_log) + except Exception: + pass self.commit([_DIM + '┄┄ ' + _t('msg.continue_loading', name=os.path.basename(path)) + ' ┄┄' + _RST]) for mm in continue_cmd.extract_ui_messages(path): c = (mm.get('content') or '').strip()