Skip to content

feat(cli): add /copy for last assistant → clipboard#190

Merged
emal-avala merged 1 commit intomainfrom
feat/copy
Apr 23, 2026
Merged

feat(cli): add /copy for last assistant → clipboard#190
emal-avala merged 1 commit intomainfrom
feat/copy

Conversation

@emal-avala
Copy link
Copy Markdown
Member

Summary

New /copy slash command: pipes the text content of the most recent assistant message into the platform clipboard via a subprocess.

> /copy
Copied 284 byte(s) to clipboard (via pbcopy).

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. /copy is one keystroke and preserves bytes exactly.

How

Probes clipboard commands in least-surprise order for each platform:

Platform Probe order
macOS pbcopy
Windows clip
Linux + $WAYLAND_DISPLAY wl-copy, xclip, xsel
Linux X11 xclip, xsel, wl-copy

Pipes via std::process::Command stdin. 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:

Failed to copy to clipboard: no clipboard command available on this platform
Install one of: pbcopy (macOS), xclip or xsel (Linux X11),
wl-copy (Wayland), or clip (Windows).

Test plan

  • cargo fmt --all — clean
  • cargo clippy --workspace --all-targets -- -D warnings — clean
  • cargo 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
  • Manual: on Linux+xclip, /copy after a turn places the text on the primary clipboard (xclip -selection clipboard -o echoes it back)

@chatgpt-codex-connector
Copy link
Copy Markdown

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 emal-avala merged commit 63652aa into main Apr 23, 2026
13 of 14 checks passed
@emal-avala emal-avala deleted the feat/copy branch April 23, 2026 02:44
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.
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