Skip to content

fix(cli): eliminate extra Ctrl+C needed to exit local spawn session#3430

Open
aulorbe wants to merge 1 commit into
mainfrom
fix/ctrl-c-exit-delay
Open

fix(cli): eliminate extra Ctrl+C needed to exit local spawn session#3430
aulorbe wants to merge 1 commit into
mainfrom
fix/ctrl-c-exit-delay

Conversation

@aulorbe
Copy link
Copy Markdown
Collaborator

@aulorbe aulorbe commented May 21, 2026

Summary

Exiting a local spawn session with Ctrl+C requires pressing it three times instead of two. After the agent process exits on the second Ctrl+C, the parent process hangs briefly — long enough that the user presses Ctrl+C again.

Root cause

Two things add delay between the agent exiting and the process actually terminating:

  1. spawnInteractive runs stty sane — a synchronous nodeSpawnSync call that blocks right after the agent exits, during the exact moment the user expects the process to be dying.

  2. runOrchestration continues post-session cleanup — reconnect logic, tunnel teardown, and history pull all run before process.exit(), even on SIGINT where the user just wants out.

Fix

  • ssh.ts: On exit code 130 or SIGINT signal, skip terminal reset (stty sane, ANSI escape writes) and return immediately.
  • orchestrate.ts: On exit code 130, call process.exit(130) immediately after the interactive session returns, skipping all post-session cleanup.

Test plan

  • bunx @biomejs/biome check src/shared/ssh.ts src/shared/orchestrate.ts — zero errors
  • Full test suite — 2201 pass, 3 pre-existing flaky failures unrelated to this change
  • Run spawn cursor local, press Ctrl+C twice — should exit cleanly without needing a third press

After the agent exits via Ctrl+C (exit 130), two things added delay
that forced the user to press Ctrl+C a third time:

1. spawnInteractive ran `stty sane` (a synchronous child spawn) after
   the agent exited, blocking during the exact moment the user expects
   the process to be dying.

2. runOrchestration continued through post-session cleanup (reconnect
   logic, history pull, tunnel teardown) before calling process.exit.

Fix: on exit code 130, skip terminal cleanup in spawnInteractive and
fast-path to process.exit(130) in runOrchestration.
Copy link
Copy Markdown
Collaborator Author

aulorbe commented May 21, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@aulorbe aulorbe marked this pull request as ready for review May 21, 2026 05:53
@aulorbe aulorbe requested review from AhmedTMM and louisgv May 21, 2026 06:21
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