fix(QUA-577): recover partial typed input when agent finishes mid-typing#101
Closed
Desperado wants to merge 1 commit into
Closed
fix(QUA-577): recover partial typed input when agent finishes mid-typing#101Desperado wants to merge 1 commit into
Desperado wants to merge 1 commit into
Conversation
If the agent's response races the user's typing (turn ends before the user has pressed Enter), the typing-line buffer was silently dropped, making the v1.13 "type while agent runs, auto-queue" feature appear broken: the user sees `⌨ partial text` appear, agent response prints, and the partial vanishes. Subsequent keystrokes that arrive between stopQueueReader() and the next tui.ReadInput end up split across two prompts, producing confusing "phantom" input. The queue reader now exposes its in-flight line buffer via its stop function. After the agent finishes, repl pushes any partial line onto the queue with a clear "↩ partial input recovered" notice. Users can discard it with the new `/queue clear` command if it was stray input. The fix preserves the existing Enter-to-queue, Enter-cancels-agent, and Ctrl+C-clears behaviour unchanged. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
✅ QualityMax Pipeline
Powered by QualityMax — AI-Powered Test Automation |
Contributor
Author
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.
Summary
Fixes QUA-577. The v1.13 "type while agent runs, auto-queue" feature was silently dropping the user's typed-but-not-yet-Enter-terminated input when the agent's response came back before they could press Enter.
Root cause (from e2e PTY probe)
StartQueueReaderaccumulates each typed character in an in-goroutinelineRunesbuffer. On Enter the buffer is pushed onto the queue.stopQueueReader()fires (agent turn ended), the goroutine returns andlineRunesis garbage-collected — even if it contained a partial line the user was mid-typing.stopQueueReader()and the nexttui.ReadInput()end up split across two prompts.Reproduction (real keyboard, confirmed by @strazhnyk): submit a slow prompt, start typing a second one, and let the agent finish before you press Enter. Your typed text vanishes; the next prompt opens empty.
Fix
StartQueueReadernow returnsfunc() string. The goroutine sends its finallineRunesvalue through a buffered channel before exiting; the stop function returns it afterwg.Wait.repl.goreads the partial after the agent's turn finishes and, if non-empty after trim, pushes it onto the queue with a clear notice:/queue clearslash command (PromptQueue.Clear) lets the user discard recovered text if it was stray input.Verification
go test ./... -short -count=1is green.TestPromptQueue_ClearReturnsCount,TestPromptQueue_ClearEmpty.Test plan
qmax-code, submit a slow prompt, type a few chars during thinking but don't press Enter. Confirm the agent's response is followed by↩ partial input recovered → queued [1]: <your text>, thenprocessing queued prompt.✓ queued [N]:path still works and Enter still cancels the running agent./queue cleardiscards queued items as expected.go test ./....🤖 Generated with Claude Code