Repository navigation
FEAT: copy displayed commands to the clipboard - #59
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🔵 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, andcprompt 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
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.
Behavior
cat 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.clai copyafter a one-shot request or/copyinside 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.Verification
go test -race ./...,go vet ./..., and the production duplication check passed locally.