Private
Public Access
0
0

feat(gui): Implement per-response token metrics and AI discussion compression

- Display token metrics (input/output/cache) per response in Discussion Hub.
- Add total Discussion Token usage in the panel header.
- Implement 'Compress' feature to intelligently summarize and replace exhausted discussion histories using an AI subagent.
This commit is contained in:
2026-06-02 01:36:57 -04:00
parent b3b9baf91f
commit 5b7b818ed2
5 changed files with 106 additions and 24 deletions
+22
View File
@@ -2323,6 +2323,8 @@ class AppController:
"collapsed": True,
"ts": entry.get("ts", project_manager.now_ts())
}
if "usage" in payload:
entry_obj["usage"] = payload["usage"]
if segments:
entry_obj["thinking_segments"] = [{"content": s.content, "marker": s.marker} for s in segments]
@@ -3259,6 +3261,26 @@ class AppController:
self.ai_status = f"error: {e}"
threading.Thread(target=worker, daemon=True).start()
def _handle_compress_discussion(self) -> None:
def worker():
try:
self.ai_status = "compressing discussion..."
disc_text = project_manager.format_discussion(self.disc_entries)
if not disc_text.strip():
self.ai_status = "discussion is empty"
return
response_text = ai_client.run_discussion_compression(disc_text)
if response_text and not response_text.startswith("ERROR:"):
self.disc_entries = [{"role": "System", "content": f"[COMPRESSED HISTORY]\n{response_text}", "collapsed": False, "ts": project_manager.now_ts()}]
self.ai_status = "compression complete"
else:
self.ai_status = f"compression failed: {response_text}"
except Exception as e:
self.ai_status = f"compression error: {e}"
threading.Thread(target=worker, daemon=True).start()
def _handle_generate_send(self) -> None:
"""