Skip to content

fix(web): clear composer draft synchronously on send - #1163

Merged
wbxl2000 merged 1 commit into
mainfrom
fix/web-composer-draft-clear
Jun 27, 2026
Merged

fix(web): clear composer draft synchronously on send#1163
wbxl2000 merged 1 commit into
mainfrom
fix/web-composer-draft-clear

Conversation

@wbxl2000

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue — user-reported bug.

Problem

Users reported that the web composer occasionally keeps the just-sent text after clicking send, most often when sending the first message of a new (empty) session.

Root cause: when the first message is submitted, the optimistic user turn makes turns.length go from 0 to 1, which unmounts the empty-session composer. The text watcher that persists the cleared draft is flush: 'post', so it does not run before the component unmounts. The docked composer then mounts and reloads the stale draft from localStorage.

What changed

  • Expose a synchronous clearDraft() from useComposerDraft.
  • Call it right after clearing text.value in every send path: normal submit, slash-command submit, steer (Ctrl+S), and bare slash-command menu selection.
  • Add a regression test that confirms the draft is removed synchronously, so a remount starts empty.

Relying on the text watcher is unsafe here because Vue stops a child component's effect scope when the parent unmounts it in the same tick, regardless of watcher flush mode. Clearing the draft synchronously before emit('submit') sidesteps that entirely.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

When the first message of an empty session is submitted, the optimistic
user turn unmounts the empty-session composer before the post-flush text
watcher can persist the cleared draft. The docked composer then mounts
and reloads the stale text from localStorage.

Clear the persisted draft synchronously in the submit / steer / slash
command paths instead of relying on the text watcher, so the next mount
always starts empty.
@changeset-bot

changeset-bot Bot commented Jun 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a7ddc18

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jun 27, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@a7ddc18
npx https://pkg.pr.new/@moonshot-ai/kimi-code@a7ddc18

commit: a7ddc18

@wbxl2000
wbxl2000 merged commit ff6e8bb into main Jun 27, 2026
10 checks passed
@wbxl2000
wbxl2000 deleted the fix/web-composer-draft-clear branch June 27, 2026 17:55
@github-actions github-actions Bot mentioned this pull request Jun 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant