Skip to content
Source
Sign inSign up
pingdotgg/t3code

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

Mergedcestercian(GitHub profile, opens in a new tab)merged 3 commits intomain fromrefs/pull/12577/headmerged by juliusmarminge View on GitHub

What Changed

While a pending question is active, the composer edits the question's custom answer. Clicking an option used to wipe that text (and clear promptRef), so anything typed during the question disappeared.

Selecting an option now parks a non-empty custom answer onto the thread draft (appending if a draft already exists). When the question clears, ChatComposer resyncs promptRef from the thread draft so Send reads the parked text. The option is still what gets submitted; typed text returns as the next composer draft.

Why

Fixes #12569 — clicking a question option discarded composer text with no way to recover it.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Tests

apps/web/src/pendingUserInput.test.ts — 21 passed (including empty-answer, empty-draft, and append-to-existing-draft cases)

Summary by CodeRabbit

  • Bug Fixes
    • Preserved custom text entered for a pending question when users select a suggested option.
    • Restored drafts correctly after pending questions disappear.
    • Improved cursor placement and trigger detection when restoring composer text, including mentions and path suggestions.
  • Tests
    • Added coverage for draft preservation, text appending, cursor placement, and trigger behavior.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    2. Approvability

      Verdict: Would Approve

      Macroscope's review found this PR approvable — This is a focused composer bug fix that preserves pending-question text in the existing thread draft, with small production changes and targeted tests. A separate unresolved Medium finding concerns caret placement after restoration and represents a correctness risk requiring attention.

      Not approved because:

      • 1 blocking correctness issue found at or above your repo's Minimum Blocking Severity
      Adjust the Minimum Blocking Severity for this repo — including turning it Off — in [Settings](https://app.macroscope.com/pingdotgg/settings#Repos). 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: d53b1d09-beed-4681-8e4e-931b931bed3a

      📥 Commits

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

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

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


      📝 Walkthrough

      Walkthrough

      The change preserves typed custom answers when a pending-question option is selected. It adds prompt and composer-state helpers, updates option selection and composer synchronization, and adds tests for answer transfer, cursor placement, and trigger detection.

      Changes

      Pending input preservation

      Layer / File(s)Summary
      Answer preservation helpers
      apps/web/src/pendingUserInput.ts, apps/web/src/composer-logic.ts, apps/web/src/pendingUserInput.test.ts, apps/web/src/composer-logic.test.ts
      carryDisplacedCustomAnswerIntoPrompt trims and appends displaced answers. composerStateAtPromptEnd calculates the collapsed cursor and trigger state. Tests cover both helpers.
      Pending input integration
      apps/web/src/components/ChatView.tsx, apps/web/src/components/chat/ChatComposer.tsx
      Option selection transfers the custom answer into the thread draft. Composer synchronization restores the draft and updates cursor and trigger state when the pending question changes.

      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 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 6 files.Write docstrings for the functions missing them to satisfy the coverage threshold.
      ✅ Passed checks (4 passed)
      Check nameStatusExplanation
      Title check✅ PassedThe title clearly and concisely describes the main change: preserving typed text when a question option is selected.
      Description check✅ PassedThe description explains what changed, why it changed, the linked issue, implementation behavior, and test coverage. It is focused and mostly complete. The UI and interaction checklist items remain un…
      Linked Issues check✅ PassedIssue #12569 requires preserving text typed in the shared composer when the user selects a structured-question option. The change reads the displaced custom answer, moves non-empty text into the threa…
      Out of Scope Changes check✅ PassedThe changes stay within issue #12569. The helper, ChatView integration, composer synchronization, caret handling, and tests directly support preserving the displaced text and restoring usable draft ed…
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create a new PR

      Comment `@coderabbitai help` to get the list of available commands.
    4. Macroscope caret thread resolved — on HEAD (886ccd7) clearing the pending question restores the parked draft via composerStateAtPromptEnd and setComposerCursor (end of prompt), not cursor 0.

      Ready for re-review / approve when convenient.

    5. /recheck-vouch

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

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

    8. juliusmarminge merged thise367256

    9. juliusmarminge closed this

Sign in to join this conversation.