fix(gui): parse thinking traces out of response text before rendering in history and comms panels

This commit is contained in:
2026-03-14 09:19:47 -04:00
parent 47c5100ec5
commit 3d0c40de45
2 changed files with 26 additions and 8 deletions

View File

@@ -25,6 +25,7 @@ from src import project_manager
from src import performance_monitor
from src import models
from src import presets
from src import thinking_parser
from src.file_cache import ASTParser
from src import ai_client
from src import shell_runner
@@ -613,13 +614,17 @@ class AppController:
# ONLY add to history when turn is complete
if self.ui_auto_add_history and not stream_id and not is_streaming:
role = payload.get("role", "AI")
segments, parsed_response = thinking_parser.parse_thinking_trace(self.ai_response)
entry = {
"role": role,
"content": parsed_response,
"collapsed": True,
"ts": project_manager.now_ts()
}
if segments:
entry["thinking_segments"] = [{"content": s.content, "marker": s.marker} for s in segments]
with self._pending_history_adds_lock:
self._pending_history_adds.append({
"role": role,
"content": self.ai_response,
"collapsed": True,
"ts": project_manager.now_ts()
})
self._pending_history_adds.append(entry)
elif action in ("mma_stream", "mma_stream_append"):
# Some events might have these at top level, some in a 'payload' dict
stream_id = task.get("stream_id") or task.get("payload", {}).get("stream_id")