feat(webui): refine day-night themes and interaction continuity

This commit is contained in:
Xubin Ren committed 2026-11-07 23:19:32 +08:00
1 parent 12c7d116a0
commit e8544a79a6
32 files changed
+613 -29

No files matched your search

+6
View File
@@ -56,6 +56,12 @@ History request hooks own loading, pagination and errors. `usePromptHistory.oper
Prompt navigation retains at most three server pages. Static ready Blocks appear only during an uncommitted boundary pull; a completed header is hidden and offers no second pagination entry point. Loading continues at the new boundary, where the header binds to the current first display unit for wheel, touch and keyboard alike; page eviction therefore does not remove the header or the message being read. A failure animates the same Blocks in red without visible error text; hovering shows details, and selecting the red Blocks or a fresh boundary gesture starts another request. Failed reads suppress scroll-triggered automatic requests, not explicit user input.
## Theme artwork and surface motion
The application theme remains the single owner for paired day/night artwork. The Sidebar keeps the original daytime mark and uses a sleeping-cap variant in dark mode; the Star invitation pairs matching day/night illustrations. Both layers reserve the same geometry. `.theme-art` blends opacity for System changes and browsers without native snapshots; a native root View Transition owns the whole-frame fade instead. Reduced motion switches artwork directly. Warm/cool decoration is limited to entry and empty states, not conversation reading surfaces.
Dropdowns and popovers use Radix's resolved transform origin and side, so motion stays attached to the trigger after collision handling. Radix owns their presence and focus. `SidebarPanel` retains its content until the slot and surface finish their actual exit animations, ignores descendant activity, and cancels teardown when reopened. Closing content is inert and hidden from assistive navigation; callers still own focus restoration. Disclosures keep their existing in-flow height transition and draft retention.
## Typography
Use the text roles in `tailwind.config.js` for shared metrics: `text-ui` for navigation, `text-control-label` for controls, `text-ui-label` for compact labels, `text-caption` for auxiliary text, and `text-title` / `text-ui-heading` for interface headings. These roles stay independent of reading preferences. Register new size utilities in `src/lib/utils.ts` so `cn()` distinguishes them from text colors.
+3
View File
@@ -238,7 +238,10 @@ test("unfinished numeric input reports an error instead of acting like a cleared
expect(await input.evaluate((element: HTMLInputElement) => element.validity.badInput)).toBe(true);
await input.press("Enter");
await expect(input).toHaveAttribute("aria-invalid", "true");
// The pointer can leave the editor while the user reads the validation hint.
await page.mouse.move(0, 0);
await expect(page.getByRole("tooltip", { name: /Your text remains at 18 px\./ })).toBeVisible();
await expect(input).toBeFocused();
await expect(paragraph).toHaveCSS("font-size", "18px");
await input.click();
await input.press("Escape");
+35
View File
@@ -0,0 +1,35 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>nanobot · 昼夜小猫对比</title>
<style>
* { box-sizing: border-box; }
body { margin: 0; padding: 48px 24px; color: #262626; background: #f4f3f0; font-family: system-ui, sans-serif; }
main { max-width: 760px; margin: auto; }
h1 { margin: 0 0 12px; font-size: 28px; font-weight: 600; }
p { margin: 0 0 28px; color: #666; line-height: 1.6; }
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
figure { margin: 0; padding: 36px 24px 24px; border-radius: 24px; text-align: center; background: white; }
.night { color: #eee; background: #303030; }
.large { display: block; width: 144px; height: 144px; margin: 0 auto 28px; object-fit: contain; }
figcaption { font-size: 17px; font-weight: 500; }
.actual { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 32px; font-size: 12px; opacity: 0.75; }
.actual img { width: 32px; height: 32px; object-fit: contain; }
footer { margin-top: 22px; color: #777; font-size: 12px; line-height: 1.6; }
@media (max-width: 500px) { body { padding: 28px 16px; } .pair { gap: 12px; } figure { padding: 28px 12px 20px; } .large { width: 104px; height: 104px; } .actual { flex-direction: column; } }
</style>
</head>
<body>
<main>
<h1>同一只小猫,陪你从白天到夜晚。</h1>
<p>白天还是熟悉的橘猫,夜晚戴上小睡帽,安静陪着你。</p>
<div class="pair">
<figure><img class="large" src="/brand/nanobot_mark.svg" alt="原版睁眼橘猫" /><figcaption>白天 · 原版</figcaption><div class="actual"><img src="/brand/nanobot_mark.svg" alt="" /><span>侧栏实际大小 · 32px</span></div></figure>
<figure class="night"><img class="large" src="/brand/nanobot_mark_night.svg" alt="戴睡帽的夜间橘猫" /><figcaption>夜晚 · 小睡帽</figcaption><div class="actual"><img src="/brand/nanobot_mark_night.svg" alt="" /><span>侧栏实际大小 · 32px</span></div></figure>
</div>
<footer>图形对比预览。实际侧栏跟随应用深浅主题,不代表 Agent 停止运行;Dock、favicon 和原版素材均未改变。</footer>
</main>
</body>
</html>
+53
View File
@@ -0,0 +1,53 @@
import { useRef, useState } from "react";
import { Button } from "@/components/ui/button";
import { Disclosure } from "@/components/ui/disclosure";
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";
import { Input } from "@/components/ui/input";
import { sidePanelSurfaceClassName } from "@/components/ui/floating-surface";
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
import { SidebarPanel } from "@/components/ui/sidebar-panel";
export function ContinuityFixture() {
const [open, setOpen] = useState(false);
const trigger = useRef<HTMLButtonElement>(null);
const close = () => { setOpen(false); trigger.current?.focus(); };
return <main className="mx-auto flex min-h-screen max-w-5xl flex-col gap-6 px-5 py-12">
<h1 className="text-title">Interaction continuity</h1>
<div className="flex flex-wrap gap-3">
<DropdownMenu>
<DropdownMenuTrigger asChild><Button variant="outline">Conversation actions</Button></DropdownMenuTrigger>
<DropdownMenuContent align="start">
<DropdownMenuItem>Rename conversation</DropdownMenuItem>
<DropdownMenuItem>Duplicate conversation</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
<Popover>
<PopoverTrigger asChild><Button variant="outline">Quick note</Button></PopoverTrigger>
<PopoverContent className="w-64 p-4" align="start"><Input aria-label="Quick note draft" placeholder="Write a note" /></PopoverContent>
</Popover>
<Button ref={trigger} variant="outline" onClick={() => setOpen(value => !value)} aria-expanded={open}>Toggle details</Button>
</div>
<section className="max-w-lg space-y-4 rounded-panel border p-5">
<Disclosure summary="Advanced options" summaryClassName="text-control-label" contentClassName="pt-4">
<Input aria-label="Advanced draft" placeholder="This draft survives folding" />
<p className="mt-3 text-caption text-muted-foreground">The next row moves with the expanded content.</p>
</Disclosure>
<p data-testid="following-row" className="text-ui">The following row stays in the page flow.</p>
</section>
<div className="thread-preview-layout relative flex shrink-0 overflow-hidden rounded-panel border" style={{ height: 340 }}>
<div className="min-w-0 flex-1 p-5">
<p className="mb-3 text-control-label">Conversation stays in place</p>
<Input aria-label="Conversation draft" placeholder="Your next message" />
</div>
<SidebarPanel open={open} width={420} aria-label="Details" contentClassName={sidePanelSurfaceClassName} header={<span className="text-control-label">Details</span>}
onKeyDown={event => { if (event.key === "Escape") { event.preventDefault(); close(); } }}>
<div className="space-y-4 p-5">
<Input aria-label="Details draft" placeholder="Reopen during closing to keep editing" />
<span aria-label="Activity" className="block size-4 animate-spin rounded-full border-2 border-current border-t-transparent motion-reduce:animate-none" />
<Button variant="outline" onClick={close}>Close details</Button>
</div>
</SidebarPanel>
</div>
</main>;
}
+136
View File
@@ -0,0 +1,136 @@
import { expect, test } from "@playwright/test";
for (const width of [1280, 390]) {
for (const name of ["Conversation actions", "Quick note"]) {
test(`${name} grows from its anchor and returns keyboard focus at ${width}px`, async ({ page }) => {
await page.setViewportSize({ width, height: 900 });
await page.goto("/browser/fixture.html?case=continuity");
// Capture at animation start, before protocol latency can outlive the 150ms entry.
await page.evaluate(() => {
const capture = (event: AnimationEvent) => {
const element = event.target as HTMLElement;
if (!element.matches("[role=menu], [role=dialog]")) return;
for (const animation of element.getAnimations()) if (animation instanceof CSSAnimation) animation.pause();
document.removeEventListener("animationstart", capture);
};
document.addEventListener("animationstart", capture);
});
const trigger = page.getByRole("button", { name, exact: true, includeHidden: true });
const before = (await trigger.boundingBox())!;
await trigger.click();
const surface = page.getByRole(name === "Quick note" ? "dialog" : "menu");
await expect(surface).toBeVisible();
await expect(surface).toHaveCSS("pointer-events", "auto");
// Keep the entry measurable while Radix resolves the anchor's final geometry.
await surface.evaluate(element => { for (const animation of element.getAnimations()) if (animation instanceof CSSAnimation) animation.pause(); });
await expect(surface).toHaveCSS("transform-origin", "0px 0px");
if (name === "Quick note") await expect(page.getByRole("textbox", { name: "Quick note draft" })).toBeFocused();
else await expect(surface).toBeFocused();
const motion = await surface.evaluate(element => {
const animation = element.getAnimations().find(item => item instanceof CSSAnimation);
if (!animation) return null;
animation.pause();
animation.currentTime = 75;
const css = getComputedStyle(element);
const sample = { transform: css.transform, origin: css.transformOrigin, side: element.getAttribute("data-side"), width: element.clientWidth };
animation.play();
return sample;
});
expect(motion).not.toBeNull();
expect(motion!.transform).not.toBe("none");
const origin = motion!.origin.split(" ").map(Number.parseFloat);
if (motion!.side === "bottom") expect(origin[1]).toBe(0);
else if (motion!.side === "top") expect(origin[1]).toBeGreaterThan(0);
expect(Math.abs((await trigger.boundingBox())!.x - before.x)).toBeLessThan(1);
const box = (await surface.boundingBox())!;
expect(box.x).toBeGreaterThanOrEqual(0);
expect(box.x + box.width).toBeLessThanOrEqual(width);
if (name === "Quick note") await page.getByRole("textbox", { name: "Quick note draft" }).press("Escape");
else await surface.press("Escape");
await expect(surface).toBeHidden();
await expect(trigger).toBeFocused();
});
}
}
test("a sidebar follows its actual exit and preserves an interrupted editor", async ({ page }) => {
await page.goto("/browser/fixture.html?case=continuity");
const toggle = page.getByRole("button", { name: "Toggle details", exact: true });
const panel = page.locator(".file-preview-pane");
await toggle.click();
await expect.poll(() => panel.evaluate(element => Math.round(element.getBoundingClientRect().width))).toBe(420);
await page.getByRole("textbox", { name: "Details draft" }).fill("Keep this draft");
const original = (await panel.elementHandle())!;
// Hold the real close in flight; a wall-clock timeout must not remove the surface.
await page.evaluate(async () => {
(document.querySelector("button[aria-expanded=true]") as HTMLButtonElement).click();
await new Promise(requestAnimationFrame);
const node = document.querySelector(".file-preview-pane")!;
const animations = [node, node.firstElementChild!].flatMap(element => element.getAnimations());
for (const animation of animations) { animation.pause(); animation.currentTime = 80; }
});
await expect(panel).toHaveAttribute("inert");
await expect(panel).toHaveAttribute("aria-hidden", "true");
// This exceeds the old fixed 300ms teardown while the actual exit is paused.
const heldSince = Date.now();
await expect.poll(async () => ({
connected: await original.evaluate(element => element.isConnected),
held: Date.now() - heldSince >= 350,
})).toEqual({ connected: true, held: true });
await toggle.click();
await expect(panel).not.toHaveAttribute("inert");
expect(await original.evaluate(element => element === document.querySelector(".file-preview-pane"))).toBe(true);
await expect(page.getByRole("textbox", { name: "Details draft" })).toHaveValue("Keep this draft");
await page.getByRole("textbox", { name: "Details draft" }).focus();
await page.keyboard.press("Escape");
await expect(panel).toHaveCount(0);
await expect(toggle).toBeFocused();
});
test("folding moves the next row continuously without discarding drafts", async ({ page }) => {
await page.goto("/browser/fixture.html?case=continuity");
const toggle = page.getByRole("button", { name: "Advanced options", exact: true });
const content = page.locator(".inline-disclosure");
const row = page.getByTestId("following-row");
const closed = (await row.boundingBox())!.y;
await toggle.click();
await expect.poll(() => content.evaluate(element => element.getAnimations().length)).toBe(0);
await page.getByRole("textbox", { name: "Advanced draft" }).fill("Keep folded draft");
const expanded = (await row.boundingBox())!.y;
expect(expanded).toBeGreaterThan(closed + 50);
await toggle.click();
const middle = await content.evaluate(element => {
for (const animation of element.getAnimations()) { animation.pause(); animation.currentTime = 110; }
const top = document.querySelector("[data-testid=following-row]")!.getBoundingClientRect().y;
for (const animation of element.getAnimations()) animation.play();
return top;
});
expect(middle).toBeGreaterThan(closed);
expect(middle).toBeLessThan(expanded);
await expect(content).toHaveAttribute("inert");
await toggle.click();
await expect(page.getByRole("textbox", { name: "Advanced draft" })).toHaveValue("Keep folded draft");
});
test("reduced motion keeps the same controls without travel or delayed teardown", async ({ page }) => {
await page.emulateMedia({ reducedMotion: "reduce" });
await page.goto("/browser/fixture.html?case=continuity");
for (const name of ["Conversation actions", "Quick note"]) {
const trigger = page.getByRole("button", { name, exact: true });
await trigger.click();
const surface = page.getByRole(name === "Quick note" ? "dialog" : "menu");
await expect(surface).toHaveCSS("animation-name", "none");
await expect(surface).toHaveCSS("pointer-events", "auto");
if (name === "Quick note") await expect(page.getByRole("textbox", { name: "Quick note draft" })).toBeFocused();
else await expect(surface).toBeFocused();
if (name === "Quick note") await page.getByRole("textbox", { name: "Quick note draft" }).press("Escape");
else await surface.press("Escape");
await expect(surface).toBeHidden();
await expect(trigger).toBeFocused();
}
await page.getByRole("button", { name: "Toggle details", exact: true }).click();
const panel = page.locator(".file-preview-pane");
await expect(page.getByRole("textbox", { name: "Details draft" })).toBeVisible();
await page.getByRole("button", { name: "Close details", exact: true }).click();
await expect(panel).toHaveCount(0);
});
+4 -1
View File
@@ -47,6 +47,7 @@ import { DisplayMathFixture } from "./display-math-fixture";
import { AttachmentLayoutFixture } from "./attachment-layout-fixture";
import { LoadedSessionSearchFixture } from "./loaded-session-search-fixture";
import { AppearanceFixture } from "./appearance-fixture";
import { ContinuityFixture } from "./continuity-fixture";
import { installSubagentDockApi, SubagentDockFixture } from "./subagent-dock-fixture";
const history: UIMessage[] = [
@@ -226,7 +227,9 @@ if (parameters.get("case") === "appearance" && parameters.has("lang")) {
await setAppLanguage(normalizeLocale(parameters.get("lang")));
}
createRoot(document.getElementById("root")!).render(<TooltipProvider>
{parameters.get("case") === "appearance"
{parameters.get("case") === "continuity"
? <ContinuityFixture />
: parameters.get("case") === "appearance"
? <AppearanceFixture />
: parameters.get("case") === "loaded-session-search"
? <LoadedSessionSearchFixture />
+88
View File
@@ -0,0 +1,88 @@
import { expect, test } from "@playwright/test";
test("sidebar cat follows the chosen app theme without moving or losing the draft", async ({ page }) => {
await page.setViewportSize({ width: 1440, height: 900 });
await page.emulateMedia({ colorScheme: "dark", reducedMotion: "reduce" });
await page.addInitScript(() => {
localStorage.setItem("nanobot.locale", "en");
if (!localStorage.getItem("nanobot-webui.theme")) localStorage.setItem("nanobot-webui.theme", "light");
});
await page.goto("/browser/fixture.html?case=theme-toggle&chat");
const mark = page.getByTestId("sidebar-brand-mark");
const day = mark.locator("img").nth(0);
const night = mark.locator("img").nth(1);
await expect.poll(() => mark.locator("img").evaluateAll(elements => elements.every(element => {
const image = element as HTMLImageElement;
return image.complete && image.naturalWidth === 759 && image.naturalHeight === 718;
}))).toBe(true);
await expect(day).toHaveCSS("opacity", "1");
await expect(night).toHaveCSS("opacity", "0");
const before = (await mark.boundingBox())!;
const draft = page.getByRole("textbox");
await draft.fill("Keep this draft while the cat gets sleepy");
await page.getByRole("button", { name: "Toggle theme from header", exact: true }).click();
await expect(night).toHaveCSS("opacity", "1");
await expect(day).toHaveCSS("opacity", "0");
expect(await mark.boundingBox()).toEqual(before);
await expect(draft).toHaveValue("Keep this draft while the cat gets sleepy");
await page.reload();
await expect(night).toHaveCSS("opacity", "1");
await page.getByRole("button", { name: "Toggle theme from header", exact: true }).click();
await expect(day).toHaveCSS("opacity", "1");
await expect(night).toHaveCSS("opacity", "0");
});
test("the sidebar night mark follows live System theme changes", async ({ page }) => {
await page.setViewportSize({ width: 1440, height: 900 });
await page.emulateMedia({ colorScheme: "light", reducedMotion: "reduce" });
await page.addInitScript(() => {
localStorage.setItem("nanobot.locale", "en");
localStorage.setItem("nanobot-webui.theme", "system");
});
await page.goto("/browser/fixture.html?case=theme-toggle&chat");
const images = page.getByTestId("sidebar-brand-mark").locator("img");
await expect(images.nth(0)).toHaveCSS("opacity", "1");
await expect(images.nth(1)).toHaveCSS("opacity", "0");
await page.emulateMedia({ colorScheme: "dark" });
await expect(images.nth(1)).toHaveCSS("opacity", "1");
await expect(images.nth(0)).toHaveCSS("opacity", "0");
});
test("paired artwork blends in place without native snapshots", async ({ page }) => {
await page.setViewportSize({ width: 1440, height: 900 });
await page.addInitScript(() => {
localStorage.setItem("nanobot.locale", "en");
localStorage.setItem("nanobot-webui.theme", "light");
Object.defineProperty(document, "startViewTransition", { value: undefined });
});
await page.goto("/browser/fixture.html?case=theme-toggle&chat");
const mark = page.getByTestId("sidebar-brand-mark");
const box = await mark.boundingBox();
const draft = page.getByRole("textbox");
await draft.fill("A draft survives the artwork transition");
await expect(mark.locator("img").first()).toHaveCSS("opacity", "1");
// Hold each real opacity transition when it starts, not after a protocol round trip.
await page.evaluate(() => document.addEventListener("transitionrun", event => {
const image = event.target as HTMLElement;
if (!image.matches(".theme-art") || event.propertyName !== "opacity") return;
for (const fade of image.getAnimations()) { fade.pause(); fade.currentTime = 100; }
}));
for (const target of ["dark", "light"]) {
await page.getByRole("button", { name: "Toggle theme from header", exact: true }).click();
await expect(mark.locator("img").first()).toHaveCSS("opacity", "0.5");
const middle = await mark.evaluate(element => {
const images = Array.from(element.querySelectorAll("img"));
const fades = images.flatMap(image => image.getAnimations());
const result = { theme: document.documentElement.className, count: fades.length, opacity: images.map(image => Number(getComputedStyle(image).opacity)) };
for (const fade of fades) fade.finish();
return result;
});
expect(middle.count).toBe(2);
expect(middle.theme.includes("dark")).toBe(target === "dark");
for (const opacity of middle.opacity) expect(opacity).toBeCloseTo(0.5);
await expect(mark.locator("img").nth(target === "dark" ? 1 : 0)).toHaveCSS("opacity", "1");
expect(await mark.boundingBox()).toEqual(box);
await expect(draft).toHaveValue("A draft survives the artwork transition");
await expect.poll(() => page.locator("html").getAttribute("data-theme-transition")).toBeNull();
}
});
+46
View File
@@ -0,0 +1,46 @@
import { expect, test } from "@playwright/test";
for (const width of [1280, 390]) {
test(`invitation follows the app theme without losing its artwork or layout at ${width}px`, async ({ page }, info) => {
await page.setViewportSize({ width, height: 900 });
await page.emulateMedia({ colorScheme: "light", reducedMotion: "reduce" });
await page.addInitScript(() => localStorage.setItem("nanobot.locale", "en"));
await page.goto("/browser/fixture.html?case=theme-toggle&star");
await page.getByRole("button", { name: "Open invitation", exact: true }).click();
const dialog = page.getByRole("dialog");
const images = dialog.locator(".star-prompt-art img");
await expect(images).toHaveCount(2);
await expect.poll(() => images.evaluateAll(elements => elements.every(element => {
const image = element as HTMLImageElement;
return image.complete && image.naturalWidth === 1672 && image.naturalHeight === 941;
}))).toBe(true);
await expect(images.nth(0)).toHaveCSS("opacity", "1");
await expect(images.nth(1)).toHaveCSS("opacity", "0");
await expect(dialog).toHaveCSS("animation-name", "none");
const initial = (await dialog.boundingBox())!;
await page.screenshot({ path: info.outputPath("invitation-day.png") });
// System changes are live even while the modal is open.
await page.emulateMedia({ colorScheme: "dark" });
await expect(images.nth(0)).toHaveCSS("opacity", "0");
await expect(images.nth(1)).toHaveCSS("opacity", "1");
// Color can still fade; await its settled state rather than sampling the first paint.
await expect(dialog).toHaveCSS("background-color", "rgb(36, 41, 50)");
const night = (await dialog.boundingBox())!;
expect(Math.abs(night.height - initial.height)).toBeLessThanOrEqual(1);
expect(night.x).toBeGreaterThanOrEqual(0);
expect(night.x + night.width).toBeLessThanOrEqual(width);
await expect(dialog.getByRole("button", { name: "Maybe later" })).toBeInViewport();
await page.screenshot({ path: info.outputPath("invitation-night.png") });
// Explicit Light must override a dark OS, rather than using an image media query.
await page.keyboard.press("Escape");
await expect(dialog).toBeHidden();
await page.getByRole("button", { name: "Toggle theme", exact: true }).click();
await page.getByRole("button", { name: "Open invitation", exact: true }).click();
await expect(images.nth(0)).toHaveCSS("opacity", "1");
await expect(images.nth(1)).toHaveCSS("opacity", "0");
await dialog.getByRole("button", { name: "Maybe later" }).click();
await expect(dialog).toBeHidden();
});
}
+13 -1
View File
@@ -9,12 +9,14 @@ import type { ChatSummary, UIMessage } from "@/lib/types";
import { ThreadComposer } from "@/components/thread/ThreadComposer";
import { ThreadHeader } from "@/components/thread/ThreadHeader";
import { ThemeProvider, useTheme } from "@/hooks/useTheme";
import { StarPromptView } from "@/components/StarPromptView";
import { Button } from "@/components/ui/button";
export function ThemeToggleFixture() {
const { theme, toggle } = useTheme();
return (
<ThemeProvider theme={theme}>
{new URLSearchParams(location.search).has("chat") ? <ThemeChatFixture theme={theme} toggle={toggle} /> : (
{new URLSearchParams(location.search).has("star") ? <ThemeInvitationFixture toggle={toggle} /> : new URLSearchParams(location.search).has("chat") ? <ThemeChatFixture theme={theme} toggle={toggle} /> : (
<main data-theme-surface className="thread-workspace relative flex flex-col justify-center gap-8 bg-background px-6" style={{ height: "100vh" }}>
<div className="absolute inset-x-0 top-0">
<ThreadHeader title="Theme preview" hideTitle theme={theme} onToggleTheme={toggle} onToggleSidebar={() => {}} />
@@ -31,6 +33,16 @@ export function ThemeToggleFixture() {
);
}
function ThemeInvitationFixture({ toggle }: { toggle: () => void }) {
const [open, setOpen] = useState(false);
return <main className="flex h-full flex-col items-center justify-center gap-4 bg-background">
<Button onClick={toggle}>Toggle theme</Button>
<Button onClick={() => setOpen(true)}>Open invitation</Button>
<StarPromptView open={open} saving={false} error={false} onOpenChange={setOpen}
onDismissForever={() => setOpen(false)} onStar={() => {}} />
</main>;
}
const sessions: ChatSummary[] = ["Theme chat", "Another chat"].map((title, index) => ({
key: `websocket:theme-${index}`, channel: "websocket", chatId: `theme-${index}`,
title, preview: "", createdAt: null, updatedAt: null,
+2
View File
@@ -199,6 +199,7 @@ for (const width of [1440, 390]) {
oldBlend: oldTheme.mixBlendMode, newBlend: newTheme.mixBlendMode,
isolation: getComputedStyle(root, "::view-transition-image-pair(root)").isolation,
mask: newTheme.maskImage, clip: newTheme.clipPath,
artworkDuration: getComputedStyle(document.querySelector(".theme-art")!).transitionDuration,
};
});
expect(middle.durations).toEqual([200, 200]);
@@ -212,6 +213,7 @@ for (const width of [1440, 390]) {
expect(middle.isolation).toBe("isolate");
expect(middle.mask).toBe("none");
expect(middle.clip).toBe("none");
expect(middle.artworkDuration).toBe("0s");
await expect(toggle).toBeFocused();
expect(await input.boundingBox()).toEqual(box);
await page.screenshot({ path: test.info().outputPath(`crossfade-${width}-${initial}-mid.png`), animations: "allow" });
+31
View File
@@ -0,0 +1,31 @@
<svg width="759" height="718" viewBox="0 0 759 718" fill="none" xmlns="http://www.w3.org/2000/svg">
<title>nanobot mark</title>
<path d="M229.029 127.134C308.64 112.113 354.143 106.879 379.029 108.134V716.634L272.029 715.634C251.029 715.634 243.029 702.634 201.529 678.134L54.5291 581.634C30.0291 565.134 23.9802 560.075 13.0291 549.134C3.52914 537.634 -1.97086 526.634 3.52914 481.634L28.0291 340.634L29.5291 27.1337C31.0291 -2.36625 53.0291 -6.86625 77.0291 12.6337L229.029 127.134Z" fill="#F4A949" stroke="#F4A949"/>
<path d="M529.842 126.817C450.231 111.796 404.728 106.562 379.842 107.817V716.317L486.842 715.317C509.342 714.317 570.342 661.817 611.842 637.317L704.342 581.317C728.842 564.817 734.891 559.759 745.842 548.817C755.342 537.317 760.842 526.317 755.342 481.317L730.842 340.317L729.342 26.817C727.842 -2.68287 705.842 -7.18287 681.842 12.3171L529.842 126.817Z" fill="#EF8E30" stroke="#EF8E30"/>
<path d="M143.342 497.317H1.84164C-6.15857 550.317 22.8417 557.817 56.3419 582.817L143.342 497.317Z" fill="#E27223" stroke="#DF6E22"/>
<path d="M615.342 496.817H757.001C765.002 549.817 735.842 557.317 702.342 582.317L615.342 496.817Z" fill="#D96016" stroke="#D45F16"/>
<path d="M379.342 716.317V517.817H288.342C239.842 517.817 243.342 531.817 144.842 640.817L233.342 698.817C245.302 707.847 260.342 717.317 275.342 715.817L379.342 716.317Z" fill="#FBCB89" stroke="#FBCB8A"/>
<path d="M503.342 406.817Q534.092 435.817 564.842 406.817" stroke="#B94D0B" stroke-width="26" stroke-linecap="round"/>
<path d="M379.342 716.317V517.817H470.342C518.842 517.817 513.342 528.317 611.842 637.317L522.842 698.817C510.881 707.847 495.342 715.817 483.342 715.817L379.342 716.317Z" fill="#F7B066" stroke="#F8B166"/>
<path d="M195.342 406.817Q226.092 435.817 256.842 406.817" stroke="#B94D0B" stroke-width="26" stroke-linecap="round"/>
<path d="M439.342 517.817H318.342L379.842 583.317L439.342 517.817Z" fill="#C85513" stroke="#C85513"/>
<path d="M379.342 583.317V517.817H438.842L379.342 583.317Z" fill="#BA470A" stroke="#B94D0B"/>
<path d="M367.842 304.817L339.842 109.817C369.864 107.082 387.219 106.437 420.842 109.817L391.342 304.817C382.555 322.184 376.628 321.255 367.842 304.817Z" fill="#D35E14" stroke="#D35E14"/>
<path d="M446.412 112.822C473.271 116.662 491.893 119.703 529.928 126.325L530.604 126.442L530.284 127.05L529.842 126.817L530.283 127.051C530.283 127.051 530.282 127.054 530.281 127.055C530.279 127.059 530.276 127.064 530.273 127.071C530.265 127.085 530.254 127.107 530.239 127.135C530.209 127.193 530.164 127.279 530.105 127.391C529.986 127.617 529.81 127.951 529.581 128.387C529.122 129.261 528.449 130.543 527.59 132.177C525.872 135.444 523.413 140.12 520.448 145.753C514.519 157.018 506.565 172.113 498.471 187.426C490.377 202.738 482.142 218.27 475.65 230.412C469.165 242.538 464.401 251.316 463.262 253.088C460.97 256.653 457.712 259.067 454.529 259.067C451.263 259.067 448.386 256.547 446.859 250.949C446.467 249.511 446.169 246.271 445.938 241.776C445.705 237.256 445.537 231.406 445.42 224.701C445.186 211.289 445.154 194.441 445.217 177.94C445.279 161.438 445.436 145.281 445.576 133.249C445.647 127.233 445.713 122.248 445.762 118.767C445.786 117.027 445.806 115.662 445.82 114.733C445.827 114.268 445.832 113.912 445.836 113.673C445.838 113.553 445.839 113.462 445.84 113.401C445.84 113.371 445.841 113.348 445.841 113.333C445.841 113.325 445.842 113.319 445.842 113.315C445.842 113.313 445.842 113.311 445.842 113.31C445.845 113.31 445.882 113.31 446.342 113.317L445.842 113.309L445.851 112.742L446.412 112.822Z" fill="#D35E14" stroke="#D35C15"/>
<path d="M311.842 251.317C314.842 240.317 313.842 112.817 313.842 112.817C281.05 117.181 262.657 120.321 229.842 126.817C229.842 126.817 291.842 246.317 296.342 253.317C300.842 260.317 308.842 262.317 311.842 251.317Z" fill="#DF6E23" stroke="#DA6D1F"/>
<path d="M562.842 166.317L686.842 67.8171V278.317L562.842 166.317Z" fill="#D66114" stroke="#D86116"/>
<path d="M196.342 166.317L72.3416 67.8171V278.317L196.342 166.317Z" fill="#E17125" stroke="#E27326"/>
<path d="M752.342 465.817L625.342 432.817L737.497 377.487L752.342 465.817Z" fill="#D66015"/>
<path d="M737.842 377.317L737.497 377.487M737.497 377.487L625.342 432.817L752.342 465.817L737.497 377.487Z" stroke="#D66115"/>
<path d="M6.34164 464.817L134.342 432.004L21.3031 376.986L6.34164 464.817Z" fill="#E06B1F"/>
<path d="M20.9558 376.817L21.3031 376.986M21.3031 376.986L134.342 432.004L6.34164 464.817L21.3031 376.986Z" stroke="#DF6E1E"/>
<path d="M379.842 317.775C376.246 317.475 372.636 313.145 368.342 305.112L340.342 110.112C355.495 108.732 367.422 107.884 379.842 107.817V317.775Z" fill="#E16D22" stroke="#E27225"/>
<g>
<path d="M203 169C226 87 293 36 374 32C459 28 514 76 551 120C586 161 618 178 655 180C645 204 614 212 585 199C550 183 518 158 485 151L203 169Z" fill="#8798CC"/>
<path d="M374 32C459 28 514 76 551 120C586 161 618 178 655 180C645 204 614 212 585 199C550 183 518 158 485 151C461 95 422 51 374 32Z" fill="#6B7FB8"/>
<path d="M204 151C295 123 410 120 509 143C522 146 530 158 527 172L522 198C520 210 508 217 496 214C402 193 301 196 215 221C202 225 190 217 188 204L184 180C182 167 191 155 204 151Z" fill="#E4EAF7"/>
<path d="M204 151C295 123 410 120 509 143C522 146 530 158 527 172L525 181C424 154 294 160 187 192L184 180C182 167 191 155 204 151Z" fill="#F4F6FC"/>
<circle cx="658" cy="208" r="32" fill="#E4EAF7"/>
<path d="M658 176A32 32 0 0 0 626 208C626 214 628 220 631 224C657 231 681 209 680 185C674 179 666 176 658 176Z" fill="#F4F6FC"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 5.4 KiB

+1 -1
View File
@@ -407,7 +407,7 @@ function AuthForm({
aria-labelledby="webui-auth-title"
className="w-full max-w-xs"
>
<div className="text-center">
<div className="brand-atmosphere text-center">
<img
src="/brand/nanobot_mark.svg"
alt=""
Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

+8 -2
View File
@@ -182,7 +182,7 @@ export function Sidebar(props: SidebarProps) {
onClick={collapsed ? props.onExpand : undefined}
tabIndex={collapsed ? 0 : -1}
className={cn(
"host-no-drag flex h-8 w-8 shrink-0 items-center justify-center rounded-control transition-colors",
"host-no-drag relative flex h-8 w-8 shrink-0 items-center justify-center rounded-control transition-colors",
props.hostChromeInset && "mt-5",
!collapsed && "pointer-events-none",
)}
@@ -190,7 +190,13 @@ export function Sidebar(props: SidebarProps) {
<img
src="/brand/nanobot_mark.svg"
alt=""
className="h-8 w-8 select-none object-contain"
className="theme-art h-8 w-8 select-none object-contain dark:opacity-0"
draggable={false}
/>
<img
src="/brand/nanobot_mark_night.svg"
alt=""
className="theme-art absolute inset-0 h-8 w-8 select-none object-contain opacity-0 dark:opacity-100"
draggable={false}
/>
</button>
+5
View File
@@ -1,3 +1,8 @@
:root.dark .star-prompt-dialog {
background-color: hsl(220 16% 17%);
border-color: hsl(220 14% 28%);
}
.star-prompt-decoration {
position: absolute;
top: -12px;
+8 -3
View File
@@ -3,6 +3,7 @@ import { ExternalLink, Sparkle, Star, X } from "lucide-react";
import { useTranslation } from "react-i18next";
import starInvitation from "@/assets/star-invitation.webp";
import starInvitationNight from "@/assets/star-invitation-night.webp";
import { Button } from "@/components/ui/button";
import { Dialog, DialogClose, DialogContent, DialogDescription, DialogTitle } from "@/components/ui/dialog";
@@ -57,13 +58,17 @@ export function StarPromptView({ open, saving, error, starError = false, onOpenC
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent showCloseButton={false}
className="flex max-h-[calc(100dvh-32px)] max-w-[520px] flex-col gap-0 overflow-y-auto overscroll-contain p-5 pb-2.5 outline-none max-[480px]:p-4 max-[480px]:pb-2"
className="star-prompt-dialog flex max-h-[calc(100dvh-32px)] max-w-[520px] flex-col gap-0 overflow-y-auto overscroll-contain p-5 pb-2.5 outline-none max-[480px]:p-4 max-[480px]:pb-2"
onOpenAutoFocus={(event) => {
event.preventDefault();
titleRef.current?.focus({ preventScroll: true });
}} onCloseAutoFocus={onCloseAutoFocus}>
<img src={starInvitation} alt="" width={1672} height={941} draggable={false}
className="aspect-[1672/941] w-full shrink-0 select-none rounded-control bg-muted object-cover" />
<div className="star-prompt-art relative aspect-[1672/941] w-full shrink-0 overflow-hidden rounded-control bg-muted">
<img src={starInvitation} alt="" width={1672} height={941} draggable={false}
className="theme-art absolute inset-0 h-full w-full select-none object-cover dark:opacity-0" />
<img src={starInvitationNight} alt="" width={1672} height={941} draggable={false}
className="theme-art absolute inset-0 h-full w-full select-none object-cover opacity-0 dark:opacity-100" />
</div>
<DialogClose aria-label={t("common.close")}
className="absolute right-[23px] top-[23px] grid h-11 w-11 place-items-center rounded-full outline-none focus-visible:ring-2 focus-visible:ring-white max-[480px]:right-[18px] max-[480px]:top-[18px]">
<span className="grid h-[30px] w-[30px] place-items-center rounded-full bg-black/40 text-white backdrop-blur-sm transition-colors hover:bg-black/60 motion-reduce:transition-none">
@@ -10,7 +10,7 @@ export function AboutSettingsLayout({ versionCheck, links, starLink }: {
starLink: ReactNode;
}) {
return <div className="flex flex-1 flex-col gap-5">
<div className="flex flex-col items-center gap-3 py-6 text-center">
<div className="brand-atmosphere flex flex-col items-center gap-3 py-6 text-center">
<img src="/brand/nanobot_mark.svg" alt="" className="h-16 w-16 select-none" draggable={false} />
<h1><img src="/brand/nanobot_wordmark.svg" alt="nanobot" width={800} height={164} className="h-auto w-40 select-none dark:brightness-150" draggable={false} /></h1>
</div>
@@ -40,6 +40,7 @@ export function AppearanceSettingsView({ themePreference, onChangeTheme, localPr
<span className="appearance-theme-miniature" data-mode={value} aria-hidden>
<span className="appearance-mini-sidebar"><span /><span /><span /></span>
<span className="appearance-mini-main"><span /><span /><span /><span /></span>
<span className="appearance-mini-sky"><Sun /><Moon /></span>
</span>
<span className="appearance-theme-label text-ui-label">
<span className="flex min-w-0 items-center gap-1.5"><Icon className="h-3.5 w-3.5 shrink-0" aria-hidden /><span>{label}</span></span>
@@ -104,7 +104,11 @@ export function ReadingSettings({ preferences, onChange }: {
if (!commitDraft()) event.preventDefault();
}}
onKeyDown={(event) => {
if (event.key === "Enter") event.currentTarget.blur();
if (event.key === "Enter") {
event.preventDefault();
// Keep an invalid edit focused so hover/blur dismissal cannot hide its feedback.
if (commitDraft()) event.currentTarget.blur();
}
if (event.key === "Escape") {
event.preventDefault();
event.stopPropagation();
@@ -7,17 +7,27 @@
.appearance-theme-option input:focus-visible + .appearance-theme-card { outline: 2px solid hsl(var(--ring) / 0.65); outline-offset: 3px; }
.appearance-theme-check { opacity: 0; }
.appearance-theme-option input:checked + .appearance-theme-card .appearance-theme-check { opacity: 1; }
.appearance-theme-option input:checked + .appearance-theme-card { border-color: hsl(var(--foreground) / 0.5); }
.appearance-theme-label { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 8px 4px 2px; min-height: 36px; }
.appearance-theme-miniature { --mini-paper: #fff; --mini-sidebar: #f1f0ec; --mini-line: #dad9d5; display: flex; height: 84px; overflow: hidden; border-radius: calc(var(--radius-panel) - var(--appearance-theme-inset) - 1px); background: var(--mini-paper); box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.04); }
.appearance-theme-miniature { --mini-paper: #fff; --mini-sidebar: #f1f0ec; --mini-line: #dad9d5; position: relative; display: flex; height: 84px; overflow: hidden; border-radius: calc(var(--radius-panel) - var(--appearance-theme-inset) - 1px); background: var(--mini-paper); box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.04); }
.appearance-theme-miniature[data-mode="dark"] { --mini-paper: #303030; --mini-sidebar: #383838; --mini-line: #656565; }
.appearance-theme-miniature[data-mode="system"] { --mini-paper: linear-gradient(110deg, #fff calc(50% - 0.5px), #303030 calc(50% + 0.5px)); --mini-sidebar: #f1f0ec; --mini-line: #969590; }
.appearance-mini-sidebar { width: 24%; display: flex; flex-direction: column; gap: 6px; padding: 11px 7px; background: var(--mini-sidebar); }
.appearance-mini-sidebar::before { content: ""; width: 8px; height: 8px; border-radius: 3px; background: #d7834c; margin-bottom: 6px; }
.appearance-mini-sidebar::before { content: ""; width: 11px; height: 11px; background: url('/brand/nanobot_mark.svg') center / contain no-repeat; margin-bottom: 3px; }
.appearance-mini-sidebar span { height: 3px; border-radius: 3px; background: var(--mini-line); }
.appearance-mini-main { display: flex; min-width: 0; flex: 1; flex-direction: column; align-items: flex-start; gap: 5px; padding: 16px 12px 10px; }
.appearance-mini-main span { height: 3px; width: 80%; border-radius: 3px; background: var(--mini-line); }
.appearance-mini-main span:first-child { width: 46%; height: 5px; margin-bottom: 4px; }
.appearance-mini-main span:last-child { width: 100%; height: 13px; margin-top: auto; border: 1px solid var(--mini-line); background: transparent; border-radius: 5px; }
.appearance-mini-sky { position: absolute; inset: 0 0 0 24%; pointer-events: none; background: radial-gradient(ellipse at 80% 15%, rgb(252 204 110 / 0.2), transparent 65%); }
.appearance-mini-sky svg { position: absolute; top: 10px; right: 10px; width: 12px; height: 12px; color: #b87522; stroke-width: 1.5; }
.appearance-mini-sky svg + svg { display: none; color: #b4c6e8; }
.appearance-theme-miniature[data-mode="dark"] .appearance-mini-sky { background: radial-gradient(ellipse at 80% 15%, rgb(103 147 220 / 0.2), transparent 65%); }
.appearance-theme-miniature[data-mode="dark"] .appearance-mini-sky svg:first-child { display: none; }
.appearance-theme-miniature[data-mode="dark"] .appearance-mini-sky svg + svg { display: block; }
.appearance-theme-miniature[data-mode="system"] .appearance-mini-sky { background: linear-gradient(110deg, rgb(252 204 110 / 0.12) 40%, rgb(103 147 220 / 0.12) 60%); }
.appearance-theme-miniature[data-mode="system"] .appearance-mini-sky svg:first-child { right: 56%; }
.appearance-theme-miniature[data-mode="system"] .appearance-mini-sky svg + svg { display: block; }
.appearance-reading-card { overflow: hidden; border-radius: var(--radius-panel); background: hsl(var(--settings-surface)); }
.appearance-reading-controls { padding: 20px var(--settings-inset, 16px); }
.appearance-size-options { display: flex; align-items: center; gap: 12px; max-width: 100%; }
+1 -1
View File
@@ -1471,7 +1471,7 @@ export function ThreadShell({
const emptyState = initialHistoryLoading ? (
<ThreadLoadingSkeleton />
) : (
<div className="flex w-full flex-col items-center text-center animate-in fade-in-0 slide-in-from-bottom-2 [animation-duration:220ms] motion-reduce:animate-none">
<div className="brand-atmosphere brand-atmosphere-welcome flex w-full flex-col items-center text-center animate-in fade-in-0 slide-in-from-bottom-2 [animation-duration:220ms] motion-reduce:animate-none">
<HeroGreeting text={t(heroGreetingKey)} />
</div>
);
+2 -2
View File
@@ -24,7 +24,7 @@ const DialogOverlay = React.forwardRef<
ref={ref}
className={cn(
modalOverlayClassName,
"duration-200 motion-reduce:animate-none",
"duration-200 motion-reduce:data-[state=open]:animate-none motion-reduce:data-[state=closed]:animate-none",
className,
)}
{...props}
@@ -209,7 +209,7 @@ const DialogContent = React.forwardRef<
}}
className={cn(
modalSurfaceClassName,
"relative grid w-full max-w-lg gap-4 p-6 duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 motion-reduce:animate-none",
"relative grid w-full max-w-lg gap-4 p-6 duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 motion-reduce:data-[state=open]:animate-none motion-reduce:data-[state=closed]:animate-none",
placement === "bottom"
? "mt-auto max-h-[85dvh] overflow-y-auto overscroll-contain rounded-t-modal pb-[max(1rem,env(safe-area-inset-bottom))] data-[state=open]:slide-in-from-bottom-full data-[state=closed]:slide-out-to-bottom-full ease-[cubic-bezier(0.2,0,0,1)] duration-300"
: "my-auto origin-center rounded-modal data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",
+2 -2
View File
@@ -37,7 +37,7 @@ const DropdownMenuContent = React.forwardRef<
className={cn(
floatingSurfaceClassName,
floatingSurfaceMotionClassName,
"max-h-[min(var(--radix-dropdown-menu-content-available-height),28rem)] min-w-[10rem]",
"origin-[var(--radix-dropdown-menu-content-transform-origin)] max-h-[min(var(--radix-dropdown-menu-content-available-height),28rem)] min-w-[10rem]",
className,
)}
{...props}
@@ -147,7 +147,7 @@ const DropdownMenuSubContent = React.forwardRef<
className={cn(
floatingSurfaceClassName,
floatingSurfaceMotionClassName,
"max-h-[min(var(--radix-dropdown-menu-content-available-height),22rem)] min-w-[11rem] overflow-y-auto",
"origin-[var(--radix-dropdown-menu-content-transform-origin)] max-h-[min(var(--radix-dropdown-menu-content-available-height),22rem)] min-w-[11rem] overflow-y-auto",
className,
)}
{...props}
+8 -1
View File
@@ -19,7 +19,14 @@ export const floatingSurfaceClassName =
`${floatingSurfaceVisualClassName} z-50 overflow-x-hidden overflow-y-auto overscroll-contain scrollbar-thin`;
export const floatingSurfaceMotionClassName =
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0";
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 " +
"data-[state=open]:zoom-in-[0.98] data-[state=closed]:zoom-out-[0.98] " +
"data-[side=bottom]:slide-in-from-top-1 data-[side=bottom]:slide-out-to-top-1 " +
"data-[side=top]:slide-in-from-bottom-1 data-[side=top]:slide-out-to-bottom-1 " +
"data-[side=right]:slide-in-from-left-1 data-[side=right]:slide-out-to-left-1 " +
"data-[side=left]:slide-in-from-right-1 data-[side=left]:slide-out-to-right-1 " +
"transition-none data-[state=open]:duration-150 data-[state=closed]:duration-100 ease-out " +
"motion-reduce:data-[state=open]:animate-none motion-reduce:data-[state=closed]:animate-none";
export const floatingItemClassName =
"relative flex min-h-8 select-none items-center gap-2 rounded-control px-2.5 py-2 text-[13px] outline-none transition-colors [&>svg]:h-4 [&>svg]:w-4 [&>svg]:shrink-0";
+1 -1
View File
@@ -30,7 +30,7 @@ const PopoverContent = React.forwardRef<
className={cn(
floatingSurfaceClassName,
floatingSurfaceMotionClassName,
"max-h-[min(var(--radix-popover-content-available-height),28rem)]",
"origin-[var(--radix-popover-content-transform-origin)] max-h-[min(var(--radix-popover-content-available-height),28rem)]",
className,
)}
{...props}
+19 -6
View File
@@ -1,5 +1,4 @@
import { createContext, forwardRef, useCallback, useEffect, useLayoutEffect, useRef, useState, type CSSProperties, type HTMLAttributes, type ReactNode } from "react";
import { useReducedMotion } from "motion/react";
import { cn } from "@/lib/utils";
interface SidebarPanelProps extends HTMLAttributes<HTMLElement> {
@@ -18,13 +17,25 @@ export const SidebarPanel = forwardRef<HTMLElement, SidebarPanelProps>(function
open = true, isClosing, ...props
}, ref) {
const [present, setPresent] = useState(open);
const reducedMotion = useReducedMotion();
const panel = useRef<HTMLElement | null>(null);
const setPanel = useCallback((node: HTMLElement | null) => {
panel.current = node;
if (typeof ref === "function") ref(node);
else if (ref) ref.current = node;
}, [ref]);
useEffect(() => {
if (open) { setPresent(true); return; }
const timer = window.setTimeout(() => setPresent(false), reducedMotion ? 0 : 300);
return () => window.clearTimeout(timer);
}, [open, reducedMotion]);
return open || present ? <SidebarPanelContent {...props} ref={ref} isClosing={isClosing || !open} /> : null;
// Only the slot and its surface own the exit. Descendant activity may loop forever.
const animations = [panel.current, panel.current?.firstElementChild]
.flatMap((element) => element?.getAnimations?.() ?? []);
if (!animations.length) { setPresent(false); return; }
let cancelled = false;
void Promise.allSettled(animations.map((animation) => animation.finished)).then(() => {
if (!cancelled) setPresent(false);
});
return () => { cancelled = true; };
}, [open]);
return open || present ? <SidebarPanelContent {...props} ref={setPanel} isClosing={isClosing || !open} /> : null;
});
/** Shared nonmodal side slot. Contents keep their final width while the slot opens. */
@@ -46,6 +57,8 @@ const SidebarPanelContent = forwardRef<HTMLElement, SidebarPanelProps>(function
return () => cancelAnimationFrame(frame);
}, []);
return <aside {...props} ref={setPanel} data-closing={isClosing || undefined}
aria-hidden={isClosing ? true : props["aria-hidden"]}
{...(isClosing ? { inert: "" } : {})}
style={{
"--file-preview-width": `${width}px`,
"--file-preview-slot-width": isClosing ? "0px" : !entered ? "var(--sidebar-enter-width, 0px)" : `${width}px`,
+2 -2
View File
@@ -257,9 +257,9 @@ function Sidebars() {
return <div className="space-y-3">
<Button onClick={() => setOpen(!open)}>{t("controls.sidebarPanel.toggle")}</Button>
<div className="thread-preview-layout relative h-64 overflow-hidden rounded-xl border">
{open && <SidebarPanel width={320} header={<span>{t("controls.sidebarPanel.title")}</span>}>
<SidebarPanel open={open} width={320} header={<span>{t("controls.sidebarPanel.title")}</span>}>
<p className="p-4 text-sm">{t("controls.sidebarPanel.content")}</p>
</SidebarPanel>}
</SidebarPanel>
</div>
</div>;
}
+28
View File
@@ -144,6 +144,7 @@
--sidebar-border: 40 8% 90.5%;
--settings-canvas: var(--background);
--settings-surface: 60 6% 96.7%;
--brand-ambient: 36 96% 78%;
--automation-view-track: hsl(0 0% 91%);
--scrollbar-thumb: hsl(var(--muted-foreground) / 0.26);
--scrollbar-thumb-hover: hsl(var(--muted-foreground) / 0.42);
@@ -216,12 +217,39 @@
--sidebar-border: var(--border);
--settings-canvas: var(--background);
--settings-surface: var(--card);
--brand-ambient: 219 58% 58%;
--automation-view-track: hsl(var(--muted) / 0.65);
--scrollbar-thumb: hsl(var(--muted-foreground) / 0.28);
--scrollbar-thumb-hover: hsl(var(--muted-foreground) / 0.44);
}
}
/* Decoration belongs to entry/empty states, never to conversation reading surfaces. */
.brand-atmosphere {
position: relative;
isolation: isolate;
}
.brand-atmosphere::before {
content: "";
position: absolute;
z-index: -1;
pointer-events: none;
top: -72px;
left: 50%;
width: min(420px, 100%);
height: 240px;
transform: translateX(-50%);
background: radial-gradient(ellipse at center, hsl(var(--brand-ambient) / 0.22), transparent 68%);
}
.brand-atmosphere-welcome::before {
top: -100px;
width: min(620px, 100%);
height: 250px;
opacity: 0.65;
}
@layer base {
* {
@apply border-border;
+8
View File
@@ -6,6 +6,14 @@
--theme-ink-delay: 100ms;
}
/* System/storage changes and browsers without snapshots still blend paired artwork.
A native snapshot owns the whole frame; do not run a second fade inside it. */
@media (prefers-reduced-motion: no-preference) {
:root:not([data-theme-snapshot]) .theme-art {
transition: opacity 200ms ease-in-out;
}
}
/* Paint owners opt in; components with local motion compose these lists instead. */
:root[data-theme-transition] {
--theme-paint-duration: 280ms;
@@ -1,7 +1,7 @@
import { act, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { createPortal } from "react-dom";
import { describe, expect, it } from "vitest";
import { describe, expect, it, vi } from "vitest";
import { ComposerUsagePopover } from "@/components/thread/ComposerUsagePopover";
import type { ContextSnapshot } from "@/lib/types";
@@ -66,13 +66,19 @@ describe("Context sidebar", () => {
expect(screen.getByRole("complementary")).toBe(sidebar);
expect(within(sidebar).getByRole("progressbar")).toHaveAttribute("aria-valuenow", "10");
expect(within(footer).getByTestId("composer-context-usage")).toHaveAttribute("aria-expanded", "true");
// happy-dom has no CSS timeline; model the real surface exit for this interruption.
let finishExit!: () => void;
const finished = new Promise<void>((resolve) => { finishExit = resolve; });
Object.defineProperty(sidebar, "getAnimations", { value: vi.fn(() => [{ finished }]) });
await user.click(within(footer).getByTestId("composer-context-usage"));
expect(screen.getByRole("complementary")).toBe(sidebar);
expect(sidebar).toBeInTheDocument();
expect(sidebar).toHaveAttribute("inert");
expect(sidebar.style.getPropertyValue("--file-preview-slot-width")).toBe("0px");
// Reopening during exit retains the graph instead of remounting it.
await user.click(within(footer).getByTestId("composer-context-usage"));
expect(screen.getByRole("complementary")).toBe(sidebar);
await user.click(within(footer).getByTestId("composer-context-usage"));
await act(async () => finishExit());
await waitFor(() => expect(screen.queryByRole("complementary")).not.toBeInTheDocument());
view.unmount(); toolbar.remove(); footer.remove();
});
@@ -241,6 +241,26 @@ describe("Settings overview and appearance", () => {
expect(readLocalPreferences().customReadingTextSize).toBe(22);
});
it("keeps an invalid Enter edit focused until corrected or cancelled", async () => {
writeLocalPreferences({ ...DEFAULT_LOCAL_PREFS, readingTextSize: "custom" });
renderSettingsView({ initialSection: "appearance", initialSettings: settingsPayload() });
const input = screen.getByRole("spinbutton", { name: "Custom text size" });
act(() => input.focus());
fireEvent.change(input, { target: { value: "40" } });
fireEvent.keyDown(input, { key: "Enter" });
expect(input).toHaveFocus();
expect(input).toHaveAttribute("aria-invalid", "true");
expect(await screen.findByRole("tooltip")).toHaveTextContent("Your text remains at 18 px.");
expect(readLocalPreferences().customReadingTextSize).toBe(18);
fireEvent.keyDown(input, { key: "Escape" });
expect(input).toHaveValue(18);
expect(input).not.toHaveAttribute("aria-invalid", "true");
fireEvent.change(input, { target: { value: "22" } });
fireEvent.keyDown(input, { key: "Enter" });
expect(input).not.toHaveFocus();
expect(readLocalPreferences().customReadingTextSize).toBe(22);
});
it.each(["", "40"])("restores the saved custom size after another tab interrupts draft %j", async (draft) => {
writeLocalPreferences({ ...DEFAULT_LOCAL_PREFS, readingTextSize: "custom", customReadingTextSize: 24 });
renderSettingsView({ initialSection: "appearance", initialSettings: settingsPayload() });
+56
View File
@@ -0,0 +1,56 @@
import { act, render, screen } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";
import { SidebarPanel } from "@/components/ui/sidebar-panel";
describe("sidebar presence", () => {
it("retains the same surface until both slot and content finish closing", async () => {
const view = (open: boolean) => <SidebarPanel open={open} width={420} aria-label="Details"><input aria-label="Draft" /></SidebarPanel>;
const { rerender } = render(view(true));
const panel = screen.getByRole("complementary", { name: "Details" });
let finishSlot!: () => void;
let finishSurface!: () => void;
const slot = new Promise<void>((resolve) => { finishSlot = resolve; });
const surface = new Promise<void>((resolve) => { finishSurface = resolve; });
Object.defineProperty(panel, "getAnimations", { value: () => [{ finished: slot }] });
Object.defineProperty(panel.firstElementChild, "getAnimations", { value: () => [{ finished: surface }] });
rerender(view(false));
expect(panel).toBeInTheDocument();
expect(panel).toHaveAttribute("inert");
expect(panel).toHaveAttribute("aria-hidden", "true");
await act(async () => { finishSurface(); });
expect(panel).toBeInTheDocument();
await act(async () => { finishSlot(); });
expect(panel).not.toBeInTheDocument();
});
it("does not let an interrupted exit discard the reopened editor", async () => {
const view = (open: boolean) => <SidebarPanel open={open} width={420} aria-label="Details"><input aria-label="Draft" defaultValue="Unsaved" /></SidebarPanel>;
const { rerender } = render(view(true));
const panel = screen.getByRole("complementary", { name: "Details" });
const input = screen.getByRole("textbox", { name: "Draft" });
let finish!: () => void;
const finished = new Promise<void>((resolve) => { finish = resolve; });
Object.defineProperty(panel, "getAnimations", { value: () => [{ finished }] });
rerender(view(false));
rerender(view(true));
await act(async () => { finish(); });
expect(screen.getByRole("complementary", { name: "Details" })).toBe(panel);
expect(screen.getByRole("textbox", { name: "Draft" })).toBe(input);
expect(input).toHaveValue("Unsaved");
expect(panel).not.toHaveAttribute("inert");
});
it("releases immediately without surface motion, ignoring activity inside it", () => {
const ref = vi.fn();
const view = (open: boolean) => <SidebarPanel ref={ref} open={open} width={420} aria-label="Details"><span data-testid="activity" /></SidebarPanel>;
const { rerender } = render(view(true));
const panel = screen.getByRole("complementary", { name: "Details" });
const getActivityAnimations = vi.fn();
Object.defineProperty(screen.getByTestId("activity"), "getAnimations", { value: getActivityAnimations });
rerender(view(false));
expect(panel).not.toBeInTheDocument();
expect(ref).toHaveBeenLastCalledWith(null);
expect(getActivityAnimations).not.toHaveBeenCalled();
});
});