Title: mcpx stats: grouped opencode statistics always report messages: 0 (Group.Messages never populated) · Issue #261 · developing-today/code · GitHub
Open Graph Title: mcpx stats: grouped opencode statistics always report messages: 0 (Group.Messages never populated) · Issue #261 · developing-today/code
X Title: mcpx stats: grouped opencode statistics always report messages: 0 (Group.Messages never populated) · Issue #261 · developing-today/code
Description: Contribute to developing-today/code development by creating an account on GitHub.
Open Graph Description: Contribute to developing-today/code development by creating an account on GitHub.
X Description: Contribute to developing-today/code development by creating an account on GitHub.
Opengraph URL: https://github.com/developing-today/code
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"mcpx stats: grouped opencode statistics always report messages: 0 (Group.Messages never populated)","articleBody":"## Problem\n\n`mcpx stats` grouped opencode statistics always report `messages: 0`, even for sessions that have messages.\n\nThis is the same defect as dezren39/nix#393 (fixed there by dezren39/nix PR #394), present in this repo's `pkgs/mcpx` copy and not fixed here. Verified on main (54c223ce): this repo's `pkgs/mcpx/internal/opencode/opencode.go` is byte-identical to the pre-fix version in dezren39/nix.\n\n## Evidence\n\n- `pkgs/mcpx/internal/opencode/opencode.go:175-182` — `Group` declares `Messages int64 \\`json:\"messages\"\\``.\n- `pkgs/mcpx/internal/opencode/opencode.go:214` — `ByModel` merges groups with `m.Messages += g.Messages`, so the field is expected to be populated.\n- `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`.\n- There is no test file at all in `pkgs/mcpx/internal/opencode/` in this repo, so nothing catches it.\n- 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.\n\n## Why it matters\n\nAnyone 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.\n\n## Acceptance criteria\n\n- `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).\n- 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).\n- 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.\n- Reference implementation and tests: dezren39/nix PR #394 (commit d308cf5) — the fix should mirror it, since the two copies of this file were identical before that fix.\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-10-18T09:02:08Z","url":"https://github.com/developing-today/code/issues/261"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/issues/:id(.:format) |
| route-controller | issues |
| route-action | show |
| fetch-nonce | v2:3bc11f93-ac1b-e070-9740-c6c51b38d909 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E0E0:1E2325:5C2AAF:7E7FB8:6B068E54 |
| html-safe-nonce | 0037f6a11b21236346fede5e2f1d3ef78982f43482d2e2ee6606ccca8be6ee3d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMEUwOjFFMjMyNTo1QzJBQUY6N0U3RkI4OjZCMDY4RTU0IiwidmlzaXRvcl9pZCI6IjYxOTU3MzExMjc5MTIwMDkzMDAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 64aab3395a97abfa10b5cba2c20b85d9e1e42c36a79dee66cdf5ac22131a7008 |
| hovercard-subject-tag | repository:627308783 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/developing-today/code/issues/261 |
| twitter:image | https://opengraph.githubassets.com/c1a2d415bd2c796fea2e23b2fed64a1efc7802730482e5b3777242c3e81bd5e2/developing-today/code |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c1a2d415bd2c796fea2e23b2fed64a1efc7802730482e5b3777242c3e81bd5e2/developing-today/code |
| og:image:alt | Contribute to developing-today/code development by creating an account on GitHub. |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4462ff7ebfd3d551f202659f2423dae617b6849d23b1df6465dc504ef497d14a |
| turbo-cache-control | no-cache |
| go-import | github.com/developing-today/code git https://github.com/developing-today/code.git |
| octolytics-dimension-user_id | 26439447 |
| octolytics-dimension-user_login | developing-today |
| octolytics-dimension-repository_id | 627308783 |
| octolytics-dimension-repository_nwo | developing-today/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627308783 |
| octolytics-dimension-repository_network_root_nwo | developing-today/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 6d3909414814ff86ce7da4c51a0f4918a13fb41b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width