@devries-cameron20 / t3code Mirror · read-only / commits / 0ce257b880
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 12:00 UTC

fix(ssh): detect lost connections during remote commands (#23025)

Co-authored-by: maria-rcks <maria@kuuro.net>

Ümit Demir committed Oct 31, 2026 at 01:44 UTC 0ce257b8804a7a6dffa2892a280a59dd20e5a159
2 files changed +17
packages/ssh/src/command.test.ts
+12
@@ -143,6 +143,18 @@ describe("ssh command", () => {
143 }).pipe(Effect.provide(NodeServices.layer)),
144 );
145
146 + it.live("enables server-alive checks for long remote commands", () =>
147 + Effect.gen(function* () {
148 + // Ask OpenSSH for its effective configuration without opening a connection.
149 + const { stdout } = yield* runSshCommand(
150 + { alias: "synthetic-fixture", hostname: "synthetic-fixture", username: null, port: null },
151 + { preHostArgs: ["-F", "none", "-G"], timeoutMs: 900_000 },
152 + );
153 + assert.match(stdout, /^serveraliveinterval 15\r?$/mu);
154 + assert.match(stdout, /^serveralivecountmax 3\r?$/mu);
155 + }).pipe(Effect.provide(NodeServices.layer)),
156 + );
157 +
158 it.effect("redacts credentials from stdout in non-zero command failures", () => {
159 const spawner = ChildProcessSpawner.make(() =>
160 Effect.succeed(makeFailedProcess({ stdout: '{"credential":"pairing-secret"}\n' })),
packages/ssh/src/command.ts
+5
@@ -202,6 +202,11 @@ const runSshCommandInScope = Effect.fn("ssh/command.runSshCommand.inScope")(func
202 ...baseSshArgs(target, {
203 batchMode: input.batchMode ?? (input.interactiveAuth ? "no" : "yes"),
204 }),
205 + // Cold installs need a long command budget; a lost connection must fail sooner.
206 + "-o",
207 + "ServerAliveInterval=15",
208 + "-o",
209 + "ServerAliveCountMax=3",
210 ...(input.preHostArgs ?? []),
211 "--",
212 hostSpec,