fix(webui): keep composer placeholders readable in narrow panes

This commit is contained in:
chengyongru authored and chengyongru committed 2026-11-06 13:06:00 +08:00
1 parent 92e6608e6e
commit 7ea2c9a830
13 files changed
+82 -7

No files matched your search

@@ -7,6 +7,7 @@ export function ComposerActionFixture({ parameters }: { parameters: URLSearchPar
return <main className="mx-auto w-full max-w-5xl px-4 pt-24">
<ThreadComposer
variant={parameters.get("composerVariant") === "thread" ? "thread" : "hero"}
placeholder={parameters.has("opening") ? "Opening a new topic…" : undefined}
modelLabel="Preview"
goalState={parameters.has("goal") ? { active: true, objective: "Keep the work in focus." } : undefined}
isStreaming={running}
+36 -4
View File
@@ -149,7 +149,7 @@ test("idle voice and ready send remain distinct from the composer in both themes
});
test("a long mobile placeholder remains available without shifting the composer", async ({ browser, baseURL }) => {
test("a compact mobile placeholder keeps the full hint available without shifting the composer", async ({ browser, baseURL }) => {
const context = await browser.newContext({ baseURL, viewport: { width: 314, height: 844 }, hasTouch: true, isMobile: true, reducedMotion: "reduce" });
try {
const page = await context.newPage();
@@ -158,9 +158,10 @@ test("a long mobile placeholder remains available without shifting the composer"
await page.evaluate(() => document.fonts.ready);
const input = page.locator(".thread-composer-input textarea");
const action = page.locator(".composer-primary-action");
await expect(input).toHaveAttribute("placeholder", /compétences/);
const placeholder = (await input.getAttribute("placeholder"))!;
await expect(input).toHaveAttribute("aria-description", placeholder);
await expect(input).toHaveAttribute("placeholder", "Votre message…");
await expect.poll(() => input.evaluate(node => node.scrollWidth <= node.clientWidth)).toBe(true);
const placeholder = (await input.getAttribute("aria-description"))!;
expect(placeholder).toContain("compétences");
await expect(page.getByRole("tooltip")).toHaveCount(0);
const before = (await action.boundingBox())!;
const initialHeight = await input.evaluate(node => node.clientHeight);
@@ -200,3 +201,34 @@ test("a long mobile placeholder remains available without shifting the composer"
await context.close();
}
});
for (const variant of ["hero", "thread"]) {
test(`placeholder follows available input width in a ${variant} composer`, async ({ page }) => {
await page.setViewportSize({ width: 1200, height: 900 });
await page.addInitScript(() => localStorage.setItem("nanobot.locale", "en"));
await page.goto(`/browser/fixture.html?case=composer-action&composerVariant=${variant}`);
await page.evaluate(() => document.fonts.ready);
const container = page.locator("main");
const input = page.locator(".thread-composer-input textarea");
const fullHint = "Type / for commands, @ for chats or apps, $ for skills";
await expect(input).toHaveAttribute("placeholder", fullHint);
await container.evaluate(node => { node.style.maxWidth = "340px"; });
await expect(input).toHaveAttribute("placeholder", "Type a message…");
await expect(input).toHaveAttribute("aria-description", fullHint);
await expect.poll(() => input.evaluate(node => node.scrollWidth <= node.clientWidth)).toBe(true);
await input.fill("Keep this draft");
await container.evaluate(node => { node.style.maxWidth = "600px"; });
await expect(input).toHaveAttribute("placeholder", fullHint);
await container.evaluate(node => { node.style.setProperty("--text-reading-size", "28px"); });
await expect(input).toHaveAttribute("placeholder", "Type a message…");
await container.evaluate(node => { node.style.maxWidth = "900px"; });
await expect(input).toHaveAttribute("placeholder", fullHint);
await expect(input).toHaveValue("Keep this draft");
await page.goto(`/browser/fixture.html?case=composer-action&composerVariant=${variant}&opening`);
await page.locator("main").evaluate(node => { node.style.maxWidth = "340px"; });
await expect(input).toHaveAttribute("placeholder", "Opening a new topic…");
});
}