Skip to content

Commit bdf7e91

Browse files
committed
fix(ui): propagate user accent to Talk Mode and widget frames
talk.config forwarded only the operator ui.seamColor, so a user-selected ui.prefs.accent never reached the native Talk overlay; it now wins with the same precedence the Control UI applies (regression test fails pre-fix). The widget-theme observer now explicitly watches the <html> style attribute that carries the inline accent override instead of relying on incidental data-theme re-sets.
1 parent f40cb15 commit bdf7e91

4 files changed

Lines changed: 34 additions & 3 deletions

File tree

‎src/gateway/server-methods/talk.test.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,6 +1118,26 @@ describe("talk.config handler", () => {
11181118
},
11191119
);
11201120

1121+
it("prefers the user accent over the operator seam color", async () => {
1122+
markTalkOwnerCold("tts");
1123+
const runtimeConfig = createTalkConfig("healthy-talk-key");
1124+
mocks.getSpeechProvider.mockReturnValue({ id: "acme" });
1125+
mocks.readConfigFileSnapshot.mockResolvedValue({
1126+
config: { ...runtimeConfig, ui: { seamColor: "#123456", prefs: { accent: "#52c99a" } } },
1127+
});
1128+
const respond = vi.fn();
1129+
1130+
await callTalkHandler("talk.config", {
1131+
params: {},
1132+
client: { connect: { scopes: ["operator.read"] } },
1133+
respond,
1134+
context: { getRuntimeConfig: () => runtimeConfig },
1135+
});
1136+
1137+
expect(respond.mock.calls[0]?.[0]).toBe(true);
1138+
expect(respond.mock.calls[0]?.[1]?.config?.ui).toEqual({ seamColor: "#52c99a" });
1139+
});
1140+
11211141
it("projects the runtime realtime transport when source config is invalid", async () => {
11221142
mocks.readConfigFileSnapshot.mockResolvedValue({
11231143
path: "/tmp/openclaw.json",

‎src/gateway/server-methods/talk.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,9 @@ export const talkHandlers: GatewayRequestHandlers = {
802802
configPayload.session = { mainKey: sessionMainKey };
803803
}
804804

805-
const seamColor = snapshot.config.ui?.seamColor;
805+
// User accent wins over the operator seam color, matching Control UI
806+
// precedence (ui.prefs.accent -> ui.seamColor -> theme default).
807+
const seamColor = snapshot.config.ui?.prefs?.accent ?? snapshot.config.ui?.seamColor;
806808
if (typeof seamColor === "string") {
807809
configPayload.ui = { seamColor };
808810
}

‎ui/src/lib/widget-theme.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ export function installWidgetThemeObserver(): void {
9494
}
9595
}).observe(root, {
9696
attributes: true,
97-
attributeFilter: ["data-theme", "data-theme-mode"],
97+
// "style" carries the accent override (inline custom properties on <html>);
98+
// without it a user accent change would only reach frames incidentally.
99+
attributeFilter: ["data-theme", "data-theme-mode", "style"],
98100
});
99101
}

‎ui/src/pages/chat/components/widget-theme.test.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ describe("widget theme bridge", () => {
130130
document.documentElement,
131131
{
132132
attributes: true,
133-
attributeFilter: ["data-theme", "data-theme-mode"],
133+
attributeFilter: ["data-theme", "data-theme-mode", "style"],
134134
},
135135
);
136136
FakeMutationObserver.instances[0]?.trigger({
@@ -139,5 +139,12 @@ describe("widget theme bridge", () => {
139139
expect(chatPost).toHaveBeenCalledOnce();
140140
expect(boardPost).toHaveBeenCalledOnce();
141141
expect(unrelatedPost).not.toHaveBeenCalled();
142+
// Accent overrides land as inline style mutations on <html>.
143+
FakeMutationObserver.instances[0]?.trigger({
144+
attributeName: "style",
145+
} as MutationRecord);
146+
expect(chatPost).toHaveBeenCalledTimes(2);
147+
expect(boardPost).toHaveBeenCalledTimes(2);
148+
expect(unrelatedPost).not.toHaveBeenCalled();
142149
});
143150
});

0 commit comments

Comments
 (0)