Skip to content

[Bug]: Ctrl+C Copy/Interrupt Conflict in CLI #16181

@0xharryriddle

Description

@0xharryriddle

Bug Description

In the Hermes CLI (prompt_toolkit-based terminal interface), pressing Ctrl+C triggers an interrupt signal that stops the agent, making it impossible to use the standard terminal copy shortcut (Ctrl+C on macOS, Ctrl+Shift+C on Linux/Windows) to copy text from the terminal output. This creates a usability conflict: users cannot copy errors, logs, or agent responses without first interrupting the agent.

The TUI (xterm.js-based interface) already handles this correctly by checking if text is selected before treating Ctrl+C as an interrupt.

Steps to Reproduce

  1. Start Hermes in CLI mode: hermes
  2. Let the agent run a task that produces output
  3. Try to select and copy text using the terminal emulator's copy shortcut:
    • On macOS: Cmd+C (or Ctrl+C if terminal is configured)
    • On Linux/Windows: Ctrl+Shift+C
  4. Observe that pressing the copy shortcut triggers an interrupt instead of copying
  5. The agent stops, and the text is not copied

Expected Behavior

  • Copy shortcuts should work to copy text from the terminal without interrupting the agent
  • Interrupt should still be available via a dedicated shortcut (Ctrl+C or alternative)
  • Platform conventions should be respected:
    • macOS: Cmd+C copies, Ctrl+C interrupts
    • Linux/Windows: Ctrl+Shift+C copies, Ctrl+C interrupts
    • When text is selected, copy should take precedence over interrupt (TUI already does this)

Actual Behavior

  • Ctrl+C is always captured as an interrupt signal by prompt_toolkit
  • Terminal emulator's native copy mechanism never receives the keystroke
  • Users must interrupt the agent before they can copy text, disrupting workflow

Affected Component

CLI (interactive chat)

Messaging Platform (if gateway-related)

N/A (CLI only)

Debug Report

Debug report uploaded:
  Report     https://paste.rs/lLfqv
  agent.log  https://dpaste.com/3UKJPD6PB

Operating System

Ubuntu 24.04

Python Version

No response

Hermes Version

No response

Additional Logs / Traceback (optional)

Root Cause Analysis (optional)

No response

Proposed Fix (optional)

  1. Add new config option display.copy_shortcut with values: auto (platform-aware), ctrl_c, ctrl_shift_c, disabled
  2. Add @kb.add('c-S-c') handler (Ctrl+Shift+C) that does nothing — allows terminal to handle copy natively
  3. Add @kb.add('c-q') handler (Ctrl+Q) as alternative interrupt/exit shortcut
  4. Keep @kb.add('c-c') handler as primary interrupt (config-aware: if copy_shortcut is ctrl_shift_c on non-macOS, Ctrl+C remains interrupt; if ctrl_c then Ctrl+C becomes copy and Ctrl+Q becomes interrupt)
  5. Update documentation (CHANGELOG.md, TUI hotkeys.ts, AGENTS.md)

Platform defaults for auto:

  • macOS: Cmd+C copies (terminal-native), Ctrl+C interrupts
  • Linux/Windows: Ctrl+Shift+C copies (terminal-native), Ctrl+C interrupts
  • Users can override to suit their terminal emulator or preference

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/cliCLI entry point, hermes_cli/, setup wizardtype/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions