Repository navigation
Add X Subscription usage collector to the agents panel - #15252
the4rchangel wants to merge 6 commits into
Conversation
Track the shared Cursor + Grok first-party pool from Cursor's dashboard APIs as one agents record, with local prompt counts from Cursor transcripts. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Always treat Cursor percent fields as 0–100, key the limits cache per sign-in, date prompts from transcript stamps, keep recentDays in tokens, and stop inventing activity from empty files. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Addressed the Greptile findings:
|
|
Addressed the Greptile findings in a9cbcc7:
@greptileai please recheck |
Transcript timestamps carry an offset; count them on the machine's local date so late-evening UTC-5 turns do not land on the wrong day after a timezone change. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Fixed the remaining P2: prompt @greptileai please recheck |
|
A few questions before this is reviewable:
|
Call out that the shared-pool meter still comes from undocumented DashboardService endpoints until xAI publishes a usage API for the merged plan. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Thanks for the questions — answers below. Manual checks {
"id": "x",
"name": "X Subscription",
"ready": true,
"tierLabel": "Super · shared weekly pool",
"limits": [
{
"label": "Included pool (Cursor + Grok)",
"percent": 0.025,
"resetsAt": "2026-10-20T05:15:23.057000Z",
"title": "First-party"
}
],
"limitsStale": false,
"todayPrompts": 13,
"totalPrompts": 118,
"totalSessions": 3
}The Agents panel picks that up as an X Subscription section with the shared-pool meter. Test plan boxes are checked. DashboardService stability Default on #14040 |
recentDays was left at zero after we stopped stuffing prompt counts into the token field; pull real per-day totals from GetAggregatedUsageEvents so the agents panel hero and meters have numbers again. Co-authored-by: Cursor <cursoragent@cursor.com>
|
One more thing on the live record: tokens-by-day were showing 0 because we deliberately stopped putting prompt counts into |
| stats["recentDays"] = tokens.get("recentDays") or stats.get("recentDays") | ||
| stats["todayTotalTokens"] = int(tokens.get("todayTotalTokens") or 0) | ||
| stats["todayTokensByModel"] = tokens.get("todayTokensByModel") or {} | ||
| stats["modelUsage"] = tokens.get("modelUsage") or {} |
There was a problem hiding this comment.
The new token totals cover the whole Cursor account, but the record uses the default device scope. If the same account is signed in on two synced machines, aggregateSnapshots adds the same dashboard totals twice. Separate account-wide token totals from device-local prompt counts so syncing does not inflate usage.
There was a problem hiding this comment.
Fixed in 5ac0235: the collector record now sets scope: "account" so synced machines do not sum the same dashboard token totals.
| except Exception: | ||
| payload = {} | ||
| rows = payload.get("aggregations") if isinstance(payload, dict) else None | ||
| usage = summarize_day_rows(rows if isinstance(rows, list) else []) |
There was a problem hiding this comment.
A failed daily request becomes zero usage, and cached_remote_token_stats writes that result over the last successful cache. A timeout or expired sign-in therefore erases known token counts from the panel, even when the limits request succeeds. Keep the cached counts for failed dates and mark them stale instead of treating failed requests as empty days.
There was a problem hiding this comment.
Fixed in 5ac0235: a failed GetAggregatedUsageEvents day keeps the prior count for that date, marks tokens stale, and refuses to overwrite a good cache with a total failure.
| prompt_days = stats.get("activeDates") or [] | ||
| active = sorted(set(prompt_days) | set(token_days)) | ||
| stats["activeDates"] = active[-30:] | ||
| stats["activeDays"] = len(active) |
There was a problem hiding this comment.
local_stats keeps the full activeDays count but only the last 30 entries in activeDates. The new merge rebuilds activeDays from that shortened list. A signed-in user with 80 active transcript dates and no dashboard token activity now reports 30 instead of 80. Preserve the full count when adding token dates, or merge against the full set of prompt dates.
There was a problem hiding this comment.
Fixed in 5ac0235: activeDays is now max(prompt_active_days, len(merged_dates)) so truncating activeDates to 30 no longer shrinks the prompt-day count.
Mark dashboard aggregates as account-scoped, retain prior day counts when a request fails, and preserve the full prompt activeDays count when merging token dates. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Addressed the three new Greptile findings in 5ac0235:
Tests cover all three. Retriggered review. |
Summary
omarchy-agent-usage-xso the stock Agents panel tracks The X Subscription shared first-party pool (Cursor + Grok).xin the agents widget defaults, and document the collector (including that it depends on Cursor's private dashboard RPCs).Test plan
./test/shell.d/agent-usage-x-test.shomarchy agent usage-update --force x, confirmx.jsonshows the shared pool meter and plan label (see comment with redacted output: Super · shared weekly pool)