Skip to content

Commit 31b26d0

Browse files
authored
feat(ui): group advanced settings by messaging channel (#130591)
* feat(ui): group advanced settings by messaging channel * test(ui): connect channel settings fixture for label checks
1 parent 943400e commit 31b26d0

8 files changed

Lines changed: 196 additions & 12 deletions

File tree

‎docs/web/control-ui.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ select it to open the owning Approvals page.
331331
- Labs exposes shipped experimental switches. Code Mode and Swarm are the current entries and save `tools.codeMode.enabled` and `tools.swarm.enabled` immediately; unshipped experiments do not appear or write speculative config keys.
332332
- Notifications: browser web-push status, subscribe/unsubscribe, and a test send.
333333
- Advanced: every config section without a curated home, plus the raw JSON5 editor (previously the General page's Advanced mode).
334+
- In **Advanced → Communication → Channels**, use **Channel settings** to show one messaging channel at a time, including custom channel plugins. **Other** groups shared channel defaults and model overrides. Switching groups does not change the saved configuration.
334335
- Model Setup (`/settings/model-setup`) is a subpage of Model Providers, launched from its header.
335336
- Agents: a settings page (**Settings → Agents**, `/settings/agents`) with an **Agent defaults** row for the shared template plus per-agent tabs (Overview, Files, Tools, Skills, Channels, Automations, Memory). The Overview tab edits the agent's identity — display name, emoji, and an avatar image that is downscaled and size-bounded in the browser before `agents.update`. Saving stores configured identity fields and mirrors them to the workspace `IDENTITY.md`; configured values take precedence over manual edits to the same file fields. The Tools tab connects a system or per-agent GitHub identity through a user-clicked device-authorization link, shows the one-time code and credential health, and keeps one-use PAT setup as an explicit fallback.
336337
- Profile: a settings page showing the default agent's identity with all-time usage stats — lifetime tokens, peak day, longest session, activity streaks, a year-long token heatmap, top tools, and channel highlights (`usage.cost`, `sessions.usage`).

‎src/config/channel-config-keys.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const CHANNEL_KERNEL_CONFIG_KEYS = new Set(["defaults", "modelByChannel"]);
2+
3+
/** Return whether a channel config key names a kernel-owned namespace. */
4+
export function isKernelOwnedChannelConfigKey(key: string): boolean {
5+
return CHANNEL_KERNEL_CONFIG_KEYS.has(key);
6+
}

‎src/config/schema.hints.ts‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
} from "@openclaw/net-policy/redact-sensitive-url";
66
import { z } from "zod";
77
import type { ConfigUiHints } from "../shared/config-ui-hints-types.js";
8+
import { isKernelOwnedChannelConfigKey } from "./channel-config-keys.js";
89
import { FIELD_HELP } from "./schema.help.js";
910
import { FIELD_LABELS } from "./schema.labels.js";
1011
import { applyDerivedTags } from "./schema.tags.js";
@@ -115,12 +116,6 @@ const FIELD_PLACEHOLDERS: Record<string, string> = {
115116
};
116117

117118
const CHANNEL_NAMESPACE_PREFIX = "channels.";
118-
const CHANNEL_KERNEL_CONFIG_KEYS = new Set(["defaults", "modelByChannel"]);
119-
120-
/** Return whether a channel config key names a kernel-owned namespace. */
121-
export function isKernelOwnedChannelConfigKey(key: string): boolean {
122-
return CHANNEL_KERNEL_CONFIG_KEYS.has(key);
123-
}
124119

125120
function isKernelOwnedChannelHintPath(path: string): boolean {
126121
if (path === "channels") {

‎src/system-agent/config-redaction.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ import {
77
import { isRecord } from "@openclaw/normalization-core/record-coerce";
88
import { CHANNEL_IDS } from "../channels/ids.js";
99
import { parseConfigSetPath, parseConfigSetValue } from "../cli/config-cli-path.js";
10+
import { isKernelOwnedChannelConfigKey } from "../config/channel-config-keys.js";
1011
import {
1112
collectChannelSchemaMetadataCore,
1213
collectPluginSchemaMetadataCore,
1314
} from "../config/channel-config-metadata.js";
1415
import { REDACTED_SENTINEL, redactConfigObject } from "../config/redact-snapshot.js";
1516
import { getRuntimeConfigSnapshot } from "../config/runtime-snapshot.js";
16-
import { isKernelOwnedChannelConfigKey } from "../config/schema.hints.js";
1717
import {
1818
buildConfigSchemaCore,
1919
classifyConfigSchemaPathSegment,

‎ui/src/i18n/locales/en.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,6 +1769,7 @@ export const en: TranslationMap = {
17691769
},
17701770
configView: {
17711771
adminRequired: "Configuration changes require operator.admin access.",
1772+
channelSettings: "Channel settings",
17721773
categories: {
17731774
core: "Core",
17741775
ai: "Agent Defaults",

‎ui/src/pages/config/view-navigation.ts‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
11
import type { TemplateResult } from "lit";
2+
import { isKernelOwnedChannelConfigKey } from "../../../../src/config/channel-config-keys.js";
3+
import type { ConfigUiHints } from "../../api/types.ts";
4+
import { hintForPath, humanize, type JsonSchema } from "../../components/config-form.shared.ts";
25
import { icons } from "../../components/icons.ts";
6+
import { t } from "../../i18n/index.ts";
7+
8+
export function getChannelConfigGroups(schema: JsonSchema, hints: ConfigUiHints) {
9+
const entries = Object.entries(schema.properties ?? {});
10+
const channels = entries
11+
.filter(([key]) => !isKernelOwnedChannelConfigKey(key))
12+
.map(([key, node]) => ({
13+
key,
14+
label: hintForPath(["channels", key], hints)?.label ?? node.title ?? humanize(key),
15+
keys: [key],
16+
}))
17+
.toSorted((a, b) => a.label.localeCompare(b.label) || a.key.localeCompare(b.key));
18+
const sharedKeys = entries
19+
.filter(([key]) => isKernelOwnedChannelConfigKey(key))
20+
.map(([key]) => key);
21+
return [
22+
...channels,
23+
...(sharedKeys.length > 0
24+
? [{ key: null, label: t("configView.categories.other"), keys: sharedKeys }]
25+
: []),
26+
];
27+
}
328

429
const sidebarIcons: Record<string, TemplateResult> = {
530
all: icons.layoutGrid,

‎ui/src/pages/config/view.browser.test.ts‎

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,114 @@ describe("config view", () => {
877877
expect(onWebPushSubscribe).toHaveBeenCalledOnce();
878878
});
879879

880+
it.each(["tabs", "accordion"] as const)(
881+
"groups channel settings without changing patch paths (%s)",
882+
(settingsLayout) => {
883+
const { container, props } = renderConfigView({
884+
activeSection: "channels",
885+
settingsLayout,
886+
forceShowAdvanced: true,
887+
schema: {
888+
type: "object",
889+
properties: {
890+
channels: {
891+
type: "object",
892+
additionalProperties: true,
893+
properties: {
894+
telegram: {
895+
type: "object",
896+
properties: { username: { type: "string", title: "Bot username" } },
897+
},
898+
"custom-chat": {
899+
anyOf: [
900+
{ type: "object", properties: { room: { type: "string", title: "Room" } } },
901+
{ type: "null" },
902+
],
903+
},
904+
defaults: {
905+
type: "object",
906+
properties: { groupPolicy: { type: "string", title: "Group policy" } },
907+
},
908+
modelByChannel: {
909+
type: "object",
910+
additionalProperties: {
911+
type: "object",
912+
additionalProperties: { type: "string" },
913+
},
914+
},
915+
},
916+
},
917+
},
918+
},
919+
uiHints: {
920+
"channels.telegram": { label: "Telegram" },
921+
"channels.custom-chat": { label: "Custom Chat" },
922+
"channels.modelByChannel": { label: "Channel Model Overrides" },
923+
},
924+
formValue: {
925+
channels: {
926+
telegram: { username: "test_bot" },
927+
"custom-chat": { room: "team" },
928+
defaults: { groupPolicy: "allowlist" },
929+
modelByChannel: {},
930+
},
931+
},
932+
});
933+
document.body.append(container);
934+
try {
935+
const picker = queryRequired(container, "select", HTMLSelectElement);
936+
expect(picker.labels?.[0]?.textContent).toContain("Channel settings");
937+
expect(Array.from(picker.options, (option) => option.textContent?.trim())).toEqual([
938+
"Custom Chat",
939+
"Telegram",
940+
"Other",
941+
]);
942+
expect(picker.selectedOptions[0]?.textContent?.trim()).toBe("Other");
943+
const content = () =>
944+
normalizedText(queryRequired(container, ".settings-page", HTMLElement));
945+
expect(content()).toContain("Group policy");
946+
expect(content()).toContain("Channel Model Overrides");
947+
expect(content()).not.toContain("Bot username");
948+
props.onSubsectionChange = (key) => {
949+
props.activeSubsection = key;
950+
render(renderConfig(props), container);
951+
};
952+
render(renderConfig(props), container);
953+
const choose = (key: string) => {
954+
picker.value = key;
955+
picker.dispatchEvent(new Event("change", { bubbles: true }));
956+
};
957+
choose("telegram");
958+
expect(content()).toContain("Bot username");
959+
expect(content()).not.toContain("Group policy");
960+
expect(content()).not.toContain("Room");
961+
const username = queryRequired(container, 'input[type="text"]', HTMLInputElement);
962+
expect(username.value).toBe("test_bot");
963+
username.value = "updated_bot";
964+
username.dispatchEvent(new Event("input", { bubbles: true }));
965+
expect(props.onFormPatch).toHaveBeenCalledWith(
966+
["channels", "telegram", "username"],
967+
"updated_bot",
968+
);
969+
choose("custom-chat");
970+
expect(content()).toContain("Room");
971+
expect(content()).not.toContain("Bot username");
972+
choose("");
973+
const policy = queryRequired(container, 'input[type="text"]', HTMLInputElement);
974+
policy.value = "open";
975+
policy.dispatchEvent(new Event("input", { bubbles: true }));
976+
expect(props.onFormPatch).toHaveBeenCalledWith(
977+
["channels", "defaults", "groupPolicy"],
978+
"open",
979+
);
980+
render(renderConfig({ ...props, formMode: "raw" }), container);
981+
expect(container.querySelector("select")).toBeNull();
982+
} finally {
983+
container.remove();
984+
}
985+
},
986+
);
987+
880988
it("resets config content scroll when switching top-tab sections", async () => {
881989
const { container } = renderConfigView({
882990
activeSection: "channels",

‎ui/src/pages/config/view.ts‎

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { renderAppearanceSection } from "./view-appearance.ts";
1616
import { computeRawDiff, formatConfigDiffPath, renderRawDiffValue } from "./view-diff.ts";
1717
import {
1818
CATEGORISED_KEYS,
19+
getChannelConfigGroups,
1920
getSectionIcon,
2021
SECTION_CATEGORIES,
2122
type SectionCategory,
@@ -188,8 +189,30 @@ export function renderConfig(props: ConfigProps) {
188189
? { id: "other", label: t("configView.categories.other"), sections: extraSections }
189190
: null;
190191

191-
// Config subsections are always rendered as a single page per section.
192-
const effectiveSubsection = null;
192+
const channelSchema = props.activeSection === "channels" ? schemaProps.channels : undefined;
193+
const channelGroups = channelSchema ? getChannelConfigGroups(channelSchema, props.uiHints) : [];
194+
const channelGroup =
195+
channelGroups.find((group) => group.key === props.activeSubsection) ?? channelGroups[0];
196+
// Keep the original field paths and values: Other is navigation, not a config namespace.
197+
const formSchema =
198+
channelSchema && channelGroup
199+
? {
200+
...analysis.schema,
201+
properties: {
202+
...schemaProps,
203+
channels: {
204+
...channelSchema,
205+
properties: Object.fromEntries(
206+
Object.entries(channelSchema.properties ?? {}).filter(([key]) =>
207+
channelGroup.keys.includes(key),
208+
),
209+
),
210+
required: channelSchema.required?.filter((key) => channelGroup.keys.includes(key)),
211+
additionalProperties: false,
212+
},
213+
},
214+
}
215+
: analysis.schema;
193216
const topTabs = [
194217
...(showRootTab
195218
? [{ key: null as string | null, label: props.navRootLabel ?? t("nav.settings") }]
@@ -368,7 +391,8 @@ export function renderConfig(props: ConfigProps) {
368391
: nothing;
369392
const showToolbar = showModeToggle || showSectionTabs;
370393
const showValidityWarning = validity === "invalid" && !viewState.validityDismissed;
371-
const showLead = showToolbar || settingsLayout === "accordion" || showValidityWarning;
394+
const showLead =
395+
showToolbar || settingsLayout === "accordion" || showValidityWarning || Boolean(channelGroup);
372396

373397
const lead = html`<div class="config-lead">
374398
${showToolbar
@@ -403,6 +427,30 @@ export function renderConfig(props: ConfigProps) {
403427
</div>`
404428
: nothing}
405429
${settingsLayout === "accordion" ? renderAccordionNav() : nothing}
430+
${channelGroup && formMode === "form"
431+
? html`<div class="config-toolbar">
432+
<label class="field">
433+
<span>${t("configView.channelSettings")}</span>
434+
<select
435+
class="settings-select"
436+
.value=${channelGroup.key ?? ""}
437+
@change=${(event: Event) => {
438+
// SAFETY: This handler is bound directly to the native select above.
439+
const select = event.currentTarget as HTMLSelectElement;
440+
props.onSubsectionChange(select.value || null);
441+
resetContentScroll(event.currentTarget);
442+
}}
443+
>
444+
${channelGroups.map(
445+
(group) =>
446+
html`<option value=${group.key ?? ""} ?selected=${group.key === channelGroup.key}>
447+
${group.label}
448+
</option>`,
449+
)}
450+
</select>
451+
</label>
452+
</div>`
453+
: nothing}
406454
${showValidityWarning
407455
? html`<div class="config-validity-warning">
408456
<svg
@@ -475,7 +523,7 @@ export function renderConfig(props: ConfigProps) {
475523
<span>${t("configView.loadingSchema")}</span>
476524
</div>`
477525
: renderConfigForm({
478-
schema: analysis.schema,
526+
schema: formSchema,
479527
uiHints: props.uiHints,
480528
value: props.formValue,
481529
embedded: props.embeddedEditor === true,
@@ -485,7 +533,7 @@ export function renderConfig(props: ConfigProps) {
485533
onPatch: props.onFormPatch,
486534
onRemove: props.onFormRemove,
487535
activeSection: props.activeSection,
488-
activeSubsection: effectiveSubsection,
536+
activeSubsection: null,
489537
showAdvanced: effectiveShowAdvanced,
490538
forceAdvancedSection: props.forceAdvancedSection,
491539
onShowAdvanced: () => props.setShowAdvancedSettings(true),

0 commit comments

Comments
 (0)