Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(views): stop page-switch layout jumps and prefetch page data (MUL-8337) (#9643)
Jiayuan Zhang48df97775559
diff --git a/apps/web/app/[workspaceSlug]/(dashboard)/loading.tsx b/apps/web/app/[workspaceSlug]/(dashboard)/loading.tsxdeleted file mode 100644index 68d1b00e20..0000000000--- a/apps/web/app/[workspaceSlug]/(dashboard)/loading.tsx+++ /dev/null@@ -1,20 +0,0 @@-import { Skeleton } from "@multica/ui/components/ui/skeleton";--// Rendered by Next.js as the Suspense fallback during route transitions-// inside the (dashboard) segment. Scoped to this segment only — auth /-// landing keep their own full-screen fallbacks.-export default function DashboardLoading() {- return (- <div className="flex h-svh w-full flex-col">- <div className="flex h-12 shrink-0 items-center gap-3 border-b px-4">- <Skeleton className="h-5 w-5 rounded-md" />- <Skeleton className="h-4 w-32" />- </div>- <div className="flex-1 space-y-2 p-4">- {Array.from({ length: 8 }).map((_, i) => (- <Skeleton key={i} className="h-9 w-full" />- ))}- </div>- </div>- );-}diff --git a/packages/ui/components/ui/skeleton.tsx b/packages/ui/components/ui/skeleton.tsxindex da90c642c9..c5d1778625 100644--- a/packages/ui/components/ui/skeleton.tsx+++ b/packages/ui/components/ui/skeleton.tsx@@ -4,7 +4,7 @@ function Skeleton({ className, ...props }: React.ComponentProps<"div">) {return (<divdata-slot="skeleton"- className={cn("animate-pulse rounded-md bg-muted", className)}+ className={cn("animate-skeleton rounded-md bg-muted", className)}{...props}/>)diff --git a/packages/ui/styles/base.css b/packages/ui/styles/base.cssindex 50ddc7faab..940a2b7f02 100644--- a/packages/ui/styles/base.css+++ b/packages/ui/styles/base.css@@ -158,6 +158,25 @@animation: nav-progress-sweep 1.4s cubic-bezier(0.4, 0, 0.2, 1) infinite;}+/* Skeleton: hidden (space still reserved) for the first 200ms, then pulses.+ * Data that lands inside that window — a warm cache, a prefetched route, a+ * fast API — swaps straight from nothing to content instead of flashing a+ * placeholder for a frame or two. Visibility, not opacity, so the hold never+ * fights the pulse over the same property. */+@keyframes skeleton-hold {+ from, to { visibility: hidden; }+}++@keyframes skeleton-pulse {+ 50% { opacity: 0.5; }+}++.animate-skeleton {+ animation:+ skeleton-hold 200ms step-end,+ skeleton-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;+}+/* Border beam: a brand-tinted highlight sweeps continuously around the* host's rounded border, drawing the eye to a CTA that would otherwise blend* into the chrome (e.g. the "switch to agent" affordance in manual create).@@ -302,6 +321,10 @@ html[data-dnd-dragging="true"] * {animation: none;}+ .animate-skeleton {+ animation: skeleton-hold 200ms step-end;+ }+.shimmer-text-window {display: none;}diff --git a/packages/views/agents/components/agents-page.test.tsx b/packages/views/agents/components/agents-page.test.tsxindex d4b7ecd772..af3b49e1e9 100644--- a/packages/views/agents/components/agents-page.test.tsx+++ b/packages/views/agents/components/agents-page.test.tsx@@ -328,6 +328,19 @@ describe("AgentsPage listReady gate", () => {expect(screen.getAllByTestId("skeleton").length).toBeGreaterThan(0);});+ it("keeps the toolbar above the skeleton while the agent list loads", () => {+ // A toolbar that only mounts once rows land pushes the list down by its+ // height mid-navigation (MUL-8337).+ mocks.agents = [];+ mocks.agentsLoading = true;++ renderPage();++ expect(screen.getByTestId("agent-list-toolbar")).toBeInTheDocument();+ expect(screen.getAllByTestId("skeleton").length).toBeGreaterThan(0);+ expect(screen.queryByText("No agents yet")).not.toBeInTheDocument();+ });+it("shows the empty state without blocking on auxiliary queries when there are no agents", () => {mocks.agents = [];// All auxiliary queries pending — the empty state must not wait on them.diff --git a/packages/views/agents/components/agents-page.tsx b/packages/views/agents/components/agents-page.tsxindex f12305f503..625bf82b30 100644--- a/packages/views/agents/components/agents-page.tsx+++ b/packages/views/agents/components/agents-page.tsx@@ -1037,16 +1037,14 @@ export function AgentsPage(_props: AgentsPageProps = {}) {onCreate={() => navigation.push(paths.newAgent())}/>- {isLoading || (!showEmpty && !listReady) ? (- <div className="flex-1 overflow-y-auto @container">- <LoadingSkeleton />- </div>- ) : showEmpty ? (+ {showEmpty ? (<div className="flex flex-1 items-center justify-center"><EmptyState onCreate={() => navigation.push(paths.newAgent())} /></div>) : (<>+ {/* Mounted through loading so the rows don't drop by a toolbar's+ height when the list lands. */}<AgentListToolbarscope={scope}onScopeChange={setScope}@@ -1066,6 +1064,11 @@ export function AgentsPage(_props: AgentsPageProps = {}) {members={members}visibleCount={rows.length}/>+ {isLoading || !listReady ? (+ <div className="flex-1 overflow-y-auto @container">+ <LoadingSkeleton />+ </div>+ ) : (<divref={listScrollRef}className="min-h-0 flex-1 overflow-auto @container"@@ -1184,6 +1187,7 @@ export function AgentsPage(_props: AgentsPageProps = {}) {</ListGridBody></ListGrid></div>+ )}</>)}diff --git a/packages/views/autopilots/components/autopilots-page.tsx b/packages/views/autopilots/components/autopilots-page.tsxindex bd173ef849..a0ec289c6a 100644--- a/packages/views/autopilots/components/autopilots-page.tsx+++ b/packages/views/autopilots/components/autopilots-page.tsx@@ -854,10 +854,6 @@ export function AutopilotsPage() {</Button>}/>- ) : isLoading ? (- <div className="flex-1 overflow-y-auto @container">- <LoadingSkeleton />- </div>) : showEmpty ? (<div className="flex flex-col items-center px-5 py-16"><Zap className="mb-3 h-10 w-10 text-faint-foreground" />@@ -902,6 +898,8 @@ export function AutopilotsPage() {</div>) : (<>+ {/* Mounted through loading so the rows don't drop by a toolbar's+ height when the list lands. */}<AutopilotListToolbarscope={scope}onScopeChange={setScope}@@ -918,6 +916,11 @@ export function AutopilotsPage() {allRows={scopeRows}visibleCount={rows.length}/>+ {isLoading ? (+ <div className="flex-1 overflow-y-auto @container">+ <LoadingSkeleton />+ </div>+ ) : (<divref={listScrollRef}className="min-h-0 flex-1 overflow-auto @container"@@ -1014,6 +1017,7 @@ export function AutopilotsPage() {</ListGridBody></ListGrid></div>+ )}</>)}diff --git a/packages/views/inbox/components/inbox-page.tsx b/packages/views/inbox/components/inbox-page.tsxindex 17efcde1a7..34af52ee50 100644--- a/packages/views/inbox/components/inbox-page.tsx+++ b/packages/views/inbox/components/inbox-page.tsx@@ -732,6 +732,30 @@ export function InboxPage() {</>);+ // Same header and row boxes as `InboxListItem` (32px avatar, body + caption+ // lines), so the list doesn't shift when the items land.+ const loadingListPanel = (+ <>+ {listHeader}+ {isArchivedView && archivedBackRow}+ <div className="flex-1 min-h-0 overflow-hidden px-2 py-1">+ {Array.from({ length: 6 }).map((_, i) => (+ <div key={i} className="flex items-center gap-3 px-2 py-2.5">+ <Skeleton className="size-8 shrink-0 rounded-full" />+ <div className="min-w-0 flex-1">+ <div className="flex h-5 items-center">+ <Skeleton className="h-3.5 w-3/4" />+ </div>+ <div className="mt-0.5 flex h-4 items-center">+ <Skeleton className="h-3 w-1/2" />+ </div>+ </div>+ </div>+ ))}+ </div>+ </>+ );+// Compact widths only: the detail fills the screen there, so the trip back to// the list has to live inside it. On desktop the list is still on screen in// the left panel and needs no back control at all.@@ -924,24 +948,7 @@ export function InboxPage() {if (isCompact) {if (viewLoading) {- return (- <div className="flex flex-1 flex-col min-h-0">- <div className={cn("flex h-12 shrink-0 items-center border-b", PAGE_GUTTER)}>- <Skeleton className="h-5 w-16" />- </div>- <div className="flex-1 min-h-0 overflow-y-auto space-y-1 p-2">- {Array.from({ length: 5 }).map((_, i) => (- <div key={i} className="flex items-center gap-3 px-2 py-2.5">- <Skeleton className="h-7 w-7 shrink-0 rounded-full" />- <div className="flex-1 space-y-2">- <Skeleton className="h-4 w-3/4" />- <Skeleton className="h-3 w-1/2" />- </div>- </div>- ))}- </div>- </div>- );+ return <div className="flex flex-1 flex-col min-h-0">{loadingListPanel}</div>;}// Compact: show detail full-screen when an item is selected. The two kinds@@ -987,30 +994,13 @@ export function InboxPage() {maxSize={INBOX_LIST_MAX_SIZE}groupResizeBehavior="preserve-pixel-size">- <div className="flex flex-col border-r h-full">- <div className={cn("flex h-12 shrink-0 items-center border-b", PAGE_GUTTER)}>- <Skeleton className="h-5 w-16" />- </div>- <div className="flex-1 min-h-0 overflow-y-auto space-y-1 p-2">- {Array.from({ length: 5 }).map((_, i) => (- <div key={i} className="flex items-center gap-3 px-2 py-2.5">- <Skeleton className="h-7 w-7 shrink-0 rounded-full" />- <div className="flex-1 space-y-2">- <Skeleton className="h-4 w-3/4" />- <Skeleton className="h-3 w-1/2" />- </div>- </div>- ))}- </div>- </div>+ <div className="flex flex-col border-r h-full">{loadingListPanel}</div></ResizablePanel><ResizableHandle />- <ResizablePanel id="detail" minSize="40%">- <div className="p-6">- <Skeleton className="h-6 w-48" />- <Skeleton className="mt-4 h-4 w-32" />- </div>- </ResizablePanel>+ {/* Left blank: once loaded this pane is either a centred prompt or an+ issue detail with its own skeleton, so any placeholder here would+ be a third shape. */}+ <ResizablePanel id="detail" minSize="40%" /></ResizablePanelGroup>);}diff --git a/packages/views/issues/surface/issue-surface.tsx b/packages/views/issues/surface/issue-surface.tsxindex f03a0cad27..a9a1307c3e 100644--- a/packages/views/issues/surface/issue-surface.tsx+++ b/packages/views/issues/surface/issue-surface.tsx@@ -31,6 +31,7 @@ import {} from "@multica/core/issues/surface/scope";import type { Issue } from "@multica/core/types";import { BoardView } from "../components/board-view";+import { BOARD_COL_WIDTH } from "../components/board-column";import { BatchActionToolbar } from "../components/batch-action-toolbar";import { GanttView } from "../components/gantt-view";import { IssuesHeader } from "../components/issues-header";@@ -461,25 +462,63 @@ function FilteredEmptyState() {// Table is deliberately absent. It owns its own placeholders, drawn as rows// inside its real grid so the header, column widths and toolbar are up before// any data is — a surface-level stand-in would replace all of that with bars-// of a different shape and then jump when the rows arrived.+// of a different shape and then jump when the rows arrived. For the same+// reason list and board are drawn box-for-box with `ListView` (40px group+// header, issue-row-height rows) and `BoardView` (fixed-width columns, plain+// one-line cards).function IssueSurfaceSkeleton({ mode }: { mode: string }) {if (mode === "list") {return (- <div className="flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto p-2">- {Array.from({ length: 4 }).map((_, i) => (- <Skeleton key={i} className="h-10 w-full rounded-lg" />- ))}+ <div className="flex-1 min-h-0 overflow-hidden p-2 pt-0">+ <div className="space-y-1">+ {[4, 3].map((rows, g) => (+ <div key={g}>+ <div className="flex h-10 items-center gap-2 rounded-lg bg-muted px-3">+ <Skeleton className="size-3.5 rounded-full" />+ <Skeleton className="h-3.5 w-20" />+ </div>+ {Array.from({ length: rows }).map((_, i) => (+ <div key={i} className="flex h-[var(--issue-row-height)] items-center gap-2 px-4">+ <Skeleton className="size-4 shrink-0 rounded-full" />+ <span className="min-w-16 shrink-0">+ <Skeleton className="h-3 w-12" />+ </span>+ <Skeleton className="h-3.5 w-full max-w-80" />+ </div>+ ))}+ </div>+ ))}+ </div></div>);}return (- <div className="flex flex-1 min-h-0 gap-4 overflow-x-auto p-4">- {Array.from({ length: 5 }).map((_, i) => (- <div key={i} className="flex min-w-52 flex-1 flex-col gap-2">- <Skeleton className="h-4 w-20" />- <Skeleton className="h-24 w-full rounded-lg" />- <Skeleton className="h-24 w-full rounded-lg" />+ <div className="flex flex-1 min-h-0 gap-4 overflow-hidden p-2">+ {[3, 2, 2, 1, 1].map((cards, c) => (+ <div+ key={c}+ style={{ width: BOARD_COL_WIDTH }}+ className="flex shrink-0 flex-col rounded-xl bg-muted/40 p-2"+ >+ <div className="mb-2 flex h-6 items-center gap-2 px-1.5">+ <Skeleton className="size-2.5 rounded-full" />+ <Skeleton className="h-3.5 w-20" />+ </div>+ <div className="p-1">+ {Array.from({ length: cards }).map((_, i) => (+ <div key={i} className={i === 0 ? undefined : "pt-2"}>+ <div className="rounded-lg border-[0.5px] border-surface-border bg-surface px-2.5 py-3">+ <div className="flex h-4 items-center">+ <Skeleton className="h-3 w-14" />+ </div>+ <div className="mt-1 flex h-5 items-center">+ <Skeleton className="h-3.5 w-4/5" />+ </div>+ </div>+ </div>+ ))}+ </div></div>))}</div>diff --git a/packages/views/layout/app-sidebar.test.tsx b/packages/views/layout/app-sidebar.test.tsxindex c4d308c3d9..4803879863 100644--- a/packages/views/layout/app-sidebar.test.tsx+++ b/packages/views/layout/app-sidebar.test.tsx@@ -207,7 +207,11 @@ vi.mock("@tanstack/react-query", async (importOriginal) => ({if (queryKey[0] === "chat" && queryKey[2] === "sessions") return { data: chatSessions.current };return { data: [] };},- useQueryClient: () => ({ fetchQuery: vi.fn(), invalidateQueries: invitationApi.invalidateQueries }),+ useQueryClient: () => ({+ fetchQuery: vi.fn(),+ prefetchQuery: vi.fn(),+ invalidateQueries: invitationApi.invalidateQueries,+ }),}));describe("PinRow", () => {diff --git a/packages/views/layout/app-sidebar.tsx b/packages/views/layout/app-sidebar.tsxindex c5d8963f2c..de640b380b 100644--- a/packages/views/layout/app-sidebar.tsx+++ b/packages/views/layout/app-sidebar.tsx@@ -82,6 +82,7 @@ import type { PinnedItem } from "@multica/core/types";import { useLogout } from "../auth";import { ProjectIcon } from "../projects/components/project-icon";import { routeIconForPath } from "./route-icon-components";+import { RouteDataPrefetch } from "./route-data-prefetch";import { useT } from "../i18n";import {useShortcut,@@ -610,6 +611,7 @@ export function AppSidebar({ topSlot, searchSlot, headerClassName, headerStyle }const createIssueShortcut = useShortcut("createIssue");return (+ <RouteDataPrefetch wsId={wsId} userId={userId ?? null}><Sidebar variant="inset">{topSlot}{/* Workspace Switcher */}@@ -936,5 +938,6 @@ export function AppSidebar({ topSlot, searchSlot, headerClassName, headerStyle }</SidebarFooter><SidebarRail /></Sidebar>+ </RouteDataPrefetch>);}diff --git a/packages/views/layout/route-data-prefetch.test.tsx b/packages/views/layout/route-data-prefetch.test.tsxnew file mode 100644index 0000000000..5d5ab1341a--- /dev/null+++ b/packages/views/layout/route-data-prefetch.test.tsx@@ -0,0 +1,95 @@+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";+import { fireEvent, render, screen } from "@testing-library/react";+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";+import { WorkspaceSlugProvider } from "@multica/core/paths";+import { NavigationProvider, AppLink, type NavigationAdapter } from "../navigation";+import { RouteDataPrefetch } from "./route-data-prefetch";++function adapter(): NavigationAdapter {+ return {+ push: vi.fn(),+ replace: vi.fn(),+ back: vi.fn(),+ pathname: "/acme/issues",+ searchParams: new URLSearchParams(),+ hash: "",+ getShareableUrl: (p) => p,+ };+}++let qc: QueryClient;+let prefetched: unknown[][];++function renderLinks({ wsId }: { wsId: string | undefined } = { wsId: "ws-1" }) {+ return render(+ <QueryClientProvider client={qc}>+ <NavigationProvider value={adapter()}>+ <WorkspaceSlugProvider slug="acme">+ <RouteDataPrefetch wsId={wsId} userId="user-1">+ <AppLink href="/acme/agents">Agents</AppLink>+ <AppLink href="/acme/projects?view=board">Projects</AppLink>+ <AppLink href="/acme/settings">Settings</AppLink>+ </RouteDataPrefetch>+ </WorkspaceSlugProvider>+ </NavigationProvider>+ </QueryClientProvider>,+ );+}++beforeEach(() => {+ vi.useFakeTimers();+ qc = new QueryClient();+ prefetched = [];+ vi.spyOn(qc, "prefetchQuery").mockImplementation(async (options) => {+ prefetched.push([...(options.queryKey as readonly unknown[])]);+ });+});++afterEach(() => {+ vi.useRealTimers();+});++const keys = () => prefetched.map((key) => JSON.stringify(key));++describe("RouteDataPrefetch", () => {+ it("warms the destination page's queries when a link is hovered", () => {+ renderLinks();+ fireEvent.mouseEnter(screen.getByText("Agents"));++ expect(prefetched.length).toBeGreaterThan(0);+ expect(prefetched.every((key) => key.includes("ws-1"))).toBe(true);+ });++ it("matches hrefs that carry a query string", () => {+ renderLinks();+ fireEvent.focus(screen.getByText("Projects"));++ expect(prefetched.length).toBeGreaterThan(0);+ });++ it("does nothing for routes without a registered page", () => {+ renderLinks();+ fireEvent.mouseEnter(screen.getByText("Settings"));++ expect(prefetched).toHaveLength(0);+ });++ it("warms the common list pages once the workspace is idle", () => {+ renderLinks();+ expect(prefetched).toHaveLength(0);++ vi.advanceTimersByTime(3000);++ const warmed = keys();+ expect(warmed.length).toBeGreaterThan(0);+ expect(new Set(warmed).size).toBeGreaterThanOrEqual(5);+ });++ it("stays idle without a resolved workspace", () => {+ renderLinks({ wsId: undefined });+ fireEvent.mouseEnter(screen.getByText("Agents"));+ vi.advanceTimersByTime(3000);++ expect(prefetched).toHaveLength(0);+ });+});diff --git a/packages/views/layout/route-data-prefetch.tsx b/packages/views/layout/route-data-prefetch.tsxnew file mode 100644index 0000000000..c7e1dd4552--- /dev/null+++ b/packages/views/layout/route-data-prefetch.tsx@@ -0,0 +1,137 @@+"use client";++import { useCallback, useEffect, useMemo, type ReactNode } from "react";+import { useQueryClient, type QueryClient } from "@tanstack/react-query";+import {+ agentActivity30dOptions,+ agentRunCounts30dOptions,+ agentTaskSnapshotOptions,+} from "@multica/core/agents/queries";+import { autopilotListOptions } from "@multica/core/autopilots/queries";+import { chatSessionsOptions } from "@multica/core/chat/queries";+import { inboxListOptions } from "@multica/core/inbox/queries";+import { useWorkspacePaths } from "@multica/core/paths";+import { pinListOptions } from "@multica/core/pins/queries";+import { projectListOptions } from "@multica/core/projects/queries";+import { runtimeProfileListOptions } from "@multica/core/runtimes";+import { runtimeListOptions } from "@multica/core/runtimes/queries";+import {+ agentListOptions,+ memberListOptions,+ skillListOptions,+ squadListOptions,+} from "@multica/core/workspace/queries";+import { RouteDataPrefetchProvider } from "../navigation/route-data-prefetch";++type WarmRoute = (qc: QueryClient, wsId: string, userId: string | null) => void;++// Each entry warms what its page holds its first paint on — the list behind+// the skeleton plus the queries its default sort or columns gate on (Agents'+// lastActive sort waits on activity + run counts). An entry that drifts from+// its page just prefetches the wrong keys, so keep them in step.+// prefetchQuery honours each query's staleTime, so a warm cache costs nothing.+const ROUTES = {+ agents: (qc, wsId) => {+ void qc.prefetchQuery(agentListOptions(wsId));+ void qc.prefetchQuery(runtimeListOptions(wsId));+ void qc.prefetchQuery(memberListOptions(wsId));+ void qc.prefetchQuery(agentRunCounts30dOptions(wsId));+ void qc.prefetchQuery(agentActivity30dOptions(wsId));+ void qc.prefetchQuery(agentTaskSnapshotOptions(wsId));+ },+ skills: (qc, wsId) => {+ void qc.prefetchQuery(skillListOptions(wsId));+ void qc.prefetchQuery(agentListOptions(wsId));+ void qc.prefetchQuery(memberListOptions(wsId));+ void qc.prefetchQuery(runtimeListOptions(wsId));+ },+ squads: (qc, wsId) => {+ void qc.prefetchQuery(squadListOptions(wsId));+ void qc.prefetchQuery(agentListOptions(wsId));+ void qc.prefetchQuery(memberListOptions(wsId));+ },+ autopilots: (qc, wsId) => {+ void qc.prefetchQuery(autopilotListOptions(wsId));+ },+ projects: (qc, wsId, userId) => {+ void qc.prefetchQuery(projectListOptions(wsId));+ void qc.prefetchQuery(memberListOptions(wsId));+ if (userId) void qc.prefetchQuery(pinListOptions(wsId, userId));+ },+ runtimes: (qc, wsId) => {+ void qc.prefetchQuery(runtimeListOptions(wsId));+ void qc.prefetchQuery(runtimeProfileListOptions(wsId));+ void qc.prefetchQuery(agentListOptions(wsId));+ void qc.prefetchQuery(chatSessionsOptions(wsId));+ },+ inbox: (qc, wsId) => {+ void qc.prefetchQuery(inboxListOptions(wsId));+ },+} satisfies Record<string, WarmRoute>;++type RouteKey = keyof typeof ROUTES;++// Small, workspace-scoped lists worth fetching before anyone asks, so the+// first visit to each is already warm. Unobserved queries are collected after+// their gcTime; hover/focus prefetch covers visits after that.+const WARM_ON_IDLE: RouteKey[] = [+ "agents",+ "skills",+ "squads",+ "autopilots",+ "projects",+];++/**+ * Feeds `AppLink`'s hover/focus prefetch with the destination page's data and+ * warms the common list pages once the workspace is idle. Mount inside the+ * workspace shell, around the navigation that should benefit.+ */+export function RouteDataPrefetch({+ wsId,+ userId,+ children,+}: {+ wsId: string | undefined;+ userId: string | null;+ children: ReactNode;+}) {+ const qc = useQueryClient();+ const p = useWorkspacePaths();++ const routeByHref = useMemo(+ () =>+ new Map<string, WarmRoute>(+ (Object.keys(ROUTES) as RouteKey[]).map((key) => [p[key](), ROUTES[key]]),+ ),+ [p],+ );++ const prefetch = useCallback(+ (href: string) => {+ if (!wsId) return;+ const path = href.split(/[?#]/)[0] ?? href;+ routeByHref.get(path)?.(qc, wsId, userId);+ },+ [qc, routeByHref, wsId, userId],+ );++ useEffect(() => {+ if (!wsId) return;+ const warm = () => {+ for (const key of WARM_ON_IDLE) ROUTES[key](qc, wsId, userId);+ };+ if (typeof window.requestIdleCallback === "function") {+ const id = window.requestIdleCallback(warm, { timeout: 3000 });+ return () => window.cancelIdleCallback(id);+ }+ const timer = window.setTimeout(warm, 1500);+ return () => window.clearTimeout(timer);+ }, [qc, wsId, userId]);++ return (+ <RouteDataPrefetchProvider value={prefetch}>+ {children}+ </RouteDataPrefetchProvider>+ );+}diff --git a/packages/views/navigation/app-link.tsx b/packages/views/navigation/app-link.tsxindex d1f9b07ddf..e99aad19b3 100644--- a/packages/views/navigation/app-link.tsx+++ b/packages/views/navigation/app-link.tsx@@ -3,6 +3,7 @@import { forwardRef } from "react";import { resolveClickIntent } from "./click-intent";import { useNavigation } from "./context";+import { useRouteDataPrefetch } from "./route-data-prefetch";interface AppLinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {href: string;@@ -30,6 +31,7 @@ export const AppLink = forwardRef<HTMLAnchorElement, AppLinkProps>(ref,) {const { push, openInNewTab, getShareableUrl, prefetch } = useNavigation();+ const prefetchData = useRouteDataPrefetch();// A packaged Electron renderer runs at file://.../index.html. Keeping a// route-relative href there makes native affordances such as right-click// "Copy Link Address" expose (or reject) a local file URL. Desktop is@@ -117,11 +119,13 @@ export const AppLink = forwardRef<HTMLAnchorElement, AppLinkProps>(const handleMouseEnter = (e: React.MouseEvent<HTMLAnchorElement>) => {prefetch?.(href);+ prefetchData?.(href);onMouseEnter?.(e);};const handleFocus = (e: React.FocusEvent<HTMLAnchorElement>) => {prefetch?.(href);+ prefetchData?.(href);onFocus?.(e);};diff --git a/packages/views/navigation/index.ts b/packages/views/navigation/index.tsindex 72227427bf..c7e9a496db 100644--- a/packages/views/navigation/index.ts+++ b/packages/views/navigation/index.ts@@ -6,6 +6,11 @@ export {useReportNavigating,} from "./context";export { AppLink } from "./app-link";+export {+ RouteDataPrefetchProvider,+ useRouteDataPrefetch,+} from "./route-data-prefetch";+export type { RouteDataPrefetcher } from "./route-data-prefetch";export { currentPath } from "./current-path";export { resolveClickIntent } from "./click-intent";export type { LinkClickIntent } from "./click-intent";diff --git a/packages/views/navigation/route-data-prefetch.tsx b/packages/views/navigation/route-data-prefetch.tsxnew file mode 100644index 0000000000..b5bc885fc8--- /dev/null+++ b/packages/views/navigation/route-data-prefetch.tsx@@ -0,0 +1,22 @@+"use client";++import { createContext, use } from "react";++/**+ * Warms the query cache for an in-app href. `AppLink` calls it on hover and+ * focus, alongside the adapter's route-code `prefetch`, so the destination's+ * data is usually cached by the time the click lands. The provider sits+ * inside the workspace shell; links rendered outside one get `null` and skip+ * it.+ */+export type RouteDataPrefetcher = (href: string) => void;++const RouteDataPrefetchContext = createContext<RouteDataPrefetcher | null>(+ null,+);++export const RouteDataPrefetchProvider = RouteDataPrefetchContext.Provider;++export function useRouteDataPrefetch(): RouteDataPrefetcher | null {+ return use(RouteDataPrefetchContext);+}diff --git a/packages/views/runtimes/components/runtimes-page.test.tsx b/packages/views/runtimes/components/runtimes-page.test.tsxindex e2f87ba5fd..8902acd230 100644--- a/packages/views/runtimes/components/runtimes-page.test.tsx+++ b/packages/views/runtimes/components/runtimes-page.test.tsx@@ -96,14 +96,15 @@ function renderPage({connection = qoder(),desktop = false,}: {- runtimes?: AgentRuntime[];+ /** `null` leaves the runtime list unseeded, so the page renders loading. */+ runtimes?: AgentRuntime[] | null;connection?: QoderConnection;desktop?: boolean;} = {}) {const qc = new QueryClient({defaultOptions: { queries: { retry: false, staleTime: Infinity } },});- qc.setQueryData(runtimeListOptions(WS).queryKey, runtimes);+ if (runtimes) qc.setQueryData(runtimeListOptions(WS).queryKey, runtimes);qc.setQueryData(runtimeProfileListOptions(WS).queryKey, []);qc.setQueryData(agentListOptions(WS).queryKey, []);qc.setQueryData(memberListOptions(WS).queryKey, []);@@ -140,6 +141,16 @@ describe("RuntimesPage", () => {expect(screen.getByText("Claude Managed Agents")).toBeInTheDocument();});+ it("keeps the header, toolbar and column headers up while the list loads", () => {+ const { container } = renderPage({ runtimes: null });++ expect(screen.getByRole("heading", { name: "Runtimes" })).toBeInTheDocument();+ expect(screen.getByRole("textbox")).toBeInTheDocument();+ expect(screen.getAllByRole("columnheader").length).toBeGreaterThan(0);+ expect(container.querySelector('[data-slot="skeleton"]')).not.toBeNull();+ expect(screen.queryByText("Machines")).not.toBeInTheDocument();+ });+it("offers the desktop download on web when no machine is connected", () => {renderPage({ runtimes: [] });diff --git a/packages/views/runtimes/components/runtimes-page.tsx b/packages/views/runtimes/components/runtimes-page.tsxindex de324cde91..76f475c06c 100644--- a/packages/views/runtimes/components/runtimes-page.tsx+++ b/packages/views/runtimes/components/runtimes-page.tsx@@ -74,7 +74,7 @@ import {} from "./mika-runtime-choice";import { Skeleton } from "@multica/ui/components/ui/skeleton";import { CollectionPageHeader } from "../../layout/collection-page";-import { PAGE_GUTTER, PAGE_RAIL, PageHeader } from "../../layout/page-header";+import { PAGE_GUTTER, PAGE_RAIL } from "../../layout/page-header";import { cn } from "@multica/ui/lib/utils";import {AppLink,@@ -233,9 +233,9 @@ export function RuntimesPage({});}, [machines, runtimeProfiles]);- if (isAuthLoading || runtimesLoading || profilesLoading) {- return <RuntimesPageSkeleton />;- }+ // The header, toolbar and column headers render through loading; only the+ // rows wait, so nothing above them moves when the list lands.+ const listLoading = isAuthLoading || runtimesLoading || profilesLoading;const isDesktop = hasLocalMachine === true;const qoder = qoderConnection ?? null;@@ -355,7 +355,9 @@ export function RuntimesPage({<ListGridHeaderCell aria-hidden="true" /></ListGridHeader>- {nothingMatches ? (+ {listLoading ? (+ <RuntimeRowsSkeleton />+ ) : nothingMatches ? (<divrole="row"className="col-span-full px-4 py-10 text-center text-caption text-muted-foreground"@@ -1259,31 +1261,40 @@ function ProviderIconStack({ providers }: { providers: string[] }) {);}-function RuntimesPageSkeleton() {+function RuntimeRowsSkeleton() {return (- <div className="flex min-h-0 flex-1 flex-col">- <PageHeader>- <Skeleton className="h-4 w-24" />- </PageHeader>- <div className={cn(PAGE_RAIL, PAGE_GUTTER, "py-6")}>- <div className="overflow-hidden rounded-lg border">- {Array.from({ length: 5 }).map((_, index) => (- <div- key={index}- className="flex h-[76px] items-center gap-3 border-b px-4 last:border-b-0"- >- <Skeleton className="h-10 w-10 rounded-lg" />- <div className="flex-1">- <Skeleton className="h-4 w-44" />- <Skeleton className="mt-2 h-3 w-28" />- </div>- <Skeleton className="hidden h-4 w-24 md:block" />- <Skeleton className="hidden h-4 w-28 lg:block" />- </div>- ))}- </div>+ <>+ <div+ role="row"+ className="col-span-full flex h-9 items-center border-b bg-muted/40 px-4"+ >+ <Skeleton className="h-3 w-20" /></div>- </div>+ {Array.from({ length: 3 }).map((_, index) => (+ <ListGridRow key={index} className="h-auto min-h-14 border-b hover:bg-transparent">+ <ListGridCell className="gap-3">+ <Skeleton className="size-8 shrink-0 rounded-lg" />+ <div className="min-w-0 flex-1">+ <Skeleton className="h-3.5 w-36 max-w-full" />+ <Skeleton className="mt-1.5 h-3 w-24 max-w-full" />+ </div>+ </ListGridCell>+ <ListGridCell className={OPTIONAL_CELL}>+ <Skeleton className="size-4 rounded-sm" />+ </ListGridCell>+ <ListGridCell className={OPTIONAL_CELL}>+ <Skeleton className="h-3 w-6" />+ </ListGridCell>+ <ListGridCell className={OPTIONAL_CELL}>+ <Skeleton className="h-3 w-10" />+ </ListGridCell>+ <ListGridCell>+ <Skeleton className="h-3 w-16" />+ </ListGridCell>+ <ListGridCell aria-hidden="true" />+ </ListGridRow>+ ))}+ </>);}diff --git a/packages/views/skills/components/skills-page.tsx b/packages/views/skills/components/skills-page.tsxindex 35a624b692..620ef70a96 100644--- a/packages/views/skills/components/skills-page.tsx+++ b/packages/views/skills/components/skills-page.tsx@@ -794,16 +794,14 @@ export default function SkillsPage() {</div>)}- {isLoading ? (- <div className="flex-1 overflow-y-auto @container">- <LoadingSkeleton />- </div>- ) : showEmpty ? (+ {showEmpty ? (<div className="flex flex-1 items-center justify-center"><EmptyState onCreate={() => setCreateOpen(true)} /></div>) : (<>+ {/* Mounted through loading so the rows don't drop by a toolbar's+ height when the list lands. */}<SkillListToolbarsearch={search}onSearchChange={setSearch}@@ -819,6 +817,11 @@ export default function SkillsPage() {allRows={allRows}visibleCount={rows.length}/>+ {isLoading ? (+ <div className="flex-1 overflow-y-auto @container">+ <LoadingSkeleton />+ </div>+ ) : (<divref={listScrollRef}className="min-h-0 flex-1 overflow-auto @container"@@ -902,6 +905,7 @@ export default function SkillsPage() {</ListGridBody></ListGrid></div>+ )}</>)}diff --git a/packages/views/squads/components/squads-page.tsx b/packages/views/squads/components/squads-page.tsxindex 09339f9268..b1918aa14b 100644--- a/packages/views/squads/components/squads-page.tsx+++ b/packages/views/squads/components/squads-page.tsx@@ -923,9 +923,7 @@ export function SquadsPage() {}/>- {isLoading ? (- <LoadingSkeleton />- ) : squads.length === 0 ? (+ {!isLoading && squads.length === 0 ? (<CollectionPageStateicon={Users}title={t(($) => $.page.empty_no_squads)}@@ -941,6 +939,8 @@ export function SquadsPage() {/>) : (<>+ {/* Mounted through loading so the rows don't drop by a toolbar's+ height when the list lands. */}<SquadListToolbarscope={scope}onScopeChange={setScope}@@ -959,6 +959,9 @@ export function SquadsPage() {hiddenColumns={hiddenColumns}onToggleColumn={toggleColumn}/>+ {isLoading ? (+ <LoadingSkeleton />+ ) : (<div className="min-h-0 flex-1 overflow-auto @container"><ListGridclassName={`${GRID_COLS} @2xl:min-w-[var(--sqc-minw)]`}@@ -1027,6 +1030,7 @@ export function SquadsPage() {)}</ListGrid></div>+ )}</>)}</div>