feat(usage): break down usage by project - #9015
Draft
saphid wants to merge 3 commits into
Draft
Conversation
saphid
force-pushed
the
saphid/usage-project-upstream
branch
from
September 1, 2026 11:12
684786f to
117bf75
Compare
saphid
force-pushed
the
saphid/usage-project-upstream
branch
from
September 1, 2026 11:27
117bf75 to
867cc41
Compare
saphid
force-pushed
the
saphid/usage-project-upstream
branch
2 times, most recently
from
September 1, 2026 11:56
a59e015 to
6ca946c
Compare
saphid
force-pushed
the
saphid/usage-project-upstream
branch
2 times, most recently
from
September 1, 2026 12:29
79c9fc2 to
eb2a16a
Compare
saphid
force-pushed
the
saphid/usage-project-upstream
branch
from
September 1, 2026 12:46
eb2a16a to
7178d4d
Compare
saphid
force-pushed
the
saphid/usage-project-upstream
branch
2 times, most recently
from
September 1, 2026 13:13
82b25d2 to
dce69bb
Compare
saphid
force-pushed
the
saphid/usage-project-upstream
branch
from
September 1, 2026 13:23
dce69bb to
13d4b24
Compare
saphid
force-pushed
the
saphid/usage-project-upstream
branch
from
September 1, 2026 13:31
13d4b24 to
da35181
Compare
saphid
added a commit
to saphid/t3code
that referenced
this pull request
Sep 11, 2026
The Usage page can drill project, provider and model totals down to the threads and subagents that produced them. The server maps provider sessions and worktrees to T3 threads with bounded rows, and the web and mobile clients filter by environment, project and provider ownership. Includes the stacked usage time-range (pingdotgg#9014) and project-breakdown (pingdotgg#9015) changes this feature builds on. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
saphid
added a commit
to saphid/t3code
that referenced
this pull request
Sep 11, 2026
Carries the cumulative content of pingdotgg#9014, pingdotgg#9015 and pingdotgg#9016, rebased onto current main. This PR's own change is the following commit. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
saphid
added a commit
to saphid/t3code
that referenced
this pull request
Sep 11, 2026
Price cache creation as its own estimated component in usage summaries, the model/project/thread breakdowns and the daily thread chart, keeping unknown cache-write cost unavailable rather than zero. Carries the stacked usage work from pingdotgg#9014, pingdotgg#9015, pingdotgg#9016 and pingdotgg#9017, rebased onto main and reconciled with upstream's per-model unpriced flag (pingdotgg#11021). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This was referenced Sep 11, 2026
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Usage totals now split by the T3 project whose workspace root contains each session's working directory. The server records the cwd from Claude and Codex transcripts, resolves it against the project list at scan time, and tags each bucket as project, outside, or unknown. The web Usage page gains a Project breakdown and a project picker that narrows every figure on the page. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
saphid
force-pushed
the
saphid/usage-project-upstream
branch
from
September 11, 2026 07:22
a3eb8de to
80985a7
Compare
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.
Usage totals show which provider and model spent the money, but not which project. When several workspaces share one environment, that's the question users actually have.
Depends on #9014. This branch contains #9014's commits (
cf2474d602,0f7cd7f00d) followed by this PR's single commit80985a75ad. Review only the project increment. Merge #9014 first; the PR stays in draft until then.How it works
cwd(Codex followsturn_contextchanges). At scan time it resolves the cwd against the environment's project list (ProjectionProjectRepository.listAll, which includes soft-deleted projects so their past spend stays attributed). The deepest workspace root wins. Each bucket is taggedproject,outside, orunknown. Grok logs carry no folder, and a project-list read failure also yieldsunknown, never a misleading "outside".UsageBucketgains optionalproject,projectId, andprojectAttribution;USAGE_CONTRACT_VERSIONgoes 5 → 6. Older servers keep merging, and their buckets count as unknown attribution. The scan cache goes v3 → v4 so cached records carry their cwd; this costs one full rescan after upgrade.mergeUsagerolls buckets up intoprojects, keyed per environment, so equal ids or titles on two servers stay separate. An optionalprojectFilternarrows every other figure. Session counts can't be split by project, so they're hidden while a filter is active. Fully unpriced projects reuse main's unpriced treatment (fix(usage): flag unpriced model activity instead of showing $0.00 #11021) instead of showing $0.00.Screenshots
Isolated dev server, synthetic Claude transcripts for two projects (Atlas, Beacon) plus work in an unregistered folder, 30-day window.
Before (#9014 head
0f7cd7f00d): model and day breakdowns only.After (
80985a75ad): Project breakdown. The rows add up to the $36.04 headline, and unregistered work appears as "Outside projects".After, Atlas selected in the picker: headline, chart, totals and table all narrow to $12.23.
Verification
vp test run apps/server/src/usage/ apps/web/src/components/usage/ apps/web/src/state/usage.test.tsx packages/shared/src/usageMerge.test.ts packages/shared/src/usageFormat.test.ts: 17 files, 210 tests pass. New coverage: service-level attribution (project vs outside), unknown attribution on repository failure, the resolver's nesting/boundary/deleted-project rules, scan-cache cwd round trip, Codex cwd changes, and merge filtering/namespacing/unpriced projects.t3,@t3tools/web,@t3tools/shared,@t3tools/contracts,@t3tools/mobile.vp lintandvp fmtpass on the touched files.Rework note
This head replaces the earlier cumulative stack. The refresh-token cache bypass, retained refresh statuses, refresh error toasts/alerts, the segmented
Inputvariant, and the three unshipped contract bumps (v6–v8) are gone. They weren't needed for project attribution; any that are still wanted belong in their own PRs.Coordination trace: T3 thread 7227674d-e4cd-4b7a-b0d4-08e32d2e1e0e
Reworked with Claude Opus 5 in the Claude Code harness (via T3 Code).
🤖 Generated with Claude Code