Skip to content

Add drill-through: from aggregates to the sessions that compose them - #1295

Closed
ozymandiashh wants to merge 4 commits into
getagentseal:mainfrom
ozymandiashh:zcode/goal-8-drill-through
Closed

ozymandiashh wants to merge 4 commits into
getagentseal:mainfrom
ozymandiashh:zcode/goal-8-drill-through

Conversation

@ozymandiashh

@ozymandiashh ozymandiashh commented Sep 12, 2026 •

Copy link
Copy Markdown
Collaborator

Connect desktop aggregates to the sessions behind them: day, model, category, project and PR selections open a filtered session list with a detail drawer and navigation history. The view separates each session's contribution to the selection from its full cost.

sessions --format json --contributions supplies canonical project ids and call-day segments with model costs and actual per-model call/token counts. Provider identity participates in row matching; ambiguous identities remain explicitly unattributable. Each call follows its own timestamp across midnight. Model usage is independent of model price, including free models and supplementary accounting. PR selection retains the existing even-share attribution rules. Older cached payloads without model usage are excluded with a coverage disclosure when a model filter needs that data, and the report cache namespace is refreshed.

Concrete regression fixtures now return:

  • Same session id in Claude and Codex: costs $2 and $9 remain attached to their own rows.
  • One turn crossing midnight: $3 belongs to the first day and $5 to the next.
  • A $9 model with one call/100 tokens versus a $1 model with one call/900 tokens: selecting the first returns exactly one call and 100 tokens.

Validation: full root suite compared with upstream/main a1805393 (3,948 passed; the same four Node 26 DEP0205 stderr failures as main). The full app run had 905 passes and three timing failures in unchanged electron/cli.test.ts; rerunning that entire file alone passed all 81 tests (four skipped). Root/app typechecks and CLI/Electron/renderer builds passed. The production contribution engine and renderer selection functions were replayed over the concrete fixtures above; all corrected values reconcile. The main project-filter suite passes all nine tests on Node 24.

Branch, period-comparison and work-unit integrations across the other feature PRs remain separate work. Details: docs/drill-through.md.

… the CLI reports

sessions --format json --contributions attaches turn-granular segments
(day, task category, carried git branch, short-model costs, active PR set)
that partition each session, so a selection can sum its exact share (20 of
a session's 100) while aggregate totals reconcile. Legacy prLinks-only
transcripts carry the whole set with the approx even-split marker, matching
the by-PR report. The menubar payload's topSessions and project
sessionDetails now carry provider + sessionId (+ raw projectKey for
topSessions) so the desktop can open the exact session behind a row, and
topActivities carries the raw TaskCategory for chips. serve learns the
--contributions flag so the desktop's resident child can answer it.
…n drawer

InvestigationFilters is a normalized, serializable selection (days,
providers, projects, models, categories, PRs, project-scoped branches,
provider-scoped sessions) with OR within a dimension and AND across them.
Contribution math walks each row's segments and multiplies per-dimension
shares, so sums reconcile every dimension's aggregate exactly; rows without
segments are excluded and disclosed. NavState + the history stack back the
in-app Back/Forward (filters, sort, page depth, open drawer) and the
restart snapshot. The drawer shows metadata, full totals beside the
in-selection figures, and the per-model/category/branch/day/PR breakdowns
with an Escape-and-focus-return contract.
…s, drawer, history

Every report grows real entries: Overview day bars, expensive sessions
(provider+id matched), model names, task categories, Spend projects,
and PR cards. The Sessions destination renders the selection chips with
per-chip removal and Clear, fetches the contributions report once per
population (widened to cover the selected days so a day outside the top-bar
period still reconciles), computes every chip combination client-side over
the full population, and shows each row's contribution beside its full
cost. Row clicks open the side drawer (Escape closes, focus returns); the
top bar gains Back/Forward (Cmd+[ / Cmd+] on macOS, Alt+arrows elsewhere)
over the in-app history; the position survives a renderer restart. IPC
gains getSessionsContributions with the same argv validation as the plain
report.
@iamtoruk

Copy link
Copy Markdown
Member

Landed as #1316 (2d18da0) with your commits and authorship intact, rebased onto current main, plus three fixes found on real data: the new sessions handler now carries the Projects-pane filter from #1307 (it landed beside it with no textual conflict and silently bypassed it), rawCategory is now actually produced so category drill-through works (it was declared and forwarded but never written), and the model drill keys off the display name so it matches the segments (0 of 19 matched before). Contribution partition verified exact over 1929 sessions. One gap left open and tracked in #1317: the pull-request row is not wired. Thank you.

@iamtoruk iamtoruk closed this Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants