Skip to content

fix: reduce typing lag in long chats - #2343

Open
bkudiess wants to merge 2 commits into
openclaw:mainfrom
bkudiess:bkudiess-openclaw-typing-latency
Open

bkudiess wants to merge 2 commits into
openclaw:mainfrom
bkudiess:bkudiess-openclaw-typing-latency

Conversation

@bkudiess

Copy link
Copy Markdown
Collaborator

Related: microsoft/microsoft-ui-reactor#1617 (Avoid idle Markdown selection layout work).

What Problem This Solves

Typing in a long conversation can stall while a reply streams. Even when nothing is selected, old messages repeatedly measure where their text could be selected.

User Impact

Text can still be selected within a Markdown block and copied with the existing copy controls. Selecting across multiple blocks is temporarily unavailable, including the message-wide accessibility text range.

Why This Change Was Made

Use native per-block selection until a released Reactor package can keep idle messages out of layout. Keep unchanged replies behind their existing content comparison, reuse localized strings and animation resources, and avoid recalculating chat navigation and window geometry on unrelated updates.

Evidence

Before the fix, cross-block Markdown selection accounted for 43.8% of sampled UI-thread stacks during typing and streaming. The post-change native tests cover code selection, stable syntax colors, list layout, table framing and language changes. No matched before/after latency trace has been collected; the baseline percentage is not a measured speedup.

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

Required proof pools

  • windows-winui-interactive: compare typing with chat idle and streaming; check history ticks, title-bar tab input during pane moves, and setup connector alignment.

Validation

Windows x64, final pre-commit tree:

  • .\build.ps1: all five Debug projects and documentation checks passed.
  • dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore: 5,961 passed, 29 skipped, 0 failed.
  • dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore: 6,842 passed, 0 failed.
  • dotnet test .\tests\OpenClaw.Tray.UITests\OpenClaw.Tray.UITests.csproj -r win-x64 --filter 'FullyQualifiedName~ReactorMarkdown|FullyQualifiedName~ChatLayout|FullyQualifiedName~LocalizationHelperTests': 241 passed, 3 skipped, 0 failed in the isolated native host.
  • .\build.ps1 -Project WinUI -Configuration Release -DevBuild: passed. A non-Dev Release build stopped at the signed cleanup-host prerequisite; this is not signed-package proof.
  • Independent Opus and GPT rubber-duck reviews found no medium or higher issues. Low-severity follow-ups include test language-override cleanup, tab-list discovery after unload, history tick refresh coverage, and selection test coverage.

Real Behavior Proof

  • Environment tested: Windows x64, real WinUI controls with pinned Reactor preview.18; optimized Dev Companion also launched locally.
  • PR head or commit tested: tests ran on the uncommitted source based on 8ffe470e; the reviewed diff was fingerprint-verified immediately before committing it as 91f7e26b.
  • Exact steps or command run: mounted Markdown, layout and localization tests above; the web-parity case selects a fenced code block and reconciles the unchanged message.
  • Evidence after fix: the mounted code block retained its selected text and syntax colors; the mounted table had two columns, six rows, twelve cells and the rounded frame.
  • Observed result: focused native tests passed for these cases. The running Dev build opened Workspace; that alone does not measure typing.
  • Screenshot or artifact links verified? N/A. No private chat or trace artifacts attached.
  • Not verified or blocked: interactive proof pool, comparable post-change typing/streaming latency and GC timings, and packaged acceptance.

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
  • If any answer is Yes, explain the risk and mitigation: N/A. Secret redaction was not cached.

Compatibility and Migration

  • Backward compatible? No for cross-block selection; yes for settings, chat data and Gateway protocol.
  • Config or environment changes? No
  • Migration needed? No
  • If yes, list the exact upgrade steps: N/A. Re-enable cross-block selection in a follow-up after the fixed Reactor version is released and tested.

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.

Skip cross-block Markdown selection geometry until Reactor can keep idle messages off the layout path. Reuse unchanged message content, localized strings, and animation resources, and avoid unrelated rail and title-row refreshes.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@clawsweeper

clawsweeper Bot commented Nov 19, 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 clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. 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:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 19, 2026
@clawsweeper

clawsweeper Bot commented Nov 19, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge.

What this changes

This PR disables cross-block Markdown selection and reduces repeated rendering, allocation, and layout work while chatting.

Example: An assistant reply contains two paragraphs separated by a fenced code block containing Console.WriteLine(1);.

  • Before: Readers can select across all three blocks, while idle selection hosts inspect text geometry on layout updates.
  • After: Selection stays within individual blocks and the cross-block selection hosts are absent; the latency improvement remains unmeasured.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The implementation has a supported mechanism and one non-blocking visual defect, but the changed performance behavior has only test-level evidence.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Typing can stall in long conversations while an assistant reply streams.
Reason: The dependency source supports the mechanism, and the maintainer-authored PR explicitly chooses the temporary selection and accessibility tradeoff.

Merge readiness

✅ Ready for maintainer review

Keep this maintainer-authored PR open because it provides a distinct performance mitigation that current main does not contain.

Priority: P2
Reviewed head: 91f7e26bdb864cce17877429b174e8473d75fffd

Before merge

None.

Findings

  • [P3] Preserve table styling inside lists and block quotes — src/OpenClaw.Tray.WinUI/Chat/ChatMarkdownPresentation.cs:263-265

Tests

  • Missing end-to-end proof: Provide current-head Debug and production-shaped Release evidence of typing during a long streaming chat, with comparable latency measurements and focused checks of retained selection, history ticks, moving panel tabs, and setup connectors; redact private content and endpoints.
Agent review details

How this fits together

Gateway chat content enters the native Reactor timeline, which sanitizes Markdown and renders WinUI text, code, disclosures, navigation, and progress controls.

flowchart LR
Gateway[Gateway chat content] --> Timeline[Reactor chat timeline]
Timeline --> Sanitizer[Markdown sanitization]
Sanitizer --> Presentation[Markdown presentation]
Presentation --> Controls[Native WinUI controls]
Timeline --> Navigation[History and progress controls]
Loading

Technical review

Best possible solution:

Retain the focused temporary selection rollback, preserve existing nested-table presentation, and restore cross-block selection after adopting a proven released Reactor fix.

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

Current main mounts the pinned Reactor selection host whose layout handler scans idle message content, supporting the reported mechanism; the reported typing stalls and baseline percentage were not independently reproduced.

Is this the best way to solve the issue?

The temporary rollback removes the identified dependency work without adding a parallel renderer, and the record-props component preserves unchanged-message reuse; the surrounding optimizations retain existing owners.

Full review comments:

  • [P3] Preserve table styling inside lists and block quotes — src/OpenClaw.Tray.WinUI/Chat/ChatMarkdownPresentation.cs:263-265
    The replacement framing pass visits only direct document children. For a quoted table such as > | Name | State |\n> | --- | --- |\n> | Alice | Ready |, the direct child is the quote container, so its nested table never reaches Table(). The previous MarkdownOptions.Table callback handled tables at every nesting level. Because TableHeaderBackground is also null, these tables now lose their header tint, cell rules, and rounded frame. Apply the existing table presentation within nested containers while keeping their spacing unchanged.
    Confidence: 0.98

