From 3f6fb9c63b08546f67dee3ce578a0ef8a08750e1 Mon Sep 17 00:00:00 2001 From: Liang Jiaqing Date: Fri, 10 Jul 2026 14:56:36 +0800 Subject: [PATCH] fix: persist UI history and retain recent L4 sessions --- frontends/stapp.py | 3 ++- memory/L4_raw_sessions/compress_session.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/frontends/stapp.py b/frontends/stapp.py index 0d336752..3792d009 100644 --- a/frontends/stapp.py +++ b/frontends/stapp.py @@ -279,7 +279,8 @@ def render_main_stream(prompt=None): b = get_controller() b['obj'] = st.session_state.get('loop_prompt_input', ''); b['ready'] = False; b['ev'].set() -if "messages" not in st.session_state: st.session_state.messages = [] +if not hasattr(agent, "_ui_messages"): agent._ui_messages = st.session_state.get("messages", []) +if "messages" not in st.session_state: st.session_state.messages = agent._ui_messages for msg in st.session_state.messages: with st.chat_message(msg["role"]): # 用 slot=st.empty() + with slot.container(): ... 的外壳,DOM 路径和流式渲染完全一致,跨 rerun 对齐 diff --git a/memory/L4_raw_sessions/compress_session.py b/memory/L4_raw_sessions/compress_session.py index feb81dd2..a186a3bb 100644 --- a/memory/L4_raw_sessions/compress_session.py +++ b/memory/L4_raw_sessions/compress_session.py @@ -156,6 +156,7 @@ def batch_process(src, l4_dir=None, dry_run=True): l4_dir = os.path.normpath(l4_dir or L4_DIR) raw_files = sorted(src) if isinstance(src, (list, tuple)) else \ sorted(glob.glob(os.path.join(src, 'model_responses_*.txt'))) + raw_files = sorted(raw_files, key=os.path.getmtime)[:-10] # always retain 10 newest raw files if not raw_files: print("No raw files found"); return {'processed': 0, 'skipped': 0, 'errors': 0, 'new_sessions': 0}