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

@@ -3,7 +3,6 @@ import {
CalendarClock,
ChevronRight,
CircleAlert,
RefreshCcw,
} from "lucide-react";
import type { TFunction } from "i18next";
import { useTranslation } from "react-i18next";
@@ -15,6 +14,7 @@ import {
} from "@/components/settings/system/AutomationsSettings";
import type { AutomationAction } from "@/components/settings/system/AutomationsSettings";
import { Button } from "@/components/ui/button";
import { SkeletonStatus } from "@/components/settings/shared/SkeletonStatus";
import { formControlFocusClassName } from "@/components/ui/form-control";
import {
Popover,
@@ -112,12 +112,18 @@ export function SessionInfoPopoverView({ title, jobs, loading, loadFailed, now,
setActionKey(null);
}
};
const automationContent = loading ? (
<div className="mx-2 flex items-center gap-2 rounded-floating bg-muted/45 px-3 py-3 text-[12.5px] text-muted-foreground">
<RefreshCcw className="h-3.5 w-3.5 animate-spin" />
{t("thread.sessionInfo.loading")}
</div>
) : loadFailed ? (
const automationContent = loading && jobs.length === 0 ? (
<SkeletonStatus label={t("thread.sessionInfo.loading")} className="space-y-1 px-2">
{[0, 1, 2].map((index) => <div key={index} data-session-job-skeleton className="grid min-h-12 grid-cols-[0.375rem_minmax(0,1fr)_1rem] items-center gap-2.5 px-3 py-2">
<div className="h-1.5 w-1.5 rounded-full bg-muted-foreground/20" />
<div className="min-w-0">
<div className="flex h-5 items-center"><div className="h-3 w-2/3 rounded bg-muted-foreground/20" /></div>
<div className="flex h-4 items-center"><div className="h-2.5 w-1/2 rounded bg-muted-foreground/15" /></div>
</div>
<div className="h-4 w-4" />
</div>)}
</SkeletonStatus>
) : loadFailed && jobs.length === 0 ? (
<div className="mx-2 flex items-center gap-2 rounded-floating bg-destructive/10 px-3 py-3 text-[12.5px] text-destructive">
<CircleAlert className="h-3.5 w-3.5" />
{t("thread.sessionInfo.loadFailed")}
@@ -175,7 +181,7 @@ export function SessionInfoPopoverView({ title, jobs, loading, loadFailed, now,
{t("thread.sessionInfo.automations")}
</span>
<span className="rounded-full bg-muted/70 px-2 py-0.5 text-[11px] tabular-nums text-muted-foreground">
{t("thread.sessionInfo.count", { count: jobs.length })}
{loading && jobs.length === 0 ? "—" : t("thread.sessionInfo.count", { count: jobs.length })}
</span>
</div>
</div>
@@ -121,7 +121,7 @@ function WorkspaceDirectorySkeleton() {
useLayoutEffect(() => {
const viewport = viewportRef.current;
if (!viewport) return;
const measure = () => setRows(Math.max(1, Math.ceil(viewport.clientHeight / DIRECTORY_ROW_HEIGHT)));
const measure = () => setRows(Math.max(1, Math.floor(viewport.clientHeight / DIRECTORY_ROW_HEIGHT)));
measure();
const observer = new ResizeObserver(measure);
observer.observe(viewport);
@@ -129,7 +129,7 @@ function WorkspaceDirectorySkeleton() {
}, []);
const widths = ["64%", "78%", "52%", "70%", "60%", "74%"];
return (
<div ref={viewportRef} role="status" aria-label={t("workspace.picker.loading")} className="workspace-directory-loading h-full">
<div ref={viewportRef} role="status" aria-label={t("workspace.picker.loading")} className="workspace-directory-loading flex h-full flex-col justify-center">
<span className="sr-only">{t("workspace.picker.loading")}</span>
<div aria-hidden="true">
{Array.from({ length: rows }, (_, index) => (
@@ -636,7 +636,7 @@ export function WorkspaceProjectPicker({ isHero, disabled, scope, defaultScope,
<div className={cn("mr-[var(--picker-toolbar-inset)] flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden rounded-[var(--picker-field-radius)] bg-[#fcfcfc] dark:bg-muted", compact && showLocations && canBrowse && "hidden")}>
<div ref={attachColumns} data-workspace-columns className="sidebar-scrollbar flex flex-1 min-h-0 min-w-0 overflow-x-auto overscroll-x-contain">
{columns.map((column, columnIndex) => (!compact || columnIndex === currentColumnIndex) && <WorkspaceDirectoryColumn key={columnIndex} options={column.options} selectedPath={column.selectedPath} initialScrollTop={previewingPath ? 0 : currentVisit.scrollTops[columnIndex] ?? 0} visitRevision={history.revision} activeIndex={highlightActive && columnIndex === activeColumn ? activeOption : null}
id={`${optionsId}-${columnIndex}`} data-workspace-column={columnIndex} data-current-directory={columnIndex === currentColumnIndex ? "" : undefined} role="listbox" tabIndex={0} aria-activedescendant={highlightActive && columnIndex === activeColumn && column.options.length ? `${optionsId}-${columnIndex}-${activeOption}` : undefined} aria-label={column.path || t("thread.composer.workspace.projectAria")} aria-busy={columnIndex === currentColumnIndex && loading} style={{ width: `${compact ? 100 : 100 / columnCount}%` }} className="sidebar-scrollbar relative min-w-0 shrink-0 overflow-x-hidden overflow-y-auto px-2 outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/50"
id={`${optionsId}-${columnIndex}`} data-workspace-column={columnIndex} data-current-directory={columnIndex === currentColumnIndex ? "" : undefined} role="listbox" tabIndex={0} aria-activedescendant={highlightActive && columnIndex === activeColumn && column.options.length ? `${optionsId}-${columnIndex}-${activeOption}` : undefined} aria-label={column.path || t("thread.composer.workspace.projectAria")} aria-busy={columnIndex === currentColumnIndex && loading} style={{ width: `${compact ? 100 : 100 / columnCount}%` }} className="sidebar-scrollbar relative min-w-0 shrink-0 overflow-x-hidden overflow-y-auto px-2 outline-none [scrollbar-gutter:stable] focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/50"
onFocus={event => { if (event.target === event.currentTarget) { setActiveColumn(columnIndex); setActiveIndex(0); } }}
onKeyDown={event => {
if (event.target !== event.currentTarget || event.altKey || event.metaKey || event.ctrlKey || pickingFolder) return;