Skip to content

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

Open
larroy wants to merge 1 commit into
openclaw:mainfrom
larroy:feat/chat-context-popover-throughput
Open

larroy wants to merge 1 commit 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

This branch has not been deployed

No deployments
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