From 5470f2106f28cd3a3aefc1284598e914a8a6b4fb Mon Sep 17 00:00:00 2001 From: Ed_ Date: Sun, 15 Mar 2026 16:11:09 -0400 Subject: [PATCH] fix(gui): fix missing thinking_segments parameter persistence across sessions --- src/models.py | 11 ++++++++++- src/project_manager.py | 8 ++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/models.py b/src/models.py index 4166f47..55581e2 100644 --- a/src/models.py +++ b/src/models.py @@ -111,6 +111,7 @@ DEFAULT_TOOL_CATEGORIES: Dict[str, List[str]] = { def parse_history_entries(history_strings: list[str], roles: list[str]) -> list[dict[str, Any]]: import re + from src import thinking_parser entries = [] for raw in history_strings: ts = "" @@ -128,7 +129,15 @@ def parse_history_entries(history_strings: list[str], roles: list[str]) -> list[ content = rest[match.end():].strip() else: content = rest - entries.append({"role": role, "content": content, "collapsed": True, "ts": ts}) + + entry_obj = {"role": role, "content": content, "collapsed": True, "ts": ts} + if role == "AI" and ("" in content or "" in content or "Thinking:" in content): + segments, parsed_content = thinking_parser.parse_thinking_trace(content) + if segments: + entry_obj["content"] = parsed_content + entry_obj["thinking_segments"] = [{"content": s.content, "marker": s.marker} for s in segments] + + entries.append(entry_obj) return entries @dataclass diff --git a/src/project_manager.py b/src/project_manager.py index 2fa227c..277d889 100644 --- a/src/project_manager.py +++ b/src/project_manager.py @@ -33,6 +33,14 @@ def entry_to_str(entry: dict[str, Any]) -> str: ts = entry.get("ts", "") role = entry.get("role", "User") content = entry.get("content", "") + + segments = entry.get("thinking_segments") + if segments: + for s in segments: + marker = s.get("marker", "thinking") + s_content = s.get("content", "") + content = f"<{marker}>\n{s_content}\n\n{content}" + if ts: return f"@{ts}\n{role}:\n{content}" return f"{role}:\n{content}"