feat(webui): simplify automation management and unify disclosure motion
Replace the dense automation workspace with a calm list and on-demand details, show current linked-chat titles, and remember manual system-task expansion preferences. Reuse disclosure transitions across expandable controls, preserve drafts and focus through closing, and release large diffs after their exit animation. Refs NAN-116
This commit is contained in:
1 parent
90b889394f
commit
1640784d45
37 files changed
+1746
-721
No files matched your search
@@ -0,0 +1,77 @@
|
||||
import { useEffect, useId, useRef, useState, type KeyboardEventHandler, type ReactNode } from "react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
/** Keep the content mounted so both directions animate and form drafts survive closing. */
|
||||
export function DisclosureContent({
|
||||
open, children, id, className, onKeyDown, onExitComplete,
|
||||
}: {
|
||||
open: boolean;
|
||||
children: ReactNode;
|
||||
id?: string;
|
||||
className?: string;
|
||||
onKeyDown?: KeyboardEventHandler<HTMLDivElement>;
|
||||
onExitComplete?: () => void;
|
||||
}) {
|
||||
const node = useRef<HTMLDivElement>(null);
|
||||
useEffect(() => {
|
||||
if (open || !onExitComplete) return;
|
||||
// Read the actual CSS transitions, including a reversal in progress. With
|
||||
// reduced motion (or no transition), there is nothing to wait for.
|
||||
const animations = node.current?.getAnimations?.() ?? [];
|
||||
if (!animations.length) {
|
||||
onExitComplete();
|
||||
return;
|
||||
}
|
||||
let cancelled = false;
|
||||
void Promise.allSettled(animations.map((animation) => animation.finished)).then(() => {
|
||||
if (!cancelled) onExitComplete();
|
||||
});
|
||||
return () => { cancelled = true; };
|
||||
}, [open, onExitComplete]);
|
||||
return (
|
||||
<div
|
||||
ref={node}
|
||||
id={id}
|
||||
className="inline-disclosure"
|
||||
data-state={open ? "open" : "closed"}
|
||||
aria-hidden={open ? undefined : true}
|
||||
onKeyDown={onKeyDown}
|
||||
{...(!open ? { inert: "" } : {})}
|
||||
>
|
||||
<div className="inline-disclosure-clip">
|
||||
<div className={cn("inline-disclosure-content", className)}>{children}</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function Disclosure({
|
||||
summary, children, className, summaryClassName, contentClassName,
|
||||
}: {
|
||||
summary: ReactNode;
|
||||
children: ReactNode;
|
||||
className?: string;
|
||||
summaryClassName?: string;
|
||||
contentClassName?: string;
|
||||
}) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const id = useId();
|
||||
return (
|
||||
<div className={className}>
|
||||
<button
|
||||
type="button"
|
||||
className={cn("group/disclosure w-full select-none text-start", summaryClassName)}
|
||||
data-state={open ? "open" : "closed"}
|
||||
aria-expanded={open}
|
||||
aria-controls={id}
|
||||
onClick={() => setOpen((value) => !value)}
|
||||
>
|
||||
{summary}
|
||||
</button>
|
||||
<DisclosureContent id={id} open={open} className={contentClassName}>
|
||||
{children}
|
||||
</DisclosureContent>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user