Skip to content

feat: add /copy shortcut to copy the current conversation to clipboard - #565

Merged
edenreich merged 3 commits into
mainfrom
feat/copy-shortcut-562
Jun 1, 2026
Merged

edenreich merged 3 commits into
mainfrom
feat/copy-shortcut-562

Conversation

@edenreich

@edenreich edenreich commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Implements a built-in /copy chat shortcut that copies the current conversation to the system clipboard, cross-platform. This pairs with /compact so a session can be moved to another terminal/machine and continued there.

Closes #562.

What it does

  • /copy copies the current conversation to the clipboard (default plain text).
  • /copy markdown and /copy json override the format (reuses the same export formats as /export).
  • The status line confirms what was copied, e.g. • Copied conversation to clipboard (text, 1234 bytes, 56 lines).
  • Graceful messaging for the empty-conversation case and when no clipboard utility is available.

How it works

  • New CGO-free internal/clipboard/text package shells out via os/exec to the platform's native clipboard utility, trying each in priority order and falling through if one is missing:
    • macOS → pbcopy
    • Linux → wl-copy (Wayland) → xclip → xsel (X11) → clip.exe (WSL)
    • Windows → clip
    • This avoids CGO entirely (the repo deliberately stays CGO-free), so it adds no new dependencies. The existing internal/clipboard package is macOS/CGO-only and image-focused, so it is intentionally left untouched.
  • CopyShortcut reuses ConversationRepository.Export(format) and is wired into the service container's registerDefaultCommands(). /help and tab-completion pick it up automatically via the shortcut registry — no extra wiring.
  • The clipboard writer is injected through a small package-local ClipboardWriter interface, so unit tests never touch the real clipboard or shell out, and no new domain mock (counterfeiter) is needed.

Testing

  • internal/shortcuts/copy_test.go — table-driven: empty conversation, successful default copy (asserts exact bytes + format + byte/line count), format routing (text/txt/markdown/md/json/uppercase), unknown format, export error, clipboard error, metadata/CanExecute arity.
  • internal/clipboard/text/text_test.go — candidate ordering per OS and the "no utility found" path (via a PATH-stub so exec.LookPath fails) — CI/headless safe.
  • Verified a real pbcopy/pbpaste round-trip locally on macOS (throwaway test, not committed).
  • task build, task test, task lint (golangci-lint 0 issues + markdownlint), and go vet all pass; go mod tidy is a no-op.

Docs

  • docs/shortcuts-guide.md — added /copy to Core Shortcuts plus a "Copy Shortcut" subsection describing the /compact → /copy workflow and per-platform utility requirements.
  • README.md — added /copy to the Core built-in shortcuts list.
  • cspell.yaml — added pbcopy, xclip, xsel.

@edenreich
edenreich requested a review from a team as a code owner June 1, 2026 09:52
Implements a built-in /copy chat shortcut that copies the current
conversation to the system clipboard, pairing with /compact so a session
can be moved to another terminal and continued there (closes #562).

- New CGO-free internal/clipboard/text package shells out to the native
  clipboard utility (pbcopy / wl-copy / xclip / xsel / clip / clip.exe),
  trying each in priority order and falling through if one is missing.
- New CopyShortcut reuses ConversationRepository.Export; default format is
  plain text, with /copy markdown and /copy json overrides. The clipboard
  writer is injected via a package-local interface so tests never touch the
  real clipboard or shell out, and no new domain mock is required.
- Registered in the service container; /help and tab-completion pick it up
  automatically via the shortcut registry.
- Documented in the shortcuts guide and README; added utility names to the
  cspell word list.
@edenreich
edenreich force-pushed the feat/copy-shortcut-562 branch from 5dca9e5 to 5679174 Compare June 1, 2026 09:55
Comment thread internal/clipboard/text/text_test.go Resolved
Comment thread internal/shortcuts/copy_test.go Resolved
@edenreich
edenreich merged commit bdfe618 into main Jun 1, 2026
@edenreich
edenreich deleted the feat/copy-shortcut-562 branch June 1, 2026 10:24
inference-gateway-releaser Bot pushed a commit that referenced this pull request Jun 1, 2026
## [0.116.0](v0.115.2...v0.116.0) (2026-06-01)

### 🚀 Features

* add /copy shortcut to copy the current conversation to clipboard ([#565](#565)) ([bdfe618](bdfe618))
* **stt:** add Whisper speech-to-text for chat /voice and Telegram voice ([2f3828a](2f3828a)), closes [#559](#559)
* regenerate config ([ae43e7f](ae43e7f))

### 👷 CI/CD

* centralize claude.yml via reusable workflow ([#557](#557)) ([3d48856](3d48856))
* centralize claude.yml via reusable workflow ([#558](#558)) ([affc7a1](affc7a1))
* centralize claude.yml via reusable workflow ([#563](#563)) ([feaeeb0](feaeeb0))
* centralize infer.yml via reusable workflow ([#564](#564)) ([2b80aed](2b80aed))
* **claude:** standardize workflow + task-based branch prefix ([2d256d0](2d256d0))

### 🧹 Maintenance

* **deps:** add whisper-cpp and ffmpeg to flox env ([2652e99](2652e99))
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.116.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Implement /copy shortcut to allow copying the current chat session to the clipboard

1 participant