fix: use transport activity for stale health

This commit is contained in:
Peter Steinberger
2026-04-22 02:56:32 +01:00
parent 270003aefd
commit d8d0380297
29 changed files with 192 additions and 122 deletions

View File

@@ -590,6 +590,7 @@ describe("TelegramPollingSession", () => {
connected: false,
lastConnectedAt: null,
lastEventAt: null,
lastTransportActivityAt: null,
});
const connectedPatch = setStatus.mock.calls.find(
([patch]) => (patch as Record<string, unknown>).connected === true,
@@ -599,9 +600,11 @@ describe("TelegramPollingSession", () => {
mode: "polling",
lastConnectedAt: expect.any(Number),
lastEventAt: expect.any(Number),
lastTransportActivityAt: expect.any(Number),
lastError: null,
});
expect(connectedPatch?.lastConnectedAt).toBe(connectedPatch?.lastEventAt);
expect(connectedPatch?.lastTransportActivityAt).toBe(connectedPatch?.lastEventAt);
abort.abort();
resolveFirstTask();
@@ -681,6 +684,7 @@ describe("TelegramPollingSession", () => {
mode: "polling",
lastConnectedAt: null,
lastEventAt: null,
lastTransportActivityAt: null,
});
expect(disconnectedPatches[1]?.[0]).toEqual({
mode: "polling",

View File

@@ -15,12 +15,14 @@ describe("createTelegramPollingStatusPublisher", () => {
connected: false,
lastConnectedAt: null,
lastEventAt: null,
lastTransportActivityAt: null,
});
expect(setStatus).toHaveBeenNthCalledWith(2, {
mode: "polling",
connected: true,
lastConnectedAt: 1234,
lastEventAt: 1234,
lastTransportActivityAt: 1234,
lastError: null,
});
expect(setStatus).toHaveBeenNthCalledWith(3, {

View File

@@ -1,5 +1,8 @@
import type { ChannelAccountSnapshot } from "openclaw/plugin-sdk/channel-contract";
import { createConnectedChannelStatusPatch } from "openclaw/plugin-sdk/gateway-runtime";
import {
createConnectedChannelStatusPatch,
createTransportActivityStatusPatch,
} from "openclaw/plugin-sdk/gateway-runtime";
type TelegramPollingStatusSink = (patch: Omit<ChannelAccountSnapshot, "accountId">) => void;
@@ -11,11 +14,15 @@ export function createTelegramPollingStatusPublisher(setStatus?: TelegramPolling
connected: false,
lastConnectedAt: null,
lastEventAt: null,
lastTransportActivityAt: null,
});
},
notePollSuccess(at = Date.now()) {
setStatus?.({
...createConnectedChannelStatusPatch(at),
// A successful getUpdates call proves the Telegram HTTP long-poll is alive
// even when the response has no user-visible updates.
...createTransportActivityStatusPatch(at),
mode: "polling",
lastError: null,
});