feat(cli): preserve user input on multiline paste, treat paste blocks as solid objects#2607
Closed
crazywriter1 wants to merge 1 commit into
Closed
Conversation
… as solid objects - Move paste collapsing into handle_paste (BracketedPaste handler) so only the pasted content is saved to file; existing buffer text is kept - Insert paste placeholder at cursor position with newline separator instead of replacing the entire buffer - Add _paste_just_collapsed flag to prevent _on_text_changed fallback from double-collapsing when bracketed paste already handled it - Left/Right arrow keys jump over paste reference blocks as solid objects - Backspace/Delete remove entire paste reference block at once - Support multiple paste blocks in a single input buffer - Expand all paste references inline on submit (re.sub instead of re.match), preserving surrounding user text - Add 22 unit tests covering paste collapse, expansion, cursor navigation, and deletion behavior Closes NousResearch#2404 Made-with: Cursor
teknium1
added a commit
that referenced
this pull request
Mar 25, 2026
When pasting 5+ lines, the CLI previously replaced the entire input buffer with a file reference placeholder. If the user had already typed a question, it was lost. Fix: move paste collapsing into handle_paste (BracketedPaste handler) so only the pasted content is saved to file. The placeholder is inserted at the cursor position, preserving existing buffer text. Also fixes: - Multi-ref expansion on submit (re.sub instead of re.match) so multiple paste blocks and surrounding text are all preserved - Double-collapse prevention via _paste_just_collapsed flag - Consistent Unicode arrow character across all paste paths Salvaged from PR #2607 by crazywriter1 (option B: core fix only, without keybinding overrides for solid-object navigation/deletion).
Contributor
|
The core fix (preserve text on paste + multi-ref expansion + double-collapse prevention) was merged via salvage PR. The keybinding overrides for solid-object navigation/deletion were omitted to keep complexity down. Thanks @crazywriter1! |
teknium1
added a commit
that referenced
this pull request
Mar 25, 2026
When pasting 5+ lines, the CLI previously replaced the entire input buffer with a file reference placeholder. If the user had already typed a question, it was lost. Fix: move paste collapsing into handle_paste (BracketedPaste handler) so only the pasted content is saved to file. The placeholder is inserted at the cursor position, preserving existing buffer text. Also fixes: - Multi-ref expansion on submit (re.sub instead of re.match) so multiple paste blocks and surrounding text are all preserved - Double-collapse prevention via _paste_just_collapsed flag - Consistent Unicode arrow character across all paste paths Salvaged from PR #2607 by crazywriter1 (option B: core fix only, without keybinding overrides for solid-object navigation/deletion).
outsourc-e
pushed a commit
to outsourc-e/hermes-agent
that referenced
this pull request
Mar 26, 2026
When pasting 5+ lines, the CLI previously replaced the entire input buffer with a file reference placeholder. If the user had already typed a question, it was lost. Fix: move paste collapsing into handle_paste (BracketedPaste handler) so only the pasted content is saved to file. The placeholder is inserted at the cursor position, preserving existing buffer text. Also fixes: - Multi-ref expansion on submit (re.sub instead of re.match) so multiple paste blocks and surrounding text are all preserved - Double-collapse prevention via _paste_just_collapsed flag - Consistent Unicode arrow character across all paste paths Salvaged from PR NousResearch#2607 by crazywriter1 (option B: core fix only, without keybinding overrides for solid-object navigation/deletion).
angelburgosrosado
pushed a commit
to angelburgosrosado/hermes-agent
that referenced
this pull request
Apr 27, 2026
When pasting 5+ lines, the CLI previously replaced the entire input buffer with a file reference placeholder. If the user had already typed a question, it was lost. Fix: move paste collapsing into handle_paste (BracketedPaste handler) so only the pasted content is saved to file. The placeholder is inserted at the cursor position, preserving existing buffer text. Also fixes: - Multi-ref expansion on submit (re.sub instead of re.match) so multiple paste blocks and surrounding text are all preserved - Double-collapse prevention via _paste_just_collapsed flag - Consistent Unicode arrow character across all paste paths Salvaged from PR NousResearch#2607 by crazywriter1 (option B: core fix only, without keybinding overrides for solid-object navigation/deletion).
02356abc
pushed a commit
to 02356abc/hermes-agent
that referenced
this pull request
May 14, 2026
When pasting 5+ lines, the CLI previously replaced the entire input buffer with a file reference placeholder. If the user had already typed a question, it was lost. Fix: move paste collapsing into handle_paste (BracketedPaste handler) so only the pasted content is saved to file. The placeholder is inserted at the cursor position, preserving existing buffer text. Also fixes: - Multi-ref expansion on submit (re.sub instead of re.match) so multiple paste blocks and surrounding text are all preserved - Double-collapse prevention via _paste_just_collapsed flag - Consistent Unicode arrow character across all paste paths Salvaged from PR NousResearch#2607 by crazywriter1 (option B: core fix only, without keybinding overrides for solid-object navigation/deletion).
olympus-terminal
pushed a commit
to olympus-terminal/hermes-agent
that referenced
this pull request
May 16, 2026
When pasting 5+ lines, the CLI previously replaced the entire input buffer with a file reference placeholder. If the user had already typed a question, it was lost. Fix: move paste collapsing into handle_paste (BracketedPaste handler) so only the pasted content is saved to file. The placeholder is inserted at the cursor position, preserving existing buffer text. Also fixes: - Multi-ref expansion on submit (re.sub instead of re.match) so multiple paste blocks and surrounding text are all preserved - Double-collapse prevention via _paste_just_collapsed flag - Consistent Unicode arrow character across all paste paths Salvaged from PR NousResearch#2607 by crazywriter1 (option B: core fix only, without keybinding overrides for solid-object navigation/deletion).
gweeteve
pushed a commit
to gweeteve/hermes-agent
that referenced
this pull request
Jun 2, 2026
When pasting 5+ lines, the CLI previously replaced the entire input buffer with a file reference placeholder. If the user had already typed a question, it was lost. Fix: move paste collapsing into handle_paste (BracketedPaste handler) so only the pasted content is saved to file. The placeholder is inserted at the cursor position, preserving existing buffer text. Also fixes: - Multi-ref expansion on submit (re.sub instead of re.match) so multiple paste blocks and surrounding text are all preserved - Double-collapse prevention via _paste_just_collapsed flag - Consistent Unicode arrow character across all paste paths Salvaged from PR NousResearch#2607 by crazywriter1 (option B: core fix only, without keybinding overrides for solid-object navigation/deletion).
Egavasyug
pushed a commit
to Egavasyug/hermes-agent
that referenced
this pull request
Jun 10, 2026
When pasting 5+ lines, the CLI previously replaced the entire input buffer with a file reference placeholder. If the user had already typed a question, it was lost. Fix: move paste collapsing into handle_paste (BracketedPaste handler) so only the pasted content is saved to file. The placeholder is inserted at the cursor position, preserving existing buffer text. Also fixes: - Multi-ref expansion on submit (re.sub instead of re.match) so multiple paste blocks and surrounding text are all preserved - Double-collapse prevention via _paste_just_collapsed flag - Consistent Unicode arrow character across all paste paths Salvaged from PR NousResearch#2607 by crazywriter1 (option B: core fix only, without keybinding overrides for solid-object navigation/deletion).
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 #2404
handle_paste(BracketedPaste handler) so only the pasted content is saved to file. Existing buffer text stays intact — the placeholder is inserted at the cursor position with a newline separator instead of replacing the entire buffer.[Pasted text ...]reference blocks as solid objects. If the cursor somehow lands inside a block (e.g. via Home key), it escapes on the next arrow press.re.match(single ref at buffer start) tore.sub(all refs expanded inline), preserving surrounding user text. Display shows user text + paste block count._paste_just_collapsedflag so the_on_text_changedheuristic (fallback for terminals without bracketed paste) doesn't double-collapse whenhandle_pastealready handled it.Test plan
tests/test_cli_paste_collapse.py— all passing