fix(ssh): reconnecting no longer restarts the remote server #13521
main fromrefs/pull/13521/head·opened View on GitHubEvery time the desktop reconnected to an SSH host, it stopped the T3 server it had launched there and started a new one, ending every agent session that server was running. On one host the server restarted on nearly every reconnect, 10 times in one day. It is one of the triggers in #5749.
The launcher reads ~/.t3/userdata/server-runtime.json to find a server that took over the host, such as the background service. Its own server writes to that same file, so on the next connect the launcher took it for another server, stopped it, and then launched a replacement. Now it hands off only when the file names a different process. This does not stop two servers from sharing one home; that is the lock work in #8442 and #9652.
A new test runs the real launch script twice against a stand-in server: the second launch keeps the same server. It also checks that a genuinely different server is still adopted. Without the fix, the test fails because the second launch returns a new process.
Made with Claude Opus 5.5 in Claude Code.
Summary by CodeRabbit#
- Bug Fixes
- Fixed remote SSH launches to correctly reuse an existing server and recognize servers running in the default location.
- Prevented a running server from being interrupted when its runtime information refers to that same server.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
Approvability#
Verdict: Approved at
e61a017Macroscope's review found this PR approvable — This is a small, well-scoped SSH bug fix that prevents a managed server from stopping itself while preserving handoff to a different server. An isolated regression test covers both reuse and external-server scenarios, with no schema, deployment, default, or static-analysis changes.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).f4llenz(GitHub profile, opens in a new tab) changed the title
Navigate logical layers of code changes, visualize relationships, and explore their blast radius.
Important
Review skipped#
Review was skipped as selected files did not have any reviewable changes.
⚙️ Run configuration
Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
06a8ec28-b1aa-4407-bb08-ef5ab497a1c0📥 Commits
Reviewing files that changed from the base of the PR and between fe616c792870f6a73c9817f7f0a4fb00f00ed95e and 336e3380f57f88436f79941f4a72b337995d7310.
You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
- 🔍 Trigger review
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
939edba0-038f-4ccb-a557-7faa5a95d7aa📥 Commits
Reviewing files that changed from the base of the PR and between d4a33457cb0da797728f4846a9da8592d7d81d36 and b8f8482c96785b31ba05e08487c9988548c7bc48.
📒 Files selected for processing (2)
packages/ssh/src/runnerProcess.test.tspackages/ssh/src/tunnel.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
Walkthrough#
The remote launch script now skips default-runtime handoff when that runtime belongs to the current SSH-managed server. A Unix-only integration test checks repeated launches, adoption of a different default-home server, and cleanup.
Changes#
SSH runtime launch
Layer / File(s) Summary Runtime reuse and handoff
packages/ssh/src/tunnel.ts,packages/ssh/src/runnerProcess.test.tsThe launch script excludes the current SSH-managed PID from the default-runtime handoff condition. The integration test checks managed-server reuse and adoption of another server. It also captures launched processes for cleanup. Priority: ➖ Normal
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Suggested reviewers:
juliusmarmingeMerge Risk: ⚪ Minimal · up to
b8f84The change appears ready to merge after normal checks; no actionable issue is established by the supplied evidence.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2… Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request. Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request. Title check ✅ Passed The title clearly and concisely describes the main change: preventing SSH reconnects from restarting the managed remote server. Description check ✅ Passed The description explains the problem, the fix, the scope, and the test coverage. It omits the template headings and checklist, but it provides the required substantive information and is focused. ✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create a new PR
Comment `@coderabbitai help` to get the list of available commands.juliusmarminge added labelsmacroscope-review
I hit exactly this today: two reconnects, two server restarts, two long agent runs cut off. I'd love to see this merged.
Note
Grok responding on behalf of Julius.
Closing as superseded by #19432, which just merged. It includes this fix: the launcher now reuses its own managed server when
server-runtime.jsonnames the PID it recorded, so reconnect no longer stops and replaces it. Thanks for tracking this down!juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes