Skip to content

fix(chat): copy confirmation can disappear before it is shown when the app is busy - #2138

Merged
bkudiess merged 1 commit into
openclaw:mainfrom
bkudiess:bkudiess-copy-feedback-flake
Nov 13, 2026
Merged

bkudiess merged 1 commit into
openclaw:mainfrom
bkudiess:bkudiess-copy-feedback-flake

Conversation

@bkudiess

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes: the chat "Copied" / "Copy failed" confirmation is never shown or announced when the app is busy for about 2 seconds right after a copy. The CopyFeedback_MessageAndCodeCapture UI test also fails intermittently in CI.

User Impact

User impact: after copying a message or a code block, users always see the "Copied" or "Copy failed" confirmation for its full duration, and screen readers announce it, even if the app was busy when they clicked.

Why This Change Was Made

ChatCopyButton started its 2-second reset timer at the click. If the UI thread stayed busy past that window, the reset ran before the feedback was ever rendered, so nothing was shown or announced. The window now starts when the feedback reaches the native button, which is where the live-region announcement is already raised. The default window is a named constant.

The CI failure has the same cause on the test side. On #2127, the fixed settle after the click took 2.94 s on a loaded runner, so the test read the label after the 2 s reset. The click block ran at 41.724 s and the assertion at 44.660 s. The tests now record the button's label transitions as they happen, so they no longer depend on when they look.

Evidence

  • Product race reproduced: I blocked the UI thread for 2.5 s right after the click.
    • Before the fix: the label never left "Copy code" and the wait timed out. The copy itself still succeeded.
    • After the fix: "Copied" renders and then resets after its full window.
  • CI failure reproduced: I added a 2.5 s test-side delay after the click.
    • Old test: fails in both variants with exactly CI's signature, Expected: "Copied", Actual: "Copy code".
    • New test: passes.
  • Mutation check: I removed Cancel() from Copy(), so a repeated click cannot restart the window. The rewritten repeated-click test then fails with "Timed out waiting for repeated copy feedback reset ... transitions: Copied@9ms".
  • Stronger assertions:
    • Every original check is kept.
    • New checks: the feedback appears first, the only later change is the reset to the idle label, and the reset comes at least the full window after the feedback appeared.
    • In the sibling test, the content, identity and disposal checks each run under a reset window that only the behavior being tested can satisfy.

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

  • none: native UI tests on the Windows desktop directly exercise the timing change in one chat control (see Validation), and CI's UI job runs the same tests. No capacity-dependent custom pool is required.

Validation

All commands ran in the task worktree on base 6ddc13b8. The tested tree has diff hash fbbbc7ef. The commit adds only one source comment on top of it.

  • ./build.ps1: all builds succeeded.
  • dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore: 5,849 passed, 29 skipped, 0 failed.
  • dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore: 6,359 passed, 0 failed.
  • dotnet test tests/OpenClaw.Tray.UITests --no-build --filter "FullyQualifiedName~ReactorChatLayoutProofTests.CopyFeedback|FullyQualifiedName~ReactorChatLayoutProofTests.CodeCopyAutomationIds": 5 consecutive rounds of 4 tests passed, 0 failed.
  • dotnet test tests/OpenClaw.Tray.UITests --no-build --filter "FullyQualifiedName~ReactorChatLayoutProofTests" with OPENCLAW_UI_TEST_RESOURCE_PROFILE=Standard: 177 passed, 3 skipped, 0 failed.
  • Isolation: native runs used isolated OPENCLAW_TRAY_DATA_DIR, OPENCLAW_TRAY_APPDATA_DIR and OPENCLAW_TRAY_LOCALAPPDATA_DIR. The real OpenClawTray profile manifests were unchanged.
  • Review: Hanselman dual-model review (Claude Opus 5.5 and GPT-6 Astra, high reasoning), four rounds.
    • Fixed and confirmed by both reviewers:
      • a race between ending the observation and reading the label;
      • an early reset passing the check;
      • the product reset racing the first render;
      • sibling-test checks that a normal timer reset could satisfy;
      • the dispatch gap between click and wait.
    • Final round: no blocking findings.

Real Behavior Proof

  • Environment tested: Windows 11 dev box, in-process native WinUI UI tests, Debug win-x64, run under the shared native-desktop lock.
  • PR head or commit tested: tree fbbbc7ef on 6ddc13b8. The commit 1617d37c adds one comment.
  • Exact steps or command run: the Validation commands, plus temporary demonstrations not in the commit: a 2.5 s UI-thread block, a 2.5 s test-thread delay, and the Cancel() mutation.
  • Evidence after fix:
    • With the UI thread blocked, feedback still renders: before the fix the wait timed out, after it the test passes.
    • Old test with a 2.5 s delay: Expected "Copied", Actual "Copy code". New test with the same delay: passes.
    • The mutation is caught.
  • Observed result: every changed test passes repeatedly, and the whole class passes.
  • Screenshot or artifact links verified? (Yes/No/N/A) N/A
  • Not verified or blocked:
    • The CI first-attempt result is pending.
    • New behavior: if the first render is deferred for a long time (for example, the view is hidden right after the click), the confirmation appears when it finally renders.

Security Impact

  • New permissions or capabilities? (Yes/No) No
  • Secrets or tokens handling changed? (Yes/No) No
  • New or changed network calls? (Yes/No) No
  • Command or tool execution surface changed? (Yes/No) No
  • Data access scope changed? (Yes/No) No
  • If any answer is Yes, explain the risk and mitigation:

Compatibility and Migration

  • Backward compatible? (Yes/No) Yes
  • Config or environment changes? (Yes/No) No
  • Migration needed? (Yes/No) No
  • If yes, list the exact upgrade steps:

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.

@clawsweeper

