Repository navigation
Conversation
Retain compatible committed rollups and publish completed usage revisions through chat metadata events. Replace session polling with publication-driven rereads, preserving provider quota retries.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 24, 2026, 4:11 PM ET / 20:11 UTC (Revision 6). ClawSweeper reviewWhat this changesThe branch keeps committed session-usage totals visible during refresh and updates the Control UI when the Gateway publishes a completed or failed rollup. Merge readiness✅ Ready for maintainer review The usage defect remains on current main, so this PR is still a distinct candidate. The related widget-test repair has merged separately and does not replace the usage work. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway builds usage totals from session transcripts and serves them to clients. The Control UI displays those totals and responds to Gateway refresh notifications. flowchart LR
A[Session transcripts] --> B[Usage rollup worker]
B --> C[Committed usage cache]
B --> D[Gateway refresh notice]
C --> E[Usage API response]
D --> F[Control UI Usage page]
E --> F
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +197, Tests +399, Docs +1. Total +597 across 35 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep the committed totals readable until authoritative new totals arrive, with a visible retry action when refresh fails. Do we have a high-confidence way to reproduce the issue? Yes. Current main's bounded retry policy and non-publishing refresh owner give a clear source-level path; the PR reports negative controls, but this read-only review did not execute them. Is this the best way to solve the issue? Yes. Publishing from the refresh owner after worker settlement and keeping UI recovery scoped to each agent is a maintainable repair for the reported behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d5e6383f4802. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
…er retries Publish refresh completion at its operation owner, including a terminal failure receipt when no rollup commits. Keep last totals visible, support manual recovery, and preserve provider retry accounting across publication-driven reads.
Keep failed refresh outcomes attached to the affected agent and preserve their paused notice across automatic reads and route preloads. Retain committed publication revisions so later failures cannot erase a pending catch-up read. Exercise Telegram session destinations through the same bot dispatch boundary as durable ingress, removing the unrelated webhook deadline and an impossible JSON fixture field. Preserve the existing routing, command, topic persistence, and reply assertions.
Declare both synthetic agents before selecting All agents in the usage recovery browser proof. Type-check Telegram updates before JSON serialization so grammY reply types and the actual wire payload stay aligned without the test-only webhook deadline.
Keep Request JSON decoding before direct Telegram bot dispatch so typed reply fixtures retain the actual wire representation without a webhook deadline. Remove a redundant default type argument from the preload request barrier.
Integrate current main metadata change flags so usage publications preserve model catalog and auth facts. Keep failure acknowledgment on the explicit Refresh action, tied to immutable per-agent receipts; filter changes cannot dismiss another agent failure. Guard selected-agent receipt lookup against inherited object keys.
Apply the maintained fixture repair from 2019fd9 (#157494). Wait for each actual menu opening before choosing pointer coordinates, retaining the real input flow and every original assertion. Co-authored-by: vincentkoc <[email protected]>
) Keep committed session usage totals visible during background refresh and reread them when chat.metadata.changed announces settled work. Scope refresh outcomes to their agent, retain successful publications through later failures, and preserve paused recovery across navigation and filter changes until explicit Refresh or a successful publication. Reject unavailable requested transcripts through the existing failure receipt, and keep provider quota retry budgets independent. Use Telegram's production dispatch boundary in its session-destination fixture instead of a generic HTTP wrapper with an unrelated ten-second deadline. Preserve routing, real-command, topic persistence, and reply assertions. Validated with original-code negative controls, real usage-worker and Gateway tests, Control UI tests and bundled browser proof, static gates, and Telegram fixture repetition on Blacksmith Testbox. No production deployment or live multi-minute refresh. Adopt the maintained widget-menu fixture synchronization from openclaw#157494, retaining every original pointer, keyboard, target, and frame-preservation assertion. Co-authored-by: vincentkoc <[email protected]>
What Problem This Solves
Session usage panels discarded committed totals while background rollups refreshed, then stopped their 5/10/20-second retries before long refreshes finished. The panel could stay empty until a manual refresh.
User Impact
Usage keeps the last committed totals visible during refresh, then updates when the background work completes. A failed refresh leaves a visible paused notice and an explicit Refresh action.
Why This Change Was Made
Keep compatible committed totals visible with
computedAt,staleSince, andrefreshing. Returnusage: nullwithcomputing: trueonly when there is no usable committed rollup. The refresh operation publishes after its worker and accepted writes settle, reusingchat.metadata.changedwithagentId,usageUpdatedAt, and a terminal failure flag. Its revision invalidates cached usage responses.The Control UI rereads on successful publications instead of polling session totals. The Gateway sets the existing
modelCatalogChangedandauthChangedflags tofalsefor usage receipts, reusing the current metadata owners. Its Gateway connection owns duplicate suppression and per-agent outcomes, including the last successful publication; disconnect retires them. Hidden and preloading pages catch up once. Failed refreshes retain totals and show a paused notice across automatic reads and navigation. Filter changes and another agent's success cannot acknowledge that failure; Refresh acknowledges only the affected receipts in its selected scope and retries immediately. New immutable receipts retire prior acknowledgments. Provider quota retries remain bounded and independent, and usage-only events do not invalidate Control UI model catalogs.Net production TypeScript growth is 197 lines, above the 120-line guideline because terminal recovery needs agent ownership, preload ordering, and independent provider retry accounting. No configuration, schema, or durability changes.
Measurement
usage: nullEvidence
Head
71f8378af881passed all selected proof and exact-head CI. The maintained widget-menu test synchronization from #157494 preserves @vincentkoc’s contributor credit and every original assertion. Independent review of this head found no actionable findings.All heavy validation used
blacksmith-testbox, profileopenclaw-check, through installed Crabbox and the repository source-transfer wrapper. No local suites, builds, or typechecks ran. Results below are remote command exits; stopping a completed lease can mark its hosting Actions job cancelled.tbx_01m39hj4k2e5c0gswh8b5pm3br(runner): 66 backend tests, 60.81 s wall with one worker; 266 UI tests, 12.02 s wall; 62 observer/view checks, 5.22 s. Full changed gate passed in 29m47s.tbx_01m39qmtmkqb9feszdymtpwj5b(runner): 53 backend tests, 74.66 s wall; focused UI checks and bundled Chromium recovery flow passed. Follow-up static gates passed ontbx_01m39srnvjpsn093r4j2pbtswtin 34m35s.tbx_01m39xexnzy38tb6x17hkke7mp(runner): Original-order baseline shard passed (20 files, 625.792 s). Final focused checks passed: 129 UI tests (11.15 s); 49 Gateway tests (54.71 s); eight real-worker tests (35.40 s); 70 Telegram destination/native-command tests (98.77 s); three durable webhook admission/ACK tests (49.83 s). Corrected preload owner file: 28 passed in 3.20 s. These are Vitest durations with--maxWorkers=1; the existing real-worker tests retain their SQLite/worker settlement boundary. The bundled Chromium rebuild/recovery scenario passed in 2.221 s test time / 25.41 s file duration. The selected changed-code gates are complete across this lease and the final lease below. The first 15 unchanged test type graphs were reused after a fixture-only correction; the remaining ten graphs, core/UI types, extension types, lint, dead exports, and runtime guards all passed without suppressions.tbx_01m3a4fzbzp412cy1qyc495n9b(runner): targeted Telegram lint and extension-test types passed; the remaining nativecheck-changedplan completed, including core/extension lint, style checks, schema and database guards, sidecar, webhook and pairing guards. Final All-agents browser proof passed ontbx_01m3a1hvdk1ck1j3k5tv078km4(runner): 1.761 s test / 16.41 s file duration. Repetition results are recorded below.tbx_01m3aavefq8kj9fc79t40mn0x9(runner): six original-code controls failed at their intended assertions; 49 Gateway tests passed (34.00 s), eight real-worker tests passed (21.61 s), 192 UI tests passed (11.15 s), bundled browser recovery passed (17.35 s file duration), and 12 Telegram tests passed (51.11 s). The changed-code gate then identified the five-line test-file overage repaired above. The lease is stopped; the final static pass uses a fresh lease for the new head.tbx_01m3ac5xcew39y7j2g595js009andtbx_01m3ad606whftcmcdr9hnj9w95stopped at the validation script’s commit-identity assertion: the wrapper deliberately uses a transport commit asHEAD. Both leases are stopped. The corrected script verifies canonical execution root and exact source tree; the receiver separately verifies the source commit. No test pass is claimed for those attempts.797f90b13719, leasetbx_01m3adeyjhbfjjnr7c0yrsmz5w(runner): the original-worker missing-transcript control failed at its intended zero-publication assertion (21.50 s file). The repaired worker passed all nine tests (35.47 s file; new regression 2.516 s), and both palette files plus the usage page passed 87 tests (8.95 s).node scripts/check-changed.mjsfor all 34 changed paths passed, including all 25 core-test type graphs, UI/extension types, lint, dead exports, and runtime guards. The composite command completed in 44m38s, exit 0; its chat replays are described below. This lease is stopped. The subsequent head changes only the separately maintained widget fixture.tbx_01m3ag5ffaha5tv3vfg168wvj2(runner):node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner --maxWorkers 3 --shard 8/8reused the original 654-path selection underCI=true: 79 files / 375 tests passed in 505.02 s. The focusedsolo-widget-chrome.e2e.test.tsinvocation passed all four tests in 21.47 s.node scripts/check-changed.mjs -- ui/src/e2e/solo-widget-chrome.e2e.test.tspassed, including its UI E2E type graph (61.3 s), localization, dead exports, and lint. Composite command 16m10s, exit 0. A preceding attempt stopped before tests because the script had not created its artifact directory; the corrected script passed on the same lease.git diff --checkpasses.Negative controls against the original implementation establish the null response and four-request defects. Further controls establish failed-refresh recovery, provider retry resets, agent scoping, automatic acknowledgment, and missed preload catch-up. Deferred writer/request barriers and fake UI time avoid real sleeps.
CI on the preceding head exposed an unrelated Telegram fixture deadline: grammY's generic webhook wrapper timed out at 10 seconds during real
/helpinitialization (11.999 s observed). Production acknowledges durable admission before dispatchingbot.handleUpdate; the destination tests now use that same dispatch boundary. All routing, real-command, persistence, and reply assertions remain. The fixture keeps JSON serialization before direct dispatch: grammY requires an undefined-only reply field in its TypeScript type, while Telegram wire JSON omits it. The authored update is checked withsatisfies Updatebefore the fixture decodes the JSON request. The unchanged original shard passed on Testbox in 625.792 s, so the replay alone is not claimed as a fix. The repaired fixture passed 20 fresh-process standalone runs (978 s total; 37–63 s per file) and three exact original-shard runs (544 / 565 / 515 s), with unchanged CI worker settings and file order. The final lease command, including remaining static guards and this repetition, completed in 49m54s with exit 0. The file retains real command initialization, loopback delivery and persisted session/topic checks; a cheaper mocked helper would bypass those contracts.CI on an intermediate head also failed
chat.reset-visible-yield.test.ts: the requester reportedyielded: true, aborted: true, then a successful replay lacked the yield field and its child continuation remained pending. Source review identified inconsistent classification as a plausible cause, but the producer cause is unproven; genuine abort/timeout guards remain unchanged. The bounded original-plan replay (129 files, both Gateway-methods configs, two workers) passed in 487 s, followed by the standalone file in 53 s. No chat source was changed and those passes are not claimed as a fix; the producer cause remains unproven.The final usage candidate’s only failing CI lane was fullscreen-widget browser chrome: after reopening the Research menu, the fixture waited for a remove request that never arrived. The maintained test fix now adopted here has controlled real-pointer proof: pointer-down hits Remove, the opening animation moves the items, and pointer-up at the same coordinates hits another item, so no selection is dispatched. A fresh
wa-after-showreceipt stabilizes coordinates while retaining real pointer/keyboard actions, the 30-second CI deadline, and every target/frame assertion. Upstream’s controlled proof and this branch’s fresh 79-file / 375-test replay passed. No production widget behavior changed.One browser attempt stopped before page creation because Playwright FFmpeg was absent; installing that test prerequisite resolved it. An isolated negative control also exposed a cold-import fixture race; it now awaits the actual request-start signal, and all negative controls fail at their intended assertions.
The screenshots below are inspected synthetic fixtures. Browser assertions cover failed refresh, manual recovery, retained totals, deduplicated completion, and unchanged model-catalog request count. No production deployment or live multi-minute refresh was performed.