Skip to content

fix: prevent Enter key infinite loop in interview notes mode#3450

Open
yokotoka wants to merge 2 commits intogsd-build:mainfrom
yokotoka:fix/interview-enter-infinite-loop
Open

fix: prevent Enter key infinite loop in interview notes mode#3450
yokotoka wants to merge 2 commits intogsd-build:mainfrom
yokotoka:fix/interview-enter-infinite-loop

Conversation

@yokotoka
Copy link
Copy Markdown

@yokotoka yokotoka commented Apr 3, 2026

Summary

Fixes #3449

  • The goNextOrSubmit() function in the interview UI re-opened the notes field every time Enter was pressed if the cursor was on "None of the above", creating an infinite loop where the user could never advance past the current question
  • Added && !states[currentIdx].notesVisible guard to the auto-open condition so it only triggers on the initial selection, not when the user is confirming already-typed notes

Root Cause

Commit b80eec6 (#3081, fix for #2715) added auto-open logic that opens the notes field when "None of the above" is selected. However, goNextOrSubmit() is also called when Enter is pressed from within notes mode (line 387). This created a cycle:

  1. Enter in notes mode → focusNotes = falsegoNextOrSubmit()
  2. goNextOrSubmit() sees cursorIndex === noneOrDoneIdxfocusNotes = true
  3. User presses Enter again → back to step 1

Fix

The auto-open check now also verifies !states[currentIdx].notesVisible. When notes have already been shown (notesVisible = true from the initial Tab or auto-open), the guard prevents re-opening and lets the flow advance normally.

The original #2715 fix is preserved: when a user first selects "None of the above" (before notes have been shown), notesVisible is false and the auto-open still triggers correctly.

Test plan

  • Select "None of the above" → notes field auto-opens (original Bug: Ask-user-questions UI lacks free-text input and can trap users in a loop #2715 behavior preserved)
  • Type a note → press Enter → advances to next question or review screen
  • Press Tab to add notes on any option → type → press Enter → advances correctly
  • Press Tab to add notes → press Tab again to close → press Enter → advances correctly

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings April 3, 2026 14:21
@github-actions github-actions bot added bug Something isn't working High Priority labels Apr 3, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 3, 2026

🟡 PR Risk Report — MEDIUM

Files changed 2
Systems affected 1
Overall risk 🟡 MEDIUM

Affected Systems

Risk System
🟡 medium TUI Components
File Breakdown
Risk File Systems
🟡 src/resources/extensions/shared/interview-ui.ts TUI Components
src/resources/extensions/shared/tests/interview-enter-loop.test.ts (unclassified)

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an interaction bug in the shared TUI interview flow where pressing Enter while editing notes could re-trigger the “auto-open notes on ‘None of the above’” behavior, trapping users in a loop and preventing progression.

Changes:

  • Adds a !states[currentIdx].notesVisible guard to the “auto-open notes” condition in goNextOrSubmit() to prevent re-opening notes after they’ve already been shown once for the current question.
  • Adds an inline comment clarifying why the guard exists (Enter-from-notes confirmation path).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Andrei Kobyshev added 2 commits April 4, 2026 23:43
When pressing Enter to confirm notes in the interview UI, goNextOrSubmit()
would re-open the notes field if the cursor was on "None of the above",
creating an infinite loop where Enter never advanced past the question.

The auto-open check (added in b80eec6 for gsd-build#2715) now also verifies that
notes haven't already been shown (notesVisible === false), so it only
triggers on the initial "None of the above" selection.

Fixes gsd-build#3449
When pressing Enter to confirm notes in the interview UI, goNextOrSubmit()
would re-open the notes field if the cursor was on 'None of the above',
creating an infinite loop where Enter never advanced past the question.

The auto-open check now also verifies that notes haven't already been shown
(notesVisible === false), so it only triggers on the initial selection.

Includes regression test for the guard condition.

Fixes gsd-build#3449
@trek-e trek-e force-pushed the fix/interview-enter-infinite-loop branch from 4433809 to f20de63 Compare April 5, 2026 03:43
@jeremymcs
Copy link
Copy Markdown
Collaborator

This PR has merge conflicts with the base branch. Please rebase or merge main to resolve before review can proceed.

🤖 Automated PR audit — 2026-04-04

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

Labels

bug Something isn't working High Priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enter key trapped in infinite loop after Tab comments in interview UI

3 participants