tui: /copy + Ctrl+Y copy an assistant reply's raw markdown to the clipboard#363
Open
erain wants to merge 1 commit into
Open
tui: /copy + Ctrl+Y copy an assistant reply's raw markdown to the clipboard#363erain wants to merge 1 commit into
erain wants to merge 1 commit into
Conversation
…pboard (closes #362) Selecting an assistant reply out of the terminal dragged in glamour styling (ANSI codes, box-drawing, wrapped/indented lines), so the paste was mangled. The transcript already keeps each reply's raw markdown in transcriptItem.Text, separate from the glamour-rendered Rendered field — this plumbs that clean text to the system clipboard. - /copy [N]: copies the last assistant reply, or reply N (1-based over assistant turns), as raw markdown. Added to slashSpecs so it shows in /help and the / picker. - Ctrl+Y: the no-arg form of /copy, handled in handleInputKey before the pickers and textarea so it fires from any input state. - Delivery via OSC 52 (go-osc52, promoted to a direct dep) written to the tty — works locally and over SSH with no external binary, and doesn't fight bubbletea's alt-screen stdout renderer. - Pure pickCopyTarget keeps the numbering/bounds logic unit-testable. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
glue-reviewNo concerns — LGTM. 🤖 Posted by glue-review. |
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.
Closes #362.
Problem
Copying an assistant reply out of the TUI to paste elsewhere was painful: terminal selection drags in glamour styling (ANSI codes, box-drawing, wrapped/indented lines), so the pasted text came out mangled.
Fix
The clean source already exists — the transcript keeps each assistant item's raw markdown in
transcriptItem.Text, separate from the glamour-renderedRendered(finalized inhandleTurnDone). This plumbs that raw text to the system clipboard./copy [N]— copies the last assistant reply, or replyN(1-based over assistant turns, tool-only turns skipped). Listed inslashSpecs()so it shows in/helpand the/picker./copy, handled inhandleInputKeybefore the pickers/textarea so it fires from any input state.go-osc52, promoted from indirect to direct dep), written to the tty. Works locally and over SSH with no external binary (unlike pbcopy/xclip), and doesn't fight bubbletea's alt-screen stdout renderer.· copied last reply (1234 chars) to clipboard.system line confirms; friendly messages when there's no reply yet orNis out of range.Tests
pickCopyTargetfactored out as a pure function: covers default-is-last, explicit N, trimming, and the zero/too-high/non-numeric bounds.assistantTextsskips blank/tool-only turns and non-assistant items.copyToClipboardasserts the OSC 52 envelope + base64 payload (clipboard writer is overridable in tests).runSlashCopyconfirmation + empty-transcript paths.TestSlashMatchesStayAlphabeticalfor the new/c→copymatch.Full
go test ./...,gofmt, andgo vetare green. README + CHANGELOG updated.🤖 Generated with Claude Code