Skip to content

Commit 6f20526

Browse files
committed
Merge remote-tracking branch 'origin/main' into fix/venice-gemini-thought-signature-v2
2 parents aceda20 + db90dff commit 6f20526

28 files changed

Lines changed: 1300 additions & 352 deletions

‎CHANGELOG.md‎

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

6565
### Fixes
6666

67+
- **Control UI read-only preferences:** keep personal preference edits browser-local without attempting unauthorized config writes or claiming server sync, preserve offline intent for a later authorized reconnect, and restore the current server value on local reset. Thanks @shakkernerd.
6768
- **Control UI owner handoff:** give browsers opened by host-issued dashboard and graphical onboarding links durable administrator access, including same-browser recovery from a limited credential, while keeping generic, Telegram, mobile, and ordinary scope-upgrade paths bounded. Thanks @shakkernerd.
6869
- **Control UI agent and skill permissions:** gate Agents, Skills, Skill Workshop, and delayed mutation dispatches by the current Gateway method catalog and operator scopes while preserving read-only browsing and legacy Gateway compatibility. Fixes #119176. Thanks @shakkernerd.
6970
- **Guided onboarding skip-UI routing:** keep `openclaw onboard --skip-ui` and `openclaw setup --skip-ui` on guided onboarding while skipping both browser and terminal handoffs, instead of silently switching to the classic wizard. Thanks @shakkernerd.

‎docs/gateway/configuration-reference.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,8 +541,10 @@ See [Plugins](/tools/plugin).
541541
- `assistant`: Control UI identity override. Falls back to active agent identity.
542542
- `prefs`: cross-device operator preferences. This is the canonical home so agents can
543543
change them through the approval gate and every Control UI client stays in
544-
sync; browsers mirror the values into local storage for instant boot and keep
545-
a device-local copy when they cannot write config (viewer scope, offline).
544+
sync; browsers mirror the values into local storage for instant boot. An
545+
explicitly read-only connection keeps edits in that browser without attempting
546+
a config write. Offline edits remain queued for a later writable connection and
547+
continue as browser-local preferences while reconnected read-only.
546548
`chatPersistCommentary` defaults to `true`. Setting it to `false` keeps live
547549
commentary visible during a run but removes it at completion and prevents new
548550
Codex commentary from entering the durable transcript mirror. Messaging-channel

‎docs/web/control-ui.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ Imported themes are stored only in the current browser profile; they are not wri
143143

144144
Appearance also has a Text size setting. It applies to chat text, composer text, tool cards, and chat sidebars, and keeps text inputs at least 16px so mobile Safari does not auto-zoom on focus.
145145

146-
Theme, theme mode, text size, language, and chat display preferences sync through the gateway config (`ui.prefs`), so they follow you across devices and agents can change them through the approval gate — connected clients apply changes live via the gateway's `config.changed` notice. Each browser keeps a local mirror for instant boot; clients that cannot write config (viewer scope, offline) keep changes device-local. See [Configuration reference](/gateway/configuration-reference#ui).
146+
Theme, theme mode, language, and chat display preferences sync through the gateway config (`ui.prefs`), so they follow you across devices and agents can change them through the approval gate — connected clients apply changes live via the gateway's `config.changed` notice. Each browser keeps a local mirror for instant boot. Text size remains browser-local. An explicitly read-only connection applies preference changes only in that browser and does not attempt a config write. Changes made while offline remain queued until a later connection can write config; on a read-only reconnect, they continue to behave as browser-local preferences. See [Configuration reference](/gateway/configuration-reference#ui).
147147

148148
## OpenClaw system care
149149

‎ui/src/app/app-shell-view.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ export function renderApplicationShell(host: ShellViewHost) {
197197
terminalAvailable,
198198
catalogOpenTarget: normalizeCatalogOpenTarget(uiSettings.catalogOpenTarget),
199199
canPairDevice: gatewayConnected && (operatorAccess.canAdmin || operatorAccess.canPair),
200+
preferencesBrowserOnly: gatewayConnected && context.runtimeConfig.canPatch === false,
200201
sidebarEntries: navigationSnapshot.sidebarEntries,
201202
workboardBoards: host.sidebarWorkboardSnapshot.boards,
202203
workboardBoardsReady: host.sidebarWorkboardSnapshot.ready,

‎ui/src/app/server-prefs-state.ts‎

Lines changed: 260 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,260 @@
1+
import { asNullableRecord as asRecord } from "@openclaw/normalization-core/record-coerce";
2+
import { normalizeSidebarEntries } from "../app-navigation.ts";
3+
import { isSupportedLocale } from "../i18n/index.ts";
4+
import {
5+
normalizeChatFollowUpModeOverride,
6+
normalizeChatSendShortcut,
7+
UI_APPEARANCE_DEFAULTS,
8+
type ChatFollowUpMode,
9+
type ChatSendShortcut,
10+
type UiSettings,
11+
} from "./settings.ts";
12+
import type { ThemeMode, ThemeName } from "./theme.ts";
13+
14+
const THEMES: ReadonlySet<ThemeName> = new Set(["claw", "knot", "dash", "custom"]);
15+
const THEME_MODES: ReadonlySet<ThemeMode> = new Set(["light", "dark", "system"]);
16+
17+
type SyncedPrefSpec<T> = {
18+
extract: (value: unknown) => T | undefined;
19+
local: (settings: UiSettings) => T | undefined;
20+
write?: (value: T | undefined) => Partial<UiSettings>;
21+
canApply?: (value: T, settings: UiSettings) => boolean;
22+
clearable?: boolean;
23+
reset?: (settings: UiSettings) => Partial<UiSettings>;
24+
};
25+
26+
const prefSpec = <T>(specification: SyncedPrefSpec<T>) => specification;
27+
28+
/**
29+
* One descriptor per synced pref: the source of truth for config ui.prefs.
30+
* Each key owns server validation, local normalization, and applicability.
31+
*/
32+
export const SYNCED_PREFS = {
33+
theme: prefSpec<ThemeName>({
34+
extract: (value) => (THEMES.has(value as ThemeName) ? (value as ThemeName) : undefined),
35+
local: (settings) => settings.theme,
36+
write: (value) => ({ theme: value ?? UI_APPEARANCE_DEFAULTS.theme }),
37+
clearable: true,
38+
reset: () => ({ theme: UI_APPEARANCE_DEFAULTS.theme }),
39+
// A server "custom" theme is only honorable once this browser imported one;
40+
// the imported palette itself is too large to live in config.
41+
canApply: (value, settings) => value !== "custom" || Boolean(settings.customTheme),
42+
}),
43+
themeMode: prefSpec<ThemeMode>({
44+
extract: (value) => (THEME_MODES.has(value as ThemeMode) ? (value as ThemeMode) : undefined),
45+
local: (settings) => settings.themeMode,
46+
write: (value) => ({ themeMode: value ?? UI_APPEARANCE_DEFAULTS.themeMode }),
47+
clearable: true,
48+
reset: () => ({ themeMode: UI_APPEARANCE_DEFAULTS.themeMode }),
49+
}),
50+
locale: prefSpec<string>({
51+
extract: (value) => (typeof value === "string" && isSupportedLocale(value) ? value : undefined),
52+
local: (settings) => settings.locale,
53+
write: (value) => ({ locale: value }),
54+
clearable: true,
55+
reset: () => ({ locale: undefined }),
56+
}),
57+
chatShowThinking: prefSpec<boolean>({
58+
extract: (value) => (typeof value === "boolean" ? value : undefined),
59+
local: (settings) => settings.chatShowThinking,
60+
}),
61+
chatShowToolCalls: prefSpec<boolean>({
62+
extract: (value) => (typeof value === "boolean" ? value : undefined),
63+
local: (settings) => settings.chatShowToolCalls,
64+
}),
65+
chatPersistCommentary: prefSpec<boolean>({
66+
extract: (value) => (typeof value === "boolean" ? value : undefined),
67+
local: (settings) => settings.chatPersistCommentary !== false,
68+
}),
69+
chatSendShortcut: prefSpec<ChatSendShortcut>({
70+
extract: (value) =>
71+
value === "enter" || value === "modifier-enter"
72+
? normalizeChatSendShortcut(value)
73+
: undefined,
74+
local: (settings) => normalizeChatSendShortcut(settings.chatSendShortcut),
75+
write: (value) => ({ chatSendShortcut: value }),
76+
clearable: true,
77+
reset: () => ({ chatSendShortcut: undefined }),
78+
}),
79+
chatFollowUpMode: prefSpec<ChatFollowUpMode>({
80+
extract: (value) => normalizeChatFollowUpModeOverride(value),
81+
local: (settings) => normalizeChatFollowUpModeOverride(settings.chatFollowUpMode),
82+
write: (value) => ({ chatFollowUpMode: value }),
83+
// Unset means "use the server-configured queue mode"; clearing must propagate,
84+
// so the push serializes an explicit null removal.
85+
clearable: true,
86+
reset: () => ({ chatFollowUpMode: undefined }),
87+
}),
88+
sidebarEntries: prefSpec<string[]>({
89+
extract: (value) => normalizeSidebarEntries(value) ?? undefined,
90+
local: (settings) => settings.sidebarEntries,
91+
}),
92+
} as const;
93+
94+
export type SyncedPrefKey = keyof typeof SYNCED_PREFS;
95+
export type ResettableServerUiPrefKey =
96+
| "theme"
97+
| "themeMode"
98+
| "locale"
99+
| "chatSendShortcut"
100+
| "chatFollowUpMode";
101+
export type SyncedPrefValue<K extends SyncedPrefKey> =
102+
ReturnType<(typeof SYNCED_PREFS)[K]["extract"]> extends (infer T) | undefined ? T : never;
103+
export type ServerUiPrefs = { [K in SyncedPrefKey]?: SyncedPrefValue<K> | null };
104+
export type ServerUiPrefProvenance = "default" | "pending" | "synced" | "device-local";
105+
export type ServerUiPrefState<T> = {
106+
overridden: boolean;
107+
provenance: ServerUiPrefProvenance;
108+
resetValue: T | undefined;
109+
value: T | undefined;
110+
};
111+
112+
export const SYNCED_PREF_KEYS = Object.keys(SYNCED_PREFS) as SyncedPrefKey[];
113+
114+
export function prefValuesEqual(left: unknown, right: unknown): boolean {
115+
if (Array.isArray(left) && Array.isArray(right)) {
116+
return left.length === right.length && left.every((value, index) => value === right[index]);
117+
}
118+
return left === right;
119+
}
120+
121+
export function extractServerUiPrefs(configObject: unknown): ServerUiPrefs {
122+
const prefs = asRecord(asRecord(asRecord(configObject)?.ui)?.prefs);
123+
if (!prefs) {
124+
return {};
125+
}
126+
const result: ServerUiPrefs = {};
127+
for (const key of SYNCED_PREF_KEYS) {
128+
const value = SYNCED_PREFS[key].extract(prefs[key]);
129+
if (value !== undefined) {
130+
(result as Record<string, unknown>)[key] = value;
131+
}
132+
}
133+
return result;
134+
}
135+
136+
export function resolveServerUiPrefStateFromSnapshot<K extends SyncedPrefKey>(
137+
configObject: unknown,
138+
key: K,
139+
shadowPrefs: ServerUiPrefs | null,
140+
settings: UiSettings,
141+
canSync?: boolean | null,
142+
): ServerUiPrefState<SyncedPrefValue<K>> {
143+
const specification = SYNCED_PREFS[key];
144+
const localValue = specification.local(settings) as SyncedPrefValue<K> | undefined;
145+
const resetPatch = specification.reset?.(settings);
146+
const productDefault = (
147+
resetPatch ? specification.local({ ...settings, ...resetPatch }) : undefined
148+
) as SyncedPrefValue<K> | undefined;
149+
const localState = (
150+
resetValue: SyncedPrefValue<K> | undefined,
151+
): ServerUiPrefState<SyncedPrefValue<K>> => {
152+
const overridden = !prefValuesEqual(localValue, resetValue);
153+
return {
154+
overridden,
155+
provenance: overridden ? "device-local" : "default",
156+
resetValue,
157+
value: localValue,
158+
};
159+
};
160+
const prefs = asRecord(asRecord(asRecord(configObject)?.ui)?.prefs);
161+
const serverValue =
162+
prefs && Object.hasOwn(prefs, key)
163+
? (specification.extract(prefs[key]) as SyncedPrefValue<K> | undefined)
164+
: undefined;
165+
const canApplyServerValue =
166+
serverValue !== undefined &&
167+
(!specification.canApply ||
168+
(specification.canApply as (value: unknown, settings: UiSettings) => boolean)(
169+
serverValue,
170+
settings,
171+
));
172+
const applicableServerValue = canApplyServerValue ? serverValue : productDefault;
173+
if (shadowPrefs && key in shadowPrefs) {
174+
if (canSync === false) {
175+
return {
176+
...localState(applicableServerValue),
177+
// Keep queued intent for a later authorized reconnect without claiming
178+
// that this connected read-only browser is pending a server sync.
179+
provenance: "device-local",
180+
};
181+
}
182+
const shadowValue = shadowPrefs[key];
183+
if (shadowValue === null) {
184+
return { ...localState(productDefault), provenance: "pending" };
185+
}
186+
return {
187+
overridden: true,
188+
provenance: "pending",
189+
resetValue: productDefault,
190+
value: shadowValue as SyncedPrefValue<K>,
191+
};
192+
}
193+
if (!prefs || !Object.hasOwn(prefs, key) || serverValue === undefined) {
194+
return localState(productDefault);
195+
}
196+
if (!canApplyServerValue) {
197+
if (canSync === false) {
198+
return localState(productDefault);
199+
}
200+
// Preserve authored server provenance even when this browser cannot render
201+
// the value, so Restore default still removes the server override.
202+
return {
203+
overridden: true,
204+
provenance: "synced",
205+
resetValue: productDefault,
206+
value: localValue,
207+
};
208+
}
209+
if (prefValuesEqual(localValue, serverValue)) {
210+
return {
211+
overridden: true,
212+
provenance: "synced",
213+
resetValue: productDefault,
214+
value: serverValue,
215+
};
216+
}
217+
return localState(serverValue);
218+
}
219+
220+
/** Local-settings patch that brings the browser mirror in line with the server. */
221+
export function serverPrefsLocalPatch(
222+
prefs: ServerUiPrefs,
223+
settings: UiSettings,
224+
): Partial<UiSettings> | null {
225+
const patch: Partial<UiSettings> = {};
226+
for (const key of SYNCED_PREF_KEYS) {
227+
const specification = SYNCED_PREFS[key];
228+
const serverValue = prefs[key];
229+
if (serverValue === undefined) {
230+
continue;
231+
}
232+
if (serverValue === null) {
233+
const resetPatch = specification.clearable ? specification.reset?.(settings) : undefined;
234+
if (resetPatch) {
235+
for (const [resetKey, resetValue] of Object.entries(resetPatch)) {
236+
if (
237+
!prefValuesEqual((settings as unknown as Record<string, unknown>)[resetKey], resetValue)
238+
) {
239+
(patch as Record<string, unknown>)[resetKey] = resetValue;
240+
}
241+
}
242+
}
243+
continue;
244+
}
245+
if (prefValuesEqual(serverValue, specification.local(settings))) {
246+
continue;
247+
}
248+
if (
249+
specification.canApply &&
250+
!(specification.canApply as (value: unknown, settings: UiSettings) => boolean)(
251+
serverValue,
252+
settings,
253+
)
254+
) {
255+
continue;
256+
}
257+
(patch as Record<string, unknown>)[key] = serverValue;
258+
}
259+
return Object.keys(patch).length > 0 ? patch : null;
260+
}

0 commit comments

Comments
 (0)