Skip to content

fix(tui): native clipboard fallback for /copy command (salvage #15963)#20159

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-0904f8fc
May 5, 2026
Merged

fix(tui): native clipboard fallback for /copy command (salvage #15963)#20159
teknium1 merged 2 commits into
mainfrom
hermes/hermes-0904f8fc

Conversation

@teknium1

@teknium1 teknium1 commented May 5, 2026

Copy link
Copy Markdown
Contributor

Summary

/copy <n> on assistant messages now hits the system clipboard on GNOME Terminal / Wayland / X11 / WSL / Windows instead of silently emitting an OSC52 that VTE-based terminals don't honor.

Changes

  • ui-tui/src/lib/clipboard.ts: extend writeClipboardText() beyond macOS-only — now tries pbcopy / powershell / powershell.exe (WSL) / wl-copy / xclip / xsel before returning false. Aligns WSL detection (WSL_INTEROP or WSL_DISTRO_NAME) on read + write paths.
  • ui-tui/src/app/slash/commands/core.ts: /copy <n> now tries writeClipboardText() first, falls back to writeOsc52Clipboard() only if no native backend worked, and reports honest status.
  • ui-tui/src/__tests__/clipboard.test.ts: coverage for each backend + fallback chain.

Validation

  • npm test -- src/__tests__/clipboard.test.ts src/__tests__/createSlashHandler.test.ts — 66/66 passing.
  • Pre-existing terminalSetup.test.ts failures on main are unrelated (verified on clean origin/main).

Salvage of #15963 by @bjianhang onto current main. Closes #18308.

@teknium1 teknium1 merged commit 2785355 into main May 5, 2026
9 of 10 checks passed
@teknium1 teknium1 deleted the hermes/hermes-0904f8fc branch May 5, 2026 10:59
@alt-glitch alt-glitch added type/bug Something isn't working comp/tui Terminal UI (ui-tui/ + tui_gateway/) P2 Medium — degraded but workaround exists labels May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tui Terminal UI (ui-tui/ + tui_gateway/) P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TUI (--tui): Copy/paste from terminal does not work on GNOME Terminal

3 participants