fix(web): preserve composer input when planning question appears#1080
fix(web): preserve composer input when planning question appears#1080Githubguy132010 wants to merge 1 commit intopingdotgg:mainfrom
Conversation
When a planning question pops up while the user is typing in the composer, their typed text was being cleared. This was caused by the sync effect that copies pending user input to the composer - it would overwrite user content with the empty pending answer. The fix adds a check to skip syncing when the user has already typed content in the composer, keeping the pending question input independent from the main composer draft. Fixes pingdotgg#808
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip You can customize the high-level summary generated by CodeRabbit.Configure the |
| const textChangedExternally = promptRef.current !== nextCustomAnswer; | ||
|
|
||
| lastSyncedPendingInputRef.current = { | ||
| requestId: nextRequestId, |
There was a problem hiding this comment.
🟠 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`.
What Changed
Preserved user-typed text in the composer when a planning question appears while the user is typing. Previously, the input would be cleared because the sync effect would overwrite it with the empty pending answer.
Why
The sync effect that copies pending user input to the composer was unconditionally overwriting user content. When a planning question pops up, the effect would set the composer value to the empty pending answer, clearing whatever the user had typed. This made for a poor user experience.
The fix adds a check to skip syncing when the user has already typed content in the composer, keeping the pending question input independent from the main composer draft.
Checklist
Fixes #808
Note
Preserve composer input when a planning question appears in ChatView
Previously, pending question input would overwrite any text the user had already typed in the composer. Now, ChatView.tsx checks
promptRef.current.length > 0before syncing and skips the sync if the user has typed content. For the same (unchanged) question, syncing only happens when the external text has actually changed; new questions still sync to display their placeholder text.📊 Macroscope summarized b948b8d. 1 file reviewed, 1 issue evaluated, 0 issues filtered, 1 comment posted
🗂️ Filtered Issues