Skip to content

fix(ssh): reconnecting no longer restarts the remote server - #13521

Open
f4llenz wants to merge 4 commits into
pingdotgg:mainfrom
f4llenz:fix/ssh-reuse-own-managed-server
Open

f4llenz wants to merge 4 commits into
pingdotgg:mainfrom
f4llenz:fix/ssh-reuse-own-managed-server

Conversation

@f4llenz

@f4llenz f4llenz commented Sep 24, 2026 •

Copy link
Copy Markdown

Every 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.

…e.json

The SSH launcher reads the default home's server-runtime.json to adopt a
server that took over, such as the background service. The launcher's own
managed server runs against that same home, so it records itself there too.
The launcher then treated it as a foreign server: it stopped the managed
PID, marked the port external, found it dead, and started a new server.

Every reconnect therefore restarted a healthy managed server and ended the
provider sessions it owned. Hand off only when the runtime file names a
different process.
@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Sep 24, 2026
@macroscopeapp

macroscopeapp Bot commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at e61a017

Macroscope'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.

@f4llenz f4llenz changed the title fix(ssh): keep the managed server when it is the one in server-runtime.json fix(ssh): reconnecting no longer restarts the remote server Sep 24, 2026
f4llenz and others added 2 commits September 24, 2026 19:59
A reaped-late zombie still answers kill -0, so a PID check can report a
stopped server as running on some Linux hosts. A refused connection is the
behavior that matters.
@coderabbitai

coderabbitai Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

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: 922bc410-f145-4490-bcf4-edaf4a147835

📥 Commits

Reviewing files that changed from the base of the PR and between b8f8482 and fe616c7.

You can disable this status message by setting the reviews.review_status to false in 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 d4a3345 and b8f8482.

📒 Files selected for processing (2)
  • packages/ssh/src/runnerProcess.test.ts
  • packages/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.ts
The 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: juliusmarminge

Merge Risk: ⚪ Minimal · up to b8f84

The 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.

This branch has not been deployed

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

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant