feat(cli): add /copy for last assistant → clipboard#190
Merged
emal-avala merged 1 commit intomainfrom Apr 23, 2026
Merged
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Pipes the text content of the most recent assistant message into the platform clipboard via a subprocess. Probes candidates in least-surprise order: macOS → pbcopy Windows → clip Wayland → wl-copy, then xclip, then xsel X11 → xclip, then xsel, then wl-copy Prints a confirmation with byte count and the tool used, or a helpful error listing install options when nothing is on PATH. Zero dependencies — uses std::process::Command rather than pulling in an arboard-style crate. The trade-off is one spawned subprocess per /copy, which is irrelevant for an interactive command. Useful for grabbing a generated diff, regex, or code snippet out of the transcript without scrolling-and-select in the terminal.
emal-avala
added a commit
that referenced
this pull request
Apr 23, 2026
Windows' CreateProcess finds clip.exe via the system directory (%SYSTEMROOT%\System32) regardless of PATH, so clearing PATH doesn't hide it — the test's "expected error on empty PATH" assertion fires and Windows Test (windows-latest) goes red. Gate the test behind `#[cfg(not(target_os = "windows"))]`. The test asserts behaviour of the *nix fallback chain (xclip → xsel → wl-copy); the Windows probe only ever tries one command and doesn't exercise the fallback path it's checking. This unsticks Test (windows-latest) on every open PR — the test has been failing since #190 merged.
emal-avala
added a commit
that referenced
this pull request
Apr 23, 2026
Windows' CreateProcess finds clip.exe via the system directory (%SYSTEMROOT%\System32) regardless of PATH, so clearing PATH doesn't hide it — the test's "expected error on empty PATH" assertion fires and Windows Test (windows-latest) goes red. Gate the test behind `#[cfg(not(target_os = "windows"))]`. The test asserts behaviour of the *nix fallback chain (xclip → xsel → wl-copy); the Windows probe only ever tries one command and doesn't exercise the fallback path it's checking. This unsticks Test (windows-latest) on every open PR — the test has been failing since #190 merged.
emal-avala
added a commit
that referenced
this pull request
Apr 23, 2026
Windows' CreateProcess finds clip.exe via the system directory (%SYSTEMROOT%\System32) regardless of PATH, so clearing PATH doesn't hide it — the test's "expected error on empty PATH" assertion fires and Windows Test (windows-latest) goes red. Gate the test behind `#[cfg(not(target_os = "windows"))]`. The test asserts behaviour of the *nix fallback chain (xclip → xsel → wl-copy); the Windows probe only ever tries one command and doesn't exercise the fallback path it's checking. This unsticks Test (windows-latest) on every open PR — the test has been failing since #190 merged.
emal-avala
added a commit
that referenced
this pull request
Apr 23, 2026
Windows' CreateProcess finds clip.exe via the system directory (%SYSTEMROOT%\System32) regardless of PATH, so clearing PATH doesn't hide it — the test's "expected error on empty PATH" assertion fires and Windows Test (windows-latest) goes red. Gate the test behind `#[cfg(not(target_os = "windows"))]`. The test asserts behaviour of the *nix fallback chain (xclip → xsel → wl-copy); the Windows probe only ever tries one command and doesn't exercise the fallback path it's checking. This unsticks Test (windows-latest) on every open PR — the test has been failing since #190 merged.
emal-avala
added a commit
that referenced
this pull request
Apr 23, 2026
Windows' CreateProcess finds clip.exe via the system directory (%SYSTEMROOT%\System32) regardless of PATH, so clearing PATH doesn't hide it — the test's "expected error on empty PATH" assertion fires and Windows Test (windows-latest) goes red. Gate the test behind `#[cfg(not(target_os = "windows"))]`. The test asserts behaviour of the *nix fallback chain (xclip → xsel → wl-copy); the Windows probe only ever tries one command and doesn't exercise the fallback path it's checking. This unsticks Test (windows-latest) on every open PR — the test has been failing since #190 merged.
emal-avala
added a commit
that referenced
this pull request
Apr 23, 2026
Windows' CreateProcess finds clip.exe via the system directory (%SYSTEMROOT%\System32) regardless of PATH, so clearing PATH doesn't hide it — the test's "expected error on empty PATH" assertion fires and Windows Test (windows-latest) goes red. Gate the test behind `#[cfg(not(target_os = "windows"))]`. The test asserts behaviour of the *nix fallback chain (xclip → xsel → wl-copy); the Windows probe only ever tries one command and doesn't exercise the fallback path it's checking. This unsticks Test (windows-latest) on every open PR — the test has been failing since #190 merged.
emal-avala
added a commit
that referenced
this pull request
Apr 23, 2026
Windows' CreateProcess finds clip.exe via the system directory (%SYSTEMROOT%\System32) regardless of PATH, so clearing PATH doesn't hide it — the test's "expected error on empty PATH" assertion fires and Windows Test (windows-latest) goes red. Gate the test behind `#[cfg(not(target_os = "windows"))]`. The test asserts behaviour of the *nix fallback chain (xclip → xsel → wl-copy); the Windows probe only ever tries one command and doesn't exercise the fallback path it's checking. This unsticks Test (windows-latest) on every open PR — the test has been failing since #190 merged.
emal-avala
added a commit
that referenced
this pull request
Apr 23, 2026
Windows' CreateProcess finds clip.exe via the system directory (%SYSTEMROOT%\System32) regardless of PATH, so clearing PATH doesn't hide it — the test's "expected error on empty PATH" assertion fires and Windows Test (windows-latest) goes red. Gate the test behind `#[cfg(not(target_os = "windows"))]`. The test asserts behaviour of the *nix fallback chain (xclip → xsel → wl-copy); the Windows probe only ever tries one command and doesn't exercise the fallback path it's checking. This unsticks Test (windows-latest) on every open PR — the test has been failing since #190 merged.
emal-avala
added a commit
that referenced
this pull request
Apr 23, 2026
Windows' CreateProcess finds clip.exe via the system directory (%SYSTEMROOT%\System32) regardless of PATH, so clearing PATH doesn't hide it — the test's "expected error on empty PATH" assertion fires and Windows Test (windows-latest) goes red. Gate the test behind `#[cfg(not(target_os = "windows"))]`. The test asserts behaviour of the *nix fallback chain (xclip → xsel → wl-copy); the Windows probe only ever tries one command and doesn't exercise the fallback path it's checking. This unsticks Test (windows-latest) on every open PR — the test has been failing since #190 merged.
emal-avala
added a commit
that referenced
this pull request
Apr 23, 2026
Windows' CreateProcess finds clip.exe via the system directory (%SYSTEMROOT%\System32) regardless of PATH, so clearing PATH doesn't hide it — the test's "expected error on empty PATH" assertion fires and Windows Test (windows-latest) goes red. Gate the test behind `#[cfg(not(target_os = "windows"))]`. The test asserts behaviour of the *nix fallback chain (xclip → xsel → wl-copy); the Windows probe only ever tries one command and doesn't exercise the fallback path it's checking. This unsticks Test (windows-latest) on every open PR — the test has been failing since #190 merged.
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
New
/copyslash command: pipes the text content of the most recent assistant message into the platform clipboard via a subprocess.Why
Grabbing a generated diff, regex, shell command, or code snippet out of the transcript currently requires scrolling-and-selecting in the terminal, which mangles line breaks and picks up ANSI sequences.
/copyis one keystroke and preserves bytes exactly.How
Probes clipboard commands in least-surprise order for each platform:
pbcopyclip$WAYLAND_DISPLAYwl-copy,xclip,xselxclip,xsel,wl-copyPipes via
std::process::Commandstdin. No new dependencies — keeps the crate surface small at the cost of one spawned subprocess per invocation (irrelevant for an interactive command).Returns a helpful error listing install options if nothing is on PATH:
Test plan
cargo fmt --all— cleancargo clippy --workspace --all-targets -- -D warnings— cleancargo test -p agent-code --bin agent copy_to_clipboard— 1/1 pass (copy_to_clipboard_errors_with_empty_path)cargo test -p agent-code --test smoke— 3/3 pass/copyafter a turn places the text on the primary clipboard (xclip -selection clipboard -oechoes it back)