Порівняти коміти

...
Автор SHA1 Повідомлення Дата
l0ng-ai 3686bbe687 Merge remote-tracking branch 'origin/main' into pr7032 2026-11-30 22:00:24 +08:00
l0ng-ai 2a32d1dbc6 fix(ui): align descriptive columns in option pickers 2026-11-30 19:51:32 +08:00
9 змінених файлів з 162 додано та 7 видалено

No files matched your search

+78
Переглянути файл
@@ -284,6 +284,84 @@ async function expectNoSubmission(page: Page) {
expect(await ipcCalls(page, "agent_create")).toEqual([]);
}
test("effort descriptions share a column regardless of label and description length", async ({
workbench: page,
}, testInfo) => {
const values = [
["Low", "Fast responses with lighter reasoning"],
["Medium", "Balances speed and reasoning depth for everyday tasks"],
["High", "Greater reasoning depth for complex problems"],
["Extra high", "Extra high reasoning depth for complex problems"],
["Max", "Maximum reasoning depth for the hardest problems"],
["Ultra", "Maximum reasoning with automatic task delegation"],
];
const effort = {
...atlas,
current: "high",
values: values.map(([name, description]) => ({
value: name!.toLowerCase(),
name: name!,
description: description!,
})),
};
const fast = option(
"fast",
"model_config",
[
["false", "Off"],
["true", "On"],
],
"false",
);
fast.name = "Fast";
await seed(page, "editor", "task", "atlas", "ready", false, {
...provider,
thoughtLevels: { ...provider.thoughtLevels, atlas: [effort, fast] },
});
await effortLabel(page).click();
const dialog = page.getByRole("dialog", { name: "Model settings" });
const list = dialog.getByRole("listbox", { name: "Effort Level" });
await expect(list.getByRole("option")).toHaveCount(values.length);
await list.getByRole("option", { name: /^Low/ }).hover();
await dialog.screenshot({ path: testInfo.outputPath("effort-descriptions.png"), scale: "css" });
const columns = () =>
list.getByRole("option").evaluateAll((rows) =>
rows.map((row) => {
const label = row.querySelectorAll<HTMLElement>("[title]")[0]!.getBoundingClientRect();
const detail = row.querySelectorAll<HTMLElement>("[title]")[1]!.getBoundingClientRect();
return {
label: label.left,
labelWidth: label.width,
detail: detail.left,
detailRight: detail.right,
rowRight: row.getBoundingClientRect().right,
};
}),
);
const assertAligned = async () => {
const cells = await columns();
expect(cells).toHaveLength(values.length);
for (const cell of cells) {
expect(cell.label).toBeCloseTo(cells[0]!.label);
expect(cell.detail).toBeCloseTo(cells[0]!.detail);
expect(cell.detailRight).toBeLessThanOrEqual(cell.rowRight);
}
return cells[0]!.labelWidth;
};
const originalWidth = await assertAligned();
// The width is based on rendered text, not a hard-coded number of characters.
await dialog.evaluate((element) => {
element.style.fontSize = "18px";
});
await expect.poll(async () => (await columns())[0]!.labelWidth).toBeGreaterThan(originalWidth);
await assertAligned();
await dialog.evaluate((element) => {
element.style.width = "240px";
});
await expect.poll(async () => (await dialog.boundingBox())!.width).toBeCloseTo(240, 0);
await assertAligned();
});
for (const surface of ["new", "task"] as const) {
test(`${surface}: switch models from the list, then set effort and context from the settings chip`, async ({
workbench: page,
+8 -1
Переглянути файл
@@ -8,7 +8,7 @@ async function selectPage(page: Page, id: string) {
}, id);
}
test("Git settings expose fetch tag modes and the check-only mode", async ({ workbench: page }) => {
test("Git settings expose fetch tag modes and the check-only mode", async ({ workbench: page }, testInfo) => {
await page.keyboard.press("Meta+,");
const dialog = page.getByRole("dialog", { name: "Settings", exact: true });
await expect(dialog).toBeVisible();
@@ -20,6 +20,13 @@ test("Git settings expose fetch tag modes and the check-only mode", async ({ wor
for (const label of ["Auto", "Sync", "Always", "Never"]) {
await expect(choices.getByRole("option", { name: new RegExp(`^${label}`) })).toBeVisible();
}
const starts = await choices
.getByRole("option")
.evaluateAll((rows) =>
rows.map((row) => row.querySelectorAll<HTMLElement>("[title]")[1]!.getBoundingClientRect().left),
);
for (const start of starts) expect(start).toBeCloseTo(starts[0]!);
await choices.screenshot({ path: testInfo.outputPath("fetch-tags-descriptions.png") });
const sync = choices.getByRole("option", { name: /^Sync/ });
await expect(sync).toContainText("Delete local tags missing on remote");
await sync.click();
+1
Переглянути файл
@@ -1542,6 +1542,7 @@ function AgentDefaults({
<div className={styles.select}>
<Select
id={`agent-default-${agent.id}-${o.id}`}
alignDetails
value={currentChoice}
options={[
{ value: "", label: defaultLabel },
+3
Переглянути файл
@@ -450,6 +450,7 @@ function ConfigPicker({
? modeIcon(opt.value)
: undefined,
}))}
alignDetails
searchable={option.category === "model"}
onChange={(v) => onChange(option.id, v)}
renderValue={
@@ -583,6 +584,7 @@ function ModelPicker({
value={modelValue}
options={configPickerOptions(model, pinnedModels, false)}
searchable
alignDetails
listClassName={styles.modelList}
onChoose={(v) => {
onChange(model.id, v);
@@ -661,6 +663,7 @@ function ModelSettings({
</span>
<SelectListbox
aria-label={label}
alignDetails
value={currentValue}
options={o.values.map((v) => agentValueOption(v))}
onChoose={(v) => {
+1
Переглянути файл
@@ -335,6 +335,7 @@ export function HomeEditor({ docked = false, input }: { docked?: boolean; input?
<Select
variant="ghost"
aria-label="Isolation"
alignDetails
value={isolation}
options={[
{
+13 -1
Переглянути файл
@@ -219,6 +219,7 @@ export interface SelectProps<V extends string> {
onChange: (value: V) => void;
disabled?: boolean;
onPreview?: (value: V | null) => void;
alignDetails?: boolean;
className?: string;
"aria-label"?: string;
}
@@ -229,6 +230,7 @@ export function Select<V extends string>({
onChange,
disabled,
onPreview,
alignDetails,
className,
...aria
}: SelectProps<V>) {
@@ -239,6 +241,7 @@ export function Select<V extends string>({
onChange={onChange}
disabled={disabled}
onPreview={onPreview}
alignDetails={alignDetails}
className={clsx(styles.select, className)}
aria-label={aria["aria-label"]}
/>
@@ -577,17 +580,26 @@ export function SettingSelect<V extends string>({
hint,
options,
disabled,
alignDetails,
}: {
k: string;
label: string;
hint?: ReactNode;
options: readonly SelectOption<V>[];
disabled?: boolean;
alignDetails?: boolean;
}) {
const [value, set] = useSetting<V>(k);
return (
<Row label={label} hint={hint} disabled={disabled}>
<Select<V> value={value} options={options} onChange={set} disabled={disabled} aria-label={label} />
<Select<V>
alignDetails={alignDetails}
value={value}
options={options}
onChange={set}
disabled={disabled}
aria-label={label}
/>
</Row>
);
}
+3 -1
Переглянути файл
@@ -1133,7 +1133,9 @@ export const VCS_PAGES: PageSpec[] = [
kind: "custom",
label: "Fetch tags",
keywords: ["Auto", "Sync", "Always", "Never", "prune"],
component: () => <SettingSelect k="vcs.git.fetchTagsMode" label="Fetch tags" options={FETCH_TAGS} />,
component: () => (
<SettingSelect k="vcs.git.fetchTagsMode" label="Fetch tags" options={FETCH_TAGS} alignDetails />
),
},
],
},
+11
Переглянути файл
@@ -106,6 +106,10 @@
max-width: 240px;
overflow: hidden;
}
/* Unlike flexing row labels, the intrinsic measurement does not depend on the detail length. */
.sizerLabel {
flex: none;
}
.optionLabel {
flex: 1 1 auto;
min-width: 0;
@@ -129,6 +133,13 @@
white-space: nowrap;
color: var(--fg-muted);
}
/* Reserve the same space for each label; cap long labels on narrow popups. */
.alignedLabel {
flex: 0 0 min(var(--select-label-width, 0px), 70%);
}
.alignedDetail {
flex: 1 1 0;
}
.disabled {
color: var(--fg-faint);
}
+44 -4
Переглянути файл
@@ -58,6 +58,8 @@ export interface SelectProps<V extends string = string> {
renderValue?: (option: SelectOption<V> | undefined) => ReactNode;
/** Show a search box in the popup (useful for long option lists); typing on the closed trigger opens it with that text. */
searchable?: boolean;
/** Align descriptive details in a shared column rather than trailing metadata at the right. */
alignDetails?: boolean;
/** Optional choice for an exact value entered into the search field. */
customOption?: (query: string) => SelectOption<V>;
/** The option under the pointer or keyboard while the list is open; `null` once it closes. */
@@ -87,6 +89,8 @@ export interface SelectListboxProps<V extends string = string> {
/** Called with the chosen option; closing, if any, is the caller's. */
onChoose: (value: V) => void;
searchable?: boolean;
/** Align details for rows with the same leading icon/check slots. */
alignDetails?: boolean;
customOption?: (query: string) => SelectOption<V>;
/** Search text the list opens with. */
initialQuery?: string;
@@ -108,6 +112,7 @@ export function SelectListbox<V extends string = string>({
options,
onChoose,
searchable = false,
alignDetails = false,
customOption,
initialQuery = "",
searchLabel,
@@ -124,6 +129,26 @@ export function SelectListbox<V extends string = string>({
const [active, setActive] = useState<number | null>(null);
const [query, setQuery] = useState(initialQuery);
const listId = useId();
const popupInner = useRef<HTMLDivElement>(null);
const sizer = useRef<HTMLDivElement>(null);
// The list virtualizes its rows, so measure the full set of labels in the existing
// hidden sizer. Keep the column stable when searching and when the UI font changes.
useLayoutEffect(() => {
if (!alignDetails || !sizer.current || !popupInner.current) return;
const inner = popupInner.current;
const labels = Array.from(sizer.current.querySelectorAll<HTMLElement>(`.${styles.sizerLabel}`));
const measure = () => {
const width = Math.max(0, ...labels.map((label) => Math.ceil(label.getBoundingClientRect().width)));
inner.style.setProperty("--select-label-width", `${width}px`);
};
measure();
const observer = new ResizeObserver(measure);
labels.forEach((label) => observer.observe(label));
return () => {
observer.disconnect();
inner.style.removeProperty("--select-label-width");
};
}, [alignDetails, options, given]);
const caretPlaced = useRef(false);
const typeAhead = useRef({ text: "", at: -Infinity });
const isSection = (o: SelectOption<V>) => !!o.section;
@@ -245,6 +270,7 @@ export function SelectListbox<V extends string = string>({
return (
<div
ref={popupInner}
tabIndex={-1}
data-autofocus={searchable ? undefined : true}
onKeyDown={onPopupKey}
@@ -278,13 +304,20 @@ export function SelectListbox<V extends string = string>({
</div>
)}
{/* Virtualised rows are absolutely positioned; this sizes the popup to the widest label. */}
<div aria-hidden className={styles.sizer}>
<div ref={sizer} aria-hidden className={styles.sizer}>
{options.map((o) => (
<div key={`${o.section ? "section" : "option"}:${o.value}`} className={styles.sizerRow}>
<span className={styles.check} />
{o.tree && <TreeIndent {...o.tree} />}
{o.icon && <Icon name={o.icon} size={14} />}
<span className={o.emphasized ? styles.emphasized : undefined}>{labelOf(o)}</span>
<span
className={clsx(
o.emphasized && styles.emphasized,
alignDetails && !o.section && o.detail && styles.sizerLabel,
)}
>
{labelOf(o)}
</span>
{o.detail && <span className={styles.sizerDetail}>{detailOf(o)}</span>}
</div>
))}
@@ -320,13 +353,18 @@ export function SelectListbox<V extends string = string>({
{o.tree && <TreeIndent {...o.tree} />}
{o.icon && <Icon name={o.icon} size={14} />}
<span
className={clsx(styles.optionLabel, detail && styles.withDetail, o.emphasized && styles.emphasized)}
className={clsx(
styles.optionLabel,
detail && styles.withDetail,
detail && alignDetails && styles.alignedLabel,
o.emphasized && styles.emphasized,
)}
title={label}
>
{highlight(label)}
</span>
{detail && (
<span className={styles.detail} title={detail}>
<span className={clsx(styles.detail, alignDetails && styles.alignedDetail)} title={detail}>
{highlight(detail)}
</span>
)}
@@ -371,6 +409,7 @@ export function Select<V extends string = string>({
title,
renderValue,
searchable = false,
alignDetails = false,
customOption,
onPreview,
onOpen,
@@ -453,6 +492,7 @@ export function Select<V extends string = string>({
value={value}
options={options}
searchable={searchable}
alignDetails={alignDetails}
customOption={customOption}
initialQuery={initialQuery}
onPreview={preview}