fix(web): preserve composer input when planning question appears #1080
Closed
thomasbrugman(GitHub profile, opens in a new tab)wants to merge 1 commit into
main fromrefs/pull/1080/head·opened View on GitHubShowing 1 changed file with 14 additions and 2 deletions.
x
@@ -665,17 +665,29 @@
- const textChangedExternally = promptRef.current !== nextCustomAnswer;
Thread on line 670
🟠 High components/ChatView.tsx:670
When advancing between pending user input questions, if the user typed a custom answer for the previous question, promptRef.current is not synchronized for the new question. The hasUserTypedInComposer check at line 677 returns early whenever promptRef.current.length > 0, regardless of whether questionChanged is true. This leaves promptRef.current stale for the new question, breaking @-mention resolution via applyPromptReplacement and the readComposerSnapshot fallback.
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file apps/web/src/components/ChatView.tsx around line 670:
When advancing between pending user input questions, if the user typed a custom answer for the previous question, `promptRef.current` is not synchronized for the new question. The `hasUserTypedInComposer` check at line 677 returns early whenever `promptRef.current.length > 0`, regardless of whether `questionChanged` is true. This leaves `promptRef.current` stale for the new question, breaking @-mention resolution via `applyPromptReplacement` and the `readComposerSnapshot` fallback.
Evidence trail:
apps/web/src/components/ChatView.tsx lines 674-700 (REVIEWED_COMMIT): Shows the early return at lines 677-680 (`if (hasUserTypedInComposer) { return; }`) executing BEFORE the `questionChanged` check at line 683. The comment at line 683 states "For new questions (questionChanged), always sync" but this is unreachable when `promptRef.current.length > 0`. Line 2939 of `applyPromptReplacement` uses `promptRef.current` directly. Line 2989 of `readComposerSnapshot` falls back to `promptRef.current`.
- if (!questionChanged && !textChangedExternally) {
+ // Don't sync when there's user-typed content in the composer.
+ // This keeps the pending question input independent from the main composer draft.
+ // Previously, this would overwrite user-typed text when a planning question appeared.
+ const hasUserTypedInComposer = promptRef.current.length > 0;
+ if (hasUserTypedInComposer) {
+ // For new questions (questionChanged), always sync to show the question's placeholder.
+ if (!questionChanged) {
+ // For same question: only sync if text actually changed externally.
+ const textChangedExternally = promptRef.current !== nextCustomAnswer;
+ if (!textChangedExternally) {
+ return;
+ }
+ }
+