hermes - ✅(Solved) Fix /copy command does not work on macOS Terminal.app (OSC 52 not supported) [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#15664Fetched 2026-04-26 05:25:55
View on GitHub
Comments
0
Participants
1
Timeline
5
Reactions
0
Participants
Timeline (top)
labeled ×4cross-referenced ×1

Error Message

def _write_osc52_clipboard(self, text: str) -> None: # ... existing OSC 52 code ...

# Fallback for terminals that don't support OSC 52 (e.g. Terminal.app)
import subprocess as _sp
import platform as _platform
try:
    if _platform.system() == 'Darwin':
        _sp.run(['pbcopy'], input=text.encode('utf-8'), check=True, timeout=3)
    elif _platform.system() == 'Linux':
        # try xclip / xsel
        ...
except Exception:
    pass  # OSC 52 already sent, native fallback failure is non-fatal

Fix Action

Fix / Workaround

Workaround (for users hitting this now)

The fix can be applied locally to ~/.hermes/hermes-agent/cli.py until it lands upstream. Note that hermes update will overwrite the patch.

PR fix notes

PR #15856: fix(cli): /copy falls back to native clipboard on OSC 52-blind terminals

Description (problem / solution / changelog)

Summary

  • macOS Terminal.app silently swallows OSC 52, so `/copy` reported success while the host clipboard never changed (#15664).
  • Add `_write_native_clipboard()` that runs alongside the existing OSC 52 write, picking the right helper per platform: `pbcopy` (macOS), `wl-copy`/`xclip`/`xsel` (Linux), `clip` (Windows).
  • The command now reports success when either OSC 52 or the native helper lands, so SSH/tmux scenarios still work and Terminal.app users finally get a real copy.

Test plan

  • `pytest tests/cli/test_cli_copy_command.py` — 11 passed
    • 4 existing tests updated to patch both clipboard writers
    • 5 new tests for `_write_native_clipboard` per platform
    • 2 new tests for the success/failure logic (success when only native works; failure only when both fail)

Closes #15664

🤖 Generated with Claude Code

Changed files

  • cli.py (modified, +52/-2)
  • scripts/release.py (modified, +1/-0)
  • tests/cli/test_cli_copy_command.py (modified, +103/-8)

Code Example

def _write_osc52_clipboard(self, text: str) -> None:
    # ... existing OSC 52 code ...

    # Fallback for terminals that don't support OSC 52 (e.g. Terminal.app)
    import subprocess as _sp
    import platform as _platform
    try:
        if _platform.system() == 'Darwin':
            _sp.run(['pbcopy'], input=text.encode('utf-8'), check=True, timeout=3)
        elif _platform.system() == 'Linux':
            # try xclip / xsel
            ...
    except Exception:
        pass  # OSC 52 already sent, native fallback failure is non-fatal
RAW_BUFFERClick to expand / collapse

Problem

On macOS Terminal.app, the /copy command silently fails to copy text to the clipboard.

The current implementation in _write_osc52_clipboard relies exclusively on the OSC 52 escape sequence. Terminal.app does not support OSC 52 (unlike iTerm2 or Warp), so the sequence is sent but has no effect — the user gets the success message but the clipboard is unchanged.

Steps to reproduce

  1. Open Hermes TUI in macOS Terminal.app (hermes)
  2. Ask anything, wait for a response
  3. Type /copy and press Enter
  4. Try to paste — clipboard is empty

Expected behavior

The last assistant response is copied to the clipboard.

Environment

  • macOS 15.x
  • Terminal.app (built-in, no iTerm2)
  • Hermes Agent v0.11.0
  • mouse_support=False is already set (not the cause)

Suggested fix

Add a native clipboard fallback after the OSC 52 attempt. On macOS, pbcopy is always available and requires no extra dependencies:

def _write_osc52_clipboard(self, text: str) -> None:
    # ... existing OSC 52 code ...

    # Fallback for terminals that don't support OSC 52 (e.g. Terminal.app)
    import subprocess as _sp
    import platform as _platform
    try:
        if _platform.system() == 'Darwin':
            _sp.run(['pbcopy'], input=text.encode('utf-8'), check=True, timeout=3)
        elif _platform.system() == 'Linux':
            # try xclip / xsel
            ...
    except Exception:
        pass  # OSC 52 already sent, native fallback failure is non-fatal

This is a two-line fix with zero new dependencies on macOS and gracefully degrades if pbcopy is somehow unavailable.

Workaround (for users hitting this now)

The fix can be applied locally to ~/.hermes/hermes-agent/cli.py until it lands upstream. Note that hermes update will overwrite the patch.

extent analysis

TL;DR

To fix the issue of the /copy command silently failing to copy text to the clipboard in macOS Terminal.app, add a native clipboard fallback using pbcopy after the OSC 52 attempt.

Guidance

  • The current implementation relies on the OSC 52 escape sequence, which is not supported by Terminal.app, so a fallback is necessary.
  • The suggested fix involves adding a try-except block to use pbcopy on macOS if the OSC 52 attempt fails.
  • To apply the fix locally, modify the ~/.hermes/hermes-agent/cli.py file, but note that hermes update will overwrite the patch.
  • Consider implementing a similar fallback for Linux using xclip or xsel.

Example

The provided code snippet demonstrates how to use pbcopy as a fallback:

import subprocess as _sp
import platform as _platform
try:
    if _platform.system() == 'Darwin':
        _sp.run(['pbcopy'], input=text.encode('utf-8'), check=True, timeout=3)

Notes

The fix is specific to macOS and Terminal.app, and may not apply to other environments or terminals.

Recommendation

Apply the workaround by modifying the ~/.hermes/hermes-agent/cli.py file until the fix is available upstream, as it provides a reliable fallback for copying text to the clipboard.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

The last assistant response is copied to the clipboard.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING