You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mcpx stats grouped opencode statistics always report messages: 0, even for sessions that have messages.
This is the same defect as dezren39/darwin-nix#393 (fixed there by dezren39/nix PR #394), present in this repo's pkgs/mcpx copy and not fixed here. Verified on main (54c223c): this repo's pkgs/mcpx/internal/opencode/opencode.go is byte-identical to the pre-fix version in dezren39/nix.
Evidence
pkgs/mcpx/internal/opencode/opencode.go:175-182 — Group declares Messages int64 \json:"messages"``.
pkgs/mcpx/internal/opencode/opencode.go:214 — ByModel merges groups with m.Messages += g.Messages, so the field is expected to be populated.
pkgs/mcpx/internal/opencode/opencode.go:259-287 — group() (used by ByAgent, ByModel, ByProject) builds SELECT %s AS k, count(*), %s, %s, %s FROM session ... (key, session count, cost, tokens in, tokens out — no message count) and scans only &g.Key, &g.Sessions, &g.Cost, &g.TokensIn, &g.TokensOut. Group.Messages is therefore never populated and always serializes as 0.
There is no test file at all in pkgs/mcpx/internal/opencode/ in this repo, so nothing catches it.
Contrast: Busiest in the same file does count messages per session with a correlated subquery on message.session_id, which is the pattern the fix should reuse.
Why it matters
Anyone reading grouped stats (by agent / model / project) from this repo's mcpx gets a permanently-zero message count — a silently wrong number, not a missing field — while totals and per-session views report real counts, so the outputs contradict each other.
Acceptance criteria
group() populates Group.Messages as the sum, over the group's sessions, of messages per session (correlated subquery on message.session_id, as Busiest uses).
A schema whose message table has no session_id column degrades to messages: 0 instead of failing the statistic (guard with the existing has("message", "session_id") helper).
New tests in pkgs/mcpx/internal/opencode/ (first test file for the package) cover: grouped counts by agent, ByModel merging summing messages across sessions sharing a model, and the missing-session_id degradation case.
Activity
Merge pull request #262 from developing-today/creator/261-group-messages