Skip to content

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

Closed
myfunc wants to merge 1 commit into
pingdotgg:mainfrom
myfunc:fix/keep-typed-answer-on-option-select
Closed

myfunc wants to merge 1 commit into
pingdotgg:mainfrom
myfunc:fix/keep-typed-answer-on-option-select

Conversation

@myfunc

@myfunc myfunc commented Sep 19, 2026 •

Copy link
Copy Markdown

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.

Selecting an option for a pending user-input question replaced the custom
answer with an empty string, so anything the user had typed into the
composer while the question was active was discarded. The typed text now
moves into the thread draft and comes back once the question resolves.

The composer also resyncs its shared prompt ref from the thread draft when
the question clears; before, Send read the stale answer text instead of
the draft shown in the editor.

Fixes pingdotgg#12569.

Done with Claude Code, model Claude Fable 5.1.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@github-actions github-actions Bot added the vouch:unvouched PR author is not yet trusted in the VOUCHED list. label Sep 19, 2026
@github-actions github-actions Bot added the size:M 30-99 changed lines (additions + deletions). label Sep 19, 2026
@macroscopeapp

macroscopeapp Bot commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

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.

@coderabbitai

coderabbitai Bot commented Sep 19, 2026 •

Copy link
Copy Markdown

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 dfbb11b and e4a94a0.

📒 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 name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring 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 name Status Explanation
Linked Issues check ✅ Passed Issue #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 ✅ Passed The 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 ✅ Passed The title clearly and concisely describes the primary fix: preserving typed text when a pending-question option is selected.
Description check ✅ Passed The 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.

@juliusmarminge

Copy link
Copy Markdown
Member

Superseded by #12577 (merged) which also fixes #12569.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Clicking a question option discards text typed into the composer

2 participants