fix(cli): defer Enter during rapid text input to prevent multiline paste splitting - #19494
Closed
Ralojeil1 wants to merge 1 commit into
Closed
fix(cli): defer Enter during rapid text input to prevent multiline paste splitting#19494Ralojeil1 wants to merge 1 commit into
Ralojeil1 wants to merge 1 commit into
Conversation
…ste splitting When pasting multiline text without bracketed paste support (Windows Terminal, tmux, some terminals), newlines arrive as individual Enter key events, causing the CLI to submit each line as a separate steering message. Add a 50ms timing guard: track _last_text_change timestamp on every buffer modification, and defer submission in handle_enter if text changed <50ms ago. This catches paste-speed input (<1ms between chars) while leaving normal typing (>50ms) unaffected. Tested on: - Windows Terminal (no bracketed paste) — works correctly - Large multi-line pastes buffer fully, only submit on manual Enter - No impact on normal or fast typing Adapted from @iRonin's approach in PR NousResearch#10997, updated for current codebase with bracketed-paste leak stripping in _on_text_changed.
This was referenced Aug 3, 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.
Problem
When pasting multiline text into the Hermes CLI prompt without bracketed paste support (Windows Terminal, tmux, some terminals), newlines arrive as individual Enter key events. Each line gets submitted as a separate steering message instead of one complete message.
This is a major UX issue — pasting a 20-line context block floods the agent with 20 fragmented steering messages.
Root Cause
Without bracketed paste, pasted newlines are indistinguishable from manual Enter presses. The
@kb.add('enter')handler fires for each newline, routing each line to the steering queue independently.Fix: 50ms Timing Guard
Three changes in
cli.py(9 lines total):_last_text_change = [None]_last_text_change[0] = time.monotonic()in_on_text_changedhandle_enterbefore normal input routing:The 50ms threshold cleanly separates:
Tested
Notes
Adapted from @iRonin's approach in PR #10997. This version updates the fix for the current codebase which has newer
_on_text_changedlogic (bracketed-paste leak stripping) not present in the original PR's base.Closes #10994