Repository navigation
Add drill-through: from aggregates to the sessions that compose them - #1316
Merged
Merged
Conversation
… 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.
…ll entries Rebasing onto main put the new getSessionsContributions handler beside the Projects-pane filter from #1307 without picking it up, so the drill-through would have listed unfiltered sessions under a filtered headline. - main.ts: add projectArgs() to the new handler, matching getSessions; the existing filter test now asserts the new channel too. - usage-aggregator/day-aggregator: actually set categories[].rawCategory. menubar-json already declared and forwarded it, but no producer wrote it, so topActivities[].rawCategory was always undefined and the category drill entry was permanently disabled in both aggregation paths. - Models.tsx: key the model drill off modelDisplayName. Contribution segments are keyed by canonical short name ("Fable 5"); the row's raw provider ids ("claude-fable-5") matched 0 of 19 segment keys on real data.
This was referenced Sep 12, 2026
iamtoruk
added a commit
that referenced
this pull request
Sep 12, 2026
…w flags Rebased on main, which since gained #1307, #1316 and #1319. - Delete app/renderer/lib/sampleNavigation.ts. It was a placeholder for a registry that never landed: #1316 ships drill-through as an onInvestigate callback prop plus NavState. The sample rows now call it, threaded from App.tsx through Compare, and open the owning session for real. - Give a CohortObservation the provider/project/session triple the sessions report keys rows by (inferSessionProvider, session.project || project.project), so a sample resolves to exactly one session row. Without it a cohort sample could not build sessionRowKey at all. - Carry projectArgs() on both cohort spawns, per #1307. The saved project filter now scopes the facet query and the report; --project-id still narrows within it. Extended the scopes-every-fetch test to cover both. - Allow --from, --to, --category and --project-id on compare in SERVE_OPTIONS. Verified over stdio: before, every cohort request but the bare facet query came back "command not served" and fell back to a spawn. - Catch the invalid-date throw on compare like report does, instead of an unhandled UsageQueryError stack trace. - Drop the unrelated CODEBURN_USER_DATA_DIR hunk in bootstrap().
ozymandiashh
pushed a commit
to ozymandiashh/codeburn
that referenced
this pull request
Sep 12, 2026
…rrors Rebase fixes on top of getagentseal#1296. - App.tsx shipped a stub inspectRange calling a setCustomRange that no longer exists after getagentseal#1316. Replaced with the real navigation: commitNav to Sessions with the clicked side's range AND projectFilters/modelFilters for the contribution key, so the drill-through lands on the population the row describes instead of the whole range. - getPeriodCompare and getPeriodCompareSessions carried no projectArgs(), so a saved project filter did not scope either fetch (getagentseal#1307). Added, and the "scopes every fetch" main-process test now covers both channels. - compare-periods --format sessions ignored --project/--exclude, so a drill-down could surface a session from a hidden project. It now filters like the report. - A bad --from-a/--to-a printed a raw stack trace: parseDateRangeFlags throws and the null check could never fire. Wrapped in the same try/catch every other date-flag command uses. - Totals card now says inline how much daily history has no session detail behind it. On a machine with aged-off sources the detail-only total is far below report/status for the same range; the Coverage card alone was three cards away from the number it qualifies.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #1295 by @ozymandiashh, rebased onto main (was 40+ commits behind, branched from effa656) with three fixes.
Drill-through: day, model, category and project aggregates open a filtered session list (the pull-request row is not wired yet: prFilters and onInvestigate are threaded through but no handler invokes them; tracked as a follow-up) with a detail drawer and navigation history, separating a session's contribution to the selection from its full cost. CLI gains
sessions --format json --contributionsplus optional identity fields onbuildJsonReportand menubar-json.Rebase
No textual conflicts. The dangerous part was what git could not see: the new
getSessionsContributionshandler landed next to #1307's Projects-pane filter without picking it up, so the drill-through would have listed unfiltered sessions under a filtered headline. Its own comment claimed "same filtering semantics as getSessions" and that was false after the rebase.Fixes on top
app/electron/main.ts— addprojectArgs()to the new handler, matchinggetSessions. The existing "scopes every fetch by it" test now asserts the new channel; without the fix it fails (6 argv entries vs 8).src/usage-aggregator.ts+src/day-aggregator.ts— actually setcategories[].rawCategory. menubar-json declared the field and forwarded it, but no producer ever wrote it, sotopActivities[].rawCategorywas alwaysundefinedandOverview.tsx'sdrillablegate was permanently false. The category drill entry was dead in both aggregation paths. Now 13/13 activities carry a raw key, and all 13 match asegment.categoryvalue.app/renderer/sections/Models.tsx— key the model drill offmodelDisplayName. Contribution segments are keyed by canonical short name ("Fable 5"); the row's raw provider ids ("claude-fable-5") matched 0 of 19 segment keys on real data.modelDisplayNamematches 15/19 (the other 4 are zero-cost models with no row).Verification on real data
Contribution partition is exact:
max |sum(segments.cost) - row.cost| = 6.8e-13over 1929 sessions, andsum(segment.calls) == row.callsfor every row.Day selection vs
report.daily, 2026-08-25..09-08, deltas at float noise:The 09-01 gap is a pre-existing
report-vs-sessionstotal difference, not this PR: main's CLI reproduces it to the digit ($2.524620 on both). Worth a separate look, since the drill-through headline comes from the report aggregate while the list sums from sessions.Model selection reconciles exactly across all 19 models (max delta 2.7e-12), and
sum(segment.models) == segment.costto 7.1e-15.Multi-day and multi-model splits, on one real 5-day session (
56dea73b, $1584.457194, 2447 calls): day segments sum to the row exactly across 08-29..09-02 with calls 203/533/566/680/465 = 2447; model segments split Fable 5 / Fable 5.1 / Opus 4.8 = 1233.400116 / 337.872770 / 13.184308, summing to the row at -1.1e-12. No double counting.Identities line up across all three outputs: every menubar
topSessionsandreport.topSessionsrow resolves to a--contributionsrow at delta 0,projectKey == row.projecteverywhere, all 32topProjects[].sessionDetailsids resolve, andprojectIdequals menubartopProjects[].idexactly.Main-vs-PR on two frozen ranges (2026-08-25..09-08 and 2026-07-01..07-15): added fields only —
activities[].rawCategory,topSessions[].provider|projectKey|sessionId,topProjects[].sessionDetails[].sessionId|provider. Zero removed. The only changed values are today's live row and month-to-date plan figures, which drift identically on a main-vs-main control run.Contract and privacy
All added fields are optional and additive; no existing field renamed, removed or re-typed.
projectKeyis the raw session project, which on Claude is a dash-encoded absolute path (-Users-…-Projects-eywa) — more identifying than the siblingprojectdisplay name. It does not leave the machine:sanitizeForSharingemptiestopProjectsandtopSessionswholesale and dropsliveSessions, and running it over the real payload removes every one ofprojectKey,sessionIdand the dash-path string. The only absolute paths surviving sanitize are the pre-existingclaudeConfigs.options[].path.withContributions'sprojectId(a real absolute path) and branch names are CLI-stdout only and never reach the menubar payload, sharing, or MCP.One latent issue, not reachable today and not fixed here:
src/mcp/redact.ts:29-31and:48redact by spreading ({...d, date: ''}/{...s, project: pseudonym(s.project)}) rather than rebuilding allowlisted objects, so the new fields would pass through unredacted — andprojectKeywould sit in plaintext beside the pseudonymizedproject.src/mcp/server.tsnever serializes those arrays, so nothing exposes it now. Worth converting to an allowlist before any MCP tool returns the fuller payload.--contributionsis rejected unless plain--format json: bare,--format table,--by-prand--by-work-unitall exit 1 with the documented message;--format jsonalone exits 0.serve --stdioallowlists it atsrc/serve.ts:107.Known gap
The PR body advertises PR drill-through, but it does not fire.
prFiltersis imported inPullRequests.tsx:14andonInvestigateis threaded through four component levels, yet neither is ever invoked —PrRowView's only handler is expand/collapse. Left as-is rather than inventing a click target;investigation.test.tscoversprFiltersin isolation, which is why it reads as wired.Two smaller ones, not fixed:
Sessions.tsx:254resetsinternalVisibleCount, which is dead onceApp.tsx:917passes a controlledvisibleCount, so removing a chip or changing sort does not reset pagination depth; andFilterChips.tsx:49keys chips by a truncated label (sessionId.slice(0,12), or a branch's leaf directory), which can collide and drop a chip's remove button.Tests
Root
tsc --noEmitclean;npm test294 files / 3995 passed, 5 skipped. Apptypecheckclean;vitest920 passed, 27 failed inusePolled.test.tsandoverviewSnapshot.test.tsonly — both pre-existing and unrelated.Mutations both caught: dropping
projectArgs()fails the filter test; removing the day boundary from the segment split fails 3 contribution tests.Lifetime on this machine (8992 sessions, 16607 segments): plain
sessions --format json2.03s/2.05s, with--contributions2.18s/2.34s. Payload 4.66 MB to 15.16 MB.