diff --git a/src/lib/runtime-recovery.test.ts b/src/lib/runtime-recovery.test.ts index cf364bd8b..868934f3f 100644 --- a/src/lib/runtime-recovery.test.ts +++ b/src/lib/runtime-recovery.test.ts @@ -74,6 +74,8 @@ describe("runtime recovery helpers", () => { expect(classifyGatewayStatus("Gateway: nemoclaw\nStatus: Disconnected").state).toBe( "inactive", ); + expect(classifyGatewayStatus("Status: Not connected").state).toBe("inactive"); + expect(classifyGatewayStatus("Connected").state).toBe("connected"); }); it("only attempts gateway recovery when sandbox access is unavailable and gateway is down", () => { diff --git a/src/lib/runtime-recovery.ts b/src/lib/runtime-recovery.ts index 134d433f2..d33162f59 100644 --- a/src/lib/runtime-recovery.ts +++ b/src/lib/runtime-recovery.ts @@ -61,9 +61,6 @@ export function classifyGatewayStatus(output = ""): StateClassification { if (!clean) { return { state: "inactive", reason: "empty" }; } - if (/\bConnected\b/i.test(clean) && !/\bDisconnected\b/i.test(clean)) { - return { state: "connected", reason: "ok" }; - } if ( /No active gateway|transport error|client error|Connection reset by peer|Connection refused|Gateway: .*Error/i.test( clean, @@ -71,6 +68,9 @@ export function classifyGatewayStatus(output = ""): StateClassification { ) { return { state: "unavailable", reason: "gateway_unavailable" }; } + if (/^\s*(?:Status:\s*)?Connected\s*$/im.test(clean)) { + return { state: "connected", reason: "ok" }; + } return { state: "inactive", reason: "not_connected" }; }