fix(web): clear composer draft synchronously on send - #1163
Merged
Conversation
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 detectedLatest commit: a7ddc18 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.lengthgo from 0 to 1, which unmounts the empty-session composer. Thetextwatcher that persists the cleared draft isflush: 'post', so it does not run before the component unmounts. The docked composer then mounts and reloads the stale draft fromlocalStorage.What changed
clearDraft()fromuseComposerDraft.text.valuein every send path: normal submit, slash-command submit, steer (Ctrl+S), and bare slash-command menu selection.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
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.