feat(ui): add comparative cost analysis#100432
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 5, 2026, 6:52 PM ET / 22:52 UTC. Summary PR surface: Source +712, Tests +752, Docs +7. Total +1471 across 76 files. Reproducibility: not applicable. this is a feature PR, not a broken existing behavior report. Source inspection confirms current main lacks the requested simultaneous cost-window cards and daily chart scale labels, while the PR proof shows the after-state UI. Review metrics: none identified. Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review detailsBest possible solution: Land the UI-only Usage comparison after maintainer product acceptance and exact-head checks, keeping the change free of new protocol, config, and storage surfaces. Do we have a high-confidence way to reproduce the issue? Not applicable: this is a feature PR, not a broken existing behavior report. Source inspection confirms current main lacks the requested simultaneous cost-window cards and daily chart scale labels, while the PR proof shows the after-state UI. Is this the best way to solve the issue? Yes, subject to product acceptance: deriving comparison windows from existing daily rows and aligning existing day-bucket semantics is the narrowest maintainable implementation path. I did not find a supported current Control UI path that already provides the side-by-side comparison. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a905eb42acda. Label changesLabel justifications:
Evidence reviewedPR surface: Source +712, Tests +752, Docs +7. Total +1471 across 76 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (9 earlier review cycles; latest 8 shown)
|
6aeffaf to
55b4fc5
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 55b4fc5d33
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const summary = await loadCostUsageSummaryCached({ | ||
| startMs, | ||
| endMs, | ||
| dailyUtcOffsetMinutes: resolveDayBucketUtcOffsetMinutes(dateInterpretation), |
There was a problem hiding this comment.
Align cost and session daily buckets
When the UI requests UTC or browser-local dates from a gateway running in another timezone, this new offset is applied only to usage.cost; sessions.usage still returns activityDates and dailyBreakdown from cached session summaries built with gateway-local formatDayKey(...) in src/infra/session-cost-usage.ts. The Usage view then intersects those session dates with data.costDaily, so a message near midnight can land on 2026-02-11 in the cost rows but 2026-02-12 in the session row, making selected-session/day filtering hide or misattribute the new cost-window/daily-chart data. Please either pass the same bucket contract through the session-summary path or avoid mixing these two daily sources.
Useful? React with 👍 / 👎.
|
@clawsweeper re-review Addressed both review findings at exact prepared head
Proof:
|
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d590a0ab99
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| defer { self.finishSetupAttempt(attemptID) } | ||
| defer { | ||
| self.finishSetupAttempt(attemptID) | ||
| self.pendingTargetSuppression.resumeAutoConnect(.qrScanner, controller: self.gatewayController) |
There was a problem hiding this comment.
Keep QR target suppression through trust prompts
When a scanned QR setup link targets a TLS gateway with no stored fingerprint, connectManual returns after setting pendingTrustPrompt; it has not connected or failed yet. This defer then resumes the .qrScanner lease opened with suspendCurrentGateway: true, so the previously active gateway can be restored behind the certificate-review alert before the user accepts or declines the new target (the Settings QR handler has the same defer). Keep or release the lease from the trust-prompt resolution path instead.
Useful? React with 👍 / 👎.
032013b to
641f048
Compare
|
Merged via squash.
|
Closes #100405
AI-assisted: yes
What Problem This Solves
The Control UI Usage page showed one selected total and rich attribution, but operators still had to reload multiple presets and hover individual bars to compare recent spend or understand the chart scale.
Why This Change Was Made
This adds calendar-correct shorter cost windows derived from the daily data already loaded for the selected range, explicit daily chart scale labels, and cost-share percentages on provider/model/agent/channel rollups. It adds no request, storage, config, or protocol surface; day-filtered views deliberately omit category percentages because the backend category rollups are session-scoped rather than day-scoped.
Daily cost and session-detail buckets now share the request's UTC/browser offset through aggregation, zero-fill, cache identity, and cached-summary projection, so a remote Gateway cannot shift boundary usage into the wrong comparison day. UTC quarter-hour data remains UTC.
The product shape follows current CodexBar prior art while reusing OpenClaw's existing, richer Usage data model. The dashboard continues to describe estimated costs from available local session history, not provider invoices or lifetime spend.
User Impact
Operators can compare the selected range with Today, 7-day, 30-day, and 90-day windows at a glance, read the chart without hovering, see provider/model cost share when the data scopes match, and retain nonzero precision for sub-cent usage.
Before / after
Before — cost bars required hover to infer the scale, and comparing periods required repeated date-range reloads.
After — selected-range and shorter calendar windows, readable chart scale, and existing cost-type attribution in one view.
Evidence
tbx_01kwswgnzqeazh2q1mcvfmsfd2(coral-hermit)usage-cost-analysis.e2e.test.tspassed and produced matched before/after capturespnpm check:changedpassed remotely, including core/core-test TSGo, complete core/UI/package lint, import-cycle, storage, loader, dependency, and runtime guards