fix(web): keep typed text when a question option is clicked #12577
main fromrefs/pull/12577/head·merged by juliusmarminge View on GitHubShowing 6 changed files with 58 additions and 8 deletions (loading 3).
🟡 Medium chat/ChatComposer.tsx:3086
When a selected option resolves the question, the restored draft keeps composerCursor at 0, so ComposerPromptEditor places the caret at the beginning and the next character is inserted before the user's draft text. Update the cursor alongside promptRef.current using the restored prompt's end position.
if (lastSyncedPendingInputRef.current !== null) {
promptRef.current = prompt;
+ setComposerCursor(collapseExpandedComposerCursor(prompt, prompt.length));
}
🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/web/src/components/chat/ChatComposer.tsx around lines 3086-3087:
When a selected option resolves the question, the restored draft keeps `composerCursor` at `0`, so `ComposerPromptEditor` places the caret at the beginning and the next character is inserted before the user's draft text. Update the cursor alongside `promptRef.current` using the restored prompt's end position.
Fixed in the follow-up commits on this branch: when the pending question clears, we restore the parked draft and set the composer cursor (and trigger) to the collapsed end of that prompt via composerStateAtPromptEnd, matching the custom-answer sync path. Added coverage in composer-logic.test.ts.
Sorry, I'm unable to act on this request because you do not have permissions within this repository.