Skip to content

feat: enhance terminal bridge and session controls#9

Open
cipriandrei10 wants to merge 5 commits intotomtev:mainfrom
cipriandrei10:feature/bridge-enhancements
Open

feat: enhance terminal bridge and session controls#9
cipriandrei10 wants to merge 5 commits intotomtev:mainfrom
cipriandrei10:feature/bridge-enhancements

Conversation

@cipriandrei10
Copy link
Copy Markdown
Contributor

@cipriandrei10 cipriandrei10 commented Apr 10, 2026

This PR enhances the terminal bridge and session management to improve the interaction between chat interfaces and underlying AI tools (Claude, Codex, Gemini, Pi, Kimi). It introduces a system prompt injection mechanism, adds a convenient session kill switch, and provides comprehensive test coverage for these new features.

Key Changes:

  • Terminal Bridge Prompt Injection:
    • Added a system prompt injection mechanism ([touchgrass] This is a terminal bridge...) to inform AI tools they are being proxied.
    • For Claude and Codex, the prompt is injected via the --append-system-prompt flag using a temporary file.
    • For Gemini, Pi, and Kimi, a fallback mechanism writes the prompt directly to the terminal PTY upon detecting the initial tool prompt (e.g., > or ? ).
    • Refactored prompt detection into testable helpers in run.ts.
  • Session Kill Switch:
    • Implemented a "kill switch" in the chat interface: sending /q or stop (case-insensitive) now triggers an immediate interruption and stops the active session.
  • Improved Session Resilience:
    • Refactored getRecoveryName to safely handle undefined remoteId during session recovery.
    • Ensured cleanup of temporary bridge prompt files after session termination.
    • Fixed scope issues for session resume variables in the main run loop.
  • Testing:
    • New packages/cli/src/tests/bridge-prompt.test.ts: Verifies the logic for terminal bridge prompt detection across different tools.
    • New packages/cli/src/tests/stdin-input.test.ts: Validates the /q kill switch and file mention prepending.
    • Updated packages/cli/src/tests/codex-args.test.ts: Ensures correct argument parsing for resume and restart scenarios.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant