fix(ui): pass agentId in sessions.usage request for usage page#87190
fix(ui): pass agentId in sessions.usage request for usage page#87190Linux2010 wants to merge 4 commits into
Conversation
- Add usageAgentId to UsageState and AppViewState - Pass agentId in sessions.usage API request when selected - Add renderAgentFilter that uses onAgentChange callback instead of query tokens - Use agents from agentsList instead of loaded sessions for agent options - Add tests for agentId parameter in sessions.usage request Fixes openclaw#87132
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. The merged replacement path now implements the useful part of this PR on current main and covers a broader, safer contract: selected agents send Canonical path: Close this PR in favor of the merged replacement implementation and keep validating the broader all-agent usage behavior from current main until it ships. So I’m closing this here because the remaining work is already tracked in the canonical issue. Review detailsBest possible solution: Close this PR in favor of the merged replacement implementation and keep validating the broader all-agent usage behavior from current main until it ships. Do we have a high-confidence way to reproduce the issue? Yes, source inspection gives a high-confidence reproduction for the original bug: v2026.5.27 lacks Is this the best way to solve the issue? No, this PR is no longer the best way to solve it. The merged replacement is broader and cleaner because it updates the UI, gateway, protocol/docs, Swift model, all-agent default behavior, selected-agent cost usage, and compatibility fallbacks together. Security review: Security review cleared: The branch only changes Control UI usage state/view/controller tests and English i18n; no concrete security or supply-chain issue was found in the proposed diff. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 8a60f39221db; fix evidence: commit 99bd27535985, main fix timestamp 2026-05-29T02:03:33+01:00. |
|
ClawSweeper PR egg 🔥 Warming up: real-behavior proof passed; findings, security review, or rank-up moves are still in progress. Hatch commandComment Hatchability rules:
What is this egg doing here?
|
Verification ProofUnit TestsTest file: Test Results: Live Proof (Playwright)Script: Test Flow:
Captured WebSocket Request: {
"startDate": "2026-05-27",
"endDate": "2026-05-27",
"mode": "specific",
"utcOffset": "UTC+8",
"groupBy": "family",
"includeHistorical": true,
"agentId": "testclaw",
"limit": 1000,
"includeContextWeight": true
}Screenshots: Summary
Fix Implementation
|
|
@clawsweeper please review - verification proof added with screenshots |
- Add retry/cache pattern for unsupported agentId param in sessions.usage - Similar to existing date/scope legacy fallback patterns - Change 'All' filter label to 'Default' to accurately reflect backend behavior - Add focused controller test for agentId fallback Addresses ClawSweeper review findings: - [P2] Preserve older-gateway usage compatibility - [P2] Do not label default-scoped usage as All
Fix AppliedAddressed both ClawSweeper findings: 1. Older-gateway compatibility (P2)Added retry/cache pattern for unsupported
2. Default agent label (P2)Changed "All" filter label to "Default" to accurately reflect backend behavior:
Test CoverageAdded focused controller test for agentId fallback:
Files Changed
Commit: 0e60e40 |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper review |
|
🦞👀 Command router queued. I will update this comment with the next step. Re-review progress:
|
…label in closed badge - Add client-side session filtering when agentId fallback is triggered - Change closed agent badge to show 'Default' instead of 'All' - Addresses ClawSweeper review findings: - [P2] Preserve selected-agent filtering after legacy retry - [P2] Show Default in the closed agent badge
Additional Fixes AppliedAddressed 2 of 3 ClawSweeper findings: 1. ✅ Client-side agent filtering after legacy retry (P2)Added if (agentIdFallback && state.usageAgentId) {
filteredRes.sessions = filteredRes.sessions.filter(
(s) => s.agentId === state.usageAgentId,
);
}2. ✅ Default label in closed badge (P2)Changed line 425 from 3.
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
This comment was marked as spam.
This comment was marked as spam.
|
ClawSweeper applied the proposed close for this PR.
|




Fixes #87132
Summary
usageAgentIdtoUsageStateandAppViewStateto track selected agent for usage pageagentIdinsessions.usageAPI request when an agent is selectedrenderAgentFilterthat usesonAgentChangecallback instead of client-side query tokensagentsListinstead of loaded sessions for agent filter optionsRoot cause
After commit 6a12c6f (v2026.5.17), the
sessions.usagebackend scopes session discovery by agentId, defaulting to "main" when no agentId is provided. The Web UI frontend never sentagentIdin the API request, so non-main agent sessions were never returned. The agent filter UI was client-side only (using query tokens), which didn't affect the API parameters.Real behavior proof
Behavior addressed: Usage page agent filter now sends
agentIdtosessions.usagebackend API, allowing non-main agent sessions to be returned when selected.Real environment tested: Local macOS source checkout of PR branch
fix/87132-usage-agent-filter, Vitest unit tests.Exact steps or command run after this patch:
Evidence after fix:
Observed result after fix:
sessions.usagerequest includesagentIdparameter whenusageAgentIdis setagentsList, usesonAgentChangecallbackWhat was not tested: Live Control UI browser test with multi-agent configuration; behavior verified via unit tests.
Verification
node scripts/run-vitest.mjs ui/src/ui/controllers/usage.node.test.ts ui/src/ui/views/usage.test.ts— 12 tests passpnpm build— successful