Skip to content

fix: usage cost off-by-one drop & rename Agent Events to Event Stream#519

Merged
shanselman merged 3 commits into
openclaw:masterfrom
christineyan4:christiney/events-usage-fixes
May 22, 2026
Merged

fix: usage cost off-by-one drop & rename Agent Events to Event Stream#519
shanselman merged 3 commits into
openclaw:masterfrom
christineyan4:christiney/events-usage-fixes

Conversation

@christineyan4
Copy link
Copy Markdown
Contributor

Changes

Usage cost fix

  • The gateway computes daily cost \days\ as \Math.ceil(range / DAY_MS) + 1, returning e.g. 8 days for a 7-day request. The client previously compared with strict equality (!=), silently dropping valid responses. Now uses \Math.Abs(cost.Days - _currentPeriodDays) > 1\ to tolerate ±1 variance.

Event Stream rename & filter removal

  • Renamed Agent EventsEvent Stream across nav, page title, and localized resource strings (.resw)
  • Removed all filter buttons from the events page — the agent dropdown and live badge provide sufficient context
  • Updated empty state messaging to clarify events are session-scoped and clear on restart

Test update

  • Updated \UsagePage_GuardsStalePeriodResponses\ assertion to match the new tolerance logic

@clawsweeper
Copy link
Copy Markdown

clawsweeper Bot commented May 22, 2026

Codex review: needs real behavior proof before merge.

Latest ClawSweeper review: 2026-05-22 22:09 UTC / May 22, 2026, 6:09 PM ET.

Workflow note: Future ClawSweeper reviews update this same comment in place.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

Summary
This PR changes the tray Usage page to accept usage-cost day counts within one day of the selected period and changes the Agent Events page/nav/resources into an Event Stream view with stream filters removed.

Reproducibility: yes. for the usage-cost bug from source inspection: current main requests 7 or 30 days but drops cost payloads whose Days field is off by one. I did not run the WinUI app because this review is read-only.

PR rating
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🦐 gold shrimp
Summary: Useful intent, but missing real behavior proof and localized UI regressions make it not quality-ready yet.

Rank-up moves:

  • Add redacted after-fix proof from a real tray/gateway setup showing the usage-cost period data applying and the Event Stream UI state.
  • Update all locale resource overrides and localize the new live/offline badge text.
  • Fix the empty-state row placement or provide visual proof that the layout is still correct.
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

Real behavior proof
Needs real behavior proof before merge: The PR body/comments include no screenshot, recording, terminal output, copied live output, linked artifact, or redacted logs showing the usage-cost update or Event Stream UI after the fix; the contributor should add redacted proof to the PR body so ClawSweeper can re-review automatically, or ask a maintainer for @clawsweeper re-review if it does not trigger.

Mantis proof suggestion
A visible tray proof would materially help verify the renamed Event Stream page, badge state, removed filters, and empty-state layout. A maintainer can ask Mantis to capture proof by posting a new PR comment that starts with the OpenClaw Mantis account mention, followed by:

visual task: verify the Event Stream page shows the renamed title, live/offline badge, no stream filter bar, and correct empty state.

Risk before merge

  • No after-fix real behavior proof was provided for either the usage-cost acceptance path or the Event Stream UI changes.
  • The PR removes stream-type filters, so existing diagnostic workflows lose the Tool/Assistant/Error/Lifecycle/Plan filtering affordance unless maintainers intentionally accept that simplification.
  • Localized builds can continue showing the old Agent Events labels and empty-state text because the non-English .resw overrides are not updated.

Maintainer options:

  1. Split the bug fix from the UX decision (recommended)
    Move the usage-cost tolerance into a narrow PR and handle the Event Stream rename/filter removal after maintainer UX approval and visual proof.
  2. Preserve stream filtering
    Restore the existing stream filter controls or provide an equivalent affordance before merging so current diagnostic workflows keep working.
  3. Accept the filter removal deliberately
    A maintainer can explicitly approve the loss of stream-type filters if the simplified Event Stream surface is the intended product direction.

Next step before merge
Needs contributor real behavior proof plus maintainer UX/compatibility judgment on removing stream filters; automation cannot supply the contributor's real setup proof.

Security
Cleared: The diff only touches WinUI pages, resource strings, and a source-wiring test; it does not change dependencies, CI, scripts, credentials, or artifact download paths.

Review findings

  • [P2] Update every localized resource override — src/OpenClaw.Tray.WinUI/Strings/en-us/Resources.resw:1549
  • [P3] Localize the new live/offline badge text — src/OpenClaw.Tray.WinUI/Pages/AgentEventsPage.xaml.cs:101
  • [P3] Keep the empty state in the content row — src/OpenClaw.Tray.WinUI/Pages/AgentEventsPage.xaml:138
Review details

Best possible solution:

Land the usage-cost tolerance with focused regression coverage, then merge the Event Stream rename/filter simplification only after locale resources, layout, UX approval, and real behavior proof are in place.

Do we have a high-confidence way to reproduce the issue?

Yes for the usage-cost bug from source inspection: current main requests 7 or 30 days but drops cost payloads whose Days field is off by one. I did not run the WinUI app because this review is read-only.

Is this the best way to solve the issue?

No: the cost tolerance is a narrow fix, but the PR mixes it with a UX rename/filter removal and currently leaves localized builds inconsistent. The safer path is to split or fix those UI issues before merge.

Label changes:

  • add P2: This is a normal-priority tray bug/UX PR with limited blast radius, but it has correctness and proof gaps before merge.
  • add merge-risk: 🚨 compatibility: The diff removes existing event stream-type filters, which can break current event-inspection workflows if merged without explicit approval or replacement.
  • add rating: 🧂 unranked krab: Current PR rating is 🧂 unranked krab because proof is 🧂 unranked krab, patch quality is 🦐 gold shrimp, and Useful intent, but missing real behavior proof and localized UI regressions make it not quality-ready yet.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body/comments include no screenshot, recording, terminal output, copied live output, linked artifact, or redacted logs showing the usage-cost update or Event Stream UI after the fix; the contributor should add redacted proof to the PR body so ClawSweeper can re-review automatically, or ask a maintainer for @clawsweeper re-review if it does not trigger.

Label justifications:

  • P2: This is a normal-priority tray bug/UX PR with limited blast radius, but it has correctness and proof gaps before merge.
  • merge-risk: 🚨 compatibility: The diff removes existing event stream-type filters, which can break current event-inspection workflows if merged without explicit approval or replacement.
  • rating: 🧂 unranked krab: Current PR rating is 🧂 unranked krab because proof is 🧂 unranked krab, patch quality is 🦐 gold shrimp, and Useful intent, but missing real behavior proof and localized UI regressions make it not quality-ready yet.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body/comments include no screenshot, recording, terminal output, copied live output, linked artifact, or redacted logs showing the usage-cost update or Event Stream UI after the fix; the contributor should add redacted proof to the PR body so ClawSweeper can re-review automatically, or ask a maintainer for @clawsweeper re-review if it does not trigger.

Full review comments:

  • [P2] Update every localized resource override — src/OpenClaw.Tray.WinUI/Strings/en-us/Resources.resw:1549
    Changing only the en-us values leaves the same x:Uid keys in fr-fr, nl-nl, zh-cn, and zh-tw with the old Agent Events title/nav/empty-state wording. In localized builds those .resw values override the new XAML defaults, so the rename and new empty state will not appear consistently; update or intentionally seed all locale .resw files with the new strings.
    Confidence: 0.93
  • [P3] Localize the new live/offline badge text — src/OpenClaw.Tray.WinUI/Pages/AgentEventsPage.xaml.cs:101
    The new badge writes user-visible "Live" and "Offline" strings directly from code-behind, so every non-English UI will show English text on this localized page. Please move these through the same resource/localization path as the surrounding x:Uid strings or add an explicit invariant rationale.
    Confidence: 0.82
  • [P3] Keep the empty state in the content row — src/OpenClaw.Tray.WinUI/Pages/AgentEventsPage.xaml:138
    After removing the filter bar, the ListView remains in row 3, the star-sized content area, but the empty state is moved to row 2, an Auto row. When there are no events it will no longer occupy and center within the same content area as the list; keep it in row 3 or adjust the row layout.
    Confidence: 0.8

