fix(gui): fix missing thinking_segments parameter persistence across sessions

This commit is contained in:
2026-03-15 16:11:09 -04:00
parent 0f62eaff6d
commit 5470f2106f
2 changed files with 18 additions and 1 deletions

View File

@@ -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 ("<thinking>" in content or "<thought>" 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