Skip to content

fix: auto-save custom answer before switching question tabs - #12537

Closed
maharshi365 wants to merge 7 commits into
anomalyco:devfrom
maharshi365:fix/question-tab-custom-answer-leak
Closed

fix: auto-save custom answer before switching question tabs#12537
maharshi365 wants to merge 7 commits into
anomalyco:devfrom
maharshi365:fix/question-tab-custom-answer-leak

Conversation

@maharshi365

Copy link
Copy Markdown
Contributor

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

Fixes anomalyco#12536
Fixes anomalyco#8199

When a user types a custom answer in the Question tool and switches tabs without confirming (pressing Enter), the typed text appears in the next question's textarea. This auto-saves the custom answer to the current question's state before switching tabs.
@github-actions

github-actions Bot commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

@maharshi365
maharshi365 marked this pull request as draft February 12, 2026 16:04
@maharshi365 maharshi365 reopened this Feb 12, 2026
Replaced saveCustomAnswer() with saveCustomAnswerMulti() helper and inlined
single-select logic to clarify code paths and eliminate duplication.
@maharshi365
maharshi365 marked this pull request as ready for review February 12, 2026 19:27
@rekram1-node

Copy link
Copy Markdown
Collaborator

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

@maharshi365

Copy link
Copy Markdown
Contributor Author

@rekram1-node can you please check this issue? the bug is still present in latest TUI

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

Projects

None yet

2 participants