fix(gui): push AI monologue/text chunks to discussion history immediately per round instead of accumulating
This commit is contained in:
@@ -611,20 +611,6 @@ class AppController:
|
||||
self._token_stats_dirty = True
|
||||
if not is_streaming:
|
||||
self._autofocus_response_tab = True
|
||||
# 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(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")
|
||||
@@ -1495,6 +1481,25 @@ class AppController:
|
||||
"ts": entry.get("ts", project_manager.now_ts())
|
||||
})
|
||||
|
||||
if kind == "response":
|
||||
if self.ui_auto_add_history:
|
||||
role = payload.get("role", "AI")
|
||||
text_content = payload.get("text", "")
|
||||
if text_content.strip():
|
||||
segments, parsed_response = thinking_parser.parse_thinking_trace(text_content)
|
||||
entry_obj = {
|
||||
"role": role,
|
||||
"content": parsed_response.strip() if parsed_response else "",
|
||||
"collapsed": True,
|
||||
"ts": entry.get("ts", project_manager.now_ts())
|
||||
}
|
||||
if segments:
|
||||
entry_obj["thinking_segments"] = [{"content": s.content, "marker": s.marker} for s in segments]
|
||||
|
||||
if entry_obj["content"] or segments:
|
||||
with self._pending_history_adds_lock:
|
||||
self._pending_history_adds.append(entry_obj)
|
||||
|
||||
if kind in ("tool_result", "tool_call"):
|
||||
if self.ui_auto_add_history:
|
||||
role = "Tool" if kind == "tool_result" else "Vendor API"
|
||||
|
||||
Reference in New Issue
Block a user