Skip to content

Commit 6a9b00a

Browse files
committed
fix(ui): keep control UI select values stable on load
1 parent 4b36759 commit 6a9b00a

6 files changed

Lines changed: 89 additions & 6 deletions

File tree

‎CHANGELOG.md‎

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

1313
### Fixes
1414

15+
- Control UI: keep Agents model and config enum dropdowns visually aligned with their configured values on initial load while inherited non-default agents stay on the inherit-default option. Fixes #40352; repairs #52948. Thanks @xiaoquanidea.
1516
- CLI/plugins: use plugin metadata snapshots for install slot selection and add opt-in plugin lifecycle timing traces, so plugin install avoids runtime-loading the plugin registry for metadata-only decisions. Thanks @shakkernerd.
1617
- fix(plugins): restrict bundled plugin dir resolution to trusted package roots. (#73275) Thanks @pgondhi987.
1718
- fix(security): prevent workspace PATH injection via service env and trash helpers. (#73264) Thanks @pgondhi987.

‎ui/src/ui/config-form.browser.test.ts‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,41 @@ describe("config form renderer", () => {
9898
expect(onPatch).toHaveBeenCalledWith(["bind"], "tailnet");
9999
});
100100

101+
it("selects the configured option for large enum dropdowns", async () => {
102+
const onPatch = vi.fn();
103+
const container = document.createElement("div");
104+
const schema = {
105+
type: "object",
106+
properties: {
107+
provider: {
108+
type: "string",
109+
enum: ["anthropic", "openai", "google", "ollama", "minimax", "xai"],
110+
},
111+
},
112+
};
113+
const analysis = analyzeConfigSchema(schema);
114+
115+
render(
116+
renderConfigForm({
117+
schema: analysis.schema,
118+
uiHints: {},
119+
unsupportedPaths: analysis.unsupportedPaths,
120+
value: { provider: "minimax" },
121+
onPatch,
122+
}),
123+
container,
124+
);
125+
126+
const select = await vi.waitFor(() => {
127+
const node = container.querySelector<HTMLSelectElement>(".cfg-select");
128+
expect(node).not.toBeNull();
129+
return node;
130+
});
131+
132+
expect(select?.value).toBe("4");
133+
expect(select?.selectedOptions[0]?.textContent).toBe("minimax");
134+
});
135+
101136
it("renders map fields from additionalProperties", () => {
102137
const onPatch = vi.fn();
103138
const container = document.createElement("div");

‎ui/src/ui/views/agents-panels-overview.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ export function renderAgentOverview(params: {
147147
onModelChange(agent.id, (e.target as HTMLSelectElement).value || null)}
148148
>
149149
${isDefault
150-
? html` <option value="">Not set</option> `
150+
? html` <option value="" .selected=${!effectivePrimary}>Not set</option> `
151151
: html`
152-
<option value="">
152+
<option value="" .selected=${!entryPrimary}>
153153
${defaultPrimary ? `Inherit default (${defaultPrimary})` : "Inherit default"}
154154
</option>
155155
`}

‎ui/src/ui/views/agents-utils.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ export function buildModelOptions(
694694
const sel = selected !== undefined ? selected : current;
695695
return options.map(
696696
(option) =>
697-
html`<option value=${option.value} ?selected=${option.value === sel}>
697+
html`<option value=${option.value} .selected=${option.value === sel}>
698698
${option.label}
699699
</option>`,
700700
);

‎ui/src/ui/views/agents.test.ts‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ describe("renderAgents", () => {
162162
).toBe(true);
163163
return select;
164164
});
165+
expect(betaSelect?.value).toBe("openai/gpt-5.4");
166+
expect(betaSelect?.selectedOptions[0]?.value).toBe("openai/gpt-5.4");
165167

166168
render(
167169
renderAgents(
@@ -188,6 +190,51 @@ describe("renderAgents", () => {
188190
return select;
189191
});
190192
expect(alphaSelect).not.toBe(betaSelect);
193+
expect(alphaSelect?.value).toBe("anthropic/claude-sonnet-4-6");
194+
expect(alphaSelect?.selectedOptions[0]?.value).toBe("anthropic/claude-sonnet-4-6");
195+
});
196+
197+
it("keeps inherited non-default agents on the inherit option", async () => {
198+
const container = document.createElement("div");
199+
const configForm = {
200+
agents: {
201+
defaults: {
202+
model: { primary: "anthropic/claude-sonnet-4-6" },
203+
models: {
204+
"anthropic/claude-sonnet-4-6": {},
205+
"openai/gpt-5.4": {},
206+
},
207+
},
208+
list: [{ id: "beta" }],
209+
},
210+
};
211+
212+
render(
213+
renderAgents(
214+
createProps({
215+
selectedAgentId: "beta",
216+
config: {
217+
form: configForm,
218+
loading: false,
219+
saving: false,
220+
dirty: false,
221+
},
222+
}),
223+
),
224+
container,
225+
);
226+
227+
const select = await vi.waitFor(() => {
228+
const node = container.querySelector<HTMLSelectElement>(".agent-model-fields select");
229+
expect(node).not.toBeNull();
230+
return node;
231+
});
232+
233+
expect(select?.value).toBe("");
234+
expect(select?.selectedOptions[0]?.value).toBe("");
235+
expect(select?.selectedOptions[0]?.textContent?.trim()).toBe(
236+
"Inherit default (anthropic/claude-sonnet-4-6)",
237+
);
191238
});
192239

193240
it("shows the skills count only for the selected agent's report", async () => {

‎ui/src/ui/views/config-form.node.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -852,11 +852,11 @@ function renderSelect(params: {
852852
onPatch(path, val === unset ? undefined : options[Number(val)]);
853853
}}
854854
>
855-
<option value=${unset} ?selected=${currentIndex < 0}>Select...</option>
855+
<option value=${unset} .selected=${currentIndex < 0}>Select...</option>
856856
${options.map(
857857
(opt, idx) => html`
858-
<option value=${String(idx)} ?selected=${idx === currentIndex}>${String(opt)}</option>
859-
`,
858+
<option value=${String(idx)} .selected=${idx === currentIndex}>${String(opt)}</option>
859+
`,
860860
)}
861861
</select>
862862
</div>

0 commit comments

Comments
 (0)