Skip to content

fix(cli): prevent paste detection from destroying multi-line input#84

Merged
teknium1 merged 1 commit intoNousResearch:mainfrom
0xbyt4:fix/cli-paste-detection-false-positive
Feb 27, 2026
Merged

fix(cli): prevent paste detection from destroying multi-line input#84
teknium1 merged 1 commit intoNousResearch:mainfrom
0xbyt4:fix/cli-paste-detection-false-positive

Conversation

@0xbyt4
Copy link
Copy Markdown
Contributor

@0xbyt4 0xbyt4 commented Feb 26, 2026

Summary

  • The paste detection heuristic in _on_text_changed triggers whenever the buffer has 5+ newlines, regardless of how those lines were entered
  • Typing manually with Alt+Enter (one newline at a time) eventually reaches the threshold and silently replaces the user's input with a file reference — causing data loss
  • Fix: track previous buffer length and only treat a change as a paste when more than one character is added in a single event

Reproduction

  1. Start the CLI (python cli.py)
  2. Type a line, press Alt+Enter, type another line, repeat 6 times
  3. Before fix: On the 6th line, the entire input is silently replaced with [Pasted text #1: 6 lines → ~/.hermes/pastes/...]
  4. After fix: Multi-line input is preserved; only actual pastes (many characters at once) are collapsed
The _on_text_changed handler collapsed buffer contents into a file
reference whenever the buffer had 5+ newlines, regardless of how
those lines were entered. This meant manually typing with Alt+Enter
would trigger the paste heuristic and silently replace the user's
carefully typed input.

Track the previous buffer length and only treat a change as a paste
when more than one character is added at once (real pastes insert many
characters in a single event, while typing adds one at a time).
@teknium1 teknium1 merged commit 9061c03 into NousResearch:main Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants