Skip to content

[Bug]: Shift+Enter in chat composer moves caret to start of text instead of inserting newline #1492

Closed

Description

@SamuelThornburg

Version: OpenClaw Companion 2026.9.4 (3c43751), Windows x64. Code path unchanged on main @ a2c4647. Gateway 2026.9.5.

Steps

  1. Open chat in the companion app.
  2. Type hello world, leave the caret at the end.
  3. Press Shift+Enter.

Expected

A newline is inserted at the caret and the caret moves to the new line (as in the web Control UI).

Actual

The caret jumps to position 0, above/before the existing text.

Analysis (from reading the source; not debugged live)

src/OpenClaw.Tray.WinUI/Chat/ReactorChatComposer.cs (~L480–566) uses AcceptsReturn(false) and handles Shift+Enter manually in OnKeyDown: it sets args.Handled = true, calls vm.SetDraft(current[..start] + "\n" + current[end..]), then sets textBox.SelectionStart = start + 1.

ChatComposerViewModel.SetDraft is enqueued via Mutate/EnqueueMutation, so the selection is set against the stale text. When the queued draft re-renders, TextBox.Text is replaced wholesale and WinUI resets the selection to 0. WinUI's \n → \r normalization may also make the read-back text never equal the draft, causing an extra re-sync.

Introduced with the chat composer rewrite (#1055 / #1098).

Suggested fix

Use AcceptsReturn(true) and only intercept unmodified Enter (set Handled, call Send()), letting the TextBox insert newlines natively. Alternatively, defer caret placement until after the draft commits and compare drafts with normalized line endings.

Activity

  1. added
    P2
    clawsweeper:fix-shape-clear
    clawsweeper:queueable-fix
    clawsweeper:source-repro
    impact:ux-friction
    issue-rating: 🦞 diamond lobster
    no-stale
    on Sep 23, 2026
  2. clawsweeper commented on Sep 23, 2026

    @clawsweeper

    Codex review: this still needs some work. Reviewed September 28, 2026, 3:19 PM ET / 19:19 UTC.

    Summary
    Keep this issue open for a focused native chat repair. Current main and the latest release still place the caret immediately after requesting a draft change, before the rendered TextBox receives that change. The prior Codex review identified the same ordering problem, and no open PR was found that owns this fix.

    Reproducibility: yes. the current source gives a high-confidence path: type text in the native composer, place the caret at the end, and press Shift+Enter. This read-only review did not execute WinUI or independently observe the exact reported jump to position zero.

    Next step
    The defect has a narrow source-established boundary and native UI test seam. Automatic implementation is already reported as queued, and no open PR was found; avoid dispatching a duplicate worker.

    Review details

    Best possible solution:

    Let the native TextBox insert the newline and move its caret, while preserving Enter-to-send and slash-menu keyboard behavior; verify the result after rendering in a native UI regression.

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

    Yes, the current source gives a high-confidence path: type text in the native composer, place the caret at the end, and press Shift+Enter. This read-only review did not execute WinUI or independently observe the exact reported jump to position zero.

    Is this the best way to solve the issue?

    Yes, native newline insertion is the narrowest promising fix for caret ownership. A failing native regression should first establish the observed behavior, then verify the caret and draft after rendering.

    AGENTS.md: found and applied where relevant.

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

    Label changes

    Label changes:

    No label changes.

    Label justifications:

    • P2: Multiline composition is disrupted, while ordinary message sending is not shown to be blocked.
    • impact:ux-friction: Shift+Enter makes caret placement confusing during a user-facing chat workflow.
    Evidence reviewed

    Acceptance criteria:

    • ./build.ps1
    • dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore
    • dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore
    • .\scripts\run-proof-tests.ps1 -Project 'tests\OpenClaw.Tray.UITests\OpenClaw.Tray.UITests.csproj' -Filter 'FullyQualifiedName~ReactorChatLayoutProofTests' -ResultName 'composer-keyboard' -RuntimeIdentifier win-x64
    • .\scripts\run-proof-tests.ps1 -Project 'tests\OpenClaw.Tray.UITests\OpenClaw.Tray.UITests.csproj' -Filter 'Category=Accessibility' -ResultName 'winui-accessibility' -RuntimeIdentifier win-x64

    What I checked:

    Likely related people:

    • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
    • Scott Hanselman: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  3. clawsweeper commented on Sep 28, 2026

    @clawsweeper

    🦞🔧
    ClawSweeper is automatically building a fix for this issue.

    The issue review finished and no active implementation pull request was found.

    Automatic implementation progress:

  4. added
    status: 🚢 actively landing
    on Sep 28, 2026
  5. locked as resolved and limited conversation to collaborators on Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2clawsweeper:fix-shape-clearclawsweeper:queueable-fixclawsweeper:source-reproimpact:ux-frictionissue-rating: 🦞 diamond lobsterno-stalestatus: 🚢 actively landing

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions