feat(webui): expand long drafts and refine chat scrollbars (#6709)

* feat(webui): expand long drafts and refine chat scrollbars

* test(webui): synchronize browser setup and isolate locale cases

* test(webui): wait for the About fixture before measuring layout
This commit is contained in:
chengyongru authored and GitHub committed 2026-11-18 23:28:36 +08:00
1 parent db430df3f6
commit cab49a1c66
20 files changed
+271 -59

No files matched your search

+4 -3
View File
@@ -8,9 +8,10 @@ test("About current-version feedback keeps its initial row height with wider sys
for (const state of ["loaded", "loading"]) {
await page.goto(`/browser/fixture.html?case=skeleton-additions&surface=settings&state=${state}&section=about`);
await page.addStyleTag({ content: "body { font-family: monospace; }" });
if (state === "loaded") await expect(page.getByText("You're up to date", { exact: true })).toBeVisible();
// Wait for the lazy About panel before measuring the row.
if (state === "loaded") await page.getByText("You're up to date", { exact: true }).waitFor();
const row = page.locator("[data-settings-section] .settings-list-row").first();
await expect(row).toBeVisible();
await row.waitFor();
positions.push((await row.boundingBox())!.y);
expect(await page.evaluate(() => document.documentElement.scrollWidth > innerWidth)).toBe(false);
}
@@ -30,7 +31,7 @@ for (const state of ["loaded", "loading"]) {
try {
await page.goto(`/browser/fixture.html?case=skeleton-additions&surface=settings&state=${state}&section=about`, { waitUntil: "domcontentloaded" });
const row = page.locator("[data-settings-section] .settings-list-row").first();
await expect(row).toBeVisible();
await row.waitFor();
const before = await row.boundingBox();
release();
const wordmark = page.locator('img[alt="nanobot"]');
+48 -1
View File
@@ -19,7 +19,8 @@ async function openThread(page: Page) {
await page.route("**/api/commands", route => route.fulfill({ json: { commands: [] } }));
await page.route("**/api/sessions/*/webui-thread?*", route => route.fulfill({ json: history }));
await page.goto("/browser/fixture.html?case=thread-loading");
await expect(page.getByRole("heading", { name: "Section 25", exact: true })).toBeVisible();
// Let the lazy Markdown renderer settle before measuring transcript geometry.
await page.getByRole("heading", { name: "Section 25", exact: true }).waitFor();
await page.evaluate(() => document.fonts.ready);
const input = page.getByRole("textbox", { name: "Message input", exact: true });
await input.fill("Next steps:\n1. Check layout\n2. ");
@@ -88,6 +89,52 @@ test("autosizing still grows, caps and shrinks the real input", async ({ page })
await expect.poll(() => scroller.evaluate(node => node.scrollHeight - node.clientHeight - node.scrollTop)).toBeLessThanOrEqual(1);
});
for (const viewport of [{ width: 1440, height: 900 }, { width: 390, height: 500 }]) {
test(`overflowing drafts can be expanded and collapsed in place at ${viewport.width}px`, async ({ page }) => {
await page.setViewportSize(viewport);
const { input } = await openThread(page);
const expand = page.getByRole("button", { name: "Expand editor" });
const collapse = page.getByRole("button", { name: "Collapse editor" });
const footer = page.locator(".thread-composer-footer");
const selection = () => input.evaluate(node => {
const { selectionStart, selectionEnd } = node as HTMLTextAreaElement;
return [selectionStart, selectionEnd];
});
await expect(expand).not.toBeVisible();
const draft = ["Which warnings should I fix?", ...Array.from({ length: 11 }, (_, i) => `Line ${i + 1}: build output`)].join("\n");
await input.fill(draft);
await expect(expand).toBeVisible();
const smallHeight = await input.evaluate(node => node.clientHeight);
const footerBounds = await footer.boundingBox();
await input.press("Control+End");
await expect.poll(() => input.evaluate(node => node.scrollTop)).toBeGreaterThan(0);
expect(await footer.boundingBox()).toEqual(footerBounds);
await expand.click();
await expect(collapse).toHaveAttribute("aria-expanded", "true");
await expect(input).toBeFocused();
await expect.poll(() => input.evaluate(node => node.clientHeight)).toBeGreaterThan(smallHeight + 24);
expect(await selection()).toEqual([draft.length, draft.length]);
const expandedFooter = (await footer.boundingBox())!;
expect(expandedFooter.y + expandedFooter.height).toBeLessThanOrEqual(viewport.height);
expect(await input.evaluate(node => node.scrollHeight)).toBe(await input.evaluate(node => node.clientHeight));
await collapse.click();
await expect(expand).toBeVisible();
await expect.poll(() => input.evaluate(node => node.scrollHeight - node.clientHeight - node.scrollTop)).toBeLessThanOrEqual(1);
await expand.click();
await input.press("Control+Home");
await input.press("Shift+End");
const firstLine = [0, draft.indexOf("\n")];
expect(await selection()).toEqual(firstLine);
await collapse.press("Enter");
await expect(input).toBeFocused();
await expect(input).toHaveValue(draft);
expect(await selection()).toEqual(firstLine);
await expect.poll(() => input.evaluate(node => node.clientHeight)).toBe(smallHeight);
});
}
test("Chromium IME composition and commit keep the transcript stationary", async ({ page }) => {
const { input } = await openThread(page);
const original = await input.inputValue();
+5 -2
View File
@@ -73,6 +73,9 @@ const group = groups.find(({ id }) => id === params.get("group")) ?? groups[0]!;
const base = loadCodexCatalog
? preset("Review", "openai_codex", "openai-codex/gpt-6.2-sol", "xhigh", ["low", "medium", "high"], { default: false, ultrafast_supported: true })
: group.id === "oauth" ? (params.has("ultrafast") ? ultrafastCodex : standardCodex) : group.presets[0]!;
const extraPresets = params.has("many-presets")
? Array.from({ length: 12 }, (_, index) => preset(`Example ${index + 1}`, "openai_codex", "gpt-6.2-sol"))
: [];
const settings: SettingsPayload = {
...baseSettings,
agent: { ...baseSettings.agent, model: base.model, provider: base.provider, resolved_provider: base.provider,
@@ -80,8 +83,8 @@ const settings: SettingsPayload = {
providers: Object.entries(providers).map(([name, provider]) => ({
name, configured: true, model_catalog: loadCodexCatalog && name === "openai_codex" ? "hybrid" : "unsupported", ...provider,
})),
model_presets: [{ ...base, name: "default", label: "Default", active: true, is_default: true }, ...group.presets],
model_call_order: group.presets.map(({ name }) => name),
model_presets: [{ ...base, name: "default", label: "Default", active: true, is_default: true }, ...group.presets, ...extraPresets],
model_call_order: [...group.presets, ...extraPresets].map(({ name }) => name),
};
function fixtureLink(groupId: string, settingsView: boolean) {
+27
View File
@@ -88,6 +88,33 @@ for (const width of [390, 1280]) {
});
}
test("a long preset list scrolls without moving the model controls in a short viewport", async ({ page }) => {
await page.setViewportSize({ width: 390, height: 380 });
await page.goto("/browser/fixture.html?case=model-options&many-presets&ultrafast");
await page.getByRole("button", { name: "Default", exact: true }).click();
const dialog = page.getByRole("dialog", { name: "Switch model", exact: true });
const list = dialog.getByRole("listbox");
const effort = dialog.getByRole("slider", { name: "Reasoning effort" });
const manage = dialog.getByRole("button", { name: "Manage presets" });
await dialog.evaluate((node) => Promise.all(node.getAnimations().map((animation) => animation.finished)));
await expect(manage).toBeInViewport({ ratio: 1 });
expect(await dialog.evaluate((node) => node.scrollHeight - node.clientHeight)).toBeLessThanOrEqual(1);
const effortBefore = await effort.boundingBox();
const manageBefore = await manage.boundingBox();
await list.hover();
await page.mouse.wheel(0, 100);
await expect.poll(() => list.evaluate((node) => node.scrollTop)).toBeGreaterThan(0);
expect(await effort.boundingBox()).toEqual(effortBefore);
expect(await manage.boundingBox()).toEqual(manageBefore);
await list.getByRole("option", { name: "default", exact: true }).press("End");
const last = list.getByRole("option", { name: "Example 12", exact: true });
await expect(last).toBeFocused();
await expect(last).toBeInViewport({ ratio: 0.9 });
await last.press("Enter");
await expect(page.getByRole("button", { name: "Example 12", exact: true })).toBeVisible();
});
test("Temporary Chats do not expose model option controls", async ({ page }) => {
await page.goto("/browser/fixture.html?case=model-options&temporary");
await page.getByRole("button", { name: "Default", exact: true }).click();
+32 -30
View File
@@ -1,4 +1,5 @@
import { expect, test, type Page } from "@playwright/test";
import { supportedLocales } from "../src/i18n/config";
async function selectRadio(page: Page, group: string, name: string) {
const radio = page.getByRole("radiogroup", { name: group }).getByRole("radio", { name, exact: true });
@@ -106,36 +107,37 @@ test("reveals MCP tools hidden by Ready only without switching tool type", async
});
test("keeps Apps section controls usable on narrow screens in each locale", async ({ page }) => {
const width = 320;
await page.setViewportSize({ width, height: 800 });
await page.route("**/api/settings/cli-apps", route => route.fulfill({ json: { apps: [], installed_count: 0 } }));
await page.route("**/api/settings/mcp-presets", route => route.fulfill({ json: { presets: [], installed_count: 0 } }));
await page.route("**/api/settings/nanobot-features", route => route.fulfill({ json: { features: [], enabled_count: 0 } }));
await page.route("**/api/webui/skills/trending?**", route => route.fulfill({ json: { skills: [] } }));
const controls = page.locator(".catalog-controls");
async function expectControlsFit(locale: string, count: number) {
const targets = page.locator(".catalog-tabs > button, .catalog-controls label");
await expect(targets).toHaveCount(count);
const geometry = await targets.evaluateAll(elements => elements.map(element => {
const bounds = element.getBoundingClientRect();
return {
label: element.textContent,
left: bounds.left,
right: bounds.right,
fits: element.scrollWidth <= element.clientWidth
&& (!element.matches("button") || element.scrollHeight <= element.clientHeight),
};
}));
expect(geometry.filter(item => item.left < 0 || item.right > width || !item.fits), locale).toEqual([]);
}
for (const locale of ["en", "es", "fr", "id", "ja", "ko", "pt-BR", "vi", "zh-CN", "zh-TW"]) {
for (const { code: locale } of supportedLocales) {
test(`keeps Apps section controls usable on narrow screens in ${locale}`, async ({ page }) => {
const width = 320;
await page.setViewportSize({ width, height: 800 });
await page.route("**/api/settings/cli-apps", route => route.fulfill({ json: { apps: [], installed_count: 0 } }));
await page.route("**/api/settings/mcp-presets", route => route.fulfill({ json: { presets: [], installed_count: 0 } }));
await page.route("**/api/settings/nanobot-features", route => route.fulfill({ json: { features: [], enabled_count: 0 } }));
await page.route("**/api/webui/skills/trending?**", route => route.fulfill({ json: { skills: [] } }));
const controls = page.locator(".catalog-controls");
async function expectControlsFit(count: number) {
const targets = page.locator(".catalog-tabs > button, .catalog-controls label");
await expect(targets).toHaveCount(count);
const geometry = await targets.evaluateAll(elements => elements.map(element => {
const bounds = element.getBoundingClientRect();
return {
label: element.textContent,
left: bounds.left,
right: bounds.right,
fits: element.scrollWidth <= element.clientWidth
&& (!element.matches("button") || element.scrollHeight <= element.clientHeight),
};
}));
expect(geometry.filter(item => item.left < 0 || item.right > width || !item.fits)).toEqual([]);
}
await page.goto(`/browser/fixture.html?case=tools-catalog&lang=${locale}`);
const types = page.getByRole("radiogroup").getByRole("radio");
const status = controls.getByRole("switch");
await expect(types).toHaveCount(4);
await expect(status).not.toBeChecked();
await expectControlsFit(locale, 8);
await expectControlsFit(8);
const cli = types.nth(1);
await cli.locator("..").click();
await expect(cli).toBeChecked();
@@ -153,20 +155,20 @@ test("keeps Apps section controls usable on narrow screens in each locale", asyn
const sections = page.locator(".catalog-tabs").getByRole("button");
await sections.nth(1).click();
await expectControlsFit(locale, 8);
await expectControlsFit(8);
const marketplace = controls.getByRole("radio").nth(1);
await marketplace.locator("..").click();
await expect(marketplace).toBeFocused();
await expect(marketplace).toBeChecked();
await expectControlsFit(locale, 8);
await expectControlsFit(8);
await sections.nth(2).click();
await expectControlsFit(locale, 4);
await expectControlsFit(4);
await status.locator("..").locator(":scope > span").click();
await expect(status).toBeChecked();
await expect(status).toBeFocused();
}
});
});
}
test("opens the generated plugin from its CLI app", async ({ page }) => {