Skip to content

feat(usage): break down usage by project - #9015

Draft
saphid wants to merge 45 commits into
pingdotgg:mainfrom
saphid:saphid/usage-project-upstream
Draft

feat(usage): break down usage by project#9015
saphid wants to merge 45 commits into
pingdotgg:mainfrom
saphid:saphid/usage-project-upstream

Conversation

@saphid

@saphid saphid commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

What Changed

The Usage page can filter totals and breakdowns to one project without combining same-named projects from different environments. Transcript working directories are resolved to stable project identities, while usage outside a project and usage whose project cannot be determined remain distinct states.

Why

Provider and model totals do not show which workspace incurred the spend. Project attribution makes that split usable without turning a repository read failure into a plausible but incorrect “outside projects” total.

Stack and Review Scope

This PR is cumulative and lands after #9014. Review the project-attribution increment; later PRs include both predecessors.

Verification

The first current-head CI Test job passed all 4,053 web tests but failed on an unhandled cancelAnimationFrame is not defined callback in upstream fileEditorHighlight.test.ts. That file is unchanged from main; its 7 focused tests passed locally. A failed-job retry was requested but GitHub rejected it because repository admin rights are required; no retry occurred. This observed teardown flake is retained as a verification limitation.

Current candidate afbb52522aa4a21c8c563854289f3a9d9d12b51f includes upstream main 39802c06117fae0b3da43624b0d54309c5437c72. The focused UsageService and chart-gesture suites passed (30 tests), and the server package typecheck passed. Repository failure doubles follow the current imported-transcript interface. Earlier evidence below retains its stated revision and scope; integrated web evidence and its attribution limits are described below.

A direct Claude Opus 5 high review attempt for this integration batch exited 1 because OAuth expired; no Claude review occurred.

Candidate: e44f88f174f0872250f0f105fe570cf3fd20d34e, including upstream main 82c2b7ffb4d450572f5baf9a70693f1e25cfdfed.

  • The full focused contribution check at ba873b8 passed 128 tests across 7 files, plus the affected package typechecks.
  • The final 82c2b7f delta removes an unused pricing helper: 7 pricing tests, server typecheck, Knip and git diff --check passed on the pre-repair main composition. The chart/runtime contribution was unchanged by that final delta.
  • The chart merge preserves upstream's live column builder and this PR's daily/hourly and range behavior. Fresh independent source review of the shared resolution found no actionable issues.
Focused commands
vp test run apps/server/src/usage/UsageService.test.ts apps/server/src/usage/usageAggregation.test.ts apps/server/src/usage/usageScanCache.test.ts apps/server/src/usage/usageTranscripts.test.ts apps/web/src/components/usage/UsagePage.test.tsx packages/shared/src/usageMerge.test.ts apps/web/src/components/usage/UsageProviderChart.test.ts
vp run --filter t3 typecheck
vp run --filter @t3tools/web typecheck
vp run --filter @t3tools/contracts typecheck
vp run --filter @t3tools/shared typecheck
vp test run apps/server/src/usage/usagePricing.test.ts
vp run --filter t3 typecheck

Refresh correctness checks

The refresh repair passed the focused UsageService suite (10 tests), 3 chart-gesture regression tests, and 7 web usage-state tests. Server and web package typechecks, changed-file formatting/lint and diff checks passed. Independent source review found no actionable issue in this frozen repair.

These repairs cancel a chart gesture if its date window changes, let each environment progress after its own pricing request, and coalesce concurrent tokened summary scans. Thread-enabled branches await their environment summary before refreshing thread rows. The source-scan revision guard prevents older aggregation from pruning files discovered by a newer scan. Integrated web evidence and remaining client limits are described below.

UI Changes

The project breakdown separates Atlas and Beacon totals. The integration retains this PR’s project grouping; later stack changes add cache-write columns and a shared table layout.

Before: upstream main 39802c06117fae0b3da43624b0d54309c5437c72. After: cumulative #9308 integration 7e248026469ec7be6d5c2bdaccf86f380e0c2476, captured in an isolated web preview with two synthetic projects, three conversations and generated transcripts. This reuses the retained feature in the integrated stack; it is not a separate capture of this PR’s individual head. Focused tests above were run on the individual published head. The 30-day preset ends at the last complete day on the integration; main includes the current day. Both captures contain the same fourteen days of synthetic usage.

Before: main exposes model/day breakdowns

After: integrated coverage and cache-write breakdown controls

Clean breakdown recording · Annotated breakdown recording. This shows project → thread → expand → collapse; idle time is trimmed from 109.7 s to 12.57 s, without a performance claim.

Clean project-filter recording · Annotated project-filter recording. Idle time is trimmed from111.93s to7.17s; unsuccessful setup attempts before the successful selection are omitted from the viewing cut, with the raw source retained.

Limits: A supplementary filter recording selects Atlas at $45.56 and clears to all projects at $62.00. Equal-name projects across environments and outside/unknown choices are not exercised. No React Native or SwiftUI mobile capture is represented here. Clean/annotated packet validation passed; uploaded derivatives were retrieved and hash-verified.

Checklist

  • The intended increment is focused; its cumulative dependency is identified above.
  • I explained what changed and why.
  • Current-head UI screenshots are attached; this gap is described above.
  • Current filter and reverse/reset interaction proof is still required.

Implemented and reviewed with GPT-6 and GPT-5.6 Sol in the Codex harness. A direct Claude Opus 5 high availability attempt exited 1 because OAuth had expired; no Opus review occurred.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Sep 1, 2026
Comment thread apps/web/src/components/usage/UsagePage.tsx Outdated
Comment thread apps/server/src/usage/usageScanCache.ts Outdated
Comment thread packages/shared/src/usageMerge.ts Outdated
Comment thread apps/web/src/components/usage/UsagePage.tsx Outdated
@saphid
saphid force-pushed the saphid/usage-project-upstream branch from 684786f to 117bf75 Compare September 1, 2026 11:12
@github-actions github-actions Bot added size:XL 500-999 changed lines (additions + deletions). and removed size:L 100-499 changed lines (additions + deletions). labels Sep 1, 2026
Comment thread apps/server/src/usage/usageTranscripts.ts
Comment thread apps/web/src/components/usage/UsageProviderChart.tsx Outdated
Comment thread docs/user/usage.md Outdated
Comment thread apps/server/src/usage/UsageService.ts
@saphid
saphid force-pushed the saphid/usage-project-upstream branch from 117bf75 to 867cc41 Compare September 1, 2026 11:27
Comment thread apps/web/src/components/usage/UsagePage.tsx Outdated
saphid and others added 4 commits September 1, 2026 21:39
The usage window was locked to four presets, so a spike on the chart
could not be inspected without eyeballing dates. Dragging across any
daily chart now commits the selection as the date window, double-click
returns to the preset, and date fields beside the presets accept any
custom range directly. The server already accepted arbitrary day
windows; this is web-only.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Cap custom windows before enumeration, keep date controls reachable in compact layouts, and complete brush gestures synchronously through pointer capture.
@saphid
saphid force-pushed the saphid/usage-project-upstream branch 2 times, most recently from a59e015 to 6ca946c Compare September 1, 2026 11:56
Comment thread apps/web/src/components/usage/UsagePage.tsx
@saphid
saphid force-pushed the saphid/usage-project-upstream branch 2 times, most recently from 79c9fc2 to eb2a16a Compare September 1, 2026 12:29
Comment thread apps/server/src/usage/usageTranscripts.ts
Comment thread apps/web/src/components/usage/UsagePage.tsx
@saphid
saphid force-pushed the saphid/usage-project-upstream branch from eb2a16a to 7178d4d Compare September 1, 2026 12:46
Comment thread packages/shared/src/usageMerge.ts Outdated
@saphid
saphid force-pushed the saphid/usage-project-upstream branch from 7178d4d to 82b25d2 Compare September 1, 2026 13:05
saphid and others added 4 commits September 1, 2026 23:12
The usage page mixed every session on the machine into one pool, so
there was no way to see which project the spend belonged to. Buckets now
carry the title of the T3 project whose folder the session ran in
(resolved per environment from the transcript cwd, including sessions
driven outside T3 Code), the breakdown gains a Project view, and a
project picker narrows the whole page to one project. Sessions outside
every project group under "Outside projects"; Grok logs record no
folder and always count there. Older environments merge unchanged with
their buckets unattributed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
# Conflicts:
#	apps/server/src/usage/UsageService.ts
#	apps/web/src/components/usage/UsagePage.test.tsx
#	apps/web/src/components/usage/UsagePage.tsx
#	apps/web/src/state/usage.ts
#	docs/user/usage.md
#	packages/shared/src/usageMerge.test.ts
@github-actions github-actions Bot added size:XXL 1,000+ changed lines (additions + deletions). and removed size:XL 500-999 changed lines (additions + deletions). labels Sep 5, 2026
Comment thread apps/mobile/src/features/usage/UsageRouteScreen.tsx Outdated
Comment thread apps/mobile/src/features/usage/UsageRouteScreen.tsx Outdated
Comment thread apps/server/src/usage/UsageService.ts Outdated
Comment thread packages/contracts/src/usage.ts
Comment thread apps/web/src/state/usage.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL 1,000+ changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant