fix: sync message_count to state.db for /insights (#163) (#164)

* fix: sync message_count to state.db for /insights (#163)

sync_session_usage() didn't write message_count to state.db, so
/insights showed 0 messages for all WebUI sessions even with
sync_to_insights enabled.

Added message_count parameter to sync_session_usage() and pass
len(s.messages) from both the streaming and non-streaming chat paths.

Fixes #163

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: use callable pattern for _execute_write in sync_session_usage

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Nathan Esquenazi
2026-04-06 22:56:27 -07:00
committed by GitHub
parent 4d2887531d
commit 8aa1c9684d
3 changed files with 15 additions and 1 deletions

View File

@@ -366,6 +366,7 @@ def _run_agent_streaming(session_id, msg_text, model, workspace, stream_id, atta
estimated_cost=s.estimated_cost,
model=model,
title=s.title,
message_count=len(s.messages),
)
except Exception:
pass # never crash the stream for sync failures