Skip to content

fix: clear the chat box after sending and keep drafts per conversation - #2430

Merged
bkudiess merged 4 commits into
openclaw:mainfrom
bkudiess:bkudiess-chat-composer-state
Dec 1, 2026
Merged

bkudiess merged 4 commits into
openclaw:mainfrom
bkudiess:bkudiess-chat-composer-state

Conversation

@bkudiess

@bkudiess bkudiess commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: c3d9a4c34620f7437c082357978ffa683a48804b

Dimension Assessment Rationale
Change confidence 9/10 ↑ The textbox cleared before acknowledgement, drafts stayed with their conversations, and accepted and rejected removals behaved correctly in Debug and Release.
↑ CI Gate passed, including the previously failing sidebar checks.
↓ Physical Enter, repeated Enter, Shift+Enter and caret handling remain unverified: the local test could not obtain focus and the hosted shard skipped it.
Diagnosis confidence 9.5/10 ↑ On unmodified main, holding the send acknowledgement kept the submitted text in the editor; switching to Home exposed the other conversation's draft in Light and Dark.
↑ The old code waited for acknowledgement to clear a shared editor. The same three assertions passed on the fix.
Evidence fit 9.5/10 ↑ The before/after comparison reproduced both reported symptoms in the real Companion app against a fixture Gateway, then showed the textbox clearing and the original draft returning only in its own conversation.
↓ This was not a replay of the reporter's live Gateway session.

What Problem This Solves

When you send a chat message in Companion, the text stays in the chat box, so it appears both in the conversation and in the box. If you then switch to another conversation, the old text follows you there, and the chat box can stay locked to the previous conversation while a send is still pending.

User Impact

User impact: the chat box clears when your message is sent, so the text no longer shows in both places. Each conversation keeps its own unsent draft. Switching conversations shows that conversation's draft (empty for a new chat) and brings yours back when you return. A pending send in one conversation no longer locks the box in another. If a send fails, your text comes back in that conversation's box, ahead of anything you typed while it was sending. Archiving or deleting a conversation clears its draft only after the Gateway confirms the removal; if the Gateway rejects it, your conversation and draft stay as they were.

Why This Change Was Made

The composer kept a single draft and a single "sending" flag for every conversation, and cleared the text only after the Gateway accepted the message. This change stores drafts and the sending state per conversation. It clears the box as soon as the send is admitted locally, before any new-chat setup and without waiting for the Gateway to accept it, and restores the text if the send fails. It also fences session switches and removals so a late result for a conversation you have left cannot overwrite the one you are viewing. A new local chat's draft moves to the real Gateway session once the Gateway creates it.

Implementation notes
  • ChatComposerViewModel owns a per-conversation draft map, binds and promotes a local draft to its materialized session, and tracks sending state per thread.
  • ChatComposerController and ChatComposerSession take the draft once the send passes local admission (before new-chat setup) and restore it on failure or rejection. They also admit a materialized session.
  • ChatPage, SessionsPage, SessionsHubController, App, WorkspaceWindow and DesktopCompanionChatHost clear the removed conversation's pending state only after the Gateway confirms removal.
  • ChatComposerSubmissionPolicy.ShouldClearInput is removed because clearing no longer waits for acceptance.
  • docs/ARCHITECTURE.md and docs/CHAT_VISUAL_DESIGN.md describe the new draft ownership and composer states.

Evidence

Real behavior proof

On the same disposable Windows desktop, the unmodified main build (02c1b86d) failed three checks at the reported behavior: the message stayed in the textbox while the fixture Gateway held the acknowledgement, and the fork's draft appeared in Home in both Light and Dark. On c3d9a4c, all three passed in both Debug and unsigned non-Dev Release. Returning to the fork restored its exact draft. Native captures also showed the sent message in the transcript with an empty textbox.

The other four passing scenarios in each configuration covered switching the mounted editor during a pending send, confirmed removal, rejected removal, and prefilling the active editor while another conversation retained a draft.

Validation

Check Result
.\build.ps1 All five projects built.
dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore 6,272 passed, 29 skipped, 0 failed.
Full Tray suite: dotnet vstest C:\repo\tests\OpenClaw.Tray.Tests\bin\Debug\net10.0\OpenClaw.Tray.Tests.dll in the guest 7,341 passed, 0 skipped or failed.
Targeted native UI, Debug and non-Dev Release In each configuration: 7 passed, 5 failed before keyboard input, 0 skipped. The guest used Windows App Runtime 2.6.5.
Build and Test, attempt 1 CI Gate passed. The layout shard passed the previously failing sidebar test in Light and Dark. Both fixture shards and the changed-test soak passed.
CodeQL, attempt 1 Passed.

