fix: persist UI history and retain recent L4 sessions

This commit is contained in:
Liang Jiaqing committed 2026-07-10 14:56:36 +08:00
1 parent 8ea8807ced
commit 3f6fb9c63b
2 files changed
+3 -1

No files matched your search

+2 -1
View File
@@ -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 对齐
@@ -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}