From dc490f1017dfeeba4cb50c317100c779b5b8eed2 Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Thu, 26 Nov 2026 21:39:30 +0800 Subject: [PATCH] fix(ui): show agent and user-defined option labels as written (#6193) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Option labels that come from agents, databases, build tools and user settings matched UI catalog keys by accident, so some were translated and others were not (reasoning effort showed 高 next to Extra high; an HTTP client environment named test showed as 测试 while prod stayed English). Mark these labels and descriptions verbatim: agent config values, model names and providers, the approval switch label, HTTP client environments, dependency scopes and Gradle configurations, chart columns, database schemas, data sources, warehouses and roles, custom scopes, and plugin setting options. Option headings stay localized. Fixes #6191 --- src/features/agents/AgentList.tsx | 1 + src/features/agents/ConfigPickers.test.tsx | 101 +++++++++++++++--- src/features/agents/ConfigPickers.tsx | 34 ++++-- src/features/analysis/dialogs.tsx | 8 +- .../build-tools/DependencyAnalyzer.tsx | 8 +- src/features/database/ChartView.tsx | 2 +- src/features/database/SchemaCompareDialog.tsx | 11 +- src/features/database/SqlScopesPage.tsx | 7 +- src/features/database/console.tsx | 6 +- src/features/http-client/editor.tsx | 5 +- src/features/plugins/settings.tsx | 2 +- src/features/search/find/FindInFiles.tsx | 2 + src/features/settings/pages/ScopesBody.tsx | 10 +- 13 files changed, 163 insertions(+), 34 deletions(-) diff --git a/src/features/agents/AgentList.tsx b/src/features/agents/AgentList.tsx index bbe057800..d6bb14cde 100644 --- a/src/features/agents/AgentList.tsx +++ b/src/features/agents/AgentList.tsx @@ -1157,6 +1157,7 @@ function AgentDefaults({ agent, backend }: { agent: AgentProvider; backend: Comm label: v.name, verbatim: true, detail: v.description ?? undefined, + verbatimDetail: true, })), ]} onChange={(value) => choose(o.id, value)} diff --git a/src/features/agents/ConfigPickers.test.tsx b/src/features/agents/ConfigPickers.test.tsx index e70ee21a9..9bc300415 100644 --- a/src/features/agents/ConfigPickers.test.tsx +++ b/src/features/agents/ConfigPickers.test.tsx @@ -1,6 +1,7 @@ import { fireEvent, render, screen, within } from "@testing-library/react"; import { beforeEach, describe, expect, it, vi } from "vitest"; import type { AgentConfigOption } from "@/bindings"; +import { useI18n } from "@/platform/i18n"; import { ConfigPickers, computeOverflowLayout, configPickerOptions } from "./ConfigPickers"; import { useAgents } from "./store"; @@ -22,8 +23,15 @@ const value = (id: string, name = id, description: string | null = null) => ({ v describe("configPickerOptions", () => { it("groups nested paths by their first provider and preserves the full value and description", () => { expect(configPickerOptions(config([value("9router/cmc/Beam", "Beam display", "Fast")]))).toEqual([ - { value: "9router", label: "9router", section: true }, - { value: "9router/cmc/Beam", label: "Beam display", detail: "cmc/Beam · Fast", keywords: "9router" }, + { value: "9router", label: "9router", verbatim: true, section: true }, + { + value: "9router/cmc/Beam", + label: "Beam display", + verbatim: true, + detail: "cmc/Beam · Fast", + verbatimDetail: true, + keywords: "9router", + }, ]); }); it("shows the agent-reported model name without the repeated provider prefix and keeps the id as the detail", () => { @@ -36,21 +44,49 @@ describe("configPickerOptions", () => { ]), ), ).toEqual([ - { value: "opencode", label: "opencode", section: true }, - { value: "opencode/beam-free", label: "Beam Free", detail: "beam-free", keywords: "opencode" }, - { value: "opencode/big-pickle", label: "Big Pickle", detail: "big-pickle", keywords: "opencode" }, - { value: "opencode/hy4-flash-free", label: "hy4 flash Free", detail: "hy4-flash-free", keywords: "opencode" }, + { value: "opencode", label: "opencode", verbatim: true, section: true }, + { + value: "opencode/beam-free", + label: "Beam Free", + verbatim: true, + detail: "beam-free", + verbatimDetail: true, + keywords: "opencode", + }, + { + value: "opencode/big-pickle", + label: "Big Pickle", + verbatim: true, + detail: "big-pickle", + verbatimDetail: true, + keywords: "opencode", + }, + { + value: "opencode/hy4-flash-free", + label: "hy4 flash Free", + verbatim: true, + detail: "hy4-flash-free", + verbatimDetail: true, + keywords: "opencode", + }, ]); }); it("falls back to the compact id tail when the agent echoes the id as its name", () => { expect(configPickerOptions(config([value("acme/ctx/big")]))).toEqual([ - { value: "acme", label: "acme", section: true }, - { value: "acme/ctx/big", label: "big", detail: "ctx/big", keywords: "acme" }, + { value: "acme", label: "acme", verbatim: true, section: true }, + { + value: "acme/ctx/big", + label: "big", + verbatim: true, + detail: "ctx/big", + verbatimDetail: true, + keywords: "acme", + }, ]); }); it("keeps plain ids ungrouped even when the display name contains a slash", () => { expect(configPickerOptions(config([value("plain", "Local / Beam", "Offline")]))).toEqual([ - { value: "plain", label: "Local / Beam", detail: "Offline", keywords: "" }, + { value: "plain", label: "Local / Beam", verbatim: true, detail: "Offline", verbatimDetail: true, keywords: "" }, ]); }); it("collects several providers in encounter order and preserves order inside each group", () => { @@ -70,7 +106,7 @@ describe("configPickerOptions", () => { }); it("leaves non-model option labels and descriptions intact", () => { expect(configPickerOptions(config([value("a/One", "Custom", "Description")], "mode"))).toEqual([ - { value: "a/One", label: "Custom", detail: "Description" }, + { value: "a/One", label: "Custom", verbatim: true, detail: "Description", verbatimDetail: true }, ]); }); it("places pinned models in a top Pinned section and prepends usageMultiplier to detail", () => { @@ -88,9 +124,23 @@ describe("configPickerOptions", () => { ); expect(options).toEqual([ { value: "__pinned__", label: "Pinned", section: true }, - { value: "gemini-4-carbon", label: "Gemini 4 Carbon", detail: "1x · Powerful · Medium cost", keywords: "" }, + { + value: "gemini-4-carbon", + label: "Gemini 4 Carbon", + verbatim: true, + detail: "1x · Powerful · Medium cost", + verbatimDetail: true, + keywords: "", + }, { value: "__models__", label: "Models", section: true }, - { value: "gpt-6-sol", label: "GPT-6 Sol", detail: "1x · Medium cost", keywords: "" }, + { + value: "gpt-6-sol", + label: "GPT-6 Sol", + verbatim: true, + detail: "1x · Medium cost", + verbatimDetail: true, + keywords: "", + }, ]); }); }); @@ -385,6 +435,33 @@ describe("model settings", () => { expect(screen.queryByRole("dialog", { name: "Model settings" })).not.toBeInTheDocument(); }); + it("keeps agent effort labels as written in every UI language", () => { + const previous = useI18n.getState().texts; + useI18n.setState({ texts: { ...previous, Low: "低", High: "高", Max: "最大值", "Effort Level": "推理强度" } }); + try { + const config = copilotConfig().map((o) => + o.category === "thought_level" + ? { + ...o, + values: ["Low", "Medium", "High", "Extra high", "Max", "Ultra"].map((name) => + value(name.toLowerCase().replace(" ", "-"), name), + ), + current: "high", + } + : o, + ); + render(); + fireEvent.click(screen.getByRole("button", { name: /: High$/ })); + const levels = within(screen.getByRole("dialog")).getByRole("listbox", { name: "推理强度" }); + expect(within(levels).getByRole("option", { name: "High" })).toHaveAttribute("aria-selected", "true"); + for (const name of ["Low", "Medium", "Extra high", "Max", "Ultra"]) + expect(within(levels).getByRole("option", { name })).toBeInTheDocument(); + expect(within(levels).queryByText(/低|高|最大值/)).not.toBeInTheDocument(); + } finally { + useI18n.setState({ texts: previous }); + } + }); + it("tucks Fast into the model popup", () => { const config = [ ...copilotConfig().filter((o) => o.category !== "thought_level"), diff --git a/src/features/agents/ConfigPickers.tsx b/src/features/agents/ConfigPickers.tsx index b70f5b9b6..1b89cb268 100644 --- a/src/features/agents/ConfigPickers.tsx +++ b/src/features/agents/ConfigPickers.tsx @@ -19,7 +19,7 @@ export function configPickerOptions( descriptions = true, ): SelectOption[] { if (option.category !== "model") { - return option.values.map((v) => ({ value: v.value, label: v.name, detail: v.description ?? undefined })); + return option.values.map((v) => agentValueOption(v)); } const pinnedSet = new Set(pinned); const buildItem = (v: AgentConfigOption["values"][number]): { provider: string; opt: SelectOption } => { @@ -40,7 +40,10 @@ export function configPickerOptions( (p): p is string => !!p, ); const detail = parts.length > 0 ? parts.join(" · ") : undefined; - return { provider, opt: { value: v.value, label, detail, keywords: provider } }; + return { + provider, + opt: { value: v.value, label, verbatim: true, detail, verbatimDetail: true, keywords: provider }, + }; }; const pinnedItems: SelectOption[] = []; @@ -61,10 +64,18 @@ export function configPickerOptions( ...(pinnedItems.length > 0 ? [{ value: "__pinned__", label: "Pinned", section: true }, ...pinnedItems] : []), ...(pinnedItems.length > 0 && plain.length > 0 ? [{ value: "__models__", label: "Models", section: true }] : []), ...plain, - ...[...groups].flatMap(([provider, items]) => [{ value: provider, label: provider, section: true }, ...items]), + ...[...groups].flatMap(([provider, items]) => [ + { value: provider, label: provider, verbatim: true, section: true }, + ...items, + ]), ]; } +/** An agent-reported value: its name and description show as the agent wrote them in every UI language. */ +function agentValueOption(v: AgentConfigOption["values"][number]): SelectOption { + return { value: v.value, label: v.name, verbatim: true, detail: v.description ?? undefined, verbatimDetail: true }; +} + /** The on and off values of a two-state permissions or fast option, or null when it has other values. */ function switchValues(option: AgentConfigOption): { on: string; off: string } | null { const isFast = option.id === "fast" || (option.category === "model_config" && !isContextOption(option.id)); @@ -79,6 +90,8 @@ interface ModeApprovalSwitch { off: string; /** Switch label inside the Mode popup footer (e.g. "Allow All", "Bypass approvals"). */ label: string; + /** The label is the agent's name for the "on" value, shown as written. */ + verbatimLabel?: boolean; /** Concise detail shown on the Mode chip when enabled (e.g. "Allow All", "Bypass"). */ chipLabel: string; } @@ -93,7 +106,13 @@ function modeApprovalSwitch(option: AgentConfigOption): ModeApprovalSwitch | nul const on = option.values.find((v) => v.value.toLowerCase() === "bypass"); const off = option.values.find((v) => v !== on); if (on && off) { - return { on: on.value, off: off.value, label: on.name || option.name, chipLabel: "Bypass" }; + return { + on: on.value, + off: off.value, + label: on.name || option.name, + verbatimLabel: !!on.name, + chipLabel: "Bypass", + }; } } return null; @@ -643,7 +662,7 @@ function ModelSettings({ ({ value: v.value, label: v.name, detail: v.description ?? undefined }))} + options={o.values.map((v) => agentValueOption(v))} onChoose={(v) => { if (v !== currentValue) onChange(o.id, v); if (only) onDone(); @@ -732,6 +751,7 @@ function ModePicker({ const [open, setOpen] = useState(false); const anchor = useRef(null); const toggle = modeApprovalSwitch(allowAll)!; + const switchLabel = toggle.verbatimLabel ? toggle.label : tx(toggle.label); const current = selected(mode, modeValue); const on = allowAllValue === toggle.on; const approvalText = @@ -790,10 +810,10 @@ function ModePicker({ ))}
- {tx(toggle.label)} + {switchLabel} onChange(allowAll.id, checked ? toggle.on : toggle.off)} />
diff --git a/src/features/analysis/dialogs.tsx b/src/features/analysis/dialogs.tsx index 22255b1f2..8263587dd 100644 --- a/src/features/analysis/dialogs.tsx +++ b/src/features/analysis/dialogs.tsx @@ -105,7 +105,13 @@ export function ScopeFields({ className={styles.grow} value={(selected ? value.custom : custom) ?? null} - options={scopes.map((s) => ({ value: s.name, label: s.name, detail: s.pattern }))} + options={scopes.map((s) => ({ + value: s.name, + label: s.name, + verbatim: true, + detail: s.pattern, + verbatimDetail: true, + }))} placeholder={scopes.length ? "Choose a scope" : "No custom scopes"} disabled={!selected} onChange={(custom) => onChange({ ...value, custom })} diff --git a/src/features/build-tools/DependencyAnalyzer.tsx b/src/features/build-tools/DependencyAnalyzer.tsx index ded16b57d..d916ad052 100644 --- a/src/features/build-tools/DependencyAnalyzer.tsx +++ b/src/features/build-tools/DependencyAnalyzer.tsx @@ -451,9 +451,13 @@ export function DependencyAnalyzer(_props: { input: EditorInput }) { const selected = artifacts.find((a) => a.key === selectedKey) ?? null; const scopeOptions: SelectOption[] = [ { value: ALL_SCOPES, label: tx("All scopes") }, - ...scopesOf(artifacts).map((s) => ({ value: s, label: s })), + ...scopesOf(artifacts).map((s) => ({ value: s, label: s, verbatim: true })), ]; - const configurationOptions: SelectOption[] = (configurations ?? []).map((c) => ({ value: c, label: c })); + const configurationOptions: SelectOption[] = (configurations ?? []).map((c) => ({ + value: c, + label: c, + verbatim: true, + })); const refreshGradle = () => { if (configuration === null) void syncTool("gradle", buildDir); else setGeneration((g) => g + 1); diff --git a/src/features/database/ChartView.tsx b/src/features/database/ChartView.tsx index fc9d5c0b3..2e60c6930 100644 --- a/src/features/database/ChartView.tsx +++ b/src/features/database/ChartView.tsx @@ -56,7 +56,7 @@ export function ChartView({ columns, rows }: { columns: readonly GridColumn[]; r return () => ro.disconnect(); }, []); - const options = columns.map((c, i) => ({ value: String(i), label: c.name })); + const options = columns.map((c, i) => ({ value: String(i), label: c.name, verbatim: true })); const values = points.map((p) => p.value); const ticks = niceTicks( Math.min(0, ...values), diff --git a/src/features/database/SchemaCompareDialog.tsx b/src/features/database/SchemaCompareDialog.tsx index 9b26dcb97..494aeee22 100644 --- a/src/features/database/SchemaCompareDialog.tsx +++ b/src/features/database/SchemaCompareDialog.tsx @@ -59,13 +59,20 @@ function SidePicker({ label, side, onChange }: { label: string; side: Side; onCh .map((s) => ({ value: s.id ?? "", label: s.name ?? "", + verbatim: true, icon: "database", })); if (side.id && !sourceOptions.some((o) => o.value === side.id)) sourceOptions.push({ value: side.id, label: targetLabel(side.id), icon: "database" }); const names = schemas?.status === "ok" ? schemas.value : []; - const schemaOptions: SelectOption[] = names.map((n) => ({ value: n, label: n, icon: "db-schema" })); - if (side.schema && !names.includes(side.schema)) schemaOptions.unshift({ value: side.schema, label: side.schema }); + const schemaOptions: SelectOption[] = names.map((n) => ({ + value: n, + label: n, + verbatim: true, + icon: "db-schema", + })); + if (side.schema && !names.includes(side.schema)) + schemaOptions.unshift({ value: side.schema, label: side.schema, verbatim: true }); return (
diff --git a/src/features/database/SqlScopesPage.tsx b/src/features/database/SqlScopesPage.tsx index 15c7210a1..dd5cc8d3b 100644 --- a/src/features/database/SqlScopesPage.tsx +++ b/src/features/database/SqlScopesPage.tsx @@ -38,7 +38,12 @@ export function SqlScopesPage() { const options: SelectOption[] = [ { value: NONE, label: tx("") }, - ...(sources ?? []).map((s) => ({ value: s.id ?? "", label: s.name ?? s.id ?? "", icon: "database" })), + ...(sources ?? []).map((s) => ({ + value: s.id ?? "", + label: s.name ?? s.id ?? "", + verbatim: true, + icon: "database", + })), ]; const sourceOptions = (current: string) => current && !options.some((o) => o.value === current) diff --git a/src/features/database/console.tsx b/src/features/database/console.tsx index ab60dff2e..9b7b45620 100644 --- a/src/features/database/console.tsx +++ b/src/features/database/console.tsx @@ -759,10 +759,10 @@ function ConsoleBar({ path, view }: { path: string; view: EditorView }) { const schemaOptions = useMemo(() => { if (!switchable) return []; const names = schemaList?.status === "ok" ? schemaList.value : []; - const out = names.map((n) => ({ value: n, label: n, icon: "db-schema" })); + const out = names.map((n) => ({ value: n, label: n, verbatim: true, icon: "db-schema" })); // The connection's default is offered even before its schema list loads. if (defaultSchema && !names.includes(defaultSchema)) - out.unshift({ value: defaultSchema, label: defaultSchema, icon: "db-schema" }); + out.unshift({ value: defaultSchema, label: defaultSchema, verbatim: true, icon: "db-schema" }); return out; }, [switchable, schemaList, defaultSchema]); // IDEA's order: pick the data source, then a database and a schema in it. @@ -1026,7 +1026,7 @@ function SnowflakeSession({ target, idle }: { target: string; idle: boolean }) { setState((s) => (what === "WAREHOUSE" ? { ...s, warehouse: name } : { ...s, role: name })); }; const options = (names: string[], current: string) => - [...new Set(current ? [current, ...names] : names)].map((n) => ({ value: n, label: n })); + [...new Set(current ? [current, ...names] : names)].map((n) => ({ value: n, label: n, verbatim: true })); return ( <>