Skip to content

Commit 12f06b3

Browse files
committed
fix(ui): cover build-aware frozen clients
1 parent fc5aed1 commit 12f06b3

6 files changed

Lines changed: 11 additions & 45 deletions

File tree

‎packages/gateway-protocol/src/client-info.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ export type GatewayClientInfo = {
8181
export const GATEWAY_CLIENT_CAPS = {
8282
AGENT_KIND: "agent-kind",
8383
APPROVALS: "approvals",
84-
CONTROL_UI_BUILD_MISMATCH: "control-ui-build-mismatch",
8584
EXEC_APPROVALS: "exec-approvals",
8685
INLINE_WIDGETS: "inline-widgets",
8786
RUN_TOOL_BINDINGS: "run-tool-bindings",

‎src/gateway/server/ws-connection/connect-session.ts‎

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ import os from "node:os";
33
import { normalizeOptionalString } from "@openclaw/normalization-core/string-coerce";
44
import type { WebSocket } from "ws";
55
import {
6-
GATEWAY_CLIENT_CAPS,
76
GATEWAY_CLIENT_IDS,
87
GATEWAY_CLIENT_MODES,
9-
hasGatewayClientCap,
108
} from "../../../../packages/gateway-protocol/src/client-info.js";
119
import { ConnectErrorDetailCodes } from "../../../../packages/gateway-protocol/src/connect-error-details.js";
1210
import { ErrorCodes, PROTOCOL_VERSION } from "../../../../packages/gateway-protocol/src/index.js";
@@ -325,29 +323,16 @@ export async function attachAuthenticatedGatewayConnect(
325323
requestOrigin,
326324
});
327325
if (controlUiBuildMismatch) {
328-
// Build identity predates the exact mismatch error. Only this capability proves
329-
// the frozen client can stop reconnecting and consume guarded auto-reload details.
330-
const supportsExactBuildMismatch = hasGatewayClientCap(
331-
connectParams.caps,
332-
GATEWAY_CLIENT_CAPS.CONTROL_UI_BUILD_MISMATCH,
333-
);
334-
const reloadMessage = "Control UI updated; reload this page to continue";
335-
const message = supportsExactBuildMismatch
336-
? reloadMessage
337-
: `protocol mismatch: ${reloadMessage}`;
326+
// Build identity predates this rejection. Frozen clients recognize the shipped
327+
// protocol-mismatch signal and surface its literal reload guidance.
328+
const message = "protocol mismatch: Control UI updated; reload this page to continue";
338329
markHandshakeFailure("control-ui-build-mismatch", {
339330
clientBuildId: controlUiBuildMismatch.clientBuildId ?? "legacy",
340331
gatewayBuildId: controlUiBuildMismatch.gatewayBuildId,
341332
});
342333
sendHandshakeErrorResponse(ErrorCodes.UNAVAILABLE, message, {
343334
retryable: false,
344-
details: supportsExactBuildMismatch
345-
? {
346-
code: ConnectErrorDetailCodes.CONTROL_UI_BUILD_MISMATCH,
347-
gatewayBuildId: controlUiBuildMismatch.gatewayBuildId,
348-
reloadRequired: true,
349-
}
350-
: { code: ConnectErrorDetailCodes.PROTOCOL_MISMATCH },
335+
details: { code: ConnectErrorDetailCodes.PROTOCOL_MISMATCH },
351336
});
352337
logWsControl.warn(
353338
`control ui build rejected conn=${connId} clientBuild=${formatForLog(controlUiBuildMismatch.clientBuildId ?? "legacy")} gatewayBuild=${formatForLog(controlUiBuildMismatch.gatewayBuildId)}; reload required`,

‎src/gateway/server/ws-connection/message-handler.control-ui-build-admission.test.ts‎

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -104,30 +104,13 @@ describe("Control UI build admission over WebSocket", () => {
104104
{
105105
name: "legacy same-origin document",
106106
clientBuildId: undefined,
107-
clientCaps: [],
108-
errorMessage: "protocol mismatch: Control UI updated; reload this page to continue",
109-
errorDetails: { code: ConnectErrorDetailCodes.PROTOCOL_MISMATCH },
110107
},
111108
{
112-
name: "pre-capability stale same-origin document",
113-
clientBuildId: "pre-capability-build",
114-
clientCaps: [],
115-
errorMessage: "protocol mismatch: Control UI updated; reload this page to continue",
116-
errorDetails: { code: ConnectErrorDetailCodes.PROTOCOL_MISMATCH },
117-
},
118-
{
119-
name: "capable stale same-origin document",
109+
name: "explicit stale same-origin document",
120110
clientBuildId: "stale-build",
121-
clientCaps: ["control-ui-build-mismatch"],
122-
errorMessage: "Control UI updated; reload this page to continue",
123-
errorDetails: {
124-
code: ConnectErrorDetailCodes.CONTROL_UI_BUILD_MISMATCH,
125-
gatewayBuildId: "gateway-build",
126-
reloadRequired: true,
127-
},
128111
},
129112
])("rejects a $name before registration or RPC dispatch", async (testCase) => {
130-
const { clientBuildId, clientCaps, errorMessage, errorDetails } = testCase;
113+
const { clientBuildId } = testCase;
131114
const wss = new WebSocketServer({ host: "127.0.0.1", port: 0 });
132115
await withDeadline(
133116
new Promise<void>((resolve) => {
@@ -230,7 +213,7 @@ describe("Control UI build admission over WebSocket", () => {
230213
...(clientBuildId ? { buildId: clientBuildId } : {}),
231214
},
232215
role: "operator",
233-
caps: clientCaps,
216+
caps: [],
234217
auth: { token: "test-token" },
235218
},
236219
}),
@@ -241,9 +224,9 @@ describe("Control UI build admission over WebSocket", () => {
241224
ok: false,
242225
error: {
243226
code: ErrorCodes.UNAVAILABLE,
244-
message: errorMessage,
227+
message: "protocol mismatch: Control UI updated; reload this page to continue",
245228
retryable: false,
246-
details: errorDetails,
229+
details: { code: ConnectErrorDetailCodes.PROTOCOL_MISMATCH },
247230
},
248231
});
249232
ws.send(

‎ui/src/api/gateway.node.test.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,6 @@ describe("GatewayBrowserClient", () => {
452452
expect(connectFrame.params?.caps).toEqual([
453453
GATEWAY_CLIENT_CAPS.AGENT_KIND,
454454
GATEWAY_CLIENT_CAPS.APPROVALS,
455-
GATEWAY_CLIENT_CAPS.CONTROL_UI_BUILD_MISMATCH,
456455
GATEWAY_CLIENT_CAPS.TASK_SUGGESTIONS,
457456
GATEWAY_CLIENT_CAPS.TERMINAL_OFFSET_SEQ,
458457
GATEWAY_CLIENT_CAPS.TOOL_EVENTS,

‎ui/src/api/gateway.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,6 @@ export class GatewayBrowserClient {
479479
caps: [
480480
GATEWAY_CLIENT_CAPS.AGENT_KIND,
481481
GATEWAY_CLIENT_CAPS.APPROVALS,
482-
GATEWAY_CLIENT_CAPS.CONTROL_UI_BUILD_MISMATCH,
483482
GATEWAY_CLIENT_CAPS.TASK_SUGGESTIONS,
484483
GATEWAY_CLIENT_CAPS.TERMINAL_OFFSET_SEQ,
485484
GATEWAY_CLIENT_CAPS.TOOL_EVENTS,

‎ui/src/e2e/login-gate.e2e.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ suite.define(() => {
120120
await gateway.waitForRequest("connect");
121121
await gateway.rejectDeferred("connect", {
122122
code: "INVALID_REQUEST",
123-
message: "protocol mismatch",
123+
message: "protocol mismatch: Control UI updated; reload this page to continue",
124124
details: { code: ConnectErrorDetailCodes.PROTOCOL_MISMATCH },
125125
});
126126

@@ -129,6 +129,7 @@ suite.define(() => {
129129
expect((await failure.textContent())?.toLowerCase()).toContain(
130130
"supported connection protocol",
131131
);
132+
expect(await page.locator(".login-gate__failure-refresh").isVisible()).toBe(true);
132133
await page.clock.runFor(1_600);
133134
expect(await gateway.getRequests("connect")).toHaveLength(1);
134135
} finally {

0 commit comments

Comments
 (0)