SSH stop could report success and remove ownership files while the remote server still ran. An active disconnect also hid stop-command failures in scope cleanup.
Check that the saved process has exited before removing its PID, port, and ownership files. If it stays alive after the existing two-second wait, keep those files and return SshCommandError. Explicit disconnect now returns that error and permits a later retry. Local tunnel cleanup keeps its existing termination bound.
Run connect and disconnect in order for each target, so reconnect cannot overtake an earlier stop. This replaces the separate pending-attempt bookkeeping. Disconnect waits for an earlier startup on the same target. Other targets can still connect.
External servers remain running. No remote force-kill was added. App shutdown and environment removal keep their existing best-effort policy.
Verification#
- The new real-shell timeout test and disconnect failure test both failed before the fix. The other 31 controls passed.
- All 42 focused runner, tunnel, and command tests pass, including app cleanup.
- Two gated reconnect tests failed before per-target ordering. They now cover held local and remote shutdown, shared reconnects, and progress on another target.
- Real
/bin/sh tests cover graceful exit, retained ownership after an ignored SIGTERM, a successful retry, and external-server protection. Fixtures use captured child handles and isolated state.
- SSH package typecheck, changed-file lint and formatting, and
git diff --check pass.
Process checks ran on Linux. No live remote host, live state, or browser was used. There are no UI changes.
Created with GPT-6 Astra in Codex.
Note
Report remote stop failures in disconnectEnvironment and preserve ownership on timeout in buildRemoteStopScript#
- Replaces the per-target pending-entry
Deferred map with a per-target Semaphore map so concurrent ensureEnvironment and disconnectEnvironment calls for the same target serialize through one lock.
buildRemoteStopScript now checks process liveness after the two-second wait; if the process is still alive it exits unsuccessfully and leaves the PID, port, and ownership files in place for a later retry.
- Explicit disconnect closes the local tunnel before stopping the remote server and returns a remote stop failure to the caller instead of suppressing it.
- The tunnel scope finalizer always terminates the local SSH process (even for stale entries), runs owner remote shutdown after local termination, and ignores remote-stop failures.
- Behavioral Change:
disconnectEnvironment can now return errors from buildRemoteStopScript timeouts; ensureTunnelEntry no longer returns a shared pending Deferred result.
Macroscope summarized 4622bec.
Bugbot is paused — on-demand spend limit reached
Bugbot uses usage-based billing for this team and has hit its on-demand spend limit.
A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue.