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