Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): preserve composer input when planning question appears #1080

Closedthomasbrugman(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/1080/headopened View on GitHub

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

  • This PR is small and focused
  • I explained what changed and why

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 > 0 before 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

    1. You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

    2. Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro

      Run ID: 778013cb-6b1f-40e5-a650-4377125d2c4e

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests
      • Post copyable unit tests in a comment
      📝 Coding Plan
      • Generate coding plan for human review comments

      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.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands and usage tips.

      Tip

      You can customize the high-level summary generated by CodeRabbit.

      Configure the reviews.high_level_summary_instructions setting to provide custom instructions for generating the high-level summary.

    3. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    4. @@ -665,7 +665,6 @@
      665665 const questionChanged =
      666666 lastSyncedPendingInputRef.current?.requestId !== nextRequestId ||
      667667 lastSyncedPendingInputRef.current?.questionId !== nextQuestionId;
      668- const textChangedExternally = promptRef.current !== nextCustomAnswer;
      669668
      670669 lastSyncedPendingInputRef.current = {
      671670 requestId: nextRequestId,
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 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`.
      thomasbrugman(GitHub profile, opens in a new tab)commented

      fix it for me

Sign in to join this conversation.