clawsweeper Bot commented Nov 13, 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-environment Preliminary submission classification; full source review pending. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 13, 2026
@clawsweeper

clawsweeper Bot commented Nov 13, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge.

What this changes

This PR starts chat copy-feedback expiry when feedback reaches the native button and makes its UI tests observe label transitions.

Example: Copy a code block while the UI thread is busy for 2.5 seconds.

  • Before: The two-second timer can expire before Copied appears.
  • After: The feedback window starts when Copied reaches the native button.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused patch has no identified correctness defect, but test-only evidence does not satisfy the shipped-behavior proof requirement.
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: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Copy feedback can disappear before users see or hear it when the UI thread is busy.
Reason: The maintainer-authored repair restores documented feedback behavior without changing the default duration or adding configuration.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR addresses a source-supported timing bug still present on main, and review found no concrete introduced defect.

Priority: P2
Reviewed head: 1617d37cc02d99e11f9f35735366f9f018fd387e

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Provide current-head recording or timestamped UI diagnostics from the shipped chat UI showing feedback surviving the busy-thread scenario and resetting after its full window; redact private content and identifiers.
Agent review details

How this fits together

Message and code renderers pass text and identity to ChatCopyButton, which invokes clipboard copying and owns temporary visual feedback, accessibility announcements, and reset cancellation.

flowchart LR
  A[Message or code renderer] --> B[ChatCopyButton]
  B --> C[Clipboard helper]
  C --> D[Copy result state]
  D --> E[Native button and announcement]
  E --> F[Reset timer]
  F --> B
Loading

Technical review

Best possible solution:

Keep reset timing in ChatCopyButton at native feedback application while preserving its existing cancellation and identity fences.

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

Main starts the reset before Reactor applies feedback, allowing delayed rendering to lose the intermediate state; the PR also describes a 2.5-second before/after demonstration, but this review ran no reproduction.

Is this the best way to solve the issue?

Moving the existing timer to the native application callback is a focused repair using the established owner; the transition recorder and held-window tests protect distinct timing and lifetime failures without adding production machinery.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Copy-feedback timing and cancellation keeps the original intent (5164faa: Native-chat modernization introduced confirmed, content-fenced copy feedback with temporary announcements and cancellation of stale resets.)
  • Native copy-feedback tests keeps the original intent (5164faa: Mounted native-control tests protected feedback, repeated clicks, content replacement, identity changes, and disposal; transition observation preserves these contracts while avoiding delayed sampling.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Pinned change and current-main behavior: The introduced diff moves timer creation out of Copy and into the existing native-button application callback; main still starts expiry immediately after setting feedback. (src/OpenClaw.Tray.WinUI/Chat/ChatCopyButton.cs:141, 1617d37cc02d)
  • Existing product contract: The documented contract requires confirmed clipboard feedback, a two-second reset, repeated-click restart, and cancellation on content changes or unmount; the patch preserves that owner and intent. (docs/CHAT_VISUAL_DESIGN.md:854, 1617d37cc02d)
  • Distinct native-control coverage: The rewritten tests observe success/failure transitions and retain repeated-click, content, identity, and disposal checks using reset windows that distinguish those behaviors. (tests/OpenClaw.Tray.UITests/ReactorChatLayoutProofTests.cs:1874, 1617d37cc02d)
  • Feature provenance and ownership: The original implementation and feedback tests were added by the merged native-chat modernization, improve(chat): modernize the native chat experience #1459 (improve(chat): modernize the native chat experience); subsequent history shows continued chat work by bkudiess. (src/OpenClaw.Tray.WinUI/Chat/ChatCopyButton.cs:69, 5164faab1df6)
  • Supplied validation and media: The PR reports successful build, Shared and Tray tests, repeated focused native UI runs, and temporary busy-thread demonstrations. The four prepared images were inspected directly and show the linked setup redesign, not chat copy feedback. (1617d37cc02d)
  • Repository policy and review limits: Read the complete root and scoped WinUI instructions and applied the relevant test, proof, and simplification guidance. No maintainer-notes directory exists. No helper, second reviewer, build, or test ran; WinApp is unavailable on this host, and the checkout remains clean. (AGENTS.md:1, 1617d37cc02d)

Likely related people:

  • Barbara Kudiess: Raw commit 5164faa adds src/OpenClaw.Tray.WinUI/Chat/ChatCopyButton.cs:66 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5164faab1df6; files: src/OpenClaw.Tray.WinUI/Chat/ChatCopyButton.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 P2: Busy UI scheduling can suppress copy confirmation, while the clipboard operation itself still succeeds.
  • 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:

  • P2: Busy UI scheduling can suppress copy confirmation, while the clipboard operation itself still succeeds.
  • 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.

Rank-up moves

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

  • Supply direct runtime evidence of the changed chat feedback timing.

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 12, 2026, 9:25 PM ET / November 13, 2026, 02:25 UTC.

…e app is busy

ChatCopyButton started its 2 s reset timer at the click. When the UI thread stayed
busy past that window, the reset ran before the "Copied" or "Copy failed" feedback
was ever rendered or announced. Start the window when the feedback reaches the
native button, and name the default window.

The proof tests now record the button's label transitions instead of sampling the
label after a fixed settle that a loaded CI runner stretched past the 2 s timer
(the CopyFeedback_MessageAndCodeCapture failure on openclaw#2127). The repeated-click,
content, identity and disposal checks use held or short reset windows so each
phase can only pass for the behavior it names.

Co-authored-by: Copilot App <[email protected]>
@bkudiess
bkudiess force-pushed the bkudiess-copy-feedback-flake branch from 1617d37 to 9aba7ea Compare November 13, 2026 07:11
@bkudiess
bkudiess merged commit 18ebdb0 into openclaw:main Nov 13, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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