From 0cbbe52887098a25e5ec3a3c1304ec29baa50a88 Mon Sep 17 00:00:00 2001 From: "exe.dev user" Date: Thu, 19 Nov 2026 19:15:17 +0000 Subject: [PATCH] Show agent tabs at once with loading skeletons Clicking Chat, Note or Dashboard kept the previous page on screen until the destination's loader finished. Each tab route now shows its pending component immediately (pendingMs 0) with a skeleton that matches its layout, while the loader fetches in the background. Revisits still render cached data at once and revalidate. This replaces the background preloading from #47: data now loads on click, as requested. Skeletons fade in after 150 ms so fast loads don't flash. Co-Authored-By: Claude Opus 5.5 (1M context) --- apps/web/src/components/agent-header.tsx | 26 +------- apps/web/src/components/conversation.tsx | 56 ++++++++++++++++ apps/web/src/components/ui/skeleton.tsx | 65 +++++++++++++++++++ apps/web/src/router.tsx | 4 -- apps/web/src/routes/agents.$agentId.tsx | 14 ++++ .../src/routes/agents.$agentId_.dashboard.tsx | 61 ++++++++++++++++- apps/web/src/routes/agents.$agentId_.note.tsx | 42 ++++++++++++ 7 files changed, 240 insertions(+), 28 deletions(-) create mode 100644 apps/web/src/components/ui/skeleton.tsx diff --git a/apps/web/src/components/agent-header.tsx b/apps/web/src/components/agent-header.tsx index 679a33d..30c7e39 100644 --- a/apps/web/src/components/agent-header.tsx +++ b/apps/web/src/components/agent-header.tsx @@ -1,6 +1,6 @@ import * as stylex from "@stylexjs/stylex"; -import { Link, useRouter } from "@tanstack/react-router"; -import { type ReactNode, useEffect } from "react"; +import { Link } from "@tanstack/react-router"; +import type { ReactNode } from "react"; import type { Agent } from "../features/agents/schema"; import { useDashboardsEnabled } from "../features/dashboards/preference"; import { motion } from "../styles/motion.stylex"; @@ -19,26 +19,6 @@ export function AgentHeader({ children?: ReactNode; }) { const dashboardsEnabled = useDashboardsEnabled(); - const showDashboard = dashboard || dashboardsEnabled; - const router = useRouter(); - // Warm every tab so a click or tap renders from the router cache at once; - // the destination then refreshes in the background. Preloads within the - // router's preload stale time are free, so remounting the header is cheap. - useEffect(() => { - const timer = setTimeout(() => { - const params = { agentId: agent.id }; - const tabs = [ - "/agents/$agentId", - "/agents/$agentId/note", - ...(agent.kind === "coding" ? ["/agents/$agentId/jobs" as const] : []), - ...(showDashboard ? ["/agents/$agentId/dashboard" as const] : []), - ] as const; - for (const to of tabs) - if (!router.matchRoute({ to, params })) - void router.preloadRoute({ to, params }).catch(() => {}); - }, 250); - return () => clearTimeout(timer); - }, [router, agent.id, agent.kind, showDashboard]); return (
@@ -75,7 +55,7 @@ export function AgentHeader({ Jobs )} - {showDashboard && ( + {(dashboard || dashboardsEnabled) && ( import("./computer-panel").then((module) => ({ @@ -683,6 +684,43 @@ const fadeIn = stylex.keyframes({ to: { opacity: 1 }, }); +/** Holds the conversation's layout while its first snapshot loads. */ +export function ConversationSkeleton({ + agent, + embedded = false, +}: { + agent: Agent; + embedded?: boolean; +}) { + return ( +
+ {embedded ? ( +
+

Conversation

+
+ ) : ( + + )} + + + + + + + + + + +
+ ); +} + // Polls and scroll bookkeeping re-render the conversation every second, so // unchanged messages must not re-render with it. const ConversationRow = memo(function ConversationRow({ @@ -895,6 +933,24 @@ const styles = stylex.create({ animationTimingFunction: motion.easeOut, animationFillMode: "backwards", }, + skeletonHistory: { + display: "flex", + flexDirection: "column", + justifyContent: "flex-end", + gap: 12, + overflow: "hidden", + }, + skeletonBubble: { height: 40, width: "40%", borderRadius: 18 }, + skeletonMine: { alignSelf: "flex-end" }, + skeletonLine: { width: "70%" }, + skeletonWide: { width: "85%", marginTop: 8 }, + skeletonShort: { width: "45%" }, + skeletonComposer: { + flexShrink: 0, + height: 56, + borderRadius: 24, + marginBottom: { default: 16, "@media (max-width: 700px)": 8 }, + }, empty: { paddingTop: 60, color: colors.muted, textAlign: "center" }, error: { display: "block", diff --git a/apps/web/src/components/ui/skeleton.tsx b/apps/web/src/components/ui/skeleton.tsx new file mode 100644 index 0000000..daf525f --- /dev/null +++ b/apps/web/src/components/ui/skeleton.tsx @@ -0,0 +1,65 @@ +import * as stylex from "@stylexjs/stylex"; +import type { ReactNode } from "react"; +import { colors } from "../../styles/tokens.stylex"; + +/** A placeholder block for content that is still loading. */ +export function Skeleton({ xstyle }: { xstyle?: stylex.StyleXStyles }) { + return