Skip to content

Fix terminal "Input ready" false positives with prompt detection heuristics + debounce#220

Merged
djeada merged 2 commits into
masterfrom
copilot/extend-improve-detection-logic
May 2, 2026
Merged

Fix terminal "Input ready" false positives with prompt detection heuristics + debounce#220
djeada merged 2 commits into
masterfrom
copilot/extend-improve-detection-logic

Conversation

Copilot AI commented May 2, 2026

Copy link
Copy Markdown
Contributor

The "Input ready" indicator fired unconditionally on process start, any stdout chunk, and any stderr output — regardless of whether the process was actually waiting for user input.

Root causes

  • setRunInputIndicatorActive(true) called in QProcess::started handler (before any output)
  • Same unconditional call on every readyReadStandardOutput and readyReadStandardError signal

Changes

Detection logic — looksLikeInputPrompt(const QString &text) (new static method)

Three-tier heuristic, checked in order:

  1. No trailing newline — most reliable; input(), read, getpass etc. leave cursor on the prompt line
  2. Yes/no patterns[y/n], [Y/n], (yes/no), …
  3. Prompt suffixes on the last non-empty line — ? , : , > , $ , # , >>> , ...

ANSI escape codes are stripped before matching so colorized prompts are handled correctly.

Debounce (80 ms)

Instead of activating the indicator immediately on each stdout chunk, a single-shot timer is restarted on every chunk. The indicator decision is made only after output has stopped arriving, eliminating flicker during rapid bursts where intermediate chunks may lack a trailing newline.

Stderr no longer triggers the indicator

Diagnostic/error output is not an input prompt.

Pattern constants moved to file scope

kYesNoPromptPattern (QRegularExpression) and kPromptSuffixes (QLatin1String[]) are initialized once at file scope rather than on each call.

Example — what now works correctly

# Non-interactive: prints lines ending with \n → indicator stays hidden
for i in range(100):
    print(f"Processing {i}...")

# Interactive: prints "Name: " without trailing newline → indicator shown after 80 ms
name = input("Name: ")

New tests

  • testLooksLikeInputPromptPatterns — unit-tests the detection function directly
  • testIndicatorNotShownForNonPromptOutput — end-to-end: process with newline-terminated output
  • testIndicatorNotShownOnProcessStart — verifies indicator stays hidden at launch
  • testIndicatorHiddenAfterNonPromptOutput — debounce path, post-process-exit state

Copilot AI changed the title [WIP] Fix input ready detection in terminal UI Fix terminal "Input ready" false positives with prompt detection heuristics + debounce May 2, 2026
Copilot finished work on behalf of djeada May 2, 2026 07:09
Copilot AI requested a review from djeada May 2, 2026 07:09
@djeada djeada marked this pull request as ready for review May 2, 2026 07:41
@djeada djeada merged commit cf57522 into master May 2, 2026
1 check passed
@djeada djeada deleted the copilot/extend-improve-detection-logic branch May 2, 2026 20:02
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.

input ready in terminal ui false postivie (even when no input is expected), extend and improve detection logic

2 participants