Open-source SEO, GEO, and marketing skills for AI agents.
feat(ui): clarify chat tool activity
Yuting Zhongf1f8a0de49e2
diff --git a/notfair/src/components/live-transcript.tsx b/notfair/src/components/live-transcript.tsxindex 9091df3c..bfa8801d 100644--- a/notfair/src/components/live-transcript.tsx+++ b/notfair/src/components/live-transcript.tsx@@ -650,7 +650,7 @@ export function LiveTranscript({role="log"aria-live="polite">- <div className="mx-auto w-full max-w-3xl px-6 py-6">+ <div className="mx-auto w-full max-w-3xl px-5 py-6 sm:px-6">{leadingContent}{rendered.length === 0 &&!pendingUserMsg &&@@ -659,7 +659,7 @@ export function LiveTranscript({!blockedReason ? (<TranscriptEmptyState agentDisplayName={agentDisplayName} />) : (- <ol className="space-y-4">+ <ol className="space-y-5">{rendered.map((item) => (<li key={item.key}><RenderItem item={item} mcpCatalog={mcpCatalog} />@@ -706,8 +706,8 @@ export function LiveTranscript({</div></div>- <div className="bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80">- <div className="relative mx-auto w-full max-w-3xl px-6 py-3">+ <div className="border-t border-border/40 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80">+ <div className="relative mx-auto w-full max-w-3xl px-5 py-3 sm:px-6">{slashOpen && (<SlashCommandPopovercommands={slashMatches}@@ -720,7 +720,7 @@ export function LiveTranscript({textarea on top, a toolbar row below with only the circularsend button. */}<form- className="rounded-2xl border border-border/60 bg-card shadow-[var(--notfair-shadow)] transition-shadow focus-within:ring-1 focus-within:ring-ring"+ className="rounded-2xl border border-border/70 bg-card/90 shadow-[var(--notfair-shadow-sm)] transition-[border-color,box-shadow] focus-within:border-foreground/20 focus-within:shadow-[var(--notfair-shadow)]"onSubmit={(e) => {e.preventDefault();void send();@@ -1113,7 +1113,7 @@ function RenderItem({function UserBubble({ body }: { body: string }) {return (<div className="flex justify-end">- <div className="max-w-[85%] rounded-2xl rounded-br-[6px] bg-muted px-4 py-2 text-sm leading-relaxed whitespace-pre-wrap break-words">+ <div className="max-w-[85%] rounded-2xl rounded-br-md bg-[hsl(var(--notfair-surface-2))] px-3.5 py-2 text-sm leading-relaxed text-foreground/90 whitespace-pre-wrap break-words">{body}</div></div>@@ -1125,7 +1125,7 @@ function AssistantText({ body }: { body: string }) {// pseudo-XML blocks. We render the assistant's prose as-is.if (body.trim() === "") return null;return (- <div className="text-sm leading-relaxed">+ <div className="text-[14px] leading-7 text-foreground/90"><Markdown>{body}</Markdown></div>);@@ -1164,20 +1164,24 @@ function ToolGroup({: hasError? "text-destructive": "text-[hsl(var(--notfair-accent))]";+ const callLabel = `${tools.length} ${tools.length === 1 ? "call" : "calls"}`;return (<detailskey={isLive ? "live" : "done"}open={isLive}- className="group rounded-[10px] bg-card shadow-[var(--notfair-shadow-sm)]"+ data-activity-kind={headMcp ? "mcp" : "tool"}+ className="group ml-1 border-l border-border/70 pl-4"><summaryclassName={cn(- "flex cursor-pointer select-none items-center gap-2 px-3 py-2 text-xs",- "rounded-[10px] hover:bg-[hsl(var(--notfair-hover))] [&::-webkit-details-marker]:hidden",+ "-ml-[25px] flex min-h-8 cursor-pointer select-none items-center gap-2 rounded-md py-1 pr-2 pl-1 text-xs",+ "hover:bg-[hsl(var(--notfair-hover))] [&::-webkit-details-marker]:hidden",)}>- <ChevronRight className="size-3.5 shrink-0 text-muted-foreground transition-transform group-open:rotate-90" />+ <span className="flex size-5 shrink-0 items-center justify-center rounded-full border border-border bg-background shadow-sm">+ <ChevronRight className="size-3 text-muted-foreground transition-transform group-open:rotate-90" />+ </span><StatusIcon className={cn("size-3.5 shrink-0", statusClass)} />{headMcp ? (<ToolBrandFavicon@@ -1187,30 +1191,41 @@ function ToolGroup({) : (<HeadIcon className="size-3.5 shrink-0 text-muted-foreground" />)}- <span className="font-mono text-[12px] font-medium text-foreground">+ <span+ className={cn(+ "rounded px-1.5 py-0.5 font-mono text-[9px] font-semibold tracking-[0.12em] uppercase",+ headMcp+ ? "bg-violet-500/10 text-violet-700 dark:text-violet-300"+ : "bg-muted text-muted-foreground",+ )}+ >+ {headMcp ? "MCP" : "Tool"}+ </span>+ {headMcp && (+ <span className="max-w-28 truncate text-[11px] font-medium text-muted-foreground">+ {headMcp.display_name}+ </span>+ )}+ <span className="font-medium text-foreground/90">{intent.verb}</span>{intent.target && (- <span className="min-w-0 flex-1 truncate font-mono text-[11px] text-muted-foreground">+ <span className="min-w-0 flex-1 truncate font-mono text-[10.5px] text-muted-foreground">{intent.target}</span>)}- <span className="ml-auto font-mono text-[10px] tabular-nums text-muted-foreground">+ <span className="ml-auto shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground">{isLive ? (<span className="inline-flex items-center gap-1.5"><RunningDot size="sm" aria-label="" />- {tools.length === 1- ? "working"- : `${tools.length} steps · ${inFlightCount} live`}+ {tools.length === 1 ? "running" : `${inFlightCount} running`}</span>- ) : tools.length === 1 ? (- <>1 step</>) : (- <>{tools.length} steps</>+ <>{callLabel}</>)}</span></summary>- <div className="space-y-2 bg-[hsl(var(--notfair-surface-2))/0.45] px-3 py-2">+ <div className="divide-y divide-border/50 pb-1 pl-1">{tools.map((t) => (<ToolRow key={t.toolCallId} entry={t} mcpCatalog={mcpCatalog} />))}@@ -1248,7 +1263,7 @@ function ToolRow({entry.label.trim() !== "" &&entry.label.trim() !== intent.target?.trim();return (- <div className="space-y-1">+ <div className="space-y-1.5 py-2.5 first:pt-1.5"><div className="flex items-center gap-2 text-xs"><StatusIcon className={cn("size-3.5 shrink-0", statusClass)} />{mcp ? (@@ -1259,28 +1274,43 @@ function ToolRow({) : (<Icon className="size-3.5 shrink-0 text-muted-foreground" />)}- <span className="font-mono text-[12px] font-medium text-foreground">+ <span+ className={cn(+ "rounded px-1 py-0.5 font-mono text-[8.5px] font-semibold tracking-[0.1em] uppercase",+ mcp+ ? "bg-violet-500/10 text-violet-700 dark:text-violet-300"+ : "bg-muted text-muted-foreground",+ )}+ >+ {mcp ? "MCP" : "Tool"}+ </span>+ {mcp && (+ <span className="max-w-28 truncate text-[10.5px] text-muted-foreground">+ {mcp.display_name}+ </span>+ )}+ <span className="font-medium text-foreground/90">{intent.verb}</span>{intent.target && (- <span className="min-w-0 flex-1 truncate font-mono text-[11px] text-muted-foreground">+ <span className="min-w-0 flex-1 truncate font-mono text-[10.5px] text-muted-foreground">{intent.target}</span>)}- <span className="ml-auto shrink-0 font-mono text-[10px] text-muted-foreground/70">+ <span className="ml-auto shrink-0 rounded bg-muted/70 px-1.5 py-0.5 font-mono text-[9.5px] text-muted-foreground/80">{formatToolName(entry.name)}</span></div>{showRawLabel && (- <pre className="ml-6 max-h-40 overflow-auto rounded bg-muted/60 px-2 py-1 font-mono text-[10.5px] leading-snug text-foreground/80 whitespace-pre-wrap break-all">+ <pre className="ml-5 max-h-40 overflow-auto rounded-md border border-border/50 bg-muted/40 px-2.5 py-2 font-mono text-[10.5px] leading-relaxed text-foreground/80 whitespace-pre-wrap break-all">{entry.label}</pre>)}{entry.done && entry.result && (- <div className="ml-6 font-mono text-[11px] text-muted-foreground/90">- <span className="text-[10px] uppercase tracking-[0.18em]">- {entry.ok ? "→ result" : "→ error"}- </span>{" "}+ <div className="ml-5 font-mono text-[10.5px] leading-relaxed text-muted-foreground/90">+ <span className="mr-1.5 text-[9px] font-semibold uppercase tracking-[0.14em]">+ {entry.ok ? "Result" : "Error"}+ </span><span className="break-words">{entry.result}</span></div>)}diff --git a/notfair/src/components/working-indicator.test.tsx b/notfair/src/components/working-indicator.test.tsxindex 6ce666f6..83edcbc9 100644--- a/notfair/src/components/working-indicator.test.tsx+++ b/notfair/src/components/working-indicator.test.tsx@@ -26,7 +26,35 @@ describe("WorkingIndicator completed state", () => {expect(screen.getByRole("status", { name: "Growth agent Turn complete" }),).toBeInTheDocument();+ expect(+ screen.getByRole("status", { name: "Growth agent Turn complete" }),+ ).toHaveAttribute("data-run-state", "complete");expect(container.querySelector('[class*="animate-"]')).toBeNull();expect(screen.queryByText("1:05")).toBeNull();});++ it("keeps an active tool run visibly running with elapsed time", () => {+ render(+ <WorkingIndicator+ agentDisplayName="Growth agent"+ headline="Calling X Ads"+ subtitle="summarizeXAccountSetup"+ phases={[+ {+ id: "x-ads-call",+ label: "Summarize X account setup",+ state: "active",+ },+ ]}+ elapsedMs={65_000}+ mood="tool"+ />,+ );++ expect(+ screen.getByRole("status", { name: "Growth agent Calling X Ads" }),+ ).toHaveAttribute("data-run-state", "running");+ expect(screen.getByText("1:05")).toBeInTheDocument();+ expect(screen.getByText("Summarize X account setup")).toBeInTheDocument();+ });});diff --git a/notfair/src/components/working-indicator.tsx b/notfair/src/components/working-indicator.tsxindex 10a17f3a..958d6dac 100644--- a/notfair/src/components/working-indicator.tsx+++ b/notfair/src/components/working-indicator.tsx@@ -1,42 +1,23 @@"use client";-import { useEffect, useState } from "react";-import { Check, ChevronRight, Wrench } from "lucide-react";+import { Check, CheckCircle2, Loader2, Wrench, X } from "lucide-react";import { cn } from "@/lib/utils";-/**- * WorkingIndicator — the bottom-anchored "agent is doing work" card.- *- * Replaces the previous BeamingHeadline (cyan ✳ + cycling verb) that- * looked janky next to the rest of the UI. The new design is- * editorial-cockpit: a thin colored aurora bar across the top, a- * trajectory of phase chips (past tools → active step), an animated- * mood dot, a monospace subtitle for tool args, a digital elapsed- * readout, and a shimmer bar across the bottom. The mood color cycles- * by phase so a quick glance tells you where the agent is:- *- * - waiting (pre-first-token / between events): sky → cyan- * - tool in flight: violet → fuchsia- * - writing response: emerald → teal- * - wrapping up: amber → orange- *- * Everything past the trajectory chips is decoration; the chips- * themselves carry the real "what is happening right now" signal.- */-export type WorkingPhase = {- /** Stable key so React reconciles correctly across renders. */id: string;- /** Human-readable tool name (already display-formatted upstream). */label: string;- /** Compact arg / detail line shown for the active phase. */detail?: string | null;state: "done" | "active" | "failed";};export type WorkingMood = "waiting" | "tool" | "writing" | "wrapping" | "ended";+/**+ * A quiet, Codex-style run status that belongs to the conversation flow.+ * It deliberately avoids card chrome: one state icon, one honest status,+ * and a compact history of the latest tool calls.+ */export function WorkingIndicator({agentDisplayName,headline,@@ -46,22 +27,13 @@ export function WorkingIndicator({mood,}: {agentDisplayName: string;- /** Primary sentence shown in the active row. */headline: string;- /** Optional monospace context line (tool args, lifecycle phase). */subtitle?: string | null;- /** Recent + active trajectory chips. Most recent right-most. */phases: WorkingPhase[];- /** ms since the turn began. null = hide the readout. */elapsedMs: number | null;- /** Drives the color story. */mood: WorkingMood;}) {- const palette = MOOD_PALETTES[mood];const ended = mood === "ended";- // Only show the last few phases — older ones scroll off-screen, the- // full transcript is the source of truth for history. Three keeps the- // strip dense without wrapping at common widths.const visiblePhases = phases.slice(-3);return (@@ -69,332 +41,89 @@ export function WorkingIndicator({role="status"aria-live="polite"aria-label={`${agentDisplayName} ${headline}`}+ data-run-state={ended ? "complete" : "running"}className={cn(- "relative overflow-hidden rounded-lg border bg-card/40 backdrop-blur-sm",- "ring-1 ring-inset",- palette.ring,+ "border-l-2 py-1.5 pl-3",+ ended ? "border-muted-foreground/35" : "border-violet-500/55",)}>- {!ended && (- /* Aurora top edge — primary "alive" signal. */- <span- aria-hidden- className="pointer-events-none absolute inset-x-0 top-0 h-[2px] overflow-hidden"- >- <span- className={cn(- "absolute inset-y-0 left-0 w-1/3",- "motion-safe:animate-aurora-sweep",- )}- style={{- backgroundImage: `linear-gradient(to right, transparent, ${palette.beam}, transparent)`,- }}+ <div className="flex min-w-0 items-center gap-2 text-xs">+ {ended ? (+ <CheckCircle2+ className="size-3.5 shrink-0 text-muted-foreground"+ aria-hidden/>- </span>- )}-- <div className="flex items-start gap-3 px-3.5 py-2.5">- {/* Mood dot: scaling heartbeat with a soft halo. */}- <span- aria-hidden- className="relative mt-1 inline-flex h-2.5 w-2.5 shrink-0 items-center justify-center"- >- <span- className={cn(- "absolute inset-[-2px] rounded-full blur-sm",- palette.haloBg,- )}- />- <span- className={cn(- "relative inline-block h-2 w-2 rounded-full",- palette.dotBg,- !ended && "motion-safe:animate-heartbeat",- )}+ ) : (+ <Loader2+ className="size-3.5 shrink-0 animate-spin text-violet-500"+ aria-hidden/>+ )}+ <span className="font-medium text-foreground/90">{headline}</span>+ <span className="text-muted-foreground/45">·</span>+ <span className="truncate text-muted-foreground">+ {agentDisplayName}</span>-- <div className="min-w-0 flex-1 space-y-1.5">- {/* Active row: agent · headline + cycling verb fallback. */}- <div className="flex items-baseline gap-2 text-xs leading-tight">- <span className={cn("font-semibold", palette.accentText)}>- {agentDisplayName}- </span>- <span className="text-muted-foreground/60">·</span>- <span className="text-foreground/85">- {headline}- {!ended && <BreathingDots />}- </span>- </div>-- {/* Subtitle: monospace context (tool args, lifecycle hint). */}- {subtitle && (- <div className="truncate font-mono text-[10.5px] tracking-tight text-muted-foreground/80">- {subtitle}- </div>- )}-- {/* Trajectory chips — what's been done + what's active. */}- {visiblePhases.length > 0 && (- <ol className="-ml-0.5 flex flex-wrap items-center gap-1 pt-0.5">- {visiblePhases.map((phase, idx) => (- <li- key={phase.id}- className="flex items-center gap-1"- >- <PhaseChip- phase={phase}- palette={palette}- animated={!ended}- />- {idx < visiblePhases.length - 1 && (- <ChevronRight- className="size-3 text-muted-foreground/35"- aria-hidden- />- )}- </li>- ))}- </ol>- )}- </div>-- {/* Elapsed readout — small digital pill, right aligned. */}{!ended && elapsedMs != null && (- <span- className={cn(- "inline-flex shrink-0 items-center rounded border px-1.5 py-0.5",- "border-border/40 bg-background/70",- "font-mono text-[10px] tabular-nums tracking-wider",- "text-muted-foreground",- )}- >+ <span className="ml-auto shrink-0 font-mono text-[10px] tabular-nums text-muted-foreground">{formatElapsed(elapsedMs)}</span>)}</div>- {!ended && (- /* Shimmer bottom edge — continuous motion when waiting. */- <span- aria-hidden- className="pointer-events-none absolute inset-x-0 bottom-0 h-[1.5px] overflow-hidden"- >- <span- className={cn(- "absolute inset-y-0 left-0 w-1/4 opacity-70",- "motion-safe:animate-shimmer-bar",- )}- style={{- backgroundImage: `linear-gradient(to right, transparent, ${palette.beam}, transparent)`,- }}- />- </span>+ {subtitle && (+ <div className="mt-1 truncate font-mono text-[10.5px] tracking-tight text-muted-foreground/80">+ {subtitle}+ </div>+ )}++ {visiblePhases.length > 0 && (+ <ol className="mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1">+ {visiblePhases.map((phase) => (+ <li+ key={phase.id}+ className="inline-flex min-w-0 items-center gap-1 text-[10.5px] text-muted-foreground"+ >+ <PhaseIcon phase={phase} animate={!ended} />+ <span className="max-w-44 truncate font-mono">+ {phase.label}+ </span>+ </li>+ ))}+ </ol>)}</div>);}-function PhaseChip({+function PhaseIcon({phase,- palette,- animated,+ animate,}: {phase: WorkingPhase;- palette: MoodPalette;- animated: boolean;+ animate: boolean;}) {if (phase.state === "done") {- return (- <span- className={cn(- "inline-flex items-center gap-1 rounded-full px-1.5 py-0.5",- "bg-emerald-500/10 text-emerald-700 dark:text-emerald-400",- )}- >- <Check className="size-2.5" aria-hidden />- <span className="max-w-[12rem] truncate font-mono text-[10px]">- {phase.label}- </span>- </span>- );+ return <Check className="size-3 shrink-0 text-emerald-500" aria-hidden />;}if (phase.state === "failed") {- return (- <span- className={cn(- "inline-flex items-center gap-1 rounded-full px-1.5 py-0.5",- "bg-destructive/10 text-destructive",- )}- >- <span className="size-1.5 rounded-full bg-destructive" aria-hidden />- <span className="max-w-[12rem] truncate font-mono text-[10px]">- {phase.label}- </span>- </span>- );+ return <X className="size-3 shrink-0 text-destructive" aria-hidden />;}- // activereturn (- <span+ <WrenchclassName={cn(- "relative inline-flex items-center gap-1 rounded-full px-1.5 py-0.5",- "ring-1 ring-inset",- palette.chipBg,- palette.chipText,- palette.chipRing,- )}- >- <Wrench className="size-2.5" aria-hidden />- <span className="max-w-[14rem] truncate font-mono text-[10px] font-medium">- {phase.label}- </span>- {animated && (- /* tiny in-chip pulse ring */- <span- aria-hidden- className={cn(- "absolute inset-0 rounded-full ring-1 ring-inset",- palette.chipRing,- "motion-safe:animate-phase-glow",- )}- />+ "size-3 shrink-0 text-violet-500",+ animate && "animate-pulse",)}- </span>- );-}--/**- * Trailing three-dot animation. Smooth amplitude pulse on each dot- * staggered by ~150 ms — reads as a wave traveling left-to-right.- * Done with state instead of CSS because we want each dot to be- * independent of the others (a single keyframe applied to all three- * would have them all pulse together, which is harsher).- */-function BreathingDots() {- const [tick, setTick] = useState(0);- useEffect(() => {- const id = setInterval(() => setTick((t) => (t + 1) % 6), 220);- return () => clearInterval(id);- }, []);- return (- <span aria-hidden className="ml-0.5 inline-flex gap-[2px]">- {[0, 1, 2].map((i) => (- <span- key={i}- className="inline-block h-1 w-1 rounded-full bg-current"- style={{- opacity: dotOpacity(tick, i),- transform: `translateY(${dotOffset(tick, i)}px)`,- transition: "opacity 200ms ease, transform 200ms ease",- }}- />- ))}- </span>+ aria-hidden+ />);}-function dotOpacity(tick: number, i: number): number {- // Each dot peaks 2 ticks apart, gives a wave-like feel.- const phase = (tick - i + 6) % 6;- if (phase === 0) return 1;- if (phase === 1 || phase === 5) return 0.7;- return 0.3;-}--function dotOffset(tick: number, i: number): number {- const phase = (tick - i + 6) % 6;- if (phase === 0) return -1;- return 0;-}-function formatElapsed(ms: number): string {const totalSec = Math.floor(ms / 1000);if (totalSec < 60) return `0:${totalSec.toString().padStart(2, "0")}`;- const m = Math.floor(totalSec / 60);- const s = totalSec % 60;- return `${m}:${s.toString().padStart(2, "0")}`;+ const minutes = Math.floor(totalSec / 60);+ const seconds = totalSec % 60;+ return `${minutes}:${seconds.toString().padStart(2, "0")}`;}--// ────────────────────────────────────────────────────────────────────-// Mood palettes-//-// Tailwind classnames are static (so the JIT can pick them up) but-// the inline-gradient `beam` color is a raw hex/HSL because the-// gradient is built via inline style. Keeping the two in lockstep is-// the whole point of bundling them per-mood — change a mood's vibe-// here and the dot, halo, chip, beam, and shimmer all update together.--type MoodPalette = {- /** Outermost ring around the card. */- ring: string;- /** Filled mood dot background. */- dotBg: string;- /** Soft glow behind the dot. */- haloBg: string;- /** Active phase chip background. */- chipBg: string;- /** Active phase chip text. */- chipText: string;- /** Active phase chip ring. */- chipRing: string;- /** Agent name accent text color. */- accentText: string;- /** Inline-style gradient stop for the aurora + shimmer bars. */- beam: string;-};--const MOOD_PALETTES: Record<WorkingMood, MoodPalette> = {- waiting: {- ring: "ring-sky-500/15",- dotBg: "bg-sky-500",- haloBg: "bg-sky-400/40",- chipBg: "bg-sky-500/10",- chipText: "text-sky-700 dark:text-sky-300",- chipRing: "ring-sky-500/30",- accentText: "text-sky-700 dark:text-sky-300",- beam: "hsl(199 89% 60%)",- },- tool: {- ring: "ring-violet-500/15",- dotBg: "bg-violet-500",- haloBg: "bg-violet-400/40",- chipBg: "bg-violet-500/10",- chipText: "text-violet-700 dark:text-violet-300",- chipRing: "ring-violet-500/30",- accentText: "text-violet-700 dark:text-violet-300",- beam: "hsl(258 90% 66%)",- },- writing: {- ring: "ring-emerald-500/15",- dotBg: "bg-emerald-500",- haloBg: "bg-emerald-400/40",- chipBg: "bg-emerald-500/10",- chipText: "text-emerald-700 dark:text-emerald-300",- chipRing: "ring-emerald-500/30",- accentText: "text-emerald-700 dark:text-emerald-300",- beam: "hsl(160 84% 45%)",- },- wrapping: {- ring: "ring-amber-500/15",- dotBg: "bg-amber-500",- haloBg: "bg-amber-400/40",- chipBg: "bg-amber-500/10",- chipText: "text-amber-700 dark:text-amber-300",- chipRing: "ring-amber-500/30",- accentText: "text-amber-700 dark:text-amber-300",- beam: "hsl(38 92% 55%)",- },- ended: {- // Muted slate and fully static. A completed turn must not retain any- // of the motion language used to communicate active work.- ring: "ring-slate-500/15",- dotBg: "bg-slate-500",- haloBg: "bg-slate-400/30",- chipBg: "bg-slate-500/10",- chipText: "text-slate-700 dark:text-slate-300",- chipRing: "ring-slate-500/30",- accentText: "text-slate-700 dark:text-slate-300",- beam: "hsl(215 16% 60%)",- },-};