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:
Xubin Ren committed 2026-09-11 20:38:38 +08:00
1 parent 90b889394f
commit 1640784d45
37 files changed
+1746 -721

No files matched your search

@@ -51,6 +51,7 @@ interface SettingsPageProps {
onToggleTheme: () => void;
onBackToChat: () => void;
skills: SkillSummary[];
titleOverrides?: Record<string, string>;
onLogout?: () => void;
isRestarting: boolean;
hostChromeInset: boolean;
@@ -64,6 +65,7 @@ export function SettingsPage({
onToggleTheme,
onBackToChat,
skills,
titleOverrides,
onLogout,
isRestarting,
hostChromeInset,
@@ -562,6 +564,7 @@ export function SettingsPage({
<div className="settings-stack">
<AutomationsSettings
payload={automations}
titleOverrides={titleOverrides}
loading={automationsLoading}
query={automationsQuery}
filter={automationsFilter}
@@ -574,7 +577,6 @@ export function SettingsPage({
onAction={handleAutomationAction}
onRequestEdit={setAutomationPendingEdit}
onRequestDelete={setAutomationPendingDelete}
onBackToChat={onBackToChat}
/>
</div>
);
@@ -730,7 +732,7 @@ export function SettingsPage({
)}
>
{!showSidebar ? (
<div className="mb-7">
<div className={activeSection === "automations" ? "lg:hidden" : "mb-7"}>
<button
type="button"
onClick={backToChat}
@@ -739,11 +741,11 @@ export function SettingsPage({
<ChevronLeft className="h-3.5 w-3.5" aria-hidden />
{t("settings.backToChat")}
</button>
<h1 className="text-[24px] font-normal leading-tight tracking-normal text-foreground sm:text-[28px]">
{activeSection !== "automations" ? <h1 className="text-[24px] font-normal leading-tight tracking-normal text-foreground sm:text-[28px]">
{t(`settings.nav.${activeSection}`, {
defaultValue: standaloneSectionTitle(activeSection),
})}
</h1>
</h1> : null}
</div>
) : null}
@@ -16,6 +16,7 @@ interface SettingsViewProps {
onModelNameChange: (modelName: string | null) => void;
onSettingsChange?: (payload: SettingsPayload) => void;
skills?: SkillSummary[];
titleOverrides?: Record<string, string>;
onSectionChange?: (section: SettingsSectionKey) => void;
onLogout?: () => void;
onRestart?: () => void;
@@ -35,6 +36,7 @@ export function SettingsView({
onModelNameChange,
onSettingsChange,
skills = [],
titleOverrides,
onSectionChange,
onLogout,
onRestart,
@@ -61,6 +63,7 @@ export function SettingsView({
onToggleTheme={onToggleTheme}
onBackToChat={onBackToChat}
skills={skills}
titleOverrides={titleOverrides}
onLogout={onLogout}
isRestarting={isRestarting}
hostChromeInset={hostChromeInset}
@@ -1,4 +1,4 @@
import { useEffect, useState, type ReactNode } from "react";
import { useEffect, useId, useState, type ReactNode } from "react";
import type { TFunction } from "i18next";
import {
Check,
@@ -25,6 +25,8 @@ import {
AlertDialogTitle,
} from "@/components/ui/alert-dialog";
import { Button } from "@/components/ui/button";
import { Disclosure } from "@/components/ui/disclosure";
import { ExpandableText } from "@/components/ui/expandable-text";
import { Input } from "@/components/ui/input";
import { SegmentedControl } from "@/components/ui/segmented-control";
import { Sheet, SheetContent, SheetDescription, SheetTitle } from "@/components/ui/sheet";
@@ -279,6 +281,7 @@ function SkillDetailSheet({
const [deleteOpen, setDeleteOpen] = useState(false);
const [refreshKey, setRefreshKey] = useState(0);
const [descriptionExpanded, setDescriptionExpanded] = useState(false);
const descriptionId = useId();
useEffect(() => {
if (!open || !skill) return;
@@ -407,18 +410,21 @@ function SkillDetailSheet({
{statusLabel}
</Pill>
</div>
<p
className={cn(
"mt-3 text-[13px] leading-5 text-muted-foreground",
descriptionExpandable && !descriptionExpanded && "line-clamp-5",
)}
>
{activeSkill.description}
</p>
<div className="mt-3">
<ExpandableText
id={descriptionId}
expanded={descriptionExpanded || !descriptionExpandable}
lines={5}
className="text-[13px] leading-5 text-muted-foreground"
>
{activeSkill.description}
</ExpandableText>
</div>
{descriptionExpandable ? (
<button
type="button"
aria-expanded={descriptionExpanded}
aria-controls={descriptionId}
onClick={() => setDescriptionExpanded((value) => !value)}
className="mt-1.5 min-h-8 rounded-full text-[12px] font-medium text-foreground/70 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
>
@@ -574,15 +580,18 @@ function RawInstructionsBlock({ markdown }: { markdown: string }) {
});
return (
<details className="group rounded-floating border border-border/45 bg-muted/20 px-3 py-3">
<summary className="flex min-h-11 cursor-pointer select-none items-center justify-between gap-3 text-[13px] font-medium text-foreground/90 transition-colors hover:text-foreground">
<Disclosure
className="rounded-floating border border-border/45 bg-muted/20 px-3 py-3"
summaryClassName="flex min-h-11 cursor-pointer items-center justify-between gap-3 rounded-sm text-[13px] font-medium text-foreground/90 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
summary={<>
<span>
{t("settings.skills.instructionsTitle", { defaultValue: "Skill instructions" })}
</span>
<code className="font-mono text-[10px] font-normal text-muted-foreground">
SKILL.md
</code>
</summary>
</>}
>
<div className="mt-3 overflow-hidden rounded-control border border-border/35 bg-background/70">
<pre
className={cn(
@@ -596,7 +605,7 @@ function RawInstructionsBlock({ markdown }: { markdown: string }) {
{content}
</pre>
</div>
</details>
</Disclosure>
);
}
@@ -1,6 +1,7 @@
import { ProviderIcon } from "@/components/settings/models/ProviderSettings";
import { useAutoSave } from "@/components/settings/shared/useAutoSave";
import { useEffect, useRef, useState, type Dispatch, type SetStateAction } from "react";
import { useEffect, useId, useRef, useState, type Dispatch, type SetStateAction } from "react";
import { DisclosureContent } from "@/components/ui/disclosure";
import {
ChevronDown,
GripVertical,
@@ -237,6 +238,7 @@ export function ModelsSettings({
const suggestedPresetNameRef = useRef<string | null>(null);
const [editorRowKey, setEditorRowKey] = useState<string | null>(null);
const [advancedOpen, setAdvancedOpen] = useState(false);
const advancedId = useId();
const [draggedCallOrderIndex, setDraggedCallOrderIndex] = useState<number | null>(null);
const [dragOverCallOrderIndex, setDragOverCallOrderIndex] = useState<number | null>(null);
const [draggedRowHeight, setDraggedRowHeight] = useState(0);
@@ -499,6 +501,7 @@ export function ModelsSettings({
<button
type="button"
aria-expanded={advancedOpen}
aria-controls={advancedId}
onClick={() => setAdvancedOpen((value) => !value)}
className="flex min-h-[62px] w-full items-center justify-between gap-4 px-4 py-3.5 text-left transition-colors settings-hover sm:px-5"
>
@@ -519,13 +522,13 @@ export function ModelsSettings({
</span>
<ChevronDown
className={cn(
"h-4 w-4 shrink-0 text-muted-foreground transition-transform",
"h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200 motion-reduce:transition-none",
advancedOpen && "rotate-180",
)}
aria-hidden
/>
</button>
{advancedOpen ? (
<DisclosureContent id={advancedId} open={advancedOpen}>
<div className="bg-muted/12 px-4 py-4 sm:px-5">
<ModelAdvancedFields
maxTokens={form.maxTokens}
@@ -535,7 +538,7 @@ export function ModelsSettings({
onChange={(value) => setForm((prev) => ({ ...prev, ...value }))}
/>
</div>
) : null}
</DisclosureContent>
<div className="flex min-h-[58px] flex-col gap-3 px-4 py-3 sm:flex-row sm:items-center sm:justify-between sm:px-5">
{creating ? (
<Button
@@ -1,4 +1,5 @@
import { useMemo, useState, type ReactNode } from "react";
import { useId, useMemo, useState, type ReactNode } from "react";
import { DisclosureContent } from "@/components/ui/disclosure";
import {
ChevronDown,
Clipboard,
@@ -431,6 +432,7 @@ function ProviderAdvancedOptions({
const { t } = useTranslation();
const [open, setOpen] = useState(false);
const enabled = new Set(fields);
const contentId = useId();
if (enabled.size === 0) return null;
const tx = (key: string, fallback: string) => t(key, { defaultValue: fallback });
@@ -446,6 +448,7 @@ function ProviderAdvancedOptions({
<button
type="button"
aria-expanded={open}
aria-controls={contentId}
onClick={() => setOpen((value) => !value)}
className="flex min-h-[48px] w-full items-center justify-between gap-4 px-1 py-2.5 text-left transition-colors hover:text-foreground"
>
@@ -454,13 +457,13 @@ function ProviderAdvancedOptions({
</span>
<ChevronDown
className={cn(
"h-4 w-4 shrink-0 text-muted-foreground transition-transform",
"h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200 motion-reduce:transition-none",
open && "rotate-180",
)}
aria-hidden
/>
</button>
{open ? (
<DisclosureContent id={contentId} open={open}>
<div className="py-3">
<div className="grid gap-3 md:grid-cols-2">
{enabled.has("api_type") ? (
@@ -622,7 +625,7 @@ function ProviderAdvancedOptions({
) : null}
</div>
</div>
) : null}
</DisclosureContent>
{footer ? (
<div className="flex items-center justify-end gap-2 py-3">
{footer}
@@ -4,17 +4,20 @@ import { useTranslation } from "react-i18next";
import { ToggleButton } from "@/components/settings/ToggleButton";
import { SettingsGroup, SettingsRow } from "@/components/settings/shared/SettingsControls";
import { Dialog, DialogContent, DialogTitle, DialogTrigger } from "@/components/ui/dialog";
import { Disclosure } from "@/components/ui/disclosure";
export function SettingsAdvancedOptions({ children }: { children: ReactNode }) {
const { t } = useTranslation();
return (
<details className="group/advanced [&>summary]:select-none">
<summary className="settings-list-inset flex min-h-12 cursor-pointer list-none items-center justify-between gap-4 rounded-xl text-[13px] leading-5 text-muted-foreground settings-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring [&::-webkit-details-marker]:hidden">
<Disclosure
summaryClassName="settings-list-inset flex min-h-12 cursor-pointer items-center justify-between gap-4 rounded-xl text-[13px] leading-5 text-muted-foreground settings-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
summary={<>
{t("settings.runtimeConfig.advancedOptions")}
<ChevronDown aria-hidden className="h-3.5 w-3.5 shrink-0 group-open/advanced:rotate-180" />
</summary>
<ChevronDown aria-hidden className="h-3.5 w-3.5 shrink-0 transition-transform duration-200 group-data-[state=open]/disclosure:rotate-180 motion-reduce:transition-none" />
</>}
>
<div className="space-y-1">{children}</div>
</details>
</Disclosure>
);
}
File diff suppressed because it is too large. Load diff