[PR #12537] fix: auto-save custom answer before switching question tabs #14257

Open
opened 2026-02-16 18:19:04 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/12537

State: open
Merged: No


Fixes #12536
Fixes #8199

Problem

When using the Question tool with multiple questions and custom answer options, typed text from one question's custom answer field appears in the next question when switching tabs without confirming (pressing Enter).

Reproduction Steps

  1. Trigger a question tool with multiple questions
  2. Select "Type your own answer" on Question 1
  3. Type some text (don't press Enter)
  4. Switch to Question 2 using Tab or arrow keys
  5. Select "Type your own answer" on Question 2
  6. The text from Question 1 appears in Question 2's textarea

Solution

Auto-save any uncommitted custom answer text to the current question's state before switching tabs.

Changes in selectTab():

  • Check if user is currently editing (store.editing is true)
  • Capture the raw textarea content
  • Save to store.custom[prevTab]
  • Update store.answers with the custom value
  • Reset editing state before switching to new tab

This prevents text from "leaking" to the next question and ensures answers don't disappear on the Confirm screen.

Testing

  • Verified typecheck passes for opencode package
  • Tested with both keyboard (Tab/arrow keys) and mouse tab switching
  • Works for both single-select and multi-select modes
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/12537 **State:** open **Merged:** No --- Fixes #12536 Fixes #8199 ## Problem When using the Question tool with multiple questions and custom answer options, typed text from one question's custom answer field appears in the next question when switching tabs without confirming (pressing Enter). ### Reproduction Steps 1. Trigger a question tool with multiple questions 2. Select "Type your own answer" on Question 1 3. Type some text (don't press Enter) 4. Switch to Question 2 using Tab or arrow keys 5. Select "Type your own answer" on Question 2 6. The text from Question 1 appears in Question 2's textarea ## Solution Auto-save any uncommitted custom answer text to the current question's state before switching tabs. ### Changes in `selectTab()`: - Check if user is currently editing (`store.editing` is true) - Capture the raw textarea content - Save to `store.custom[prevTab]` - Update `store.answers` with the custom value - Reset `editing` state before switching to new tab This prevents text from "leaking" to the next question and ensures answers don't disappear on the Confirm screen. ## Testing - Verified typecheck passes for opencode package - Tested with both keyboard (Tab/arrow keys) and mouse tab switching - Works for both single-select and multi-select modes
yindo added the pull-request label 2026-02-16 18:19:04 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14257