дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-26 20:46:22 +02:00
fix(ui): show agent and user-defined option labels as written (#6193)
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
Цей коміт міститься в:
1 джерело
5289f44620
коміт
dc490f1017
13 files changed
+163
-34
No files matched your search
@@ -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)}
|
||||
|
||||
@@ -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(<ConfigPickers config={config} onChange={vi.fn()} />);
|
||||
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"),
|
||||
|
||||
@@ -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({
|
||||
<SelectListbox
|
||||
aria-label={label}
|
||||
value={currentValue}
|
||||
options={o.values.map((v) => ({ 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<HTMLButtonElement>(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({
|
||||
))}
|
||||
</div>
|
||||
<div className={styles.modeFooter}>
|
||||
<span title={allowAll.description ?? undefined}>{tx(toggle.label)}</span>
|
||||
<span title={allowAll.description ?? undefined}>{switchLabel}</span>
|
||||
<Toggle
|
||||
checked={on}
|
||||
aria-label={tx(toggle.label)}
|
||||
aria-label={switchLabel}
|
||||
onChange={(checked) => onChange(allowAll.id, checked ? toggle.on : toggle.off)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -105,7 +105,13 @@ export function ScopeFields({
|
||||
<Select<string>
|
||||
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 })}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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 (
|
||||
<div className={styles.side}>
|
||||
<span className={styles.sideLabel}>
|
||||
|
||||
@@ -38,7 +38,12 @@ export function SqlScopesPage() {
|
||||
|
||||
const options: SelectOption[] = [
|
||||
{ value: NONE, label: tx("<none>") },
|
||||
...(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)
|
||||
|
||||
@@ -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 (
|
||||
<>
|
||||
<Select
|
||||
|
||||
@@ -106,7 +106,10 @@ function Toolbar({ path, view }: { path: string | null; view: EditorView }) {
|
||||
useEffect(() => {
|
||||
if (path) void loadEnvironments(path);
|
||||
}, [path]);
|
||||
const options = [{ value: "", label: "No Environment" }, ...(envs ?? []).map((e) => ({ value: e, label: e }))];
|
||||
const options = [
|
||||
{ value: "", label: "No Environment" },
|
||||
...(envs ?? []).map((e) => ({ value: e, label: e, verbatim: true })),
|
||||
];
|
||||
return (
|
||||
<div className={styles.toolbar}>
|
||||
<IconButton
|
||||
|
||||
@@ -80,7 +80,7 @@ function ValueControl({
|
||||
<Select
|
||||
aria-label={label}
|
||||
value={String(value)}
|
||||
options={s.options.map((o) => ({ value: o, label: o }))}
|
||||
options={s.options.map((o) => ({ value: o, label: o, verbatim: true }))}
|
||||
onChange={set}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -829,7 +829,9 @@ function FindInFilesDialog() {
|
||||
...customScopes.map((c) => ({
|
||||
value: customScopeValue(c.name),
|
||||
label: c.name,
|
||||
verbatim: true,
|
||||
detail: c.pattern,
|
||||
verbatimDetail: true,
|
||||
})),
|
||||
]
|
||||
: []),
|
||||
|
||||
@@ -200,10 +200,14 @@ export function FileColorsEditor() {
|
||||
row?.scrollIntoView({ block: "nearest", inline: "nearest" });
|
||||
}, []);
|
||||
|
||||
const scopeNames = [...BUILTIN_SCOPES, ...validateScopes(rawScopes).map((s) => s.name)];
|
||||
const scopeOptions: SelectOption[] = scopeNames.map((n) => ({ value: n, label: n }));
|
||||
const customNames = validateScopes(rawScopes).map((s) => s.name);
|
||||
const scopeNames = [...BUILTIN_SCOPES, ...customNames];
|
||||
const scopeOptions: SelectOption[] = [
|
||||
...BUILTIN_SCOPES.map((n) => ({ value: n, label: n })),
|
||||
...customNames.map((n) => ({ value: n, label: n, verbatim: true })),
|
||||
];
|
||||
if (current && !scopeNames.includes(current.scope))
|
||||
scopeOptions.push({ value: current.scope, label: tx`${current.scope} (missing)` });
|
||||
scopeOptions.push({ value: current.scope, label: tx`${current.scope} (missing)`, verbatim: true });
|
||||
const presets = FILE_COLOR_NAMES.map((n) => ({ value: n, label: colorLabel(n), css: fileColorCss(n) }));
|
||||
|
||||
return (
|
||||
|
||||
Reference in new issue
Заблокувати користувача