fix(webui): show route-aligned skeletons from first paint (#6303)

This commit is contained in:
chengyongru authored and GitHub committed 2026-10-19 15:57:32 +08:00
1 parent af68da3280
commit 5d886fbb20
43 files changed
+1592 -213

No files matched your search

@@ -348,7 +348,8 @@ export function AppsCatalogSettings({
</div>
) : null}
{loading ? (
<CatalogSkeleton label={tx("settings.apps.loading", "Loading apps…")} layout="apps" />
<CatalogSkeleton label={tx("settings.apps.loading", "Loading apps…")} layout="apps"
appActionLabel={filter === "cli" ? undefined : tx("settings.mcp.manage", "Manage")} />
) : !items.length && !statusIsError ? (
<div className="px-3 py-12 text-center text-sm text-muted-foreground">
<p>{emptyTitle}</p>
@@ -2,6 +2,7 @@ import { CircleAlert, Loader2, X } from "lucide-react";
import { useId, useLayoutEffect, useMemo, useRef, useState, type ReactNode } from "react";
import type { AutomationRunRecord } from "@/components/settings/system/AutomationRunDialogView";
import { SkeletonStatus } from "@/components/settings/shared/SkeletonStatus";
import { Button } from "@/components/ui/button";
import { formControlFocusClassName } from "@/components/ui/form-control";
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
@@ -40,6 +41,7 @@ export interface AutomationCalendarRunProps {
interface AutomationCalendarProps {
jobs: SessionAutomationJob[];
loadingLabel?: string;
month: Date;
locale: string;
copy: CalendarCopy;
@@ -226,7 +228,7 @@ function CalendarOverflowEntries({ entries, dayLabel, locale, copy, onInspect }:
);
}
export function AutomationCalendar({ jobs, month, locale, copy, onInspect, renderRunDialog }: AutomationCalendarProps) {
export function AutomationCalendar({ jobs, loadingLabel, month, locale, copy, onInspect, renderRunDialog }: AutomationCalendarProps) {
const calendarRef = useRef<HTMLElement | null>(null);
const runTrigger = useRef<HTMLElement | null>(null);
const [selectedRun, setSelectedRun] = useState<{ job: SessionAutomationJob; run: AutomationRunRecord } | null>(null);
@@ -273,8 +275,7 @@ export function AutomationCalendar({ jobs, month, locale, copy, onInspect, rende
return () => observer.disconnect();
}, []);
return (
<section ref={calendarRef} tabIndex={-1} className="automation-calendar overflow-hidden bg-[hsl(var(--settings-surface))]">
const content = <>
<div className="automation-calendar-header bg-foreground/[0.025]">
{wideCalendar ? <div className="automation-calendar-weekdays" aria-hidden>
{weekdayLabels.map((label) => <div key={label}>{label}</div>)}
@@ -307,6 +308,7 @@ export function AutomationCalendar({ jobs, month, locale, copy, onInspect, rende
</time>
</div>
<div className="space-y-0.5 px-1 pb-1">
{loadingLabel ? <div className="flex h-7 items-center px-2"><div className="h-2.5 w-3/4 rounded bg-muted-foreground/15" /></div> : null}
{entries.slice(0, 3).map((entry) => (
<CalendarEntryRow
key={entry.id}
@@ -333,7 +335,15 @@ export function AutomationCalendar({ jobs, month, locale, copy, onInspect, rende
</div> : null}
{!wideCalendar ? <div className="automation-calendar-agenda px-3 py-2 sm:px-4">
{visibleEntries.length ? (
{loadingLabel ? <div>
{[0, 1, 2].map((index) => <div key={index} data-agenda-skeleton-row className="grid grid-cols-[5.25rem_minmax(0,1fr)] gap-2 py-2.5">
<div className="pt-2"><div className="mt-1 h-2.5 w-16 rounded bg-muted-foreground/15" /></div>
<div className="px-2 py-2">
<div className="flex h-4 items-center"><div className="h-3 w-2/3 rounded bg-muted-foreground/20" /></div>
<div className="mt-1 flex h-4 items-center"><div className="h-2.5 w-1/2 rounded bg-muted-foreground/15" /></div>
</div>
</div>)}
</div> : visibleEntries.length ? (
<ol>
{days.filter((day) => entriesByDay.has(dateKey(day))).map((day) => (
<li key={dateKey(day)} className="grid grid-cols-[5.25rem_minmax(0,1fr)] gap-2 py-2.5">
@@ -357,7 +367,11 @@ export function AutomationCalendar({ jobs, month, locale, copy, onInspect, rende
<div className="flex min-h-28 items-center justify-center text-[13px] text-muted-foreground">{copy.noEntries}</div>
)}
</div> : null}
</>;
return (
<section ref={calendarRef} tabIndex={-1} className="automation-calendar overflow-hidden bg-[hsl(var(--settings-surface))]">
{loadingLabel ? <SkeletonStatus label={loadingLabel} className="">{content}</SkeletonStatus> : content}
{selectedRun ? renderRunDialog({
job: selectedRun.job, run: selectedRun.run, locale, open: runOpen,
onOpenChange: setRunOpen,
@@ -15,6 +15,7 @@ import { useTranslation } from "react-i18next";
import { channelTranslator } from "@/channel-plugins/i18n";
import { channelUiOwner, channelUiPresentation } from "@/channel-plugins/registry";
import { AutomationCalendar } from "@/components/settings/system/AutomationCalendar";
import { SkeletonStatus } from "@/components/settings/shared/SkeletonStatus";
import { AutomationRunDialog } from "@/components/settings/system/AutomationRunDialog";
import { AutomationChatBinding, type AutomationChatNames, type ChangeAutomationChat } from "@/components/settings/system/AutomationChatBinding";
import { AutomationRunAtPicker, parseAutomationRunAt } from "@/components/settings/system/AutomationRunAtPicker";
@@ -283,7 +284,7 @@ export function AutomationsSettings({
{new Intl.DateTimeFormat(locale, { month: "long", year: "numeric" }).format(month)}
</h2>
) : null}
{filters ? <div className="automation-panel-filters min-w-0">{filters}</div> : null}
{filters || (loading && !payload) ? <div className="automation-panel-filters min-w-0">{filters ?? <div className="h-8 w-8" aria-hidden />}</div> : null}
{view === "calendar" ? (
<div className="automation-calendar-navigation flex shrink-0 items-center gap-1">
<Button type="button" variant="ghost" size="sm" className="h-8 rounded-full bg-background/60 px-3 text-[12px] text-foreground"
@@ -303,11 +304,13 @@ export function AutomationsSettings({
</div>
) : null}
</div>
{loading && !payload ? (
<div role="status" className="flex h-44 items-center justify-center rounded-panel border border-border/70 bg-[hsl(var(--settings-surface))] text-[13px] text-muted-foreground">
<Loader2 className="mr-2 h-4 w-4 animate-spin" aria-hidden />
{tx("settings.automations.loading", "Loading automations...")}
</div>
{view === "tasks" && loading && !payload ? (
<SkeletonStatus label={tx("settings.automations.loading", "Loading automations...")} className="space-y-1 p-1">
{[0, 1, 2].map((index) => <div key={index} data-automation-task-skeleton className="px-3 py-3">
<div className="flex h-[21px] items-center"><div className="h-3.5 w-2/5 rounded bg-muted-foreground/20" /></div>
<div className="mt-1 flex h-5 items-center"><div className="h-3 w-1/4 rounded bg-muted-foreground/15" /></div>
</div>)}
</SkeletonStatus>
) : view === "tasks" ? (
<section className="p-1" aria-label={tx("settings.automations.views.tasks", "Tasks")}>
{filtered.length ? (
@@ -352,6 +355,7 @@ export function AutomationsSettings({
<AutomationCalendar
renderRunDialog={(props) => <AutomationRunDialog token={token} {...props} />}
jobs={filtered}
loadingLabel={loading && !payload ? tx("settings.automations.loading", "Loading automations...") : undefined}
month={month}
locale={locale}
copy={{
@@ -369,10 +369,17 @@ function ToolsPanel({
<SkeletonStatus label={tx("settings.mcp.loadingTools", "Loading tools…")} className="space-y-4">
<div className="flex flex-col gap-3 sm:flex-row sm:items-center">
<div className="h-10 min-w-0 rounded-full bg-muted-foreground/20 sm:flex-1" />
<div className="flex h-8 items-center justify-between gap-4 sm:justify-end">
<div className="mr-auto h-3 w-20 rounded bg-muted-foreground/20 sm:mr-1" />
<div className="h-3 w-6 rounded bg-muted-foreground/20" />
<div className="h-3 w-9 rounded bg-muted-foreground/20" />
<div className="flex items-center justify-between gap-2 sm:justify-end">
<div className="relative mr-auto text-[13px] tabular-nums sm:mr-1">
<span className="invisible">{tx("settings.mcp.selectedCount", "{{count}} selected").replace("{{count}}", String(selectedToolCount))}</span>
<div className="absolute inset-x-0 top-1/2 h-3 -translate-y-1/2 rounded bg-muted-foreground/20" />
</div>
{[tx("settings.mcp.allTools", "All"), tx("settings.mcp.noTools", "None")].map((label) => (
<div key={label} className="relative flex h-8 items-center px-2.5 text-[12.5px] font-semibold">
<span className="invisible">{label}</span>
<div className="absolute inset-x-2.5 top-1/2 h-3 -translate-y-1/2 rounded bg-muted-foreground/20" />
</div>
))}
</div>
</div>
<div className="overflow-hidden rounded-floating border border-border/55">
@@ -30,7 +30,7 @@ export function useSystemSettingsState() {
const [cliAppsLoading, setCliAppsLoading] = useState(true);
const [nanobotFeaturesLoading, setNanobotFeaturesLoading] = useState(true);
const [mcpPresetsLoading, setMcpPresetsLoading] = useState(true);
const [automationsLoading, setAutomationsLoading] = useState(false);
const [automationsLoading, setAutomationsLoading] = useState(true);
const [cliAppsAction, setCliAppsAction] = useState<string | null>(null);
const [nanobotFeatureAction, setNanobotFeatureAction] = useState<string | null>(null);
const nanobotFeatureActionRef = useRef<string | null>(null);