Overall correctness: patch is incorrect
Overall confidence: 0.86

What I checked:

  • Current main drops off-by-one usage cost: UsagePage.UpdateUsageCost returns when cost.Days differs from _currentPeriodDays, so a gateway response such as 8 days for a 7-day request is ignored on current main. (src/OpenClaw.Tray.WinUI/Pages/UsagePage.xaml.cs:103, 8560086ebeae)
  • PR diff changes usage guard and Event Stream UI: The PR head changes the UsagePage guard to Math.Abs(... ) > 1, removes FilterSelector, adds a live/offline badge, and updates only en-us Agent Events strings in the diff. (ae85282911da)
  • Localized resource overrides still contain old event wording: The supported non-English resource files still contain the old Agent Events title/nav/empty-state resource values for the same x:Uid keys, so localized builds will override the new XAML defaults with old wording unless those files are updated too. (src/OpenClaw.Tray.WinUI/Strings/fr-fr/Resources.resw:1500, 8560086ebeae)
  • Localization tests are structural, not semantic rename checks: The localization validation checks key sets, placeholders, empty values, and all-or-none identical strings; it does not prove that a rename was propagated to every translated value. (tests/OpenClaw.Tray.Tests/LocalizationValidationTests.cs:548, 8560086ebeae)
  • Relevant feature history: Recent history ties the usage loading guard to the async loading work and the Agent Events UI/resources to a later Fluent/WinUI tidy pass, which are the most relevant areas for routing. (8560086ebeae)

Likely related people:

  • Scott Hanselman: Commit 1fe8e52 added the UsagePage async loading behavior and the strict cost.Days guard covered by the tray source-wiring test. (role: introduced current usage loading guard; confidence: high; commits: 1fe8e5216ca7; files: src/OpenClaw.Tray.WinUI/Pages/UsagePage.xaml.cs, tests/OpenClaw.Tray.Tests/AsyncListLoadingPageWiringTests.cs)
  • bakudies: Commit 89aee64 recently touched AgentEventsPage XAML/code, all five Resources.resw files, and localization validation around the exact event-page strings affected here. (role: recent Agent Events UI and localization contributor; confidence: high; commits: 89aee64058e5, 139002cbc9d3; files: src/OpenClaw.Tray.WinUI/Pages/AgentEventsPage.xaml, src/OpenClaw.Tray.WinUI/Pages/AgentEventsPage.xaml.cs, src/OpenClaw.Tray.WinUI/Strings/en-us/Resources.resw)
  • Ranjesh Jaganathan: Blame attributes the current AgentEventsPage state fields, initialization wiring, and filter state to commit 8dea8ac, making this a useful routing signal for page behavior questions. (role: introduced adjacent AgentEventsPage code path; confidence: medium; commits: 8dea8acbae8f; files: src/OpenClaw.Tray.WinUI/Pages/AgentEventsPage.xaml.cs)

Codex review notes: model gpt-5.5, reasoning high; reviewed against 8560086ebeae.

@christineyan4 christineyan4 force-pushed the christiney/events-usage-fixes branch from 6570a51 to 9810d68 Compare May 22, 2026 22:00
christineyan4 and others added 3 commits May 22, 2026 18:02
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@christineyan4 christineyan4 force-pushed the christiney/events-usage-fixes branch from 9810d68 to ae85282 Compare May 22, 2026 22:03
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. labels May 22, 2026
@clawsweeper
Copy link
Copy Markdown

clawsweeper Bot commented May 22, 2026

ClawSweeper PR egg

🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat.

Where did the egg go?
  • The egg game starts only after the PR passes the real-behavior proof check.
  • Before that, no creature or rarity is rolled. The treat waits for real proof.
  • This is still just collectible flavor: proof affects review readiness, not creature quality.

@shanselman shanselman merged commit 8714381 into openclaw:master May 22, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants