Bug
When an interactive command like npm init is run and the user accepts all defaults via the askQuestions carousel, every send_to_terminal progress message displays the first question's text (e.g. "Package name?") instead of the correct question for each prompt.
Steps to Reproduce
- Open a chat session in default approvals mode
- Ask the agent to run
npm init in a terminal
- The agent detects the interactive prompts and shows an
askQuestions carousel with multiple questions (package name, version, description, entry point, etc.)
- Accept all defaults by leaving every field empty and submitting the carousel
- The agent sends each default answer via
send_to_terminal (pressing Enter for each prompt)
Expected Behavior
Each send_to_terminal progress message should show the corresponding question:
- Pressed
Enter in terminal (replying to: Package name?)
- Pressed
Enter in terminal (replying to: version?)
- Pressed
Enter in terminal (replying to: description?)
- …
Actual Behavior
Every progress message repeats the first question:
- Pressed
Enter in terminal (replying to: Package name? (default: @xterm/xterm))
- Pressed
Enter in terminal (replying to: Package name? (default: @xterm/xterm))
- Pressed
Enter in terminal (replying to: Package name? (default: @xterm/xterm))
- …
Cause
_getQuestionContextForTerminal matches the sent command text against carousel answer values to find the corresponding question. When all answers are identical (empty string for defaults), the loop iterates questions in order and always matches the first one.
Fix
Use positional matching: count prior send_to_terminal tool invocations after the carousel in the response parts to determine the question index, rather than relying solely on answer-value matching.
Bug
When an interactive command like
npm initis run and the user accepts all defaults via theaskQuestionscarousel, everysend_to_terminalprogress message displays the first question's text (e.g. "Package name?") instead of the correct question for each prompt.Steps to Reproduce
npm initin a terminalaskQuestionscarousel with multiple questions (package name, version, description, entry point, etc.)send_to_terminal(pressing Enter for each prompt)Expected Behavior
Each
send_to_terminalprogress message should show the corresponding question:Enterin terminal (replying to: Package name?)Enterin terminal (replying to: version?)Enterin terminal (replying to: description?)Actual Behavior
Every progress message repeats the first question:
Enterin terminal (replying to: Package name? (default: @xterm/xterm))Enterin terminal (replying to: Package name? (default: @xterm/xterm))Enterin terminal (replying to: Package name? (default: @xterm/xterm))Cause
_getQuestionContextForTerminalmatches the sent command text against carousel answer values to find the corresponding question. When all answers are identical (empty string for defaults), the loop iterates questions in order and always matches the first one.Fix
Use positional matching: count prior
send_to_terminaltool invocations after the carousel in the response parts to determine the question index, rather than relying solely on answer-value matching.