Skip to content

Fix interactive prompts skipping questions due to stray newlines#43

Merged
soniapi merged 1 commit intolibfrom
fix/interactive-prompt-stdin-9011617859792289033
Mar 30, 2026
Merged

Fix interactive prompts skipping questions due to stray newlines#43
soniapi merged 1 commit intolibfrom
fix/interactive-prompt-stdin-9011617859792289033

Conversation

@soniapi
Copy link
Copy Markdown
Owner

@soniapi soniapi commented Mar 30, 2026

Fixes a bug where interactive prompt answers skip the first question and use the answer for the second. This occurs due to stray newlines from previous commands in cargo test. Wrapped read_line in a loop to discard empty/whitespace strings while safely handling EOFs to fix the interactive flow.


PR created automatically by Jules for task 9011617859792289033 started by @soniapi

@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

When running interactive tests (like `INTERACTIVE=1 cargo test --nocapture`),
stray newlines from previous commands or input streams can cause `read_line`
to immediately return an empty string. This caused the first prompt
(`prompt_microstructure_variable`) to be skipped, and the intended
answer was instead consumed by the second prompt (`prompt_cutoff_value`).

This commit updates `helpers::prompt_microstructure_variable` and
`helpers::prompt_cutoff_value` to repeatedly read from `stdin` until a
non-empty line is provided. It also correctly handles EOF (`bytes == 0`)
to prevent infinite loops when stdin is exhausted.

Co-authored-by: soniapi <396009+soniapi@users.noreply.github.com>
@soniapi soniapi force-pushed the fix/interactive-prompt-stdin-9011617859792289033 branch from a7391f3 to 369fedf Compare March 30, 2026 18:15
@soniapi soniapi merged commit 7b1d787 into lib Mar 30, 2026
1 check passed
@soniapi soniapi deleted the fix/interactive-prompt-stdin-9011617859792289033 branch March 30, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant