From 4f7c4f0885590da48f3f7ec9f17dac52fec7cec2 Mon Sep 17 00:00:00 2001 From: chengyongru <61816729+chengyongru@users.noreply.github.com> Date: Sun, 25 Oct 2026 15:16:08 +0800 Subject: [PATCH] style(webui): refine composer surface and workspace hover (#6444) * style(webui): refine the chat composer surface Use a themed card background with a subtle edge and soft shadow. Keep focus stable without a darker frame while preserving Goal and drag rings. Align the startup composer surface and add composer-scoped browser coverage. * style(webui): align workspace hover with access control Keep the workspace trigger background clear on hover and use its existing text-color feedback, matching the adjacent access control. Preserve focus, disabled, and directory-picker behavior. --- webui/browser/composer-action-fixture.tsx | 1 + webui/browser/composer-surface.spec.ts | 59 +++++++++++++++++++ webui/src/components/startup-skeleton.css | 4 +- .../src/components/thread/ThreadComposer.tsx | 6 +- .../components/thread/WorkspaceControls.tsx | 2 +- webui/src/globals.css | 17 ++++++ 6 files changed, 83 insertions(+), 6 deletions(-) create mode 100644 webui/browser/composer-surface.spec.ts diff --git a/webui/browser/composer-action-fixture.tsx b/webui/browser/composer-action-fixture.tsx index cb6edb965..00411c556 100644 --- a/webui/browser/composer-action-fixture.tsx +++ b/webui/browser/composer-action-fixture.tsx @@ -8,6 +8,7 @@ export function ComposerActionFixture({ parameters }: { parameters: URLSearchPar "Voice draft"} onSend={() => { setStopRequested(false); setRunning(true); }} diff --git a/webui/browser/composer-surface.spec.ts b/webui/browser/composer-surface.spec.ts new file mode 100644 index 000000000..f46f5d566 --- /dev/null +++ b/webui/browser/composer-surface.spec.ts @@ -0,0 +1,59 @@ +import { expect, test } from "@playwright/test"; + +test.beforeEach(async ({ page }) => { + await page.route("**/api/commands", route => route.fulfill({ json: { commands: [] } })); +}); + +for (const theme of ["light", "dark"]) { + test.describe(theme, () => { + test.beforeEach(async ({ page }) => { + await page.addInitScript((theme) => { + localStorage.setItem("nanobot.locale", "en"); + localStorage.setItem("nanobot-webui.theme", theme); + document.documentElement.classList.toggle("dark", theme === "dark"); + }, theme); + }); + + test("composer focus keeps the surface and actions stable", async ({ page }) => { + await page.goto(`/browser/fixture.html?case=new-chat-skeleton${theme === "dark" ? "&dark" : ""}`); + const surface = page.locator(".thread-composer-surface"); + await expect(surface).toBeVisible(); + const input = page.getByRole("textbox", { name: "Message input" }); + await input.blur(); + await page.getByTestId("hero-greeting").click(); + const rest = await surface.evaluate(element => getComputedStyle(element).boxShadow); + const bounds = await surface.boundingBox(); + const footer = await page.locator(".thread-composer-footer").boundingBox(); + await input.focus(); + await expect(input).toBeFocused(); + await expect.poll(() => surface.evaluate(element => getComputedStyle(element).boxShadow)).toBe(rest); + expect(await surface.boundingBox()).toEqual(bounds); + expect(await page.locator(".thread-composer-footer").boundingBox()).toEqual(footer); + await input.fill("Keep the work in focus."); + await expect(input).toHaveValue("Keep the work in focus."); + }); + + test("composer focus preserves the active goal's blue ring", async ({ page }) => { + await page.emulateMedia({ reducedMotion: "reduce" }); + await page.goto("/browser/fixture.html?case=composer-action&goal"); + const surface = page.locator(".thread-composer-surface"); + await expect(surface).toBeVisible(); + const ring = await surface.evaluate(element => { + const probe = document.createElement("span"); + probe.style.color = getComputedStyle(element).getPropertyValue("--tw-ring-color"); + document.body.append(probe); + const color = getComputedStyle(probe).color; + probe.remove(); + return color; + }); + const input = page.getByRole("textbox", { name: "Message input" }); + await input.blur(); + const rest = await surface.evaluate(element => getComputedStyle(element).boxShadow); + expect(rest).toContain(ring); + await input.focus(); + const focused = await surface.evaluate(element => getComputedStyle(element).boxShadow); + expect(focused).toContain(ring); + expect(focused).toBe(rest); + }); + }); +} diff --git a/webui/src/components/startup-skeleton.css b/webui/src/components/startup-skeleton.css index 0bb5ca64f..9f9f9e6a0 100644 --- a/webui/src/components/startup-skeleton.css +++ b/webui/src/components/startup-skeleton.css @@ -103,8 +103,8 @@ html.dark .startup-shell { --startup-fill: hsl(0 0% 72% / .2); --startup-surface .startup-welcome-line { display: flex; width: 100%; max-width: 704px; height: 36.72px; align-items: center; justify-content: center; } .startup-welcome-line .startup-block { width: 60%; height: 24px; } .startup-composer { container: startup-composer / inline-size; width: 100%; max-width: 928px; margin: 0 auto; --composer-footer-inset: 0.75rem; --composer-action-size: 2rem; --composer-action-margin: 0px; } -.startup-composer-surface { overflow: hidden; border-radius: 28px; background: hsl(0 0% 96.1% / .8); } -html.dark .startup-composer-surface { background: hsl(0 0% 22%); } +.startup-composer-surface { overflow: hidden; border-radius: 28px; background: hsl(0 0% 100%); box-shadow: inset 0 0 0 1px hsl(40 8% 90.5% / .75), 0 4px 18px -8px hsl(240 10% 16% / .12); } +html.dark .startup-composer-surface { background: hsl(0 0% 22%); box-shadow: inset 0 0 0 1px hsl(0 0% 28% / .75), 0 4px 18px -8px hsl(240 12% 3% / .12); } .startup-composer-input { display: flex; align-items: start; height: 78px; padding: 27px 16px 8px; } .startup-composer-input .startup-block { width: 45%; height: 14px; margin-top: 5px; } .startup-composer-footer { display: flex; align-items: center; gap: 6px; padding: 0 12px 14px; } diff --git a/webui/src/components/thread/ThreadComposer.tsx b/webui/src/components/thread/ThreadComposer.tsx index b80d92e4b..3322ae865 100644 --- a/webui/src/components/thread/ThreadComposer.tsx +++ b/webui/src/components/thread/ThreadComposer.tsx @@ -2641,11 +2641,11 @@ export function ThreadComposer({ data-compact={compactIdle || undefined} style={paletteBeside ? { maxHeight: slashPaletteLayout.maxHeight, overflowY: "auto" } : undefined} className={cn( - "thread-composer-surface group/composer relative mx-auto flex w-full flex-col overflow-visible transition-all duration-200", + "thread-composer-surface group/composer relative mx-auto flex w-full flex-col overflow-visible bg-card", paletteBeside && "col-start-1 row-start-1", isHero - ? "max-w-[var(--composer-content-width,58rem)] rounded-prominent bg-muted/80 focus-within:bg-muted dark:bg-card dark:focus-within:bg-white/[0.06]" - : "max-w-[var(--composer-content-width,49.5rem)] rounded-panel bg-muted/80 focus-within:bg-muted dark:bg-card dark:focus-within:bg-white/[0.06]", + ? "max-w-[var(--composer-content-width,58rem)] rounded-prominent" + : "max-w-[var(--composer-content-width,49.5rem)] rounded-panel", compactWhenIdle && "thread-composer-collapsible transition-colors motion-reduce:transition-none", interactionDisabled && "opacity-60", sessionDragPreview && "ring-1 ring-primary/25", diff --git a/webui/src/components/thread/WorkspaceControls.tsx b/webui/src/components/thread/WorkspaceControls.tsx index d35388a81..84e4c8210 100644 --- a/webui/src/components/thread/WorkspaceControls.tsx +++ b/webui/src/components/thread/WorkspaceControls.tsx @@ -555,7 +555,7 @@ export function WorkspaceProjectPicker({ disabled, scope, defaultScope, controls -