Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): keep typed text when a question option is clicked #12575

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

What Changed

Clicking an option in a pending user-input question no longer discards text typed into the composer.

  • pendingUserInput.ts: new pure helper carryDisplacedCustomAnswerIntoPrompt with tests.
  • ChatView.tsx: onSelectActivePendingUserInputOption moves a non-empty custom answer into the thread draft before the option replaces it.
  • ChatComposer.tsx: when the question clears, the shared prompt ref is resynced from the thread draft.

Why

While a question is active the composer edits the question's custom answer. Selecting an option rebuilds that answer with customAnswer: "", because a custom answer outranks selected options. Anything the user typed in the meantime is gone: not in the answer, not in the draft, not in any message. Fixes #12569.

The second change closes a related gap: after the question resolved, the composer showed the thread draft but the prompt ref still held the last answer text, so Send without further typing read the wrong value.

Text moved into the draft comes back in the composer once the question resolves and is sent as the next message, same as text typed before the question arrived. Mobile keeps the answer in its own input on the question card and is not affected.

UI Changes

No visual change. Interaction below: typing while a question is open, then clicking an option.

Before:

before

After:

after

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes (not applicable, no visual change)
  • I included a video for animation/interaction changes (not applicable, behaviour covered by the steps below)

Validation:

  • Before, on a dev build from dfbb11bdd: type while a single-choice question is open, click an option. The composer empties and the text is not in the draft, the answer, or any message.
  • After: same steps. The answer goes out, the typed text is back in the composer, and Send submits it in full as the next message.
  • Unit tests for the helper, typecheck for apps/web, targeted lint with only pre-existing warnings.

Tests cover the new helper only. There is no regression test that fails on main: the drop happens inside the ChatView handler, and a test there costs more than the fix. We chose to skip it on purpose for now, not sure yet whether it would be overengineering for a change this size. Feedback welcome.

lovely composed in pair with Claude Fable 5.1 in Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Preserved typed custom answers when selecting options for pending questions.
    • Restored the conversation draft after a pending question is completed or removed, preventing stale answers from being sent.
    • Combined displaced custom answers with existing draft text so no user input is lost.
  • Tests
    • Added coverage for empty answers, empty drafts, and appending answers to existing drafts.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    2. Approvability

      Verdict: Approved at e4a94a0

      Macroscope's review found this PR approvable — This is a small, self-contained web bug fix that preserves typed text when selecting a pending-question option and keeps the composer’s send state consistent afterward. Its runtime impact is confined to that composer interaction, with no schema, deployment, security, billing, or static-analysis configuration changes.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review Change StackReview Change Stack

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration

      Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml

      Review profile: CHILL

      Plan: Advanced

      Run ID: d2920752-e4ae-4a75-829f-438b5da023d3

      📥 Commits

      Reviewing files that changed from the base of the PR and between dfbb11bdd7c3f1a5575cb55d3e3abb12be025727 and e4a94a0b3c81f69b4c6450ee6f316ce26ea38c3e.

      📒 Files selected for processing (4)
      • apps/web/src/components/ChatView.tsx
      • apps/web/src/components/chat/ChatComposer.tsx
      • apps/web/src/pendingUserInput.test.ts
      • apps/web/src/pendingUserInput.ts

      Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


      📝 Walkthrough

      Walkthrough

      The pending-user-input flow now preserves typed custom answers when an option is selected. It merges the answer into the thread draft and restores that draft in the composer after the pending question clears. Unit tests cover the merge behavior.

      Changes

      Pending answer preservation

      Layer / File(s)Summary
      Answer carry helper
      apps/web/src/pendingUserInput.ts, apps/web/src/pendingUserInput.test.ts
      Adds a helper that trims and merges displaced custom answers into prompts. Tests cover empty answers, empty prompts, and appended answers.
      Composer integration
      apps/web/src/components/ChatView.tsx, apps/web/src/components/chat/ChatComposer.tsx
      ChatView preserves the typed answer when an option is selected. ChatComposer restores the thread draft prompt when the pending question clears.

      Priority: ➖ Normal

      Estimated code review effort: 3 (Moderate) | ~20 minutes

      Change: Bug fix · Severity of issue fixed: Medium

      Suggested reviewers: t3dotgg

      🚥 Pre-merge checks | ✅ 4 | ❌ 1

      ❌ Failed checks (1 warning)

      Check nameStatusExplanationResolution
      Docstring Coverage⚠️ WarningDocstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 4 files.Write docstrings for the functions missing them to satisfy the coverage threshold.
      ✅ Passed checks (4 passed)
      Check nameStatusExplanation
      Linked Issues check✅ PassedIssue #12569 requires that selecting an option does not destroy typed composer text. ChatView.tsx reads the current custom answer before option selection and moves non-empty text into the thread dra…
      Out of Scope Changes check✅ PassedThe changes stay within issue #12569. The helper, option-selection integration, prompt-ref synchronization, and unit tests all support preserving typed text and sending it after the question ends. No …
      Title check✅ PassedThe title clearly and concisely describes the primary fix: preserving typed text when a pending-question option is selected.
      Description check✅ PassedThe description includes What Changed, Why, UI Changes, Checklist, validation details, screenshots, and test information. It explains the interaction change and notes why no video is included.
      • Fix all pre-merge checks with AI
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create a new PR

      Comment `@coderabbitai help` to get the list of available commands.
    4. Superseded by #12577 (merged) which also fixes #12569.

    5. juliusmarminge closed this

Sign in to join this conversation.