From a3d5b0555f719673ca7df756f9f3f79498f03fba Mon Sep 17 00:00:00 2001 From: Haze <709547807@qq.com> Date: Fri, 24 Apr 2026 17:03:05 +0800 Subject: [PATCH] perf(gateway): gate sessions.list on state=running instead of gatewayReady MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The maybeLoadSessions() guard previously waited for status.gatewayReady to become true, which is driven by the server-side gateway.ready event and backed by a 30s fallback timer in GatewayManager. In practice, OpenClaw's plugin bootstrap often exceeds that window, so the fallback fired and users stared at the loading state for ~30s after the WS handshake had already completed. sessions.list is a plain RPC — it needs the handshake to be done, not plugins to be up. Gate it on state === 'running' so the session list is fetched immediately after handshake completion. Existing throttling via LOAD_SESSIONS_MIN_INTERVAL_MS still prevents spam on state flaps. --- src/stores/gateway.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/stores/gateway.ts b/src/stores/gateway.ts index 910f336..1fa9c4f 100644 --- a/src/stores/gateway.ts +++ b/src/stores/gateway.ts @@ -98,7 +98,11 @@ function maybeLoadSessions( force = false, ): void { const { status } = useGatewayStore.getState(); - if (status.gatewayReady === false) return; + // Gate on the RPC channel being live (handshake complete), not the later + // gateway.ready event. The ready event can lag up to GATEWAY_READY_FALLBACK_MS + // behind handshake completion while plugins finish booting, and sessions.list + // does not require plugins to be up. + if (status.state !== 'running') return; const now = Date.now(); if (!force && now - lastLoadSessionsAt < LOAD_SESSIONS_MIN_INTERVAL_MS) return;