Skip to content

Add a bracketed paste transformer hook#113

Open
M09Ic wants to merge 1 commit into
reeflective:masterfrom
M09Ic:pr/readline-paste-transformer
Open

Add a bracketed paste transformer hook#113
M09Ic wants to merge 1 commit into
reeflective:masterfrom
M09Ic:pr/readline-paste-transformer

Conversation

@M09Ic

@M09Ic M09Ic commented Jun 27, 2026

Copy link
Copy Markdown

Background

Interactive AI and command consoles often need to handle large multiline pastes differently from normal typing. A common UX is the Claude Code-style paste reference: the editable prompt shows a compact placeholder such as [Pasted text #1 +6 lines], while the application keeps the original pasted payload and expands it later when executing or sending the request.

Today readline normalizes a bracketed paste and inserts it directly into the line buffer. Applications that want the placeholder/reference behavior have to duplicate paste handling or patch readline internals.

Approach

  • Add Shell.PasteTransformer and SetPasteTransformer.
  • Route bracketed paste insertion through a helper that preserves the existing CRLF/CR normalization.
  • Let applications rewrite the pasted payload before insertion, including replacing it with a placeholder like [Pasted text #1 +6 lines].
  • Treat an empty transformed string as "do not insert".

The reference store and later expansion are intentionally left to the application layer. Readline only provides the safe hook at the point where terminal paste has already been read and normalized.

Tests

  • Added coverage that the transformer receives normalized text.
  • Added coverage that a transformer can rewrite or drop pasted text.
  • Ran go test ./...

@codecov

codecov Bot commented Jun 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.37%. Comparing base (088046b) to head (77de7c1).

Files with missing lines Patch % Lines
shell.go 50.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #113      +/-   ##
==========================================
+ Coverage   38.33%   38.37%   +0.03%     
==========================================
  Files          59       59              
  Lines        9516     9525       +9     
==========================================
+ Hits         3648     3655       +7     
- Misses       5785     5786       +1     
- Partials       83       84       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant