cmux/tests/test_ctrl_signals.sh
Lawrence Chen cd0f6200c0 Fix Ctrl+C/D handling and add Unix socket control API for testing
Key changes:
- Fix keyboard input handling for control characters in GhosttyTerminalView
  - Set consumed_mods correctly (exclude Ctrl/Cmd from consumed mods)
  - Send unmodified character text for Ctrl+key combinations
  - Add unshifted_codepoint support for proper key encoding

- Add TerminalController with Unix socket API (/tmp/ghosttytabs.sock)
  - Commands: send, send_key, list_tabs, new_tab, close_tab, select_tab
  - Supports ctrl-c, ctrl-d, ctrl-z, enter, tab, escape, etc.

- Add Python test client and automated test suite
  - tests/ghosttytabs.py - Python client library
  - tests/test_ctrl_socket.py - Main Ctrl+C/D test suite (4 tests)
  - tests/test_signals_auto.py - Standalone PTY signal tests

- Update CLAUDE.md with socket API documentation and testing guide
- Update .gitignore for Python cache files

This fixes Ctrl+C/D not working in apps like claude-code, btop, opencode
while continuing to work in simpler apps like htop.
2026-01-22 02:20:51 -08:00

24 lines
784 B
Bash
Executable file

#!/bin/bash
# Test script to verify Ctrl+C and Ctrl+D work correctly in the terminal
# Run this script inside the GhosttyTabs terminal to test signal handling
set -e
echo "=== Control Signal Test Suite ==="
echo ""
# Test 1: Ctrl+C interrupt test
echo "Test 1: Ctrl+C (SIGINT) - Press Ctrl+C to interrupt the sleep"
echo " A long sleep will start. Press Ctrl+C to interrupt it."
echo " If Ctrl+C works, you should see 'SIGINT received!' within 2 seconds."
echo ""
echo "Starting sleep... (press Ctrl+C now)"
trap 'echo "SIGINT received! Ctrl+C is working correctly."; exit 0' INT
# Start a long sleep - user should interrupt this with Ctrl+C
sleep 30
# If we get here, Ctrl+C didn't work
echo "ERROR: Sleep completed without interruption. Ctrl+C may not be working!"
exit 1