Skip to content

FEAT: copy displayed commands to the clipboard - #59

Merged
merefield merged 1 commit into
mainfrom
feat/command-clipboard
Nov 27, 2026
Merged

merefield merged 1 commit into
mainfrom
feat/command-clipboard

Conversation

@merefield

Copy link
Copy Markdown
Owner

Behavior

  • Type c at the normal [y/e/c/t/N] execution prompt, the danger-zone confirmation, or the shell-handoff prompt. CLAI copies the current command and shows the same prompt again.
  • Run clai copy after a one-shot request or /copy inside a CLAI session. It uses the latest recorded request and can pick up an edited or executed command, a declined proposal, or a shell example from advice. When that request contains only prose, CLAI reports that there is no command to copy.
  • Copy works without a provider call. The exact text of edited commands and structured examples is stored in local history. CLAI uses local clipboard helpers where available and can send an OSC 52 request through the visible terminal, including over SSH.

Verification

  • go test -race ./..., go vet ./..., and the production duplication check passed locally.
  • Regression tests cover copy and reprompt, the latest saved request, edits with result sharing off, advice-only replies, and existing history.
  • A CLI smoke test verified that the clipboard helper and OSC 52 receive the exact multiline Unicode command.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The platform-specific clipboard integrations across macOS, Windows/WSL, Wayland/X11, and SSH OSC 52 require runtime validation across environments that repository-visible source review and tests cannot fully provide.

No open issues 🎉

What changed in this PR

Adds clipboard support for proposed, edited, executed, declined, and advice-only commands while preserving copyable metadata in local history without exposing it to providers.

Changes:

  • Adds clai copy, /copy, and c prompt actions.
  • Persists and retrieves the latest copyable command or shell example.
  • Adds platform clipboard helpers and OSC 52 terminal fallback.
  • Updates prompts, documentation, tests, and the Goldmark dependency.
File Description
README.md Documents the new copy command, prompt options, and clipboard behavior.
internal/​model/​model.go Adds provider-excluded local copy metadata to messages.
internal/​history/​store.go Persists and reloads copy metadata in history records.
internal/​history/​store_test.go Tests latest-command selection and provider metadata exclusion.
internal/​history/​commands.go Extracts the latest command or shell example from history.
internal/​clipboard/​clipboard.go Implements platform clipboard helpers and OSC 52 terminal fallback.
internal/​app/​terminal_handoff.go Adds copy-and-reprompt support to shell handoff prompts.
internal/​app/​terminal_handoff_test.go Updates handoff tests for context-aware prompt handling.
internal/​app/​prompts.go Guides providers toward tagged shell examples for extraction.
internal/​app/​clipboard.go Connects history lookup, clipboard copying, and prompt reprompting.
internal/​app/​clipboard_test.go Tests copying at prompts and from saved requests.
internal/​app/​app.go Integrates copy commands, history recording, and copy prompt actions.
go.mod Promotes Goldmark to a direct dependency for shell-example parsing.
cmd/​clai/​main.go Mentions clai copy in the CLI help text.

Review effort: Lite

@merefield
merefield merged commit f248dc1 into main Nov 27, 2026
8 checks passed
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.

2 participants