Skip to content

Commit 0cdfafd

Browse files
committed
feat(ui): wire seamColor from bootstrap config to CSS custom properties (fixes #56068)
1 parent 00479b1 commit 0cdfafd

3 files changed

Lines changed: 28 additions & 0 deletions

File tree

src/gateway/control-ui-contract.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ export type ControlUiBootstrapConfig = {
2020
embedSandbox?: ControlUiEmbedSandboxMode;
2121
allowExternalEmbedUrls?: boolean;
2222
chatMessageMaxWidth?: string;
23+
seamColor?: string;
2324
};

src/gateway/control-ui.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,7 @@ export async function handleControlUiHttpRequest(
979979
: "scripts",
980980
allowExternalEmbedUrls: config?.gateway?.controlUi?.allowExternalEmbedUrls === true,
981981
chatMessageMaxWidth: config?.gateway?.controlUi?.chatMessageMaxWidth,
982+
seamColor: config?.ui?.seamColor,
982983
} satisfies ControlUiBootstrapConfig);
983984
return true;
984985
}

ui/src/ui/controllers/control-ui-bootstrap.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,33 @@ export async function loadControlUiBootstrapConfig(
136136
typeof parsed.chatMessageMaxWidth === "string" && parsed.chatMessageMaxWidth.trim()
137137
? parsed.chatMessageMaxWidth
138138
: null;
139+
if (typeof parsed.seamColor === "string" && parsed.seamColor) {
140+
applySeamColor(parsed.seamColor);
141+
}
139142
} catch {
140143
// Ignore bootstrap failures; UI will update identity after connecting.
141144
}
142145
}
146+
147+
function applySeamColor(hex: string): void {
148+
const root = document.documentElement;
149+
root.style.setProperty("--accent", hex);
150+
root.style.setProperty("--accent-muted", hex);
151+
root.style.setProperty("--primary", hex);
152+
root.style.setProperty(
153+
"--accent-subtle",
154+
`color-mix(in srgb, ${hex} 12%, transparent)`,
155+
);
156+
root.style.setProperty(
157+
"--accent-glow",
158+
`color-mix(in srgb, ${hex} 20%, transparent)`,
159+
);
160+
try {
161+
root.style.setProperty(
162+
"--accent-hover",
163+
`oklch(from ${hex} calc(l + 0.1) c h)`,
164+
);
165+
} catch {
166+
/* relative color syntax not supported */
167+
}
168+
}

0 commit comments

Comments
 (0)