fix(cli): smart paste — 6 review fixes (PR #4764 follow-up)#2
Closed
StefanIsMe wants to merge 2 commits intofeat/smart-paste-in-memoryfrom
Closed
fix(cli): smart paste — 6 review fixes (PR #4764 follow-up)#2StefanIsMe wants to merge 2 commits intofeat/smart-paste-in-memoryfrom
StefanIsMe wants to merge 2 commits intofeat/smart-paste-in-memoryfrom
Conversation
added 2 commits
April 3, 2026 17:22
…er reconstruction - Replace temp-file paste storage with in-memory _paste_store dict - Track active paste IDs in _active_paste_ids set for multi-paste support - Add _reconstruct_pastes() called at submit time to expand markers - Fix / bypass: now checks pasted_text (not buffer) starts with / - Add deletion detection: wiping any part of a paste marker wipes the whole block - Replace buf.insert_text() with buf.text = buf.text + placeholder to avoid post-cursor content being pushed to next line - Remove dependency on _hermes_home/pastes/ temp directory
…back Six bugs identified during PR NousResearch#4764 review, applied as an atomic commit: 1. DRY _make_paste_marker() helper — all 3 call sites (handle_paste, _on_text_changed, _reconstruct_pastes) now share one canonical function, eliminating the char vs line format mismatch that broke paste reconstruction. 2. MAX_PASTE_SIZE = 100_000 memory cap — pastes > 100 KB are inserted as plain text to prevent OOM from hoarding oversized payloads. 3. Deletion loop: remove early return — replaced with any_deleted flag so every active paste_id is checked per keystroke; one Delete can now clear multiple stale markers instead of stopping at the first match. 4. Fallback: store pasted_portion not full buffer — _on_text_changed now saves text[prev_len:] (the newly pasted chunk) rather than buf.text in its entirety, so pre-existing typed content is never hoisted into the paste store. 5. Unified _PASTE_MARKER_RE regex — _reconstruct_pastes uses a single regex matching both [+X line(s)] and [+X char(s)] formats, making it robust against any inconsistency between the bracketed-paste path and the fallback detection path. 6. Threshold aligned to 20 chars — both handle_paste and _on_text_changed now use char_count >= 20 as the collapse trigger, consistent with the documented contract.
a625209 to
3ae7bdf
Compare
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
Six bugs identified and fixed after review of NousResearch#4764. This is a stacked PR that builds directly on NousResearch#4764 (feat/smart-paste-in-memory).
Changes
Test plan
/cc @NousResearch/hermes-agent