Skip to content

feat(cli): add /copy command for clipboard copy in TUI#2342

Open
Sskift wants to merge 1 commit into
esengine:v1from
Sskift:fix/cli-copy-paste
Open

feat(cli): add /copy command for clipboard copy in TUI#2342
Sskift wants to merge 1 commit into
esengine:v1from
Sskift:fix/cli-copy-paste

Conversation

@Sskift
Copy link
Copy Markdown

@Sskift Sskift commented May 30, 2026

Summary

Fixes the copy portion of #2260 — unable to copy content from the CLI TUI.

Changes

New: src/cli/ui/copy-history.ts

Card-to-text serialization covering all 18 card kinds: user, assistant, tool, reasoning, diff, plan, task, usage, memory, subagent, search, error, warn, live, ctx, tip, doctor, compaction.

/copy slash command

  • /copy (no args) → copies the latest completed assistant response
  • /copy all → copies the full serialized conversation
  • /copy N → copies the last N serializable chat items

Uses the existing writeClipboard() OSC 52 path with temp-file fallback for oversized content.

Guard: local TUI only

getCards is only exposed to the slash context when NOT running in a remote QQ/Telegram/Weixin channel — remote slash commands cannot trigger host-terminal clipboard writes.

Files changed

File Change
src/cli/ui/copy-history.ts NEW — card-to-text serialization
src/cli/ui/slash/commands.ts Added `/copy [all
src/cli/ui/slash/handlers/basic.ts Added /copy handler via OSC 52 clipboard
src/cli/ui/slash/types.ts Added getCards to SlashContext
src/cli/ui/App.tsx Wired getCards callback, guarded from remote channels
src/i18n/EN.ts Added i18n entries + /copy to keys reference

Verification

  • npm run typecheck
  • npm run lint

Add a new /copy slash command that extracts chat content through
OSC 52 clipboard (with temp-file fallback for oversized text).

- /copy (no args) → copies the latest assistant response
- /copy all → copies the serialized chat conversation
- /copy N → copies the last N serializable items

New src/cli/ui/copy-history.ts handles card-to-text serialization
covering all card kinds (user, assistant, tool, reasoning, diff,
plan, task, usage, memory, subagent, search, etc.).

/copy is restricted to local TUI sessions only — remote QQ/
Telegram/Weixin slash commands cannot trigger host clipboard writes.

Fixes esengine#2260 (copy portion)
@esengine esengine added the v1 Legacy TypeScript line (0.x) — v1 branch, maintenance only label May 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v1 Legacy TypeScript line (0.x) — v1 branch, maintenance only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants