Show Muse Token Spend Without Hiding Weekly Usage - #128
Conversation
Subscription meters alone cannot show Spark cost. Read local Muse session logs, price them at Meta's published rates, and keep Five-Hour and Weekly always visible.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
There was a problem hiding this comment.
🟡 Changes recommended
There are a few concrete correctness/documentation issues in the changed code/docs (notably Muse auto-enablement footprint detection and an omission in privacy docs) that should be addressed before approval.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR extends the Muse provider to derive machine-local token history and estimated API-rate spend from Muse Code session journals, while keeping the subscription meters (Five-Hour Usage / Weekly Usage) always visible in the default layout.
Changes:
- Add a new
MuseLogUsageScannerand wire it intoMuseProviderto populate Usage Trend + spend tiles from localsession.jsonllogs (including subagent logs). - Add Muse Spark Standard/Contributor pricing + alias rules to
pricing_supplement.json, plus test coverage validating resolution and rates. - Update default layout seeding and documentation so Muse spend/history stays below-the-fold and does not hide Weekly for existing layouts.
File summaries
| File | Description |
|---|---|
| Tests/RunwayTests/PricingBundledResourceTests.swift | Adds assertions for Muse Spark pricing + contributor separation. |
| Tests/RunwayTests/MuseProviderTests.swift | Adds coverage for log-backed spend/history behavior and stable descriptor/layout seeding. |
| Tests/RunwayTests/MuseLogUsageScannerTests.swift | New tests for parsing, aggregation, pricing, dedup, and subagent discovery. |
| Sources/Runway/Stores/DefaultLayout.swift | Seeds Muse trend + spend tiles as On Demand while keeping meters always visible/pinned. |
| Sources/Runway/Resources/pricing_supplement.json | Adds Muse Spark rates and alias rules. |
| Sources/Runway/Providers/SpendTileMapper.swift | Updates documentation comment to include Muse as a log-backed spend source. |
| Sources/Runway/Providers/Muse/MuseProvider.swift | Integrates local log scanning + pricing into Muse refresh and snapshot assembly. |
| Sources/Runway/Providers/Muse/MuseLogUsageScanner.swift | New scanner for Muse session journals producing LogUsageScan for shared spend/history UI. |
| Sources/Runway/Providers/JSONLScanCacheCoordination.swift | Ensures Muse JSONL scan caches flush with the shared coordination point. |
| Sources/Runway/Providers/IncrementalJSONLScanner.swift | Updates doc comment to include Muse as a consumer. |
| Sources/Runway/Providers/DailyUsageAccumulator.swift | Updates doc comment to include Muse in shared accumulation flow. |
| Sources/Runway/Pricing/ModelRates.swift | Updates doc comment to include Muse as a spend-imputation consumer. |
| Sources/Runway/Models/WidgetDescriptor+Factories.swift | Updates doc comment to include Muse in the spend-tile descriptor set. |
| README.md | Notes Muse now supports local daily spend in the provider list. |
| docs/settings.md | Adds Muse to the list of spend-tracking providers for Total Spend. |
| docs/providers/muse.md | Expands Muse provider docs for log-derived history/spend behavior and troubleshooting. |
| docs/privacy.md | Updates local cache description to include Muse (but needs a small correction). |
| docs/pricing.md | Documents Muse Spark pricing behavior and maintainer notes for supplement upkeep. |
| docs/icloud-sync.md | Adds Muse to machine-local history sources merged via iCloud sync. |
| docs/dashboard.md | Adds Muse to Total Spend + model breakdown + Usage Trend documentation and default layout notes. |
| docs/architecture.md | Updates architecture docs to include Muse in shared JSONL scanning/caching. |
| AGENTS.md | Updates contributor guidance to include Muse in the pricing pipeline description. |
Review details
- Files reviewed: 22/22 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
An empty sessions directory is not usable history. Auto-enable only when a session.jsonl exists, matching what the scanner can actually read.
There was a problem hiding this comment.
🟡 Changes recommended
The new Muse log footprint probe and rate-limit detection include avoidable performance and fragility issues that should be addressed before merging.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
Sources/Runway/Providers/Muse/MuseProvider.swift:214
rateLimitedis derived by comparing user-facing error strings (museErrorText(snapshot) == MuseUsageError...errorDescription). Using localized/formatting text for control flow is brittle (any wording tweak or localization would silently break the detection). SincerateLimitedUntilis already tracked, prefer deriving this from state (rateLimitedUntilandnow).
- Files reviewed: 22/22 changed files
- Comments generated: 1
- Review effort level: Lite
Stop the footprint walk at the first session.jsonl, and treat mint cooldown from rateLimitedUntil instead of comparing localized 429 text.
There was a problem hiding this comment.
🔵 Needs a closer look
It changes Muse’s provider runtime behavior, pricing resolution, default layout seeding, and adds a new log-scanning pipeline that should be validated by a human reviewer for edge cases and user-facing correctness.
Review details
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
Tests/RunwayTests/MuseProviderTests.swift:649
museLogScanner(tokens:)creates a unique temp directory underFileManager.default.temporaryDirectorybut never removes it. Other tests in this suite generally clean up temporary fixtures (e.g., viadefer removeItem(at:)), and leaving these directories behind can accumulate across repeated local/CI runs.
- Files reviewed: 22/22 changed files
- Comments generated: 0 new
- Review effort level: Lite
|
Stopping the Copilot loop here. Round 1: empty-directory auto-enable was real; privacy Grok mention was a one-word fix on a line this PR already owned. Same-day Round 2: early-exit footprint walk and Round 3 is a test temp-dir cleanup nit. It does not change Muse spend, prices, or keeping Five-Hour and Weekly always visible. Local Bugbot is clean. CI is green. |
TL;DR
Muse now shows local token history and estimated Spark API-rate spend from session logs, while Five-Hour Usage and Weekly Usage stay always visible.
What was happening
What this changes
model_completedevents from Muse Code journals (~/.local/share/muse/sessions/, including nested subagent logs).Heads-up
mstallone/runway, not upstream.Tests
swift test --filter Museswift test --filter 'ModelPricing|PricingBundledResource'