Fix terminal "Input ready" false positives with prompt detection heuristics + debounce#220
Merged
Merged
Conversation
…debounce Agent-Logs-Url: https://github.com/djeada/Lightpad/sessions/e704d0e2-e7c3-4cb0-acbc-2e660cf72a71 Co-authored-by: djeada <37275728+djeada@users.noreply.github.com>
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 inQProcess::startedhandler (before any output)readyReadStandardOutputandreadyReadStandardErrorsignalChanges
Detection logic —
looksLikeInputPrompt(const QString &text)(new static method)Three-tier heuristic, checked in order:
input(),read,getpassetc. leave cursor on the prompt line[y/n],[Y/n],(yes/no), …?,:,>,$,#,>>>,...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) andkPromptSuffixes(QLatin1String[]) are initialized once at file scope rather than on each call.Example — what now works correctly
New tests
testLooksLikeInputPromptPatterns— unit-tests the detection function directlytestIndicatorNotShownForNonPromptOutput— end-to-end: process with newline-terminated outputtestIndicatorNotShownOnProcessStart— verifies indicator stays hidden at launchtestIndicatorHiddenAfterNonPromptOutput— debounce path, post-process-exit state