From 3972cc1559d92fffaa08fd264ba73ab4d391f6b1 Mon Sep 17 00:00:00 2001 From: "paseo-bot[bot]" <266920839+paseo-bot[bot]@users.noreply.github.com> Date: Sat, 7 Nov 2026 23:35:42 +0000 Subject: [PATCH] fix(app): avoid false never-online claims in diagnostics A missing runtime timestamp does not establish connection history. Report it as unknown while preserving supplied timestamps. --- .../diagnostics/app-diagnostic-report.test.ts | 70 +++++++++++++------ .../src/diagnostics/app-diagnostic-report.ts | 2 +- 2 files changed, 49 insertions(+), 23 deletions(-) diff --git a/packages/app/src/diagnostics/app-diagnostic-report.test.ts b/packages/app/src/diagnostics/app-diagnostic-report.test.ts index df10b01fed..b23dda3ae1 100644 --- a/packages/app/src/diagnostics/app-diagnostic-report.test.ts +++ b/packages/app/src/diagnostics/app-diagnostic-report.test.ts @@ -46,6 +46,31 @@ function makeHost(): HostProfile { }; } +function makeSnapshot(host: HostProfile): HostRuntimeSnapshot { + return { + serverId: host.serverId, + activeConnectionId: "relay:relay.secret.test:443", + activeConnection: { + type: "relay", + endpoint: "relay.secret.test:443", + display: "relay", + }, + connectionStatus: "online", + client: null, + lastError: null, + lastOnlineAt: "2026-06-25T00:00:00.000Z", + agentDirectoryStatus: "ready", + agentDirectoryError: null, + hasEverLoadedAgentDirectory: true, + probeByConnectionId: new Map([ + ["direct:secret.example.test:6767", { status: "available", latencyMs: 42 }], + ["relay:relay.secret.test:443", { status: "available", latencyMs: 8 }], + ]), + clientGeneration: 1, + connectionEpoch: 1, + }; +} + describe("app diagnostics report", () => { test("reports whether the connected daemon is managed by Paseo Desktop", () => { const report = formatServerInfoSection({ @@ -61,31 +86,11 @@ describe("app diagnostics report", () => { test("formats connection rows without raw connection details", () => { const host = makeHost(); - const snapshot: HostRuntimeSnapshot = { - serverId: host.serverId, - activeConnectionId: "relay:relay.secret.test:443", - activeConnection: { - type: "relay", - endpoint: "relay.secret.test:443", - display: "relay", - }, - connectionStatus: "online", - client: null, - lastError: null, - lastOnlineAt: "2026-06-25T00:00:00.000Z", - agentDirectoryStatus: "ready", - agentDirectoryError: null, - hasEverLoadedAgentDirectory: true, - probeByConnectionId: new Map([ - ["direct:secret.example.test:6767", { status: "available", latencyMs: 42 }], - ["relay:relay.secret.test:443", { status: "available", latencyMs: 8 }], - ]), - clientGeneration: 1, - connectionEpoch: 1, - }; + const snapshot = makeSnapshot(host); const report = formatHostRuntimeSection({ host, snapshot }); + expect(report).toContain("Last online: 2026-06-25T00:00:00.000Z"); expect(report).toContain("direct TCP"); expect(report).toContain("relay"); expect(report).toContain("local socket"); @@ -97,6 +102,27 @@ describe("app diagnostics report", () => { expect(report).not.toContain("tcp-password"); }); + test.each(["connecting", "offline", "error"] as const)( + "does not claim a previously connected host was never online while %s", + (connectionStatus) => { + const host = makeHost(); + const snapshot = makeSnapshot(host); + const report = formatHostRuntimeSection({ + host, + snapshot: { ...snapshot, connectionStatus, lastOnlineAt: null }, + }); + + expect(report).toContain("Last online: unknown"); + expect(report).not.toContain("Last online: never"); + }, + ); + + test("does not infer connection history when the runtime has not started", () => { + const report = formatHostRuntimeSection({ host: makeHost(), snapshot: null }); + + expect(report).toContain("Last online: unknown"); + }); + test("redacts saved connection secrets from collected daemon and desktop text", () => { const host = makeHost(); const redacted = redactAppDiagnosticReport( diff --git a/packages/app/src/diagnostics/app-diagnostic-report.ts b/packages/app/src/diagnostics/app-diagnostic-report.ts index afb38e7aad..e47103a9b0 100644 --- a/packages/app/src/diagnostics/app-diagnostic-report.ts +++ b/packages/app/src/diagnostics/app-diagnostic-report.ts @@ -45,7 +45,7 @@ export function formatHostRuntimeSection(input: { ? describeConnectionKind(snapshot.activeConnection.type) : "none", }, - { label: "Last online", value: snapshot?.lastOnlineAt ?? "never" }, + { label: "Last online", value: snapshot?.lastOnlineAt ?? "unknown" }, { label: "Last error", value: snapshot?.lastError ?? "none" }, { label: "Agent directory",