Overall correctness: patch is correct
Overall confidence: 0.88

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Cross-block selection integration, resources, documentation, and acceptance fixture changes intended behavior with a stated reason (1af3ced: Enable readable selection and copying across entire assistant messages, including lists, code, tables, and expanded disclosures.)
  • Markdown list, heading, and table presentation changes intended behavior with a stated reason (26a82c9: Match native Markdown typography, quotes, table framing, and aligned columns to web chat.)
  • Window title-row geometry and panel placement keeps the original intent (0467121: Join side-panel tabs to the caption row while keeping their pointer region clickable during layout changes.)
  • Setup timeline connector positioning keeps the original intent (d8e458d: Connect the four setup steps while their hover details and progress states change size.)
  • Runtime localization lookup keeps the original intent (74fd2c1: Resolve dotted XAML property resource keys through their MRT path equivalent instead of displaying raw keys.)
  • History rail sampling and visible-row presentation keeps the original intent (5b99d9f: Provide persistent ordinal navigation through long conversations without rebuilding ticks on unrelated extent changes.)
  • Chat progress animation and resource reuse keeps the original intent (8ffe470: Scope motion to changing controls, retain reduced-motion behavior, and reset animation state when controls are reused.)
  • Tool activity classification keeps the original intent (aac07ab: Present compact, inspectable tool activity using normalized tool aliases.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • The mitigation is absent from main: Current main still constructs ChatMarkdownMessageView and supplies MarkdownOptions.TextSelection; the introduced diff removes that integration. (src/OpenClaw.Tray.WinUI/Chat/ReactorChatTimeline.cs:984, e9423aed4ba9)
  • Direction and compatibility tradeoff are explicit: The collaborator-authored body explicitly accepts temporarily losing cross-block selection and the message-wide accessibility text range, retaining per-block selection and existing Copy controls. (91f7e26bdb86)
  • Pinned dependency confirms idle layout work: The target imports Reactor preview.18, establishing the dependency contract: its MarkdownSelectionHost.OnLayout checks membership, native segments, and layout signatures before its early return, including without an active selection. (src/Reactor.Advanced/Markdown/MarkdownSelectionHost.cs:97, 4cd639795f79)
  • Upstream alternative remains proposed: The linked upstream PR proposes demand-driven idle selection geometry and remains open; it does not establish an available released replacement.
  • Nested table presentation is bypassed: Table framing now runs only over direct document children, while TableHeaderBackground remains null; tables inside list or quote containers consequently lose their former framing and header tint. (src/OpenClaw.Tray.WinUI/Chat/ChatMarkdownPresentation.cs:264, 91f7e26bdb86)
  • Supplied validation has a clear boundary: The body reports passing build, Shared, Tray, and mounted native tests, but explicitly states that comparable post-change typing measurements and interactive acceptance were not collected; both discussion comments contain review-status updates only. (91f7e26bdb86)

Likely related people:

  • Barbara Kudiess: Raw commit 1af3ced adds src/OpenClaw.Tray.WinUI/Chat/ChatMarkdownPresentation.cs:46 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 1af3ced2d0fe; files: src/OpenClaw.Tray.WinUI/Chat/ChatMarkdownPresentation.cs)
  • Karen: Raw commit 5b99d9f adds src/OpenClaw.Tray.WinUI/Chat/ChatHistoryNavigation.cs:16 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5b99d9f1d84b; files: src/OpenClaw.Tray.WinUI/Chat/ChatHistoryNavigation.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.

Review metrics

Metric Value Why it matters
Introduced source delta Production +189/-355; tests +120/-1178; docs +8/-42 The change removes the obsolete cross-block selection integration and its large acceptance fixture while retaining existing rendering owners.

Labels

Label changes:

  • add P2: Typing stalls during long streaming conversations affect normal chat use, with evidence supporting a focused performance mitigation.
  • add merge-risk: 🚨 compatibility: The explicitly accepted rollback removes cross-block selection and its message-wide accessibility text range.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Typing stalls during long streaming conversations affect normal chat use, with evidence supporting a focused performance mitigation.
  • merge-risk: 🚨 compatibility: The explicitly accepted rollback removes cross-block selection and its message-wide accessibility text range.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Attach redacted current-head interactive evidence demonstrating improved typing during streaming.

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 19, 2026, 6:19 PM ET / 23:19 UTC.

Retain list-column placement, add nested table proof, and stabilize the elapsed-clock UI test.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@bkudiess

Copy link
Copy Markdown
Collaborator Author

Update on the ClawSweeper review for head 956755612f7e2f050a0ac1289c15516bec713d91:

  • The nested list and quote table-framing finding is addressed. The table pass now reaches nested containers, and mounted UI coverage checks nested tables, list-column placement, and that fenced code is not table-framed.
  • The focused ProductionRoot_AlignsColumnAndKeepsEveryComposerActionReachable run passed locally for all six widths. Current CI still has an unresolved failure in New and changed test soak: the width-320 composer lookup failed once under CPU contention. I am not treating that as unrelated or waiving the gate.
  • Matched long-chat typing/input-latency and frame-time evidence is still missing. I cannot substantiate the requested 95% confidence or recommend merging before that proof and required maintainer review are complete.

🤖 AI-authored reply via Agency Finish PR.

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

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. 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