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

+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();
});
});