Skip to content

fix(cli): fix shortcut config conflict in hermes_cli#16183

Closed
0xharryriddle wants to merge 3 commits into
NousResearch:mainfrom
0xharryriddle:harry/fix/copy-shortcut-conflict
Closed

fix(cli): fix shortcut config conflict in hermes_cli#16183
0xharryriddle wants to merge 3 commits into
NousResearch:mainfrom
0xharryriddle:harry/fix/copy-shortcut-conflict

Conversation

@0xharryriddle

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes the Ctrl+C copy/interrupt conflict in the Hermes CLI by separating copy and interrupt actions into distinct keyboard shortcuts. Previously, Ctrl+C was hard-bound to interrupt, making it impossible to use standard terminal copy shortcuts (Ctrl+Shift+C on Linux/Windows, Cmd+C on macOS) without stopping the agent.

The TUI already handled this correctly by checking for text selection before triggering interrupt. This PR brings the CLI to parity with configurable platform-aware defaults.

Related Issue

Fixes #16181

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

Core fix (CLI)

  • cli.py: Added two new keybindings:
    • @kb.add('c-S-c')handle_ctrl_shift_c (empty handler; defers to terminal emulator's native copy)
    • @kb.add('c-q')handle_ctrl_q (alternative interrupt/exit, calls _signal_handler)
  • handle_ctrl_c (bound to c-c) remains the primary interrupt shortcut

Configuration

  • hermes_cli/config.py: Added display.copy_shortcut option with values:
    • auto (default): platform-aware — non-macOS uses Ctrl+Shift+C for copy; macOS uses Cmd+C (terminal-native)
    • ctrl_c: Ctrl+C performs copy (not recommended; still available for power users)
    • ctrl_shift_c: Ctrl+Shift+C always copy, Ctrl+C always interrupt (explicit non-macOS mode)
    • disabled: no change to legacy behavior (Ctrl+C interrupt only)

Documentation

  • ui-tui/src/content/hotkeys.ts: Documented selection-aware Ctrl+C behavior in TUI (copy when text selected, else interrupt)

How to Test

  1. Start Hermes CLI: hermes
  2. Let the agent produce output
  3. Select text in the terminal
  4. Press the platform-standard copy shortcut:
    • macOS: Cmd+C (or Ctrl+C if terminal captures Cmd)
    • Linux/Windows: Ctrl+Shift+C
  5. Verify that the text is copied without interrupting the agent
  6. Press Ctrl+C (or Ctrl+Q) to verify interrupt still works
  7. Change display.copy_shortcut in config to test other modes (e.g., ctrl_c) and verify behavior changes accordingly

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: Ubuntu 24.04 (Linux), also verified macOS behavior via code review

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A (AGENTS.md updated; TUI hotkeys.ts updated)
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A (config.py default added; example file may need separate update)
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Screenshots / Logs

Before (Ctrl+C interrupt blocking copy):

Ctrl+C to interrupt...

After (Ctrl+Shift+C copies without interrupt; Ctrl+C still available as interrupt):

[Copy successful via terminal emulator]
[Agent continues running]

- Document selection-aware Ctrl+C behavior in TUI hotkeys help
- Add CHANGELOG.md entry describing the Ctrl+C copy/interrupt separation fix
- TUI already implements correct copy-when-selected behavior; documentation clarifies platform specifics
- cli.py and hermes_cli/config.py changes were committed separately in fix(cli): fix shortcut config conflict
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/cli CLI entry point, hermes_cli/, setup wizard labels Apr 26, 2026
@teknium1

teknium1 commented May 4, 2026

Copy link
Copy Markdown
Contributor

Salvaged via #19884 onto current main. Main had added a separate runtime_footer default to display config; preserved both alongside your copy_shortcut. Thanks @0xharryriddle!

@teknium1 teknium1 closed this May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants