Skip to content

Commit c65aa1d

Browse files
BunsDevclaude
andauthored
fix(control-ui): persist assistant avatar override locally (#71639)
* fix(control-ui): rebalance quick settings into stable 3-col bento Pair Appearance with Automations and let Channels stand alone in the middle column so all three top-row columns reach similar heights. Promote Personal to a full-width row with a horizontal body (identity tiles | emoji + actions) so the avatar block stops fighting for half-width space. Drops the unused .qs-stack--wide hook. Co-Authored-By: Claude Opus 4.7 <[email protected]> * refactor(control-ui): rebalance Personal card with symmetric User↔Assistant identity pair Restructure Personal card layout to present User and Assistant as 2 balanced identity cards instead of separate User tile + form controls. Mirrors the visual hierarchy and UI pattern across both identities. Changes: - Move User avatar text input into User identity card's .__repair section (mirroring Assistant's structure) - Inline "Choose image" and "Clear avatar" buttons as flex-wrapped action group - Remove .qs-personal-body and .qs-personal-form wrapper divs - Update Personal card's .qs-identity-grid to 2-column layout with balanced spacing - Responsive collapse to 1-column at ≤760px Tests: - config-quick.test.ts updated to expect 2 stacks (no longer wrapping Personal in form) - config-quick.test.ts validates identity card layout now has symmetric User↔Assistant structure - All 10 quick settings view tests passing - All 20 schema regression tests passing Co-Authored-By: Claude Haiku 4.5 <[email protected]> * chore: ignore .vmux worktree paths * fix(control-ui): persist assistant avatar override locally instead of via gateway config Mirrors the user-avatar pattern: assistant avatar uploads now go to localStorage and overlay the gateway-resolved identity at bootstrap and on agent.identity.get refreshes. Sidesteps the ui.assistant.avatar zod cap that rejected uploaded data URLs as 'Too big: expected string to have <=200 characters', removes one config.patch RPC from the avatar path, and collapses the upload handler from a 44-line async/loadConfig dance into a plain synchronous setter. Also lifts the gateway-side ui.assistant.avatar schema cap from 200 to 2,000,000 to match the user-avatar size budget for non-UI clients writing the field directly, and adds a content-aware text/image normalizer in ui/src/ui/assistant-identity.ts so short-text avatars stay short while data URLs survive round-tripping. --------- Co-authored-by: Claude Opus 4.7 <[email protected]>
1 parent 95b7a85 commit c65aa1d

17 files changed

Lines changed: 288 additions & 186 deletions

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ changelog/fragments/
146146

147147
# Local scratch workspace
148148
.tmp/
149+
.vmux*
149150
.artifacts/
150151
test/fixtures/openclaw-vitest-unit-report.json
151152
analysis/

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Docs: https://docs.openclaw.ai
2525

2626
### Fixes
2727

28+
- Control UI/Quick Settings: persist the assistant avatar override to browser local storage (mirroring the user avatar) so uploaded image data URLs no longer fail config validation with "Too big: expected string to have <=200 characters". Also lift the gateway-side `ui.assistant.avatar` length cap to match the user avatar size budget for non-UI clients writing the field directly. Thanks @BunsDev.
2829
- Browser/CDP: make readiness diagnostics use the same discovery-first fallback as reachability for bare `ws://` Browserless and Browserbase CDP URLs. Fixes #69532.
2930
- ACP/OpenCode: update the bundled acpx runtime to 0.6.0 and cover the OpenCode ACP bind path in Docker live tests.
3031
- Browser/existing-session: support per-profile Chrome MCP command/args, map `cdpUrl` to `--browserUrl` or `--wsEndpoint`, and avoid combining endpoint flags with `--userDataDir`. Fixes #47879, #48037, and #62706. Thanks @puneet1409, @zhehao, and @madkow1001.

‎src/config/schema.base.generated.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ export const GENERATED_BASE_CONFIG_SCHEMA: BaseConfigSchemaResponse = {
878878
},
879879
avatar: {
880880
type: "string",
881-
maxLength: 200,
881+
maxLength: 2000000,
882882
title: "Assistant Avatar",
883883
description:
884884
"Assistant avatar image source used in UI surfaces (URL, path, or data URI depending on runtime support). Use trusted assets and consistent branding dimensions for clean rendering.",

‎src/config/zod-schema.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ export const OpenClawSchema = z
457457
assistant: z
458458
.object({
459459
name: z.string().max(50).optional(),
460-
avatar: z.string().max(200).optional(),
460+
avatar: z.string().max(2_000_000).optional(),
461461
})
462462
.strict()
463463
.optional(),

‎src/gateway/assistant-identity.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,17 @@ describe("resolveAssistantIdentity avatar normalization", () => {
4040

4141
expect(resolveAssistantIdentity({ cfg, workspaceDir: "" }).avatar).toBe("avatars/openclaw.png");
4242
});
43+
44+
it("preserves long image data URLs without truncating past 200 chars", () => {
45+
const dataUrl = `data:image/png;base64,${"A".repeat(50_000)}`;
46+
const cfg: OpenClawConfig = {
47+
ui: {
48+
assistant: {
49+
avatar: dataUrl,
50+
},
51+
},
52+
};
53+
54+
expect(resolveAssistantIdentity({ cfg, workspaceDir: "" }).avatar).toBe(dataUrl);
55+
});
4356
});

‎src/gateway/assistant-identity.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ import {
1111
} from "../shared/avatar-policy.js";
1212

1313
const MAX_ASSISTANT_NAME = 50;
14-
const MAX_ASSISTANT_AVATAR = 200;
14+
// Image-bearing avatars (data: URLs, paths) need to round-trip through
15+
// coerceIdentityValue without truncation. Sized to match
16+
// MAX_LOCAL_USER_IMAGE_AVATAR / AVATAR_MAX_BYTES expansion.
17+
const MAX_ASSISTANT_AVATAR = 2_000_000;
1518
const MAX_ASSISTANT_EMOJI = 16;
1619

1720
export const DEFAULT_ASSISTANT_IDENTITY: AssistantIdentity = {

‎ui/src/styles/config-quick.css‎

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@
5656
min-width: 0;
5757
}
5858

59-
.qs-stack--wide {
60-
grid-column: span 2;
61-
}
62-
6359
/* ── Card ── */
6460

6561
.qs-card {
@@ -83,7 +79,12 @@
8379
}
8480

8581
.qs-card--personal {
86-
grid-column: span 2;
82+
grid-column: 1 / -1;
83+
}
84+
85+
.qs-card--personal .qs-identity-grid {
86+
grid-template-columns: repeat(2, minmax(0, 1fr));
87+
padding: 14px 16px 16px;
8788
}
8889

8990
.qs-card__header {
@@ -325,14 +326,37 @@
325326

326327
.qs-identity-card__repair {
327328
display: grid;
328-
gap: 6px;
329+
gap: 8px;
329330
margin-top: 10px;
330331
}
331332

332333
.qs-identity-card__repair .btn {
333334
width: fit-content;
334335
}
335336

337+
.qs-identity-card__repair .qs-field {
338+
gap: 4px;
339+
}
340+
341+
.qs-identity-card__repair .qs-row__label {
342+
font-size: 0.68rem;
343+
font-weight: 600;
344+
letter-spacing: 0.04em;
345+
text-transform: uppercase;
346+
color: var(--muted);
347+
}
348+
349+
.qs-identity-card__repair .qs-field__input {
350+
font-size: 0.78rem;
351+
padding: 6px 9px;
352+
}
353+
354+
.qs-identity-card__actions {
355+
display: flex;
356+
flex-wrap: wrap;
357+
gap: 6px;
358+
}
359+
336360
.qs-identity-card__repair .muted {
337361
font-size: 0.68rem;
338362
line-height: 1.35;
@@ -1054,21 +1078,15 @@
10541078
.qs-grid {
10551079
grid-template-columns: repeat(2, minmax(0, 1fr));
10561080
}
1057-
1058-
.qs-card--personal,
1059-
.qs-stack--wide {
1060-
grid-column: span 1;
1061-
}
10621081
}
10631082

10641083
@media (max-width: 760px) {
10651084
.qs-grid {
10661085
grid-template-columns: 1fr;
10671086
}
10681087

1069-
.qs-card--personal,
1070-
.qs-stack--wide {
1071-
grid-column: 1 / -1;
1088+
.qs-card--personal .qs-identity-grid {
1089+
grid-template-columns: 1fr;
10721090
}
10731091
}
10741092

‎ui/src/styles/config-quick.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe("config-quick styles", () => {
1818

1919
it("includes the stacked quick-settings density layout", () => {
2020
expect(css).toContain(".qs-stack");
21-
expect(css).toContain(".qs-stack--wide");
21+
expect(css).toContain(".qs-identity-card__actions");
2222
expect(css).toContain("grid-template-columns: repeat(3, minmax(0, 1fr));");
2323
expect(css).toContain("grid-template-columns: repeat(2, minmax(0, 1fr));");
2424
expect(css).toContain("@media (max-width: 760px)");

‎ui/src/ui/app-render.ts‎

Lines changed: 13 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { html, nothing } from "lit";
22
import { t } from "../i18n/index.ts";
33
import { getSafeLocalStorage } from "../local-storage.ts";
4-
import { refreshChat, refreshChatAvatar } from "./app-chat.ts";
4+
import { refreshChat } from "./app-chat.ts";
55
import { DEFAULT_CRON_FORM } from "./app-defaults.ts";
66
import { renderUsageTab } from "./app-render-usage-tab.ts";
77
import {
@@ -1038,49 +1038,23 @@ export function renderApp(state: AppViewState) {
10381038
assistantAvatarOverride,
10391039
assistantAvatarUploadBusy: state.assistantAvatarUploadBusy,
10401040
assistantAvatarUploadError: state.assistantAvatarUploadError,
1041-
onAssistantAvatarOverrideChange: async (dataUrl) => {
1042-
state.assistantAvatarUploadBusy = true;
1041+
onAssistantAvatarOverrideChange: (dataUrl) => {
1042+
setAssistantAvatarOverride(state, dataUrl);
1043+
state.chatAvatarUrl = dataUrl;
1044+
state.chatAvatarSource = dataUrl;
1045+
state.chatAvatarStatus = "data";
1046+
state.chatAvatarReason = null;
10431047
state.assistantAvatarUploadError = null;
10441048
requestHostUpdate?.();
1045-
try {
1046-
await setAssistantAvatarOverride(state, dataUrl);
1047-
state.assistantAvatar = dataUrl;
1048-
state.assistantAvatarSource = dataUrl;
1049-
state.assistantAvatarStatus = "data";
1050-
state.assistantAvatarReason = null;
1051-
state.chatAvatarUrl = dataUrl;
1052-
state.chatAvatarSource = dataUrl;
1053-
state.chatAvatarStatus = "data";
1054-
state.chatAvatarReason = null;
1055-
await loadConfig(state);
1056-
await state.loadAssistantIdentity();
1057-
await refreshChatAvatar(state);
1058-
} catch (err) {
1059-
state.assistantAvatarUploadError = err instanceof Error ? err.message : String(err);
1060-
} finally {
1061-
state.assistantAvatarUploadBusy = false;
1062-
requestHostUpdate?.();
1063-
}
10641049
},
1065-
onAssistantAvatarClearOverride: async () => {
1066-
state.assistantAvatarUploadBusy = true;
1050+
onAssistantAvatarClearOverride: () => {
1051+
setAssistantAvatarOverride(state, null);
1052+
state.chatAvatarUrl = null;
1053+
state.chatAvatarSource = null;
1054+
state.chatAvatarStatus = null;
1055+
state.chatAvatarReason = null;
10671056
state.assistantAvatarUploadError = null;
10681057
requestHostUpdate?.();
1069-
try {
1070-
await setAssistantAvatarOverride(state, null);
1071-
state.chatAvatarUrl = null;
1072-
state.chatAvatarSource = null;
1073-
state.chatAvatarStatus = null;
1074-
state.chatAvatarReason = null;
1075-
await loadConfig(state);
1076-
await state.loadAssistantIdentity();
1077-
await refreshChatAvatar(state);
1078-
} catch (err) {
1079-
state.assistantAvatarUploadError = err instanceof Error ? err.message : String(err);
1080-
} finally {
1081-
state.assistantAvatarUploadBusy = false;
1082-
requestHostUpdate?.();
1083-
}
10841058
},
10851059
basePath: state.basePath ?? "",
10861060
configObject: configObj,
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { describe, expect, it } from "vitest";
2+
import { normalizeAssistantIdentity } from "./assistant-identity.ts";
3+
4+
describe("normalizeAssistantIdentity", () => {
5+
it("preserves long image data URLs without truncating past 200 chars", () => {
6+
const dataUrl = `data:image/png;base64,${"A".repeat(50_000)}`;
7+
expect(normalizeAssistantIdentity({ avatar: dataUrl }).avatar).toBe(dataUrl);
8+
});
9+
10+
it("preserves same-origin Control UI avatar routes", () => {
11+
expect(normalizeAssistantIdentity({ avatar: "/avatar/main" }).avatar).toBe("/avatar/main");
12+
});
13+
14+
it("keeps short text avatars", () => {
15+
expect(normalizeAssistantIdentity({ avatar: "PS" }).avatar).toBe("PS");
16+
expect(normalizeAssistantIdentity({ avatar: "🦞" }).avatar).toBe("🦞");
17+
});
18+
19+
it("drops sentence-like text that exceeds the text-avatar limit", () => {
20+
const longText = "this is a description, not an emoji or url ".repeat(4);
21+
expect(normalizeAssistantIdentity({ avatar: longText }).avatar).toBeNull();
22+
});
23+
24+
it("drops avatars containing newlines", () => {
25+
expect(normalizeAssistantIdentity({ avatar: "line1\nline2" }).avatar).toBeNull();
26+
});
27+
});

0 commit comments

Comments
 (0)