Not verified / blocked

  • Five keyboard cases in each local configuration stopped before sending a key because Explorer retained foreground. The hosted layout shard explicitly skipped ComposerInput_NativeKeyboardPreservesCaretAndEnterSends; green CI does not close this gap.
  • The fixture uses a real Companion process with a synthetic Gateway. The Ask OpenClaw refusal during a Gateway switch was source-reviewed, not exercised end to end. No signed-package or RTX proof is claimed.

Review: A bounded independent review of the Ask OpenClaw integration on c3d9a4c found no reproducible defect. The three earlier Hanselman dual-model rounds (claude-opus-5.5 high, gpt-6-astra long context high) covered the pre-integration change, not the entire final head:

  1. Full review of the change. Its findings were fixed, including legacy web-chat disposal dropping drafts, draft aliasing overwrites, late attachment or voice appends after promotion, failed first-send text loss, and tray delete clearing drafts before Gateway confirmation. The follow-up review was clean apart from two LOW notes: tray delete feedback (not reachable today) and a coverage suggestion.
  2. Delta review: both models found that a new chat's first send cleared the box only after new-chat setup. The fix moved clearing to local admission.
  3. Delta review of that fix: both models found no CRITICAL, HIGH or MEDIUM issues. They confirmed that every failure path restores the text to the originating conversation and that newer edits are kept. Opus noted one LOW test gap: the navigation case in MaterializationHistoryWait_CanStillBeCancelled does not switch the visible conversation; the transport-phase test covers the same lookup.

The subsequent UI assertion updates cover clearing while new-chat setup is pending and switching from a fork to Home and back. They do not change product behavior.

Known limitations (LOW, not changed here)
  • After a failed send, the text shows both in the failed queue card and in the box.
  • If you type while a send is in flight and it fails, the box shows the submitted text, a new line, then your newer text.
  • Legacy WebChat keeps the native composer while any conversation has an unsent draft, so the draft is not lost.
  • A confirmed delete can skip draft cleanup if the connection changes after the confirmation check (pre-existing path).
  • ChatPage.CurrentApp still uses a hard cast (unchanged from base).

Required proof pools

  • windows-winui-interactive: the chat composer's clearing, per-conversation drafts and session-switch behavior changed. Only partly covered locally (see Not verified / blocked).

The composer kept one draft and one sending flag for every conversation
and cleared the text only after the Gateway accepted the message. Text
stayed in the box after Send, followed you to other conversations, and a
pending send could lock the box in another conversation.

Drafts and sending state are now per conversation. The box clears as
soon as a send is admitted locally and the text is restored if the send
fails. Session switches and removals are fenced, and a removed
conversation's draft is cleared only after the Gateway confirms removal.

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

clawsweeper Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

🦞👀
Pull request received.

ClawSweeper review complete

ClawSweeper finished reviewing this revision.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. impact:ux-friction User-facing flow adds avoidable confusion or support burden without fully blocking progress. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Dec 1, 2026
@clawsweeper

clawsweeper Bot commented Dec 1, 2026

Copy link
Copy Markdown

Codex review: passed.

What this changes

The PR clears admitted submissions immediately and keeps drafts, attachments, and sending state separate for each conversation.

Example: Send “Summarize notes” in conversation A while acceptance is delayed, then select conversation B.

  • Before: The submitted text remains in the shared composer, follows the selection, and the pending send can block B.
  • After: A clears immediately, B shows its own draft and accepts input independently, and a failed send restores the submission to A.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A worthwhile, coherent repair with meaningful regression coverage and no definite introduced bug, supported by incomplete runtime evidence.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is exempt from contributor proof gating; supplied evidence covers isolated fixture and mounted-composer tests, while the locked desktop prevented current-head screenshots, keyboard proof, and complete removal scenarios.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Submitted text remains in the editor, follows users into another conversation, and a pending send can block that conversation's composer.
Reason: Conversation-specific draft ownership has clear user value, and the maintainer-authored PR explicitly chooses immediate clearing with failure restoration.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR addresses composer behavior still present on main, and the pinned diff contains no definite introduced defect.

Reviewed head: cca98bb8714284954b52daf05cf46fc07ad753bd

Before merge

None.

Findings

None.

Agent review details

How this fits together

The mounted native chat composer receives conversation projections and user input, delegates sends through the existing runtime adapter, and projects conversation-specific drafts and operation results back into WinUI.

flowchart LR
  User[User input] --> Composer[Reactor composer]
  Composer --> Controller[Composer controller]
  Controller --> Drafts[Conversation draft state]
  Drafts --> Composer
  Controller --> Runtime[Existing runtime adapter]
  Runtime --> Gateway[Gateway and send queue]
  Gateway --> Controller
Loading

Technical review

Best possible solution:

Land the conversation-scoped repair within the existing composer and Workspace owners after the existing validation gates settle.

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

Main's shared draft and send gate establish the reported cross-conversation path directly; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch addresses the state ownership cause using existing owners, preserves newer edits and delayed ingress, and adds only a test hang-guard environment option rather than a user setting.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Composer state ownership keeps the original intent (686afdc: The composer extraction established host-local state and separated presentation from provider queue ownership.)
  • Acceptance-time conditional clearing changes intended behavior with a stated reason (381cd50: Conditional clearing prevented an accepted send from erasing text entered while the send was pending; the follow-up in 8e8888f avoided redundant rendering.)
  • Native edit synchronization keeps the original intent (49813a6: Synchronous native edit reporting prevents Reactor renders from overwriting an edit before its delayed event arrives.)
  • Local first-send identity keeps the original intent (e9423ae: New chats remain local until first send, with confirmed materialization and retained placement intent.)
  • Removed-session host disposal changes intended behavior with a stated reason (791574d: Workspace session removal disposed the mounted conversation and pruned navigation; this PR explains retaining the host to preserve unrelated drafts while invalidating removed-session work.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Main still has shared composer state: Current main has one draft, attachment collection, sending flag, and controller send gate; accepted submissions clear only after SendCoreAsync completes. (src/OpenClaw.Tray.WinUI/Chat/ChatComposerViewModel.cs:82, 6c14fe598718)
  • Pinned implementation: The introduced change captures each submission, clears it at local admission before preparation, restores rejected submissions to their originating draft, and scopes send admission by conversation. (src/OpenClaw.Tray.WinUI/Chat/ChatComposerController.cs:277, cca98bb87142)
  • Removal preserves unrelated drafts: Confirmed removal retires the affected draft and hides the retained host instead of disposing all conversation drafts; Settings deletion and tray deletion forward confirmed results through existing Workspace owners. (src/OpenClaw.Tray.WinUI/Pages/ChatPage.xaml.cs:391, cca98bb87142)
  • Supplied validation and accepted presentation tradeoffs: The complete PR body reports a passing build, 6,179 Shared tests, 7,119 Tray tests, and seven fixture cases; its broader UI selection reports 319 passed, 16 failed, and seven skipped, with matching failure types reported on base. It explicitly accepts failed submissions remaining in both the queue row and restored editor, with newer text separated by a newline. Source body SHA-256: 4d49473172008ef13b7ea81584423256e0a3841a1ce3b17d388922af7c755b95. (cca98bb87142)
  • Current validation state: The reviewed head is mergeable, with relevant UI, fixture, integration, soak, and C# security checks still running; the check response contains no failed check. (cca98bb87142)
  • Ownership history and policy: Feature history identifies the composer extraction, draft-edit repairs, and first-send placement work across existing owners; all three applicable AGENTS.md files were read, and the checkout remained clean. (src/OpenClaw.Tray.WinUI/Chat/ChatComposerController.cs:111, 6c14fe598718)

Likely related people:

  • Barbara Kudiess: Raw commit 686afdc adds src/OpenClaw.Tray.WinUI/Chat/ChatComposerController.cs:105 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 686afdc8d4a2; files: src/OpenClaw.Tray.WinUI/Chat/ChatComposerController.cs)
  • Scott Hanselman: Raw commit 3dcf7ca adds src/OpenClaw.Tray.WinUI/Chat/ChatComposerViewModel.cs:338 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 3dcf7cab220f; files: src/OpenClaw.Tray.WinUI/Chat/ChatComposerViewModel.cs)
  • Karen: Raw commit 61979d6 adds src/OpenClaw.Tray.WinUI/Chat/ChatComposerController.cs:111 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 61979d6170a0; files: src/OpenClaw.Tray.WinUI/Chat/ChatComposerController.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 change size Production +709/-161 lines; tests +1,185/-120; docs +38/-5 The growth stays within existing owners and covers distinct conversation switching, submission rollback, promotion, removal, attachment, voice, and mounted-control boundaries.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp 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: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating guidance

  • Optionally capture the changed composer and confirmed-removal behavior on an unlocked isolated desktop to strengthen confidence.

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 readiness starts with the lower of the proof and patch scores. It is capped at 3/6 if the fix is partial, the change offers little benefit, a product decision is still open, or the PR reverses an earlier decision without saying why. ✨ 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 December 1, 2026, 11:51 AM ET / 16:51 UTC.

bkudiess and others added 3 commits December 1, 2026 10:52
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep shared message normalization for Ask OpenClaw and chat, while retaining per-conversation clearing at send admission.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep drafts in other conversations from blocking Ask OpenClaw prefills, and clear the active text through the per-conversation view model.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

impact:ux-friction User-facing flow adds avoidable confusion or support burden without fully blocking progress. P2 Normal priority bug or improvement with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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