Skip to content

Open-source SEO, GEO, and marketing skills for AI agents.

feat(goals): metrics-first goal screen — layout inversion, one chip system

Yuting Zhong77dc1e86a10e
diff --git a/notfair/src/app/(app)/[project]/goals/[agent]/page.tsx b/notfair/src/app/(app)/[project]/goals/[agent]/page.tsx
index b663cd34..5162f72e 100644
--- a/notfair/src/app/(app)/[project]/goals/[agent]/page.tsx
+++ b/notfair/src/app/(app)/[project]/goals/[agent]/page.tsx
@@ -47,7 +47,6 @@ import {
listSupportMetricSnapshots,
type GoalSupportMetric,
} from "@/server/db/goal-support-metrics";
-import { GoalSparkline } from "@/components/goal-sparkline";
import { MetricMethodDialog } from "@/components/metric-method-dialog";
import { timeUntil } from "@/lib/time-ago";
import { GoalMovesDialog } from "@/components/goal-moves-dialog";
@@ -87,11 +86,11 @@ const STATUS_CHIP: Record<Goal["status"], string> = {
};
/**
- * THE goal screen — everything about one goal on a single page. Chat is
- * the primary surface (goals are defined and steered in conversation);
- * the right rail is the loop's state: plan/START, metric + sparkline,
- * tick diary, open actions, memory. No tabs, no thread management — one
- * goal, one conversation, one screen.
+ * THE goal screen — everything about one goal on a single page. The loop
+ * dashboard is the primary surface (metric hero, supporting metrics on
+ * the same chart grammar, check diary); chat is the side panel for
+ * steering, questions, and amendments. No tabs, no thread management —
+ * one goal, one conversation, one screen.
*/
export default async function GoalPage({
params,
@@ -222,8 +221,17 @@ export default async function GoalPage({
</header>
<div className="flex min-h-0 min-w-0 flex-1 overflow-hidden">
- {/* Chat — the primary surface. */}
- <section className="flex min-w-0 flex-1 flex-col">
+ {/* The loop dashboard — metrics and checks ARE the product of a
+ running goal, so they get the primary column. */}
+ <section className="min-w-0 flex-1 overflow-y-auto px-5 py-4 md:px-7">
+ <div className="mx-auto flex max-w-3xl flex-col gap-5">
+ <GoalDashboard slug={slug} agentSlug={agentSlug} goal={goal} />
+ </div>
+ </section>
+
+ {/* Chat — important but occasional: steering, questions, amendments.
+ A calm side panel, not the main stage. */}
+ <aside className="hidden w-[420px] shrink-0 flex-col bg-[hsl(var(--notfair-surface-2)/0.4)] lg:flex">
<LiveTranscript
key={threadId}
projectSlug={slug}
@@ -235,18 +243,13 @@ export default async function GoalPage({
mcpCatalog={mcpCatalog}
modelOptions={modelOptions}
/>
- </section>
-
- {/* Status rail — the loop's state at a glance. */}
- <aside className="hidden w-[380px] shrink-0 overflow-y-auto bg-[hsl(var(--notfair-surface-2)/0.4)] px-4 py-4 xl:block">
- <GoalRail slug={slug} agentSlug={agentSlug} goal={goal} />
</aside>
</div>
</div>
);
}
-function GoalRail({
+function GoalDashboard({
slug,
agentSlug,
goal,
@@ -307,7 +310,7 @@ function GoalRail({
const streak = currentStreak(squares);
return (
- <div className="flex flex-col gap-5">
+ <>
{/* Statement */}
<p className="m-0 text-[12.5px] leading-relaxed text-[hsl(var(--notfair-ink-3))]">
“{goal.statement}”
@@ -433,11 +436,11 @@ function GoalRail({
{supportMetrics.length > 0 && (
<RailSection title="Supporting metrics" count={supportMetrics.length}>
- <ul className="m-0 flex list-none flex-col gap-3 p-0">
+ <div className="grid gap-4 md:grid-cols-2">
{supportMetrics.map((m) => (
<SupportMetricItem key={m.id} metric={m} />
))}
- </ul>
+ </div>
</RailSection>
)}
@@ -463,7 +466,7 @@ function GoalRail({
</>
)}
- </div>
+ </>
);
}
@@ -471,12 +474,18 @@ function RailCard({ children }: { children: React.ReactNode }) {
return <div className="ns-card p-3.5">{children}</div>;
}
-/** One supporting metric: current value, delta context, mini sparkline. */
+/** One supporting metric — the SAME card grammar as the main metric:
+ * name + ⓘ header, big current value with baseline context, and the
+ * same time chart (no target line: supports have no target). */
function SupportMetricItem({ metric }: { metric: GoalSupportMetric }) {
- const values = listSupportMetricSnapshots(metric.id, 90).map((sn) => sn.value);
+ const points = listSupportMetricSnapshots(metric.id, 400).map((sn) => ({
+ t: Date.parse(sn.created_at),
+ v: sn.value,
+ source: sn.source,
+ }));
return (
- <li className="text-[12px] leading-snug">
- <div className="flex items-baseline justify-between gap-2">
+ <div className="ns-card p-3.5">
+ <div className="mb-1 flex items-baseline justify-between">
<span className="flex min-w-0 items-center gap-1.5 text-[11px] text-[hsl(var(--notfair-ink-4))]">
<span className="truncate">{metric.name}</span>
<MetricMethodDialog
@@ -487,25 +496,28 @@ function SupportMetricItem({ metric }: { metric: GoalSupportMetric }) {
direction={metric.direction}
/>
</span>
- <span className="font-medium tabular-nums">
+ </div>
+ <div className="flex items-baseline gap-3">
+ <span className="text-xl font-semibold tabular-nums">
{formatMetric(metric.current_value)}
- <span className="ml-1.5 font-normal text-[11px] text-[hsl(var(--notfair-ink-4))]">
- baseline {formatMetric(metric.baseline_value)}
- </span>
+ </span>
+ <span className="text-[11.5px] tabular-nums text-[hsl(var(--notfair-ink-4))]">
+ baseline {formatMetric(metric.baseline_value)}
</span>
</div>
- {values.length >= 2 && (
- <div className="mt-1">
- <GoalSparkline
- values={values}
+ {points.length >= 2 && (
+ <div className="mt-3">
+ <GoalProgressChart
+ points={points}
+ actions={[]}
+ failures={[]}
target={null}
- direction={metric.direction}
- width={330}
- height={36}
+ baseline={metric.baseline_value}
+ deadline={null}
/>
</div>
)}
- </li>
+ </div>
);
}
diff --git a/notfair/src/app/globals.css b/notfair/src/app/globals.css
index 6c2f7b77..1bdbfb5b 100644
--- a/notfair/src/app/globals.css
+++ b/notfair/src/app/globals.css
@@ -416,6 +416,21 @@
font-size: 12.5px; padding: 5px 12px;
}
+ /* Header chip — the ONE size for every goal-header control (dialog
+ triggers, run-check, overflow). Consistency is the point: never mix
+ this row with ns-btn or shadcn Button sizes. */
+ .ns-chip {
+ @apply inline-flex shrink-0 items-center gap-1.5 cursor-pointer;
+ font: inherit; font-size: 12px; font-weight: 450;
+ padding: 4px 10px; border-radius: 6px; border: 0;
+ background: hsl(var(--notfair-surface-2));
+ color: hsl(var(--notfair-ink-3));
+ transition: 0.15s ease;
+ }
+ .ns-chip:hover { color: hsl(var(--notfair-ink-1)); }
+ .ns-chip:disabled { opacity: 0.5; cursor: not-allowed; }
+ .ns-chip > svg { width: 14px; height: 14px; flex-shrink: 0; }
+
/* Progress pips — small numbered circles + hairlines. */
.ns-progress {
@apply flex items-center;
diff --git a/notfair/src/components/goal-context-dialog.tsx b/notfair/src/components/goal-context-dialog.tsx
index 8915dc69..346ec9ed 100644
--- a/notfair/src/components/goal-context-dialog.tsx
+++ b/notfair/src/components/goal-context-dialog.tsx
@@ -132,7 +132,7 @@ export function GoalContextDialog({
<DialogTrigger asChild>
<button
type="button"
- className="inline-flex shrink-0 items-center gap-1.5 rounded-md bg-[hsl(var(--notfair-surface-2))] px-2.5 py-1 text-[12px] text-[hsl(var(--notfair-ink-3))] transition-colors hover:text-[hsl(var(--notfair-ink-1))]"
+ className="ns-chip"
title="What fills this agent's context window"
>
<Layers className="size-3.5" aria-hidden />
diff --git a/notfair/src/components/goal-controls.tsx b/notfair/src/components/goal-controls.tsx
index 6a750fbf..b37d0d4d 100644
--- a/notfair/src/components/goal-controls.tsx
+++ b/notfair/src/components/goal-controls.tsx
@@ -3,7 +3,7 @@
import { useRouter } from "next/navigation";
import { useState, useTransition } from "react";
import { toast } from "sonner";
-import { Pause, Play, Square, Zap } from "lucide-react";
+import { MoreHorizontal, Pause, Play, Square, Zap } from "lucide-react";
import {
killGoalAction,
pauseGoalAction,
@@ -11,6 +11,13 @@ import {
runTickNowAction,
} from "@/server/actions/goals";
import { Button } from "@/components/ui/button";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuSeparator,
+ DropdownMenuTrigger,
+} from "@/components/ui/dropdown-menu";
import {
Dialog,
DialogContent,
@@ -20,7 +27,12 @@ import {
DialogTitle,
} from "@/components/ui/dialog";
-/** Pause / resume / run-tick-now / close controls for a live goal. */
+/**
+ * Live-goal controls, sized for the chip row. "Run check" stays a
+ * first-class chip — it's the one control used daily. Pause/resume and
+ * Close live behind the ⋯ overflow: needed, but rare enough that they
+ * shouldn't spend header space or invite misclicks next to daily chips.
+ */
export function GoalControls({
goalId,
status,
@@ -50,52 +62,73 @@ export function GoalControls({
return (
<div className="flex items-center gap-2">
{status === "active" && (
- <>
- <Button
- variant="outline"
- size="sm"
- aria-label="Run tick now"
- disabled={pending}
- onClick={() => run(() => runTickNowAction(goalId), "Tick started — watch the diary.")}
- >
- <Zap className="size-3.5" />
- <span className="hidden sm:inline">Run tick now</span>
- </Button>
- <Button
- variant="outline"
- size="sm"
- aria-label="Pause goal"
- disabled={pending}
- onClick={() => run(() => pauseGoalAction(goalId), "Goal paused.")}
- >
- <Pause className="size-3.5" />
- <span className="hidden sm:inline">Pause</span>
- </Button>
- </>
+ <button
+ type="button"
+ className="ns-chip"
+ aria-label="Run check now"
+ disabled={pending}
+ onClick={() => run(() => runTickNowAction(goalId), "Check started — watch the diary.")}
+ >
+ <Zap aria-hidden />
+ <span className="hidden sm:inline">Run check</span>
+ </button>
)}
{status === "paused" && (
- <Button
- variant="outline"
- size="sm"
+ <button
+ type="button"
+ className="ns-chip"
aria-label="Resume goal"
disabled={pending}
onClick={() => run(() => resumeGoalAction(goalId), "Goal resumed — heartbeat restarted.")}
>
- <Play className="size-3.5" />
+ <Play aria-hidden />
<span className="hidden sm:inline">Resume</span>
- </Button>
+ </button>
)}
- <Button
- variant="outline"
- size="sm"
- aria-label="Close goal"
- disabled={pending}
- onClick={() => setKillOpen(true)}
- className="text-[hsl(0_72%_51%)]"
- >
- <Square className="size-3.5" />
- <span className="hidden sm:inline">Close goal</span>
- </Button>
+
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <button
+ type="button"
+ className="ns-chip !px-1.5"
+ aria-label="More goal actions"
+ disabled={pending}
+ >
+ <MoreHorizontal aria-hidden />
+ </button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" className="min-w-44">
+ {status === "active" && (
+ <DropdownMenuItem
+ disabled={pending}
+ onSelect={() => run(() => pauseGoalAction(goalId), "Goal paused.")}
+ >
+ <Pause />
+ Pause the loop
+ </DropdownMenuItem>
+ )}
+ {status === "paused" && (
+ <DropdownMenuItem
+ disabled={pending}
+ onSelect={() =>
+ run(() => resumeGoalAction(goalId), "Goal resumed — heartbeat restarted.")
+ }
+ >
+ <Play />
+ Resume the loop
+ </DropdownMenuItem>
+ )}
+ {(status === "active" || status === "paused") && <DropdownMenuSeparator />}
+ <DropdownMenuItem
+ variant="destructive"
+ disabled={pending}
+ onSelect={() => setKillOpen(true)}
+ >
+ <Square />
+ Close goal…
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
<Dialog open={killOpen} onOpenChange={setKillOpen}>
<DialogContent>
diff --git a/notfair/src/components/goal-memory-dialog.tsx b/notfair/src/components/goal-memory-dialog.tsx
index 30627f33..072d69c2 100644
--- a/notfair/src/components/goal-memory-dialog.tsx
+++ b/notfair/src/components/goal-memory-dialog.tsx
@@ -48,7 +48,7 @@ export function GoalMemoryDialog({ entries }: { entries: MemoryEntry[] }) {
<DialogTrigger asChild>
<button
type="button"
- className="inline-flex shrink-0 items-center gap-1.5 rounded-md bg-[hsl(var(--notfair-surface-2))] px-2.5 py-1 text-[12px] text-[hsl(var(--notfair-ink-3))] transition-colors hover:text-[hsl(var(--notfair-ink-1))]"
+ className="ns-chip"
title="What the agent has learned about this goal"
>
<Brain className="size-3.5" aria-hidden />
diff --git a/notfair/src/components/goal-moves-dialog.tsx b/notfair/src/components/goal-moves-dialog.tsx
index e8efa0f5..f86b72c8 100644
--- a/notfair/src/components/goal-moves-dialog.tsx
+++ b/notfair/src/components/goal-moves-dialog.tsx
@@ -32,7 +32,7 @@ export function GoalMovesDialog({
<DialogTrigger asChild>
<button
type="button"
- className="inline-flex shrink-0 items-center gap-1.5 rounded-md bg-[hsl(var(--notfair-surface-2))] px-2.5 py-1 text-[12px] text-[hsl(var(--notfair-ink-3))] transition-colors hover:text-[hsl(var(--notfair-ink-1))]"
+ className="ns-chip"
title="Moves the agent has made that aren't scored yet"
>
<Activity className="size-3.5" aria-hidden />
diff --git a/notfair/src/components/goal-needs-you.tsx b/notfair/src/components/goal-needs-you.tsx
index 4ae8208d..eba05daa 100644
--- a/notfair/src/components/goal-needs-you.tsx
+++ b/notfair/src/components/goal-needs-you.tsx
@@ -57,7 +57,7 @@ export function GoalNeedsYouDialog({ items }: { items: NeedsYouItem[] }) {
<DialogTrigger asChild>
<button
type="button"
- className="inline-flex shrink-0 items-center gap-1.5 rounded-md bg-[hsl(var(--notfair-warn)/0.15)] px-2.5 py-1 text-[12px] font-medium text-[hsl(var(--notfair-warn))] transition-colors hover:bg-[hsl(var(--notfair-warn)/0.25)]"
+ className="ns-chip !bg-[hsl(var(--notfair-warn)/0.15)] font-medium !text-[hsl(var(--notfair-warn))] hover:!bg-[hsl(var(--notfair-warn)/0.25)]"
title="Actions only you can take — the agent is blocked on these"
>
<TriangleAlert className="size-3.5" aria-hidden />
diff --git a/notfair/src/components/goal-prs-dialog.tsx b/notfair/src/components/goal-prs-dialog.tsx
index 4c140b2b..2b09544c 100644
--- a/notfair/src/components/goal-prs-dialog.tsx
+++ b/notfair/src/components/goal-prs-dialog.tsx
@@ -41,7 +41,7 @@ export function GoalPrsDialog({ prs }: { prs: PrRow[] }) {
<DialogTrigger asChild>
<button
type="button"
- className="inline-flex shrink-0 items-center gap-1.5 rounded-md bg-[hsl(var(--notfair-surface-2))] px-2.5 py-1 text-[12px] text-[hsl(var(--notfair-ink-3))] transition-colors hover:text-[hsl(var(--notfair-ink-1))]"
+ className="ns-chip"
title="Open pull requests this goal's agent is waiting on"
>
<GitPullRequest className="size-3.5" aria-hidden />