Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

fix: /rewind restore changed files error

ldstyle8e94e830a40da
diff --git a/jiuwenclaw/agents/harness/common/session_ops_service.py b/jiuwenclaw/agents/harness/common/session_ops_service.py
index d0f7882a6a..af75fe4e44 100644
--- a/jiuwenclaw/agents/harness/common/session_ops_service.py
+++ b/jiuwenclaw/agents/harness/common/session_ops_service.py
@@ -182,7 +182,9 @@ def rewind_session(
removed_turn_content = ""
if 0 <= target_user_index < len(history):
content = history[target_user_index].get("content", "")
- removed_turn_content = content if isinstance(content, str) else str(content)
+ raw = content if isinstance(content, str) else str(content)
+ # 剥离 <file-content> 块(系统注入的文件元数据,非用户实际输入)
+ removed_turn_content = re.sub(r"<file-content[^>]*>.*?</file-content>", "", raw, flags=re.DOTALL).strip()
result = truncate_history_records(session_id=session_id, cut_index=cut_index)
diff --git a/jiuwenclaw/gateway/channel_manager/tui/tui_connect.py b/jiuwenclaw/gateway/channel_manager/tui/tui_connect.py
index 2dac106295..4a19bd2128 100644
--- a/jiuwenclaw/gateway/channel_manager/tui/tui_connect.py
+++ b/jiuwenclaw/gateway/channel_manager/tui/tui_connect.py
@@ -1117,8 +1117,8 @@ def register_cli_handlers(bind: CliHandlersBindParams) -> None:
)
return
try:
- rewind_result = rewind_session(session_id=target_sid, turn_index=turn_index)
restore_result = restore_session_files(session_id=target_sid, turn_index=turn_index)
+ rewind_result = rewind_session(session_id=target_sid, turn_index=turn_index)
combined = {
**rewind_result,
"restored_files": restore_result.get("restored_files", []),