Repository navigation
feat: count a session's subscription turns, and say how each turn was billed - #49
Merged
Merged
Conversation
… billed A session served entirely by a subscription upstream (Codex on a ChatGPT account, say) came back with zero priced, zero unpriced and zero no-usage turns, and SessionView had no fourth number. The desktop could not tell it from a session where nothing could be priced, so it said "cannot be priced" while the overview reported the same requests as subscription usage. - SessionView carries subscription_turns. It is disjoint from the three existing counts (those only count per-token rows) and counts the same rows as the overview's subscription_requests: both now use one SUBSCRIPTION predicate, the way NO_PRICE and NO_USAGE are shared, so the two numbers cannot drift apart. - TurnView carries billing, in the same vocabulary as HistoryRow.billing. A subscription turn has no cost_micros either, and the amount alone cannot tell it from a turn without a price. Both fields are required on the wire; nothing reads an older shape. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Thanks for the PR. One thing before review: this targets
No need to close and reopen: click Edit next to the PR title and change the base branch to See CONTRIBUTING.md and CONTRIBUTING.md for the branch contract. |
Merged
fylorn
added a commit
that referenced
this pull request
Sep 20, 2026
Sessions report how many of their turns a subscription upstream served, and each turn says how it was billed (#49). The desktop needs the tag to pin: until now a session served entirely by a subscription was indistinguishable, in the protocol, from one where nothing could be priced, and the sessions page called it "cannot be priced". Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
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.
Groundwork for the desktop's sessions page, which labels a session served entirely by a subscription upstream (Codex on a ChatGPT account, say) as "cannot be priced", while the overview reports the same requests as subscription usage.
Why the page could not do better
The session aggregation already kept subscription rows out of the money:
a_subscription_row_is_neither_anywherechecks that such a row is neither priced, unpriced nor no-usage. ButSessionViewhad no fourth count, so a session made only of subscription turns came back aspriced_turns = unpriced_turns = no_usage_turns = 0, which is the same shape as a session where nothing could be priced.TurnViewhad the same gap one level down: a subscription turn hascost_micros: None, and nothing else on the turn said why.What changes
SessionView.subscription_turns: turns served by a subscription upstream. It does not overlap the three existing counts (those only count per-token rows) and counts the same rows as the overview'ssubscription_requests. Both queries now share oneSUBSCRIPTIONpredicate, the wayNO_PRICEandNO_USAGEare shared, so the two numbers cannot drift apart.TurnView.billing: same vocabulary asHistoryRow.billing(per-token/subscription/free/unknown).Both fields are required on the wire, with no
serde(default), because nothing reads an older shape.Tests
tw-store:a_session_counts_its_subscription_turns_as_what_they_arecovers a session mixing subscription turns (including one that broke mid-stream), a priced turn and an unpriced one. Each lands in exactly one count, the session's subscription count equals the overview's, and every turn carries its billing.tw-control: newtests/sessions.rschecks the JSON the desktop receives from/sessionsand/sessions/{id}, both for an all-subscription session and for a mixed one.fmt, clippy
-D warnings,cargo test --workspaceand./scripts/smoke.sh(51 passed; the 36 MB memory note is reported by smoke as over target but not a regression) all pass locally.Releasing is a separate step. The desktop change that renders these fields will pin whichever tag includes this.
🤖 Generated with Claude Code