feat(webui): add catalog loading skeletons (#6092)

* feat(webui): add catalog loading skeletons

* feat(webui): add MCP tool loading skeleton

* fix(webui): make skill discovery skeletons visible

* refactor(webui): share skeleton status markup
This commit is contained in:
chengyongru authored and GitHub committed 2026-10-07 21:28:53 +08:00
1 parent 7cb396788c
commit f24969d282
25 files changed
+538 -99

No files matched your search

@@ -53,6 +53,8 @@ interface SettingsPageProps {
onToggleTheme: () => void;
onBackToChat: () => void;
skills: SkillSummary[];
skillsLoading: boolean;
skillsError: boolean;
onStartAutomationChat?: (
content: string,
images?: SendAttachment[],
@@ -75,6 +77,8 @@ export function SettingsPage({
onToggleTheme,
onBackToChat,
skills,
skillsLoading,
skillsError,
onStartAutomationChat,
titleOverrides,
sessions,
@@ -608,7 +612,7 @@ export function SettingsPage({
</div>
);
case "skills":
return <SkillsCatalogSettings skills={skills} />;
return <SkillsCatalogSettings skills={skills} loading={skillsLoading} error={skillsError} />;
case "runtime":
return (
<div className="settings-stack">
@@ -18,6 +18,8 @@ interface SettingsViewProps {
onModelNameChange: (modelName: string | null) => void;
onSettingsChange?: (payload: SettingsPayload) => void;
skills?: SkillSummary[];
skillsLoading?: boolean;
skillsError?: boolean;
onStartAutomationChat?: (
content: string,
images?: SendAttachment[],
@@ -46,6 +48,8 @@ export function SettingsView({
onModelNameChange,
onSettingsChange,
skills = [],
skillsLoading = false,
skillsError = false,
onStartAutomationChat,
titleOverrides,
sessions,
@@ -76,6 +80,8 @@ export function SettingsView({
onToggleTheme={onToggleTheme}
onBackToChat={onBackToChat}
skills={skills}
skillsLoading={skillsLoading}
skillsError={skillsError}
onStartAutomationChat={onStartAutomationChat}
titleOverrides={titleOverrides}
sessions={sessions}
@@ -31,14 +31,19 @@ import { Input } from "@/components/ui/input";
import { SegmentedControl } from "@/components/ui/segmented-control";
import { Sheet, SheetContent, SheetDescription, SheetTitle } from "@/components/ui/sheet";
import { SkillsMarketplace } from "@/components/settings/SkillsMarketplace";
import { CatalogSkeleton } from "@/components/settings/shared/CatalogSkeleton";
import { ToggleButton } from "@/components/settings/ToggleButton";
import { deleteSkill, fetchSkillDetail, updateSkillEnabled } from "@/lib/api";
import { notifySkillsChanged } from "@/lib/skill-events";
import { notifySkillsChanged, requestSkillsRefresh } from "@/lib/skill-events";
import type { SkillDetail, SkillSummary } from "@/lib/types";
import { cn } from "@/lib/utils";
import { useClient } from "@/providers/ClientProvider";
export function SkillsCatalogSettings({ skills }: { skills: SkillSummary[] }) {
export function SkillsCatalogSettings({ skills, loading = false, error = false }: {
skills: SkillSummary[];
loading?: boolean;
error?: boolean;
}) {
const { t } = useTranslation();
const [selectedSkill, setSelectedSkill] = useState<SkillSummary | null>(null);
const [view, setView] = useState<"installed" | "discover">("installed");
@@ -140,14 +145,23 @@ export function SkillsCatalogSettings({ skills }: { skills: SkillSummary[] }) {
value,
label: (
<>
{label} <span className="ml-0.5 tabular-nums opacity-65">{count}</span>
{label} <span className="ml-0.5 tabular-nums opacity-65">{loading || error ? "—" : count}</span>
</>
),
}))}
onChange={setInstalledFilter}
/>
</div>
{groupedSkills.length ? (
{loading ? (
<CatalogSkeleton label={t("settings.skills.loading")} layout="skills" />
) : error ? (
<div className="space-y-3 px-4 py-8 text-center text-sm">
<p role="alert" className="text-destructive">{t("settings.skills.catalogLoadFailed")}</p>
<Button type="button" variant="outline" size="sm" onClick={requestSkillsRefresh}>
{t("settings.skills.retry")}
</Button>
</div>
) : groupedSkills.length ? (
<div className="space-y-5 px-3 pb-3 pt-2 sm:px-4">
{groupedSkills.map((group) => (
<section key={group.key} className="space-y-1">
@@ -173,9 +187,7 @@ export function SkillsCatalogSettings({ skills }: { skills: SkillSummary[] }) {
</div>
) : (
<div className="px-3 py-12 text-center text-sm text-muted-foreground">
{t("settings.skills.noMatching", {
defaultValue: "No matching skills.",
})}
{t(skills.length ? "settings.skills.noMatching" : "settings.skills.empty")}
</div>
)}
</section>
@@ -9,6 +9,7 @@ import {
} from "lucide-react";
import { useTranslation } from "react-i18next";
import { SkeletonStatus } from "@/components/settings/shared/SkeletonStatus";
import {
AlertDialog,
AlertDialogAction,
@@ -125,9 +126,9 @@ export function SkillsMarketplace({
}
let cancelled = false;
setLoading(true);
setError("");
const timer = window.setTimeout(() => {
setLoading(true);
setError("");
searchMarketplaceSkills(getToken(), normalized)
.then((payload) => {
if (cancelled) return;
@@ -218,7 +219,7 @@ export function SkillsMarketplace({
defaultValue: "Searching",
})}
>
<Loader2 className="h-4 w-4 animate-spin" aria-hidden />
<Loader2 className="h-4 w-4 animate-spin motion-reduce:animate-none" aria-hidden />
</span>
) : null}
</div>
@@ -252,7 +253,7 @@ export function SkillsMarketplace({
) : null}
</div>
{trendingLoading ? (
<TrendingSkeleton />
<MarketplaceSkeleton ranked />
) : visibleTrending.length ? (
<MarketplaceSkillGroups
skills={visibleTrending}
@@ -279,14 +280,18 @@ export function SkillsMarketplace({
</div>
) : (
<div className="overflow-hidden rounded-panel bg-settings-surface">
<MarketplaceSkillGroups
skills={visibleResults}
installedNames={installedNames}
installing={installing}
trends={trends}
grouped={provider === "all"}
onSelect={setSelected}
/>
{loading && !visibleResults.length ? (
<MarketplaceSkeleton />
) : (
<MarketplaceSkillGroups
skills={visibleResults}
installedNames={installedNames}
installing={installing}
trends={trends}
grouped={provider === "all"}
onSelect={setSelected}
/>
)}
</div>
)}
@@ -566,7 +571,7 @@ function MarketplaceSkillRow({
}
>
{isInstalling ? (
<Loader2 className="h-4 w-4 animate-spin" aria-hidden />
<Loader2 className="h-4 w-4 animate-spin motion-reduce:animate-none" aria-hidden />
) : installed ? (
<Check className="h-4 w-4" aria-hidden />
) : (
@@ -669,19 +674,27 @@ function TrendSparkline({ values }: { values?: number[] }) {
);
}
function TrendingSkeleton() {
function MarketplaceSkeleton({ ranked = false }: { ranked?: boolean }) {
const { t } = useTranslation();
return (
<div className="space-y-1 px-5 pb-3" aria-hidden>
<SkeletonStatus
label={t("settings.skills.loading")}
className="space-y-1 px-3 pb-3 sm:px-4"
>
{Array.from({ length: 5 }, (_, index) => (
<div key={index} className="flex items-center gap-3 py-4">
<div className="h-3 w-5 animate-pulse rounded bg-muted" />
<div className="flex-1 space-y-2">
<div className="h-3.5 w-48 max-w-[55%] animate-pulse rounded bg-muted" />
<div className="h-3 w-32 max-w-[40%] animate-pulse rounded bg-muted/70" />
<div key={index} className="flex min-w-0 items-center gap-2 px-1 py-3.5 sm:gap-3 sm:px-2">
{ranked ? <div className="h-3 w-6 shrink-0 rounded bg-muted-foreground/20 sm:w-7" /> : null}
<div className="min-w-0 flex-1">
<div className="flex h-7 items-center">
<div className="h-3.5 w-48 max-w-[70%] rounded bg-muted-foreground/20" />
</div>
<div className="mt-1 flex h-5 items-center">
<div className="h-3 w-32 max-w-[55%] rounded bg-muted-foreground/20 opacity-60" />
</div>
</div>
<div className="h-8 w-[82px] animate-pulse rounded-full bg-muted sm:w-[92px]" />
<div className="h-9 w-9 shrink-0 rounded-full bg-muted-foreground/20" />
</div>
))}
</div>
</SkeletonStatus>
);
}
@@ -0,0 +1,40 @@
import { SkeletonStatus } from "@/components/settings/shared/SkeletonStatus";
import { cn } from "@/lib/utils";
export function CatalogSkeleton({ label, layout }: {
label: string;
layout: "apps" | "channels" | "skills";
}) {
const channels = layout === "channels";
const skills = layout === "skills";
const block = "rounded bg-muted-foreground/20";
return (
<SkeletonStatus
label={label}
className={cn(
skills ? "space-y-1 px-3 pb-3 pt-2 sm:px-4" : "grid grid-cols-1 gap-y-1",
layout === "apps" && "gap-x-10 py-3 xl:grid-cols-2",
channels && "gap-x-4 min-[640px]:grid-cols-2",
)}
>
{Array.from({ length: 6 }, (_, index) => (
<div key={index} className={cn(
"flex min-w-0 items-center gap-3",
channels ? "settings-list-row py-2.5" : skills ? "px-2 py-3" : "px-3 py-3",
)}>
<div className={cn(block, "shrink-0", skills
? "h-1.5 w-1.5 rounded-full" : "h-9 w-9 rounded-[10px]")} />
<div className="min-w-0 flex-1 py-1">
<div className={cn(block, "h-3.5", index % 2 ? "w-1/2" : "w-2/3")} />
{!channels ? <div className={cn(block, "mt-2 h-3 w-4/5 opacity-60")} /> : null}
</div>
<div className={cn("flex shrink-0 items-center justify-center", channels && "w-16")}>
<div className={cn(block, channels ? "h-[22px] w-[38px] rounded-full"
: skills ? "hidden h-3 w-20 sm:block" : "h-7 w-7 rounded-full")} />
</div>
</div>
))}
</SkeletonStatus>
);
}
@@ -0,0 +1,18 @@
import type { ReactNode } from "react";
import { cn } from "@/lib/utils";
export function SkeletonStatus({ label, className, children }: {
label: string;
className: string;
children: ReactNode;
}) {
return (
<div role="status" aria-label={label} aria-busy="true">
<span className="sr-only">{label}</span>
<div aria-hidden className={cn("animate-pulse motion-reduce:animate-none", className)}>
{children}
</div>
</div>
);
}
@@ -31,6 +31,8 @@ import {
} from "lucide-react";
import { useTranslation } from "react-i18next";
import { CatalogSkeleton } from "@/components/settings/shared/CatalogSkeleton";
import {
DismissibleStatusMessage,
RestartRequiredNotice,
@@ -218,10 +220,8 @@ export function AppsCatalogSettings({
const focusedApp = cliFocusName
? (cliApps?.apps ?? []).find((app) => app.name === cliFocusName && app.installed)
: null;
const loading =
(cliAppsLoading || mcpPresetsLoading) &&
!cliApps &&
!mcpPresets;
const loading = (mcpPresetsLoading && !mcpPresets)
|| ((filter !== "mcp" || Boolean(normalizedQuery)) && cliAppsLoading && !cliApps);
const cliAppCount = cliApps?.apps.length ?? 0;
const emptyTitle = normalizedQuery
? tx("settings.apps.empty", "No tools match your search.")
@@ -305,15 +305,10 @@ export function AppsCatalogSettings({
: tx("settings.apps.featured", "Tools")}
</SettingsSectionTitle>
<span className="text-[12px] tabular-nums text-muted-foreground">
{items.length}
{loading ? "—" : items.length}
</span>
</div>
{loading ? (
<div className="flex h-36 items-center justify-center text-sm text-muted-foreground">
<Loader2 className="mr-2 h-4 w-4 animate-spin" aria-hidden />
{tx("settings.apps.loading", "Loading apps…")}
</div>
) : items.length ? (
{items.length ? (
<div className="grid grid-cols-1 gap-x-10 gap-y-1 py-3 xl:grid-cols-2">
{items.map((item) =>
item.kind === "cli" ? (
@@ -351,7 +346,10 @@ export function AppsCatalogSettings({
),
)}
</div>
) : (
) : null}
{loading ? (
<CatalogSkeleton label={tx("settings.apps.loading", "Loading apps…")} layout="apps" />
) : !items.length && !statusIsError ? (
<div className="px-3 py-12 text-center text-sm text-muted-foreground">
<p>{emptyTitle}</p>
{normalizedQuery ? (
@@ -383,7 +381,7 @@ export function AppsCatalogSettings({
</p>
)}
</div>
)}
) : null}
</section>
{filter === "mcp" ? (
@@ -1,10 +1,11 @@
import { useCallback, useLayoutEffect, useRef, useState } from "react";
import { Loader2, Search, X } from "lucide-react";
import { Search, X } from "lucide-react";
import { useTranslation } from "react-i18next";
import { Input } from "@/components/ui/input";
import { SegmentedControl } from "@/components/ui/segmented-control";
import { SETTINGS_SEARCH_INPUT_CLASS } from "@/components/settings/shared/SettingsControls";
import { CatalogSkeleton } from "@/components/settings/shared/CatalogSkeleton";
import type { ChannelFeatureAction } from "@/channel-plugins/types";
import { ChannelCatalogRow } from "@/components/settings/channels/ChannelCatalogRow";
import { localizedChannelDisplayName } from "@/components/settings/channels/ChannelIdentity";
@@ -120,10 +121,9 @@ export function ChannelsSettings({
onRestart={onRestart} isRestarting={isRestarting} />
) : null}
{loading && !nanobotFeatures ? (
<div className="flex h-36 items-center justify-center text-sm text-muted-foreground">
<Loader2 className="mr-2 h-4 w-4 animate-spin" aria-hidden />
{t("settings.channels.loading")}
</div>
<SettingsGroup>
<CatalogSkeleton label={t("settings.channels.loading")} layout="channels" />
</SettingsGroup>
) : visibleChannels.length ? (
channelGroups.map((group) => (
<section
@@ -151,11 +151,11 @@ export function ChannelsSettings({
</SettingsGroup>
</section>
))
) : (
) : !error ? (
<div className="px-3 py-12 text-center text-sm text-muted-foreground">
{t(channels.length ? "settings.channels.noResults" : "settings.channels.empty")}
</div>
)}
) : null}
<Dialog open={Boolean(selectedChannel)} onOpenChange={(open) => { if (!open) requestChannelClose(); }}>
<DialogContent ref={dialogRef} showCloseButton={false} aria-describedby={undefined} className="max-h-[85dvh] w-[min(calc(100vw-2rem),40rem)] max-w-none overflow-hidden p-0 outline-none"
onOpenAutoFocus={(event) => {
@@ -5,6 +5,7 @@ import { useEffect, useMemo, useRef, useState, type ReactNode } from "react";
import { Check, ExternalLink, Loader2, RotateCcw, Search, Server, Trash2, X } from "lucide-react";
import { useTranslation } from "react-i18next";
import { SkeletonStatus } from "@/components/settings/shared/SkeletonStatus";
import { Button } from "@/components/ui/button";
import {
Dialog,
@@ -363,6 +364,29 @@ function ToolsPanel({
}) {
const { t } = useTranslation();
const tx = (key: string, fallback: string) => t(key, { defaultValue: fallback });
if (!toolNames.length && testBusy) {
return (
<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>
</div>
<div className="overflow-hidden rounded-floating border border-border/55">
{Array.from({ length: 6 }, (_, index) => (
<div key={index} className="flex min-h-11 items-center gap-3 border-b border-border/45 px-3.5 py-2.5 last:border-b-0">
<div className="h-5 w-5 shrink-0 rounded-compact bg-muted-foreground/20" />
<div className={cn("h-3.5 max-w-[70%] rounded bg-muted-foreground/20", index % 2 ? "w-40" : "w-52")} />
</div>
))}
</div>
</SkeletonStatus>
);
}
if (!toolNames.length) {
return (
<div
@@ -373,39 +397,31 @@ function ToolsPanel({
>
<div className="flex min-w-0 items-center gap-3">
<div className="grid h-9 w-9 shrink-0 place-items-center rounded-full bg-background text-muted-foreground">
{testBusy ? (
<Loader2 className="h-4 w-4 animate-spin motion-reduce:animate-none" aria-hidden />
) : (
<AppActionsIcon className="h-4 w-4" aria-hidden />
)}
<AppActionsIcon className="h-4 w-4" aria-hidden />
</div>
<p
role={preset.error ? "alert" : undefined}
className={cn("min-w-0 text-[14px] font-medium", preset.error ? "text-destructive" : "text-foreground")}
>
{testBusy
? tx("common.loading", "Loading…")
: preset.error || tx("settings.mcp.noToolsAvailable", "No tools available")}
{preset.error || tx("settings.mcp.noToolsAvailable", "No tools available")}
</p>
</div>
{!testBusy ? (
<Button
type="button"
size="sm"
variant="outline"
onClick={configuredInstalled ? onTest : onOpenConnection}
className="h-9 shrink-0 rounded-full px-4 text-[13px] font-semibold"
>
{configuredInstalled ? (
<RotateCcw className="mr-1.5 h-3.5 w-3.5" aria-hidden />
) : (
<Server className="mr-1.5 h-3.5 w-3.5" aria-hidden />
)}
{configuredInstalled
? tx("settings.mcp.reloadTools", "Reload tools")
: tx("settings.mcp.setup", "Connect")}
</Button>
) : null}
<Button
type="button"
size="sm"
variant="outline"
onClick={configuredInstalled ? onTest : onOpenConnection}
className="h-9 shrink-0 rounded-full px-4 text-[13px] font-semibold"
>
{configuredInstalled ? (
<RotateCcw className="mr-1.5 h-3.5 w-3.5" aria-hidden />
) : (
<Server className="mr-1.5 h-3.5 w-3.5" aria-hidden />
)}
{configuredInstalled
? tx("settings.mcp.reloadTools", "Reload tools")
: tx("settings.mcp.setup", "Connect")}
</Button>
</div>
);
}