Skip to content

feat: show tokens per second in the chat context popover - #2390

Merged
larroy merged 2 commits into
openclaw:mainfrom
larroy:feat/chat-context-popover-throughput
Nov 30, 2026
Merged

larroy merged 2 commits into
openclaw:mainfrom
larroy:feat/chat-context-popover-throughput

Conversation

@larroy

@larroy larroy commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Windows Companion's chat composer shows context-window fullness and the latest run's tokens, but nothing about how fast the model is replying. Before #2117 a tokens-per-second strip sat under the composer; that strip was removed when the composer was made compact, so model speed became invisible even though the client still tracks it.

User Impact

User impact: opening the context ring now shows this session's model throughput (current rate, mean and p95 tokens per second), including a live estimate while a reply streams, without bringing back the extra row under the composer.

Why This Change Was Made

The data never left the client: ChatThroughputTracker still samples every run and OpenClawChatDataProvider still exposes GetThroughput and ThroughputChanged. This change reconnects that data inside the existing popover through a small IChatThroughputSource interface, and the indicator subscribes so an open popover refreshes during streaming without re-rendering the transcript. Values are local estimates derived from streamed text and usage events; no provider-reported rate is claimed.

Evidence

  • The composer context popover now ends with a Tokens per second section: 42.3 tps · μ 38.5 · p95 51.0, with ~ marking the live estimate while a turn streams and — before the first sample.
  • Private-desktop UI test ContextRing_TracksUsageAndKeepsGeometryWhileTyping opens the popover, asserts the placeholder row, publishes throughput for the thread, and asserts the flyout stayed open and shows 42.3 tps · μ 38.5 · p95 51.0.
  • ChatUsageFormatterTests covers live-vs-completed preference, placeholder text, and integer formatting at 100+.
  • The separate strip stays removed (ChatThroughputStrip absence is still asserted), and the ring still hides when the context window size is unknown.

Required proof pools

  • windows-winui-interactive: the composer context popover layout, localization, and the live refresh of the open flyout changed.

Validation

Run against commit 85dfa0dd8d on a native Windows 11 x64 host, Debug.

Command Result
./build.ps1 Passed: Shared, Cli, SetupEngine, WinNodeCli, WinUI
dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore Passed: 7,054; failed: 0; skipped: 0
OPENCLAW_REPO_ROOT=<repo> dotnet test ./tests/OpenClaw.Tray.UITests/OpenClaw.Tray.UITests.csproj --no-build -r win-x64 -p:Platform=x64 --filter "FullyQualifiedName~ContextRing_TracksUsageAndKeepsGeometryWhileTyping" Passed: 1; failed: 0
dotnet test ./tests/OpenClaw.Tray.Tests/... --filter "FullyQualifiedName~TestDeterminismGuardTests" Passed: 38 (new popover wait uses WaitForRenderedConditionAsync, not a settle delay)
dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore 6,149 passed, 26 failed, 28 skipped. All failures are pre-existing InstalledFileWorkerResolverTests (FileTransfer) and Mxc* cases; they reproduce identically without this change, and no OpenClaw.Shared file is touched. Reported, not claimed clean.
./scripts/validate-docs.ps1 Passed: 82 Markdown files

Independent review: shared autoreview helper, Codex engine (codex-cli 0.162.1), --mode commit --commit 85dfa0dd8d --max-priority P3. Status scoped-clean, report review_status: scoped-clean, report_produced: true, process exit 0, overall correctness 0.86, no accepted or filtered findings. That run noted it could not verify Reactor hook semantics or runtime behavior from its sandbox; the focused UI test above covers those.

Earlier failure retained

One earlier Tray run failed NativeToolProjectorTests.ToolOutput_PreservesTheFormerPreviewTailAndRetainsTheEntrySafetyBudget with a regex timeout inside ExecApprovalSecretRedactor. The isolated rerun passed and the final full run was clean; no tool-projector or redactor code is part of this change.

Real behavior proof

  • Environment tested: native Windows 11 x64, Debug build; in-process mounted WinUI chat harness that creates its own hidden window.
  • Tested source: commit 85dfa0dd8d.
  • Exact steps: the focused UI test mounts the chat surface, publishes a snapshot with context usage, opens ChatContextUsage, asserts the popover shows 10.0K / 10.0K · 100%, Input 120, Output 0, and — tps · μ — · p95 —, then publishes ChatThroughputStats(42.26, 61.04, 38.5, 51.0, 3) for the thread and waits for the rendered popover.
  • Observed result: the flyout remained open and rendered 42.3 tps · μ 38.5 · p95 51.0; ring geometry and popover identity were unchanged by a draft edit; no ChatThroughputStrip element exists.
  • Screenshot or artifact links verified? No public artifact links; the proof is the focused native UI test above.
  • Not verified or blocked: an interactive app screenshot against a live Gateway (declared pool windows-winui-interactive remains scheduled, not executed), the live ~ estimate against a real streaming Gateway, ARM64, and Release. The mounted test publishes synthetic statistics through the same provider interface the app uses.

Change Type

  • Bug fix
  • Feature
  • Refactor
  • Docs or instructions
  • Tests or validation
  • Security hardening
  • Chore or infrastructure

Scope

  • Tray or WinUI UX
  • Windows node capability
  • Local MCP or winnode
  • Gateway, connection, or pairing
  • Setup or onboarding
  • Permissions, privacy, or security
  • Tests, CI, or docs

Security Impact

  • New permissions or capabilities? No
  • Secrets or tokens handling changed? No
  • New or changed network calls? No
  • Command or tool execution surface changed? No
  • Data access scope changed? No

Compatibility and Migration

Backward compatible presentation change; no config, migration, or user action. The percentage-only numbers are local estimates and — marks anything not yet measured.

Review Conversations

  • I replied to or resolved every bot review conversation addressed by this PR.
  • I left unresolved only conversations that still need maintainer judgment.

- The composer context popover now ends with a Tokens per second section:
  current rate, mean (mu) and p95 over recent model calls in the session.
- Live estimates are prefixed with ~ while a turn streams; unavailable values
  show a placeholder until the first sample.
- The popover subscribes to the provider's throughput notifications through a
  new IChatThroughputSource, so an open popover refreshes without re-rendering
  the transcript. The pre-openclaw#2117 strip below the composer stays removed.
- Restored ChatUsageFormatter.FormatThroughput and localized the new strings in
  all six resource languages.
@clawsweeper

clawsweeper Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. clawsweeper:intake:feature Preliminary submission classification; full source review pending. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 27, 2026
@clawsweeper

clawsweeper Bot commented Nov 27, 2026

Copy link
Copy Markdown

Codex review: passed.

What this changes

Adds current, mean, and p95 tokens-per-second values to the chat context popover.

Example: Open the context ring after a response measured at 42.26 tokens per second.

  • Before: The popover shows context usage and input/output tokens.
  • After: It also shows 42.3 tps · μ 38.5 · p95 51.0.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch is focused and has useful supporting tests, but required shipped-app proof is absent and validation is not fully settled.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Users cannot inspect model response speed in the compact native chat composer.
Reason: The maintainer-authored direction restores existing measurements in an established disclosure surface without adding configuration or another toolbar row.

Merge readiness

✅ Ready for maintainer review

Keep this maintainer-authored PR open: it restores useful throughput visibility without undoing the compact composer, and no definite introduced code bug was found.

Reviewed head: 85dfa0dd8d5d24a93f450a522f6e289eb0c207a9

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Provide current-head running-Companion evidence of the open popover updating during streaming and settling on completed statistics; the supplied test uses synthetic data and no base-failure run is shown.
Agent review details

How this fits together

The existing chat provider tracks per-thread throughput from Gateway events; the composer passes that source to the context indicator, which formats statistics and refreshes its flyout.

flowchart TD
  A[Gateway chat events] --> B[Chat data provider]
  B --> C[Existing throughput tracker]
  C --> D[Throughput notifications]
  D --> E[Context usage indicator]
  C --> E
  E --> F[Formatted popover values]
Loading

Technical review

Best possible solution:

Keep throughput in the existing context popover and retain the current tracker as its sole data owner.

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

Current-main source confirms that throughput remains tracked but is absent from the context popover; no runtime reproduction was performed.

Is this the best way to solve the issue?

The focused extension reuses existing measurement and presentation owners, preserves the intentionally removed strip, and adds distinct formatter and mounted-refresh coverage.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 8d31176d3ad4.

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Pedro Larroy: Raw commit 1beeb01 adds src/OpenClaw.Tray.WinUI/Chat/ChatThroughputTracker.cs:25 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 1beeb01f8e4a; files: src/OpenClaw.Tray.WinUI/Chat/ChatThroughputTracker.cs)

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 27, 2026, 3:25 AM ET / 08:25 UTC.

@larroy

larroy commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator Author
image Proof with screenshot

@larroy

larroy commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator Author

Adversarial dual-model review (source only)

Reviewed head: 85dfa0dd8d5d24a93f450a522f6e289eb0c207a9
Base: main @ 8d31176d3ad407cf264472f48f82c1b6daa8b362
Scope: git diff main...HEAD, 17 files, +200/-13 (feat: show tokens per second in the chat context popover).
Verified head unchanged after both reviews finished.

Reviewers

Review Agent Model resolved by the harness (self-reported from each agent's own system prompt)
A code review agent Claude Opus 5.5, inference-nvidia/aws/anthropic/bedrock-claude-opus-5-5
B general agent GPT-5.6 Terra, inference-nvidia/switchyard/openai/gpt-5.6-terra

Requested pairing was Claude Opus 5.5 plus GPT-6 Astra. Opus 5.5 was used. GPT-6 Astra was not available in this harness, and the second reviewer resolved to the task role model, GPT-5.6 Terra; no per-spawn model or effort override exists here, so both ran at the harness default reasoning effort (auto).

Both got the identical brief: same revision, same constraints, same severity definitions, no sight of each other's output. This review is source-only: it ran on a Linux host, so no Windows build, no ./build.ps1, no test run, and no current-head UI proof. Those gates are still open.

Consensus

Neither model found a CRITICAL issue. Neither found a defect in the subscription lifetime, the thread-id contract, the locking, or hook order.

Both models agree: HIGH consensus

Issue Opus 5.5 GPT-5.6 Terra Fix confidence
Value line built by ChatUsageFormatter.FormatThroughput hard-codes tps, μ, p95 and formats with InvariantCulture, while the section label and tooltip are translated in all six .resw files. Result: mixed-language popover for every non-English locale. LOW MEDIUM 90%

Only one model flagged: LOW consensus

Issue Opus 5.5 GPT-5.6 Terra Fix confidence
The new divider sits directly under the Latest-run Input/Output grid, which has only Margin(0, 8, 0, 0). The first divider gets 10px from the track's bottom margin; this one gets none, so the line touches the text. not flagged LOW 95%
The indicator re-renders on every ThroughputChanged event, including when the flyout is closed and when the ring is hidden (Render returns Empty()). Thinking and usage streams publish no snapshot, so this is new UI-thread work per streamed chunk; each render rebuilds the Flyout/Popover element tree and calls GetThroughput (copy and sort of up to 50 samples). not flagged LOW 80%
Rate picks the format string from the raw value before rounding, so 99.95 to 99.99 prints 100.0 while 100.0 prints 100. not flagged LOW 99%
Claimed CS0060: public OpenClawChatDataProvider lists internal IChatThroughputSource as a base interface. HIGH not flagged 0% (disputed, no fix)

Disputed finding, rejected with evidence

The CS0060 claim is false. main already ships the same shape:

  • src/OpenClaw.Connection/LocalAi/LlamaServerClient.cs:160 declares internal interface ILlamaServerClient.
  • src/OpenClaw.Connection/LocalAi/LlamaServerClient.cs:170 declares public sealed class LlamaServerClient : ILlamaServerClient.
  • That code merged to main in b1a41be1.

CS0060 covers base classes and CS0061 covers interface-to-interface inheritance. A public class may implement an internal interface, and the explicit implementation keeps the internal ChatThroughputStats return type out of the public surface. Opus 5.5 independently reached the same conclusion.

Coordinator notes (no model flagged, verified by reading the code)

  • Throughput is unreachable when the context window size is unknown: Render returns Empty() unless Props.Usage.ContextTokens > 0, and the design places throughput only in this popover. Worth a product decision rather than a code change.
  • The UI proof publishes PublishThroughput inside RunOnUIAsync, so it proves the open-flyout refresh but not the gateway-thread path that UseState(..., threadSafe: true) exists for. A background-thread publish test would cover the actual claim.
  • Verified sound: Changed is raised outside the tracker's _gate; field-like event add/remove happens only on the UI thread while Invoke runs on the gateway thread; ChatThread.Id is the gateway session key; TurnActive comes from the selected thread's timeline; NaN and Infinity cannot reach Rate because both live and sample values require a window of at least 250 ms; all six .resw files parse and carry both new keys.

Suggested follow-ups

  1. Move the value line to a localized format resource in all six languages (string.Format(CultureInfo.CurrentCulture, ...), numbers can stay invariant like FormatCount).
  2. Give the second divider a top margin.
  3. Round before choosing the format string in Rate.
  4. Skip the render-version bump when the ring is hidden, and consider bumping only when the formatted text changes.

- Move the tokens-per-second sentence into a Chat_Throughput_ValueFormat resource for all six locales; each unit matches that locale's existing section label.
- Keep ChatUsageFormatter pure: the popover passes the localized template and the English fallback lives in DefaultThroughputValueFormat.
- Add a formatter test for a supplied localized template.
@larroy
larroy merged commit 5e4d198 into openclaw:main Nov 30, 2026
53 of 55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant