feat(harness): /copy puts the last response on the clipboard, clean#27
Merged
Conversation
A mouse-selected copy carries the terminal's line wrapping, the renderer's indentation, and footer dividers. /copy sidesteps all of it by copying the last assistant turn's raw markdown source straight from history: clean by construction. It writes by two independent paths so the text lands locally or over SSH: the OSC 52 terminal sequence, plus a local clipboard tool (wl-copy/xclip/xsel/pbcopy/clip.exe) when one is on PATH, which is what makes it reliable through tmux. Reports which path ran, and says so when none can. Deliberately does not touch mouse selection: seizing mouse control would break the native scrollback, search, and tmux copy-mode the footer design preserves, and still could not reverse the terminal's soft-wraps.
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.
What
A new
/copycommand copies the last assistant response to the system clipboard as its raw markdown source.A mouse-selected copy of the rendered transcript carries baggage: the terminal's hard line-wrapping, the renderer's
>/indentation on tool and diff lines, and footer dividers if the selection overlaps them./copysidesteps all of it by copying the source straight from session history, so it is clean by construction.How
Two independent write paths, so the text lands whether sesh is local or over SSH and whether or not the terminal allows programmatic clipboard writes:
wl-copy,xclip,xsel,pbcopy,clip.exe): reliable locally and through tmux, which is the common case./copyreports which path(s) ran, and prints an actionable error when none can. Zero dependencies.Why not reformat a mouse selection
Considered and rejected. A native mouse selection belongs to the terminal; sesh sees nothing unless it seizes mouse control, which would break the native scrollback, search, and tmux copy-mode that the footer design exists to preserve, and even then could not reliably reverse the terminal's soft-wraps. Copying the source is strictly cleaner and keeps the core belief intact.
Tests
TestLastAssistantText— reaches past trailing tool/user turns and a tool-call-only (textless) assistant turn to the response the user actually saw; empty history yields nothing. Breaker: walk history forward, or drop the non-empty check.TestOSC52— pins the clipboard escape to the wire format terminals expect (ESC ] 52 ; c ; <base64> BEL), a real external contract./copyis registered in the singleslashCommandstable, so it tab-completes and appears in/helpandsesh -helpautomatically.gofmt/vetclean, full suite green.Note
Independent of #24 (the input editor). Branches off
main.