Repository navigation
fix(ui): prevent usage exports from mixing session instances - #140573
Conversation
Include the concrete session ID in the existing export hydration key so reusing a logical key cannot mix old usage with a replacement session's prompt report. Preserve fresh details for the same instance and the existing refresh-and-retry error. Cover replacement, matching-instance, unrelated-agent, and cancellation behavior through the rendered Usage page, and document export recovery.
|
🦞👀 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 6, 2026, 9:23 PM ET / September 7, 2026, 01:23 UTC. ClawSweeper reviewWhat this changesUsage JSON exports match prompt details to the displayed session’s concrete instance, with regression coverage and refresh-recovery documentation. Merge readiness✅ Ready for maintainer review This remains a useful, focused fix: current main and v2026.9.2 retain the weaker export join. No actionable introduced defects were found, and the captured browser results support the intended behavior. Priority: P2 Review scores
Verification
How this fits togetherThe Control UI Usage page displays session accounting from the Gateway. JSON export fetches omitted prompt details and combines them with the displayed accounting snapshot before downloading the file. flowchart TD
A[Displayed usage snapshot] --> C[JSON export]
B[Gateway prompt details] --> C
C --> D{Same agent, key and instance?}
D -->|Yes| E[Download snapshot with matching details]
D -->|No required context| F[Show refresh message]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +1, Tests +58, Docs +1. Total +60 across 3 files. View PR surface stats
Review metricsNone. Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep lazy context loading and snapshot accounting while requiring the existing agent, logical key, and concrete instance to match before attaching prompt details. Do we have a high-confidence way to reproduce the issue? Yes: current-main source permits an old displayed row and replacement hydration row with the same agent/key to join despite different session IDs. The supplied compiled-browser results exercise that case; this reviewer did not execute it. Is this the best way to solve the issue? Yes: extending the shared identity repairs all three export matching operations without adding another loading path, changing the response format, or rewriting stored state. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 0cd1ca7552a0. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
…137098 * commit '8a540c252002878f3c3e9d8dfb837b83c8602a78': (2210 commits) perf(plugins): keep bundled catalog lookups lightweight (#140597) refactor: streamline skills JSON serialization (#140581) fix(feishu): expand quoted merged-forward messages (#136231) fix(talk): keep opaque realtime routes out of public config (#129144) fix(ci): avoid Linux packaging on pull requests (#140589) fix(usage): release completed request payloads (#140588) fix(tooling): omit Trae machine squash credit (#140562) fix(ui): stop catalog paging in hidden tabs (#140583) fix(portals): reach IPv6 loopback with IPv4-only localhost records (#140580) fix(transcripts): preserve fixed and legacy capture history (#140563) fix(ui): prevent Talk E2E audio capture stalls (#138803) fix(media): release completed document source buffers (#140561) fix(anthropic): preserve resumed CLI caches across Git changes (#140566) chore(ui): refresh control ui locales (#140586) fix(ui): keep usage exports bound to their session instance (#140573) refactor(exa): test response readers through tool execution (#140572) fix(macos): omit incompatible worker binaries from app bundles (#140557) fix: avoid retaining discarded tool output (#140570) refactor(gateway): share placement move matching (#140569) fix(gateway): preserve child turns during systemd drain (#140568) ... # Conflicts: # .agents/skills/release-openclaw-maintainer/SKILL.md # docs/reference/RELEASING.md
…#140573) Include the concrete session ID in the existing export hydration key so reusing a logical key cannot mix old usage with a replacement session's prompt report. Preserve fresh details for the same instance and the existing refresh-and-retry error. Cover replacement, matching-instance, unrelated-agent, and cancellation behavior through the rendered Usage page, and document export recovery.
Closes #140567
What Problem This Solves
Fixes Usage JSON exports that attach a replacement session's prompt context to an older displayed usage row after the logical session key is reused. This affects both Current instance and the default Historical lineage view.
Why This Change Was Made
The existing shared export key now includes the concrete session ID alongside agent and logical key. Map construction, required-context validation and context lookup all use that one identity. The existing refresh error handles replacement; the original lazy-loading behavior and same-instance updates are preserved.
User Impact
An export keeps the displayed usage snapshot and loads details belonging to that same instance. If it has been replaced, the UI asks the operator to refresh instead of downloading mixed data. Refreshing then exports the replacement correctly. The Usage reference documents this recovery.
Evidence
c864dc2389cdc40578c34fd9c4774d121a4612c0; fresh uncached build passed.All eight downloaded files, 20 screenshots and six videos were inspected. Complete source, dependency and generated-artifact checks passed before and after every run; browser, context, server and listeners closed normally. This is a real UI snapshot scenario with a mocked Gateway, not a live deletion/recreation or provider test.
Production +3/−2: two executable lines replaced and one ownership comment added. Tests +60/−2; docs +1. The affected owners are unchanged on inspected main
6df7c32f477a458950f01a541119944b5bd85557.Provenance: the parent-relative diff of #132064 (
d9f3d88409358603ab4c0ad1afd7eab846c6a0d8) introduced the weaker join. Stablev2026.9.2retains it; that is source evidence only.Inspected synthetic browser evidence
Before: the export completes without a refresh warning; the actual downloaded JSON contains row A with context B. After: the existing refresh message prevents that mixed download. The short recordings also include successful refresh-B recovery.
attachment-845718765.mp4
attachment-3851279919.mp4