Skip to content

Commit ccc0e8e

Browse files
committed
fix(ui): clean custodian surface/page/mock lint debris
1 parent dc27f96 commit ccc0e8e

3 files changed

Lines changed: 15 additions & 12 deletions

File tree

‎scripts/control-ui-mock-dev.ts‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { fileURLToPath } from "node:url";
55
import qrcode from "qrcode";
66
import { createServer, type Plugin, type ViteDevServer } from "vite";
77
import type {
8+
RequestFrame,
89
SystemAgentChatHistoryResult,
910
SystemAgentChatQuestion,
1011
SystemAgentChatResult,
@@ -2071,19 +2072,26 @@ function installControlUiCustodianMock(replyDelayMs: number): void {
20712072
if (!gateway || !MockWebSocket) {
20722073
return;
20732074
}
2074-
const originalSend = MockWebSocket.prototype.send;
2075+
const sendDescriptor = Object.getOwnPropertyDescriptor(MockWebSocket.prototype, "send");
2076+
const originalSend = sendDescriptor?.value as WebSocket["send"] | undefined;
2077+
if (typeof originalSend !== "function") {
2078+
return;
2079+
}
2080+
const sendOriginal = (socket: WebSocket, data: Parameters<WebSocket["send"]>[0]): void => {
2081+
Reflect.apply(originalSend, socket, [data]);
2082+
};
20752083
const sessionTurns = new Map<string, number>();
20762084
MockWebSocket.prototype.send = function (data): void {
2077-
let frame: { method?: unknown; params?: unknown; type?: unknown } | null = null;
2085+
let frame: RequestFrame | null = null;
20782086
if (typeof data === "string") {
20792087
try {
2080-
frame = JSON.parse(data) as typeof frame;
2088+
frame = JSON.parse(data) as RequestFrame;
20812089
} catch {
20822090
frame = null;
20832091
}
20842092
}
20852093
if (frame?.type !== "req" || frame.method !== "openclaw.chat") {
2086-
originalSend.call(this, data);
2094+
sendOriginal(this, data);
20872095
return;
20882096
}
20892097

@@ -2145,7 +2153,7 @@ function installControlUiCustodianMock(replyDelayMs: number): void {
21452153
// Defer before forwarding so the generic gateway records the request but
21462154
// cannot race its normal immediate response against this stateful reply.
21472155
gateway.deferNext("openclaw.chat");
2148-
originalSend.call(this, data);
2156+
sendOriginal(this, data);
21492157
window.setTimeout(
21502158
() => gateway.resolveDeferred("openclaw.chat", response),
21512159
message === undefined ? 0 : replyDelayMs,

‎ui/src/pages/custodian/custodian-page.ts‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import "../../components/openclaw-mascot.ts";
88
import { t } from "../../i18n/index.ts";
99
import { isGatewayMethodAdvertised } from "../../lib/gateway-methods.ts";
1010
import { OpenClawLightDomElement } from "../../lit/openclaw-element.ts";
11-
import { SubscriptionsController } from "../../lit/subscriptions-controller.ts";
1211
import "../../styles/custodian.css";
1312
import { renderCustodianChangeHistory } from "./custodian-history.ts";
1413
import { custodianSessionStore, type CustodianSessionStore } from "./custodian-session-store.ts";
@@ -37,11 +36,6 @@ export class CustodianPage extends OpenClawLightDomElement {
3736
private historyRequestEpoch = 0;
3837
private subscribedStore: CustodianSessionStore | null = null;
3938
private storeCleanup: (() => void) | null = null;
40-
private readonly subscriptions = new SubscriptionsController(this).watch(
41-
() => this.context?.gateway,
42-
(gateway, notify) => gateway.subscribe(notify),
43-
() => this.synchronizeHistoryClient(),
44-
);
4539

4640
override connectedCallback(): void {
4741
super.connectedCallback();
@@ -68,6 +62,7 @@ export class CustodianPage extends OpenClawLightDomElement {
6862
if (changedProperties.has("store")) {
6963
this.subscribeToStore();
7064
}
65+
this.synchronizeHistoryClient();
7166
}
7267

7368
private subscribeToStore(): void {

‎ui/src/pages/custodian/custodian-surface.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import * as eventNudgeState from "./event-nudge.ts";
1616
import { sessionVariant } from "./session-lifecycle.ts";
1717
import { renderCustodianTranscriptEntry } from "./transcript.ts";
1818

19-
export class CustodianSurface extends OpenClawLightDomElement {
19+
class CustodianSurface extends OpenClawLightDomElement {
2020
@consume({ context: applicationContext, subscribe: true })
2121
private context!: ApplicationContext;
2222

0 commit comments

Comments
 (0)