Skip to content

AI-powered virtual executive team — a single coherent executive persona backed by 8 specialist agents (FastAPI + Next.js).

feat(ui): lay out Pulse as one overview with focused screens (#418)

Rufus62f1db454da2
diff --git a/packages/core/openexecutive/guide/prebuilt/pulse.json b/packages/core/openexecutive/guide/prebuilt/pulse.json
index bb1c868b..4e4f8a59 100644
--- a/packages/core/openexecutive/guide/prebuilt/pulse.json
+++ b/packages/core/openexecutive/guide/prebuilt/pulse.json
@@ -1,7 +1,7 @@
{
"section_id": "pulse",
"title": "Pulse (Memory)",
- "markdown": "**What it is:** The Executive's running memory and heartbeat — the decisions it has made with you, the initiatives it's tracking, the advice it has gathered, and the rhythm of work it runs on its own.\n\n**What it does:**\n\n- Browse past **decisions** with their rationale and outcome.\n- Track **initiatives** as planned, active, paused, or completed.\n- Review **advice** collected from specialists, searchable by topic.\n- See your **corrections** — facts you corrected or asked the Executive to keep, where you said them, and what they replaced. They hold everywhere: every conversation, brief, scheduled run and alert review.\n- See the **heartbeat** — the recurring cadence of daily briefs, department check-ins, system scans, and pending scheduled follow-ups.\n- Edit or delete any item to keep the Executive's memory accurate.\n\n**How to use:**\n\n1. Just chat. Decisions, initiatives and advice are pulled out of your conversations automatically after each chat — there's nothing to add by hand.\n2. Click **Pulse** in the sidebar. At the top are three numbers — beats today, the next beat (when the next scheduled action is due) and memories — with the rest under **More stats**. Below them, the **Heartbeat** tab shows the rhythm the Executive runs on, with **Activity**, **Rhythm** and **Follow-ups** views; the **Memory** tab has tabs for **Decisions**, **Initiatives**, **Advice**, **Corrections** and **People**.\n3. Choose **Edit** in any row's **⋯** menu to correct it — fix a decision's rationale or outcome, change its domain or tags, or move an initiative to *completed* — then **Save**.\n4. Choose **Delete** in the same menu to remove something that's simply wrong. This can't be undone.\n5. To correct a fact, just say it in chat — *\"Maple House is 48 units, not 52\"* or *\"we're 42 people now\"*. The Executive keeps it (a company-profile field such as headcount or burn updates the profile too), and it shows under **Corrections** with your words. Choose **Retire (stop using it)** in a correction's **⋯** menu when it no longer holds; older versions stay under **Show history**. You can also email a correction from your own address: nothing changes until you reply CONFIRM to the confirmation email the Executive sends you. Teammates on your People list can correct facts too, from the web app or their own Slack or Discord. Theirs are marked with their name and wait for your approval at the top of the tab, and they appear in your morning brief. Untick **needs my approval** next to a teammate you trust to let theirs apply straight away; one that would replace yours still waits for you. Only you can retire someone else's correction.\n\n**Example:** tell the Executive *\"we've decided to push the EU launch to Q2 so we can finish SOC 2 first.\"* Afterwards, **Pulse → Memory → Decisions** shows that decision with its rationale. If it captured the wrong reason, edit it — future answers build on what's recorded here.\n\n**Just for yourself?** When you use Open Executive just for yourself, the heartbeat leaves out department check-ins and the \"Awaiting people\" list, and the count of active projects takes the department check-ins' place under **More stats**. The same projects appear on Home under **Your projects**.\n\n*Note: this memory is searchable across the system, so what's captured here informs future answers.*",
+ "markdown": "**What it is:** The Executive's running memory and heartbeat — the decisions it has made with you, the initiatives it's tracking, the advice it has gathered, and the rhythm of work it runs on its own.\n\n**What it does:**\n\n- Browse past **decisions** with their rationale and outcome.\n- Track **initiatives** as planned, active, paused, or completed.\n- Review **advice** collected from specialists, searchable by topic.\n- See your **corrections** — facts you corrected or asked the Executive to keep, where you said them, and what they replaced. They hold everywhere: every conversation, brief, scheduled run and alert review.\n- See the **heartbeat** — the recurring cadence of daily briefs, department check-ins, system scans, and pending scheduled follow-ups.\n- Edit or delete any item to keep the Executive's memory accurate.\n\n**How to use:**\n\n1. Just chat. Decisions, initiatives and advice are pulled out of your conversations automatically after each chat — there's nothing to add by hand.\n2. Click **Pulse** in the sidebar. The **Heartbeat** card shows the last 90 days beside three numbers: what it did today, how long until the next thing it does, and how many days in a row it has been active. **More detail** opens the rest. Below it, **Coming up** lists the next few briefs, check-ins and follow-ups (**Full schedule** shows them all, with background scans under **Show background scans**), and **Done recently** lists the last few things it did (**All activity** shows the full feed). Under **What it remembers**, a tile for **Decisions**, **Projects**, **Advice**, **Facts you taught it** and **Your notes** opens that list on its own screen; **Pulse** at the top takes you back.\n3. Choose **Edit** in any row's **⋯** menu to correct it — fix a decision's rationale or outcome, change its domain or tags, or move an initiative to *completed* — then **Save**.\n4. Choose **Delete** in the same menu to remove something that's simply wrong. This can't be undone.\n5. To correct a fact, just say it in chat — *\"Maple House is 48 units, not 52\"* or *\"we're 42 people now\"*. The Executive keeps it (a company-profile field such as headcount or burn updates the profile too), and it shows under **Facts you taught it** with your words. Choose **Retire (stop using it)** in a correction's **⋯** menu when it no longer holds; older versions stay under **Show history**. You can also email a correction from your own address: nothing changes until you reply CONFIRM to the confirmation email the Executive sends you. Teammates on your People list can correct facts too, from the web app or their own Slack or Discord. Theirs are marked with their name and wait for your approval at the top of that list (the tile says how many), and they appear in your morning brief. Untick **needs my approval** next to a teammate you trust to let theirs apply straight away; one that would replace yours still waits for you. Only you can retire someone else's correction.\n\n**Example:** tell the Executive *\"we've decided to push the EU launch to Q2 so we can finish SOC 2 first.\"* Afterwards, **Pulse → Decisions** shows that decision with its rationale. If it captured the wrong reason, edit it — future answers build on what's recorded here.\n\n**Just for yourself?** When you use Open Executive just for yourself, the heartbeat leaves out department check-ins and the \"Awaiting people\" list, and the count of active projects takes the department check-ins' place under **More detail**. The same projects appear on Home under **Your projects**.\n\n*Note: this memory is searchable across the system, so what's captured here informs future answers.*",
"mermaid": null,
- "generated_at": "2026-10-03T12:00:00Z"
+ "generated_at": "2026-10-09T21:30:00Z"
}
diff --git a/packages/ui/scripts/pulseView.test.mjs b/packages/ui/scripts/pulseView.test.mjs
new file mode 100644
index 00000000..3675183b
--- /dev/null
+++ b/packages/ui/scripts/pulseView.test.mjs
@@ -0,0 +1,51 @@
+import assert from "node:assert/strict";
+import test from "node:test";
+import { clockLabel, isMemoryView, pulseViewFor, upcomingLabel, whenLabel } from "../src/lib/pulseView.ts";
+
+// Local-time constructors, so the labels hold in any test-runner time zone.
+const NOW = new Date(2026, 9, 9, 14, 0); // Fri Oct 9 2026, 2 pm local
+const at = (...args) => new Date(...args).toISOString();
+
+test("pulseViewFor keeps the old tab links working", () => {
+ assert.equal(pulseViewFor(null), "overview");
+ assert.equal(pulseViewFor("heartbeat"), "overview");
+ assert.equal(pulseViewFor("memory"), "overview");
+ assert.equal(pulseViewFor("nonsense"), "overview");
+ assert.equal(pulseViewFor("rhythm"), "schedule");
+ assert.equal(pulseViewFor("followups"), "schedule");
+ assert.equal(pulseViewFor("schedule"), "schedule");
+ assert.equal(pulseViewFor("activity"), "activity");
+ assert.equal(pulseViewFor("corrections"), "corrections");
+ assert.equal(pulseViewFor("history"), "history");
+});
+
+test("isMemoryView picks out the memory lists", () => {
+ assert.equal(isMemoryView("decisions"), true);
+ assert.equal(isMemoryView("history"), true);
+ assert.equal(isMemoryView("schedule"), false);
+ assert.equal(isMemoryView("overview"), false);
+});
+
+test("clockLabel drops :00 and uses am/pm", () => {
+ assert.equal(clockLabel(new Date(2026, 9, 9, 9, 0)), "9\u00a0am");
+ assert.equal(clockLabel(new Date(2026, 9, 9, 18, 30)), "6:30\u00a0pm");
+ assert.equal(clockLabel(new Date(2026, 9, 9, 0, 5)), "12:05\u00a0am");
+ assert.equal(clockLabel(new Date(2026, 9, 9, 12, 0)), "12\u00a0pm");
+});
+
+test("whenLabel says today's time, Yesterday, a weekday, or a date", () => {
+ assert.equal(whenLabel(at(2026, 9, 9, 18, 0), NOW), "6\u00a0pm");
+ assert.equal(whenLabel(at(2026, 9, 9, 7, 0), NOW), "7\u00a0am");
+ assert.equal(whenLabel(at(2026, 9, 8, 22, 0), NOW), "Yesterday");
+ assert.equal(whenLabel(at(2026, 9, 10, 7, 0), NOW), "Sat 7\u00a0am");
+ assert.equal(whenLabel(at(2026, 9, 12, 10, 0), NOW), "Mon 10\u00a0am");
+ assert.equal(whenLabel(at(2026, 9, 6, 10, 0), NOW), "Tue");
+ assert.equal(whenLabel(at(2026, 9, 1, 10, 0), NOW), "Oct 1");
+ assert.equal(whenLabel(at(2026, 9, 20, 10, 0), NOW), "Oct 20");
+ assert.equal(whenLabel("not a date", NOW), "");
+});
+
+test("upcomingLabel says Now for anything already due", () => {
+ assert.equal(upcomingLabel(at(2026, 9, 9, 13, 0), NOW), "Now");
+ assert.equal(upcomingLabel(at(2026, 9, 9, 18, 0), NOW), "6\u00a0pm");
+});
diff --git a/packages/ui/src/components/memories/CadenceSection.tsx b/packages/ui/src/components/memories/CadenceSection.tsx
index bf79fcc4..3e453052 100644
--- a/packages/ui/src/components/memories/CadenceSection.tsx
+++ b/packages/ui/src/components/memories/CadenceSection.tsx
@@ -29,11 +29,12 @@ import FeatureName from "@/components/FeatureName";
// metaFor / groupByRhythm) now lives in ./shared so the header stat strip and
// these cards agree on how raw scheduled_actions `kind`s map to human groups.
//
-// The Heartbeat tab of the Pulse page has three views, each its own export:
-// Activity (`RecentActivity`), Rhythm (the default export) and Follow-ups
-// (`FollowUpsCard`). The rhythm card shows the *pending* queue only (the
+// The Pulse overview previews the next few and last few items; these are the
+// full lists behind its links. The Schedule screen shows the rhythm (the
+// default export) and the follow-ups (`FollowUpsCard`); the Activity screen
+// shows `RecentActivity`. The rhythm card shows the *pending* queue only (the
// upcoming cadence), fetched soonest-first; follow-ups (ad_hoc one-offs) are
-// their own view.
+// their own card, and background scans sit behind "Show background scans".
// Over-fetch cap. The backend can't filter by `kind`, so we pull a generous
// slice and group client-side; high-frequency system scans are capped at render
@@ -144,7 +145,7 @@ export default function RhythmSection() {
// `subject` names who/what it was directed at. Ported from the Briefing rail
// (now removed) so the Pulse shows the same rich rows. The full summary is
// always rendered as the body, so no information is lost.
-function activityLine(item: ActivityItem): { verb: string; subject: string } {
+export function activityLine(item: ActivityItem): { verb: string; subject: string } {
switch (item.kind) {
case "dm_sent":
return { verb: "DM'd", subject: item.target ?? "a colleague" };
@@ -184,7 +185,7 @@ function activityLine(item: ActivityItem): { verb: string; subject: string } {
// Kinds whose `subject` IS the full summary: the body row renders the text, so
// the inline subject span is suppressed to avoid repeating it (only the verb
// shows inline). Kept beside activityLine so adding a kind is a one-place edit.
-const SUMMARY_KINDS = new Set([
+export const SUMMARY_KINDS = new Set([
"decision_logged",
"advice_given",
"action",
@@ -197,7 +198,7 @@ const SUMMARY_KINDS = new Set([
]);
// Take the lead and Handle it for me rows say whose name it acted in.
-function actingAs(item: ActivityItem): string | null {
+export function actingAs(item: ActivityItem): string | null {
if (item.kind === "sent_as_you") return "As you";
if (item.kind === "took_the_lead") return "As the Executive";
return null;
@@ -418,8 +419,8 @@ function RhythmCard({
}
// ---------------------------------------------------------------------------
-// System pulse — the literal heartbeat (internal scans). Shown like the other
-// rhythm groups (shared SectionHeading) and always expanded. Capped at render
+// System pulse — the literal heartbeat (internal scans). Folded behind "Show
+// background scans", then shown like the other rhythm groups. Capped at render
// time: under done/all these fire every few minutes, so an uncapped list would
// bury the user-facing groups above.
// ---------------------------------------------------------------------------
@@ -427,13 +428,28 @@ function RhythmCard({
const SYSTEM_PULSE_CAP = 50;
function SystemPulse({ actions }: { actions: ScheduledAction[] }) {
+ // Nothing here is sent to the person, so it stays folded away until asked.
+ const [open, setOpen] = useState(false);
if (actions.length === 0) return null;
+ if (!open) {
+ return (
+ <button
+ type="button"
+ onClick={() => setOpen(true)}
+ aria-expanded={false}
+ className="inline-flex h-10 items-center gap-1.5 rounded-xl px-2 text-sm font-medium text-fg-muted hover:text-fg hover:bg-surface-overlay transition-colors"
+ >
+ <Icon name="chevron-right" size="w-4 h-4" />
+ Show background scans ({actions.length})
+ </button>
+ );
+ }
const shown = actions.slice(0, SYSTEM_PULSE_CAP);
const hidden = actions.length - shown.length;
return (
<section>
<SectionHeading
- title="System pulse"
+ title="Background scans"
count={actions.length}
icon="activity"
tag="Internal · continuous"
diff --git a/packages/ui/src/components/memories/MemorySection.tsx b/packages/ui/src/components/memories/MemorySection.tsx
index 67afee0e..ea23480b 100644
--- a/packages/ui/src/components/memories/MemorySection.tsx
+++ b/packages/ui/src/components/memories/MemorySection.tsx
@@ -17,107 +17,38 @@ import {
} from "@/lib/api";
import Button from "@/components/ui/Button";
import OverflowMenu from "@/components/ui/OverflowMenu";
-import SectionTabs from "@/components/ui/SectionTabs";
import CorrectionsTab from "./CorrectionsTab";
import HistoryTab from "./HistoryTab";
+import type { MemoryView } from "@/lib/pulseView";
import { DOMAINS, STATUSES, EmptyState, formatDate } from "./shared";
-type MemoryTab = "decisions" | "initiatives" | "advice" | "corrections" | "history";
-
-export const MEMORY_TABS: readonly MemoryTab[] = [
- "decisions",
- "initiatives",
- "advice",
- "corrections",
- "history",
-];
-
const MEMORY_EMPTY = "No memories yet — they're extracted automatically after chats.";
+// Counts are shown on the Pulse overview's tiles, not here.
+const ignoreCount = () => {};
+
// ---------------------------------------------------------------------------
-// Section shell — the "what it knows" half of the Pulse page.
+// One memory list, on its own screen behind a Pulse tile.
// ---------------------------------------------------------------------------
-export default function MemorySection() {
- const [tab, setTab] = useState<MemoryTab>("decisions");
- // Each tab reports its row count so the tab labels can carry a live badge.
- // All tabs stay mounted (inactive ones hidden) so every count loads up
- // front; a tab's own edit/delete re-runs its refresh, which reports the new
- // length back here, keeping that tab's badge correct.
- const [counts, setCounts] = useState<Record<MemoryTab, number | null>>({
- decisions: null,
- initiatives: null,
- advice: null,
- corrections: null,
- history: null,
- });
- // History (Always in the loop) is the signed-in person's own notes: it goes
- // away for anyone with none to see (not signed in, not on the roster).
- const [historyEnabled, setHistoryEnabled] = useState<boolean | null>(null);
- // Stable per-tab callbacks — these are passed to the (always-mounted) tabs as
- // `onCount`, which lives in each tab's `refresh` useCallback deps. They MUST
- // keep a constant identity across renders, or the tab's refresh→useEffect
- // chain would re-fire every render and loop forever. (Do NOT inline a
- // `setCount(tab)` factory here.)
- const onCountDecisions = useCallback((n: number) => setCounts((c) => ({ ...c, decisions: n })), []);
- const onCountInitiatives = useCallback((n: number) => setCounts((c) => ({ ...c, initiatives: n })), []);
- const onCountAdvice = useCallback((n: number) => setCounts((c) => ({ ...c, advice: n })), []);
- const onCountCorrections = useCallback(
- (n: number) => setCounts((c) => ({ ...c, corrections: n })),
- [],
- );
- const onCountHistory = useCallback(
- (n: number | null) => setCounts((c) => ({ ...c, history: n })),
- [],
- );
- const onHistoryAvailable = useCallback((available: boolean) => setHistoryEnabled(available), []);
-
- useEffect(() => {
- if (historyEnabled === false && tab === "history") setTab("decisions");
- }, [historyEnabled, tab]);
-
- // `/memories?tab=corrections` (the chat chip after remember_fact) opens
- // that tab. Read once on mount from the URL, so the page needs no Suspense
- // boundary for useSearchParams.
- useEffect(() => {
- const wanted = new URLSearchParams(window.location.search).get("tab");
- if (wanted && (MEMORY_TABS as readonly string[]).includes(wanted)) setTab(wanted as MemoryTab);
- }, []);
-
- const tabs: MemoryTab[] = MEMORY_TABS.filter((t) => !(t === "history" && historyEnabled === false));
+export default function MemoryList({ view }: { view: MemoryView }) {
+ // History (Always in the loop) is the signed-in person's own notes; someone
+ // with none to see (not signed in, not on the roster) gets a plain message.
+ const [historyAvailable, setHistoryAvailable] = useState(true);
+ const onHistoryAvailable = useCallback((available: boolean) => setHistoryAvailable(available), []);
return (
- <div>
- <SectionTabs
- label="Memory"
- className="mb-4"
- active={tab}
- onChange={setTab}
- tabs={tabs.map((t) => ({
- id: t,
- label: t.charAt(0).toUpperCase() + t.slice(1),
- badge: counts[t],
- }))}
- />
-
- {/* All tabs stay mounted (inactive ones hidden) so every count loads. */}
- <div className="rounded-2xl border border-line bg-surface-elevated px-4 sm:px-5 py-1">
- <div className={tab === "decisions" ? "" : "hidden"}>
- <DecisionsTab onCount={onCountDecisions} />
- </div>
- <div className={tab === "initiatives" ? "" : "hidden"}>
- <InitiativesTab onCount={onCountInitiatives} />
- </div>
- <div className={tab === "advice" ? "" : "hidden"}>
- <AdviceTab onCount={onCountAdvice} />
- </div>
- <div className={tab === "corrections" ? "" : "hidden"}>
- <CorrectionsTab onCount={onCountCorrections} />
- </div>
- <div className={tab === "history" ? "" : "hidden"}>
- <HistoryTab onCount={onCountHistory} onAvailable={onHistoryAvailable} />
- </div>
- </div>
+ <div className="rounded-2xl border border-line bg-surface-elevated px-4 sm:px-5 py-1">
+ {view === "decisions" && <DecisionsTab onCount={ignoreCount} />}
+ {view === "initiatives" && <InitiativesTab onCount={ignoreCount} />}
+ {view === "advice" && <AdviceTab onCount={ignoreCount} />}
+ {view === "corrections" && <CorrectionsTab onCount={ignoreCount} />}
+ {view === "history" &&
+ (historyAvailable ? (
+ <HistoryTab onCount={ignoreCount} onAvailable={onHistoryAvailable} />
+ ) : (
+ <EmptyState message="There are no notes for you here. They're kept for people on the People list, once they're signed in." />
+ ))}
</div>
);
}
diff --git a/packages/ui/src/components/memories/PulseHeader.tsx b/packages/ui/src/components/memories/PulseHeader.tsx
index c3ad8f4f..e6648fa9 100644
--- a/packages/ui/src/components/memories/PulseHeader.tsx
+++ b/packages/ui/src/components/memories/PulseHeader.tsx
@@ -7,7 +7,10 @@ import {
listDecisions,
listInitiatives,
listScheduledActions,
+ type Advice,
type DailyActivityCount,
+ type Decision,
+ type Initiative,
type ScheduledAction,
type WorkspaceMode,
} from "@/lib/api";
@@ -24,41 +27,40 @@ import {
LivePulse,
STAT_VALUE_TONE,
Skeleton,
- StatTile,
groupByRhythm,
metaFor,
type StatTone,
} from "./shared";
-// The Pulse page's at-a-glance numbers and its "heartbeat" — a
-// GitHub-contributions-style heatmap of the Executive's self-initiated
-// activity over the last 90 days. Up front sit three headline numbers (beats
-// today, next beat, memories); the rest (rhythm counts and the vitals derived
-// from the heatmap: streaks, totals, trend) sit under "More stats". Every
-// metric is derived from data the page already needs (pending scheduled
-// actions + the three memory lists); only the per-day heatmap requires its own
-// endpoint, since /today/activity returns the last-N items, not a daily
-// timeline. What peer memory learned about the signed-in person is theirs
-// alone (Settings → About you), so it is not counted here.
+// The Pulse page's heartbeat card: a GitHub-contributions-style heatmap of
+// the Executive's self-initiated activity over the last 90 days, beside three
+// headline numbers (done today, the next thing it will do, days in a row).
+// The rest (rhythm counts and the vitals derived from the heatmap: streaks,
+// totals, trend) sit under "More detail" in the same card. Every metric is
+// derived from data the page already needs (pending scheduled actions + the
+// three memory lists, which the memory tiles reuse); only the per-day heatmap
+// requires its own endpoint, since /today/activity returns the last-N items,
+// not a daily timeline. What peer memory learned about the signed-in person
+// is theirs alone (Settings → About you), so it is not counted here.
const HEATMAP_DAYS = 90;
interface HeaderData {
pending: ScheduledAction[];
- memoriesTotal: number;
- /** Initiatives with status "active" — solo's stand-in for dept check-ins. */
- activeProjects: number;
+ decisions: Decision[];
+ initiatives: Initiative[];
+ advice: Advice[];
heatmap: DailyActivityCount[];
}
export interface PulseData {
data: HeaderData | null;
loading: boolean;
- /** Headline numbers first, then the ones under "More stats". */
+ /** Headline numbers first, then the ones under "More detail". */
stats: { headline: Stat[]; more: Stat[] } | null;
}
-/** Loads everything the Pulse numbers and heatmap need, once per page. */
+/** Loads everything the Pulse numbers, heatmap and memory tiles need, once per page. */
export function usePulseData(): PulseData {
const { mode } = useWorkspace();
const [data, setData] = useState<HeaderData | null>(null);
@@ -78,12 +80,7 @@ export function usePulseData(): PulseData {
])
.then(([pending, decisions, initiatives, advice, daily]) => {
if (cancelled) return;
- setData({
- pending,
- memoriesTotal: decisions.length + initiatives.length + advice.length,
- activeProjects: initiatives.filter((i) => i.status === "active").length,
- heatmap: daily.days,
- });
+ setData({ pending, decisions, initiatives, advice, heatmap: daily.days });
})
.catch((err) => {
if ((err as Error)?.name !== "AbortError" && !cancelled) setData(null);
@@ -105,56 +102,67 @@ export function usePulseData(): PulseData {
return { data, loading, stats };
}
-/** The three headline numbers, with the rest folded under "More stats". */
-export function PulseSummary({ pulse }: { pulse: PulseData }) {
+/** The heatmap and its numbers in one card, with the rest under "More detail". */
+export function HeartbeatCard({ pulse }: { pulse: PulseData }) {
const { data, loading, stats } = pulse;
const [open, setOpen] = useState(false);
const moreId = useId();
return (
- <section aria-label="At a glance" className="space-y-3">
- <div className="grid grid-cols-3 gap-2 sm:gap-4">
- {loading || !stats
- ? Array.from({ length: 3 }).map((_, i) => (
- <div key={i} className="rounded-2xl border border-line bg-surface-elevated px-4 py-4 sm:px-5">
- <Skeleton className="h-4 w-20" />
- <Skeleton className="h-8 w-12 mt-2" />
- </div>
- ))
- : stats.headline.map((s) => (
- <StatTile key={s.label} label={s.label} value={s.value} hint={s.hint} tone={s.tone} />
- ))}
+ <section
+ aria-label="Heartbeat"
+ className="rounded-2xl border border-line bg-surface-elevated p-4 sm:p-6"
+ >
+ <div className="flex items-center justify-between gap-3 mb-4">
+ <div className="flex items-center gap-3">
+ <h2 className="text-lg font-semibold text-fg">Heartbeat</h2>
+ <LivePulse />
+ </div>
+ <button
+ type="button"
+ onClick={() => setOpen((o) => !o)}
+ aria-expanded={open}
+ aria-controls={moreId}
+ className="inline-flex h-10 items-center gap-1 rounded-xl px-2 text-sm font-semibold text-accent hover:bg-surface-overlay transition-colors"
+ >
+ {open ? "Less detail" : "More detail"}
+ <Icon
+ name="chevron-right"
+ size="w-4 h-4"
+ className={`transition-transform ${open ? "rotate-90" : ""}`}
+ />
+ </button>
</div>
- <button
- type="button"
- onClick={() => setOpen((o) => !o)}
- aria-expanded={open}
- aria-controls={moreId}
- className="inline-flex h-10 items-center gap-1.5 rounded-xl px-2 text-sm font-medium text-fg-muted hover:text-fg hover:bg-surface-overlay transition-colors"
- >
- <Icon
- name="chevron-right"
- size="w-4 h-4"
- className={`transition-transform ${open ? "rotate-90" : ""}`}
- />
- {open ? "Fewer stats" : "More stats"}
- </button>
+ <div className="flex flex-col-reverse md:flex-row md:items-center gap-5 md:gap-10">
+ <div className="shrink-0 min-w-0">
+ {loading || !data ? <Skeleton className="h-32 w-60" /> : <Heatmap days={data.heatmap} />}
+ </div>
+ <div className="grid grid-cols-3 gap-3 sm:gap-6 flex-1 min-w-0">
+ {loading || !stats
+ ? Array.from({ length: 3 }).map((_, i) => (
+ <div key={i}>
+ <Skeleton className="h-8 w-12" />
+ <Skeleton className="h-4 w-20 mt-2" />
+ </div>
+ ))
+ : stats.headline.map((s) => <Headline key={s.label} stat={s} />)}
+ </div>
+ </div>
{open && (
- <div id={moreId} className="rounded-2xl border border-line bg-surface-elevated p-4 sm:p-5 space-y-5">
+ <div id={moreId} className="border-t border-line mt-5 pt-5">
<div className={VITALS_GRID}>
- {loading || !stats
- ? Array.from({ length: 3 }).map((_, i) => <VitalSkeleton key={i} />)
- : stats.more.map((s) => (
+ {loading || !stats || !data ? (
+ Array.from({ length: VITALS_COUNT }).map((_, i) => <VitalSkeleton key={i} />)
+ ) : (
+ <>
+ {stats.more.map((s) => (
<Vital key={s.label} label={s.label} value={String(s.value)} hint={s.hint} tone={s.tone} />
))}
- </div>
- <div className="border-t border-line pt-5">
- <h3 className="text-sm font-semibold text-fg mb-3">
- Heartbeat, last {HEATMAP_DAYS} days
- </h3>
- {loading || !data ? <VitalsSkeleton /> : <Vitals days={data.heatmap} />}
+ <Vitals days={data.heatmap} />
+ </>
+ )}
</div>
</div>
)}
@@ -162,34 +170,18 @@ export function PulseSummary({ pulse }: { pulse: PulseData }) {
);
}
-/** The heatmap card at the top of the Heartbeat tab. */
-export function HeartbeatCard({ pulse }: { pulse: PulseData }) {
- const { data, loading } = pulse;
- const vitals = useMemo(() => (data ? deriveVitals(data.heatmap) : null), [data]);
+/** A big number with its label under it. */
+function Headline({ stat }: { stat: Stat }) {
return (
- <section className="rounded-2xl border border-line bg-surface-elevated p-4 sm:p-5">
- <div className="flex items-center justify-between gap-3 mb-4">
- <div className="flex items-baseline gap-2 flex-wrap">
- <h2 className="text-base font-semibold text-fg">Heartbeat</h2>
- <span className="text-sm text-fg-subtle">last {HEATMAP_DAYS} days</span>
- </div>
- <LivePulse />
- </div>
- <div className="flex flex-col md:flex-row md:items-center gap-5 md:gap-8">
- <div className="shrink-0 min-w-0">
- {loading || !data ? <Skeleton className="h-32 w-60" /> : <Heatmap days={data.heatmap} />}
- </div>
- {vitals && data && (
- <p className="text-[15px] text-fg-muted leading-relaxed">
- <span className="text-fg font-semibold">{plural(vitals.total, "beat")}</span> on{" "}
- {vitals.activeDays} of {data.heatmap.length} days.
- <br />
- Current streak:{" "}
- <span className="text-fg font-semibold">{plural(vitals.currentStreak.days, "day")}</span>
- </p>
- )}
+ <div className="min-w-0">
+ <div
+ className={`text-2xl sm:text-3xl font-bold tabular-nums leading-tight truncate ${STAT_VALUE_TONE[stat.tone ?? "default"]}`}
+ title={String(stat.value)}
+ >
+ {stat.value}
</div>
- </section>
+ <div className="text-sm text-fg-muted mt-1 line-clamp-2">{stat.label}</div>
+ </div>
);
}
@@ -205,33 +197,40 @@ export interface Stat {
}
function deriveStats(
- { pending, memoriesTotal, activeProjects, heatmap }: HeaderData,
+ { pending, initiatives, heatmap }: HeaderData,
mode: WorkspaceMode,
): { headline: Stat[]; more: Stat[] } {
const groups = groupByRhythm(pending);
const followups = pending.filter((a) => a.kind === "ad_hoc").length;
-
- // Soonest pending fire = the literal "next beat". One whose time has
- // passed is waiting for the scheduler's next tick, so it reads "Due now".
- const soonest = pending.reduce<ScheduledAction | null>((best, a) => {
- if (!best) return a;
- return a.run_at.localeCompare(best.run_at) < 0 ? a : best;
- }, null);
- const nextBeat = soonest
- ? { value: formatNextBeat(soonest.run_at) || "soon", hint: metaFor(soonest).label }
- : { value: "—", hint: "nothing scheduled" };
+ const activeProjects = initiatives.filter((i) => i.status === "active").length;
+
+ // The next thing it will do for you. Background scans fire every few
+ // minutes, so counting them would make this read "Due now" all day. One
+ // whose time has passed is waiting for the scheduler's next tick.
+ const soonest = pending
+ .filter((a) => metaFor(a).group !== "system")
+ .reduce<ScheduledAction | null>(
+ (best, a) => (!best || a.run_at.localeCompare(best.run_at) < 0 ? a : best),
+ null,
+ );
+ const nextLabel = soonest ? formatNextBeat(soonest.run_at) || "soon" : "";
+ const next: Stat = soonest
+ ? {
+ label: nextLabel === "Due now" ? `${nextName(soonest)} is due` : `until ${nextName(soonest)}`,
+ value: nextLabel === "Due now" ? "Now" : nextLabel.replace(/^in /, ""),
+ tone: "accent",
+ }
+ : { label: "nothing scheduled", value: "—", tone: "accent" };
// The heatmap is oldest → newest, so the last entry is today.
- const beatsToday = heatmap.length > 0 ? heatmap[heatmap.length - 1].count : 0;
-
- // The three episodic lists the Memory tabs show.
- const memories: Stat = { label: "Memories", value: memoriesTotal, hint: "decisions, initiatives, advice" };
+ const doneToday = heatmap.length > 0 ? heatmap[heatmap.length - 1].count : 0;
+ const streak = deriveVitals(heatmap).currentStreak.days;
return {
headline: [
- { label: "Beats today", value: beatsToday, tone: "emerald", hint: "actions fired" },
- { label: "Next beat", value: nextBeat.value, tone: "accent", hint: nextBeat.hint },
- memories,
+ { label: "done today", value: doneToday, tone: "emerald" },
+ next,
+ { label: streak === 1 ? "day in a row" : "days in a row", value: streak },
],
more: [
{ label: "Daily rhythms", value: groups.daily.length },
@@ -244,11 +243,19 @@ function deriveStats(
};
}
+/** "the morning brief", "a follow-up": the next action's name, in a sentence. */
+function nextName(action: ScheduledAction): string {
+ if (action.kind === "ad_hoc") return "a follow-up";
+ const label = metaFor(action).label;
+ return `the ${label.charAt(0).toLowerCase()}${label.slice(1)}`;
+}
+
// --------------------------------------------------------------------------- #
// Vitals — summary numbers beside the heatmap, derived from the same counts
// --------------------------------------------------------------------------- #
-const VITALS_COUNT = 6;
+// The three counts plus the six vitals.
+const VITALS_COUNT = 9;
const TREND_TONE: Record<TrendDirection, StatTone> = {
up: "emerald",
@@ -291,7 +298,7 @@ function Vitals({ days }: { days: DailyActivityCount[] }) {
const { trend } = v;
return (
- <div className={VITALS_GRID}>
+ <>
<Vital
label="Current streak"
value={plural(v.currentStreak.days, "day")}
@@ -307,7 +314,7 @@ function Vitals({ days }: { days: DailyActivityCount[] }) {
<Vital label="Longest streak" value={plural(v.longestStreak, "day")} />
<Vital
label={`${days.length}-day total`}
- value={plural(v.total, "beat")}
+ value={plural(v.total, "action")}
hint={`on ${v.activeDays} of ${days.length} days`}
/>
<Vital
@@ -325,7 +332,7 @@ function Vitals({ days }: { days: DailyActivityCount[] }) {
hint={trend.windowDays > 0 ? `${trend.current} vs ${trend.prior}` : undefined}
tone={TREND_TONE[trend.direction]}
/>
- </div>
+ </>
);
}
@@ -338,16 +345,6 @@ function VitalSkeleton() {
);
}
-function VitalsSkeleton() {
- return (
- <div className={VITALS_GRID}>
- {Array.from({ length: VITALS_COUNT }).map((_, i) => (
- <VitalSkeleton key={i} />
- ))}
- </div>
- );
-}
-
// --------------------------------------------------------------------------- #
// Heatmap — GitHub-contributions-style grid (weeks as columns, weekdays as rows)
// --------------------------------------------------------------------------- #
diff --git a/packages/ui/src/components/memories/PulseOverview.tsx b/packages/ui/src/components/memories/PulseOverview.tsx
new file mode 100644
index 00000000..263d3cbf
--- /dev/null
+++ b/packages/ui/src/components/memories/PulseOverview.tsx
@@ -0,0 +1,360 @@
+"use client";
+
+import Link from "next/link";
+import { useEffect, useMemo, useState, type ReactNode } from "react";
+import { getActivity, getHistory, listStandingFacts, type ActivityItem } from "@/lib/api";
+import Icon from "@/components/Icon";
+import { upcomingLabel, whenLabel, type MemoryView } from "@/lib/pulseView";
+import { SUMMARY_KINDS, activityLine } from "./CadenceSection";
+import type { PulseData } from "./PulseHeader";
+import { Skeleton, metaFor } from "./shared";
+
+// The Pulse overview's three blocks under the heartbeat: the next few things
+// the Executive will do (Coming up), the last few it did (Done recently), and
+// a tile per kind of memory. Each links to its full list on its own screen
+// (`/memories?tab=…`), so the overview stays short.
+
+const PREVIEW_ROWS = 4;
+
+/** A card with a heading and a "see all" link in its top-right corner. */
+function PreviewCard({
+ title,
+ href,
+ linkLabel,
+ children,
+}: {
+ title: string;
+ href: string;
+ linkLabel: string;
+ children: ReactNode;
+}) {
+ return (
+ <section className="rounded-2xl border border-line bg-surface-elevated p-4 sm:p-6 min-w-0">
+ <div className="flex items-center justify-between gap-3 mb-2">
+ <h2 className="text-lg font-semibold text-fg">{title}</h2>
+ <Link
+ href={href}
+ className="inline-flex h-10 items-center gap-1 rounded-xl px-2 -mr-2 text-sm font-semibold text-accent hover:bg-surface-overlay transition-colors"
+ >
+ {linkLabel}
+ <Icon name="chevron-right" size="w-4 h-4" />
+ </Link>
+ </div>
+ {children}
+ </section>
+ );
+}
+
+/** One row: a short "when" on the left, what on the right. */
+function PreviewRow({
+ when,
+ upcoming,
+ title,
+ detail,
+ chip,
+}: {
+ when: string;
+ upcoming: boolean;
+ title: string;
+ detail?: string;
+ chip?: string;
+}) {
+ return (
+ <li className="flex items-start gap-3 py-3 border-t border-line first:border-t-0">
+ <span
+ className={`w-20 shrink-0 text-sm tabular-nums pt-0.5 ${
+ upcoming ? "font-semibold text-accent" : "font-medium text-fg-subtle"
+ }`}
+ >
+ {when}
+ </span>
+ <div className="min-w-0 flex-1">
+ <div className="text-[15px] font-semibold text-fg break-words line-clamp-2" title={title}>
+ {title}
+ {chip && (
+ <span className="ml-2 inline-block rounded-md border border-accent/40 px-1.5 text-xs font-medium text-accent align-[1px]">
+ {chip}
+ </span>
+ )}
+ </div>
+ {detail && (
+ <div className="text-sm text-fg-muted mt-0.5 line-clamp-1" title={detail}>
+ {detail}
+ </div>
+ )}
+ </div>
+ </li>
+ );
+}
+
+function RowsSkeleton() {
+ return (
+ <div className="space-y-3 py-2">
+ <Skeleton className="h-10 w-full" />
+ <Skeleton className="h-10 w-full" />
+ <Skeleton className="h-10 w-5/6" />
+ </div>
+ );
+}
+
+function Empty({ children }: { children: ReactNode }) {
+ return <p className="py-6 text-[15px] text-fg-muted">{children}</p>;
+}
+
+/** The next few things it will do, background scans left out. */
+export function ComingUp({ pulse }: { pulse: PulseData }) {
+ const { data, loading } = pulse;
+ const next = useMemo(
+ () =>
+ (data?.pending ?? [])
+ .filter((a) => metaFor(a).group !== "system")
+ .sort((x, y) => x.run_at.localeCompare(y.run_at))
+ .slice(0, PREVIEW_ROWS),
+ [data],
+ );
+
+ return (
+ <PreviewCard title="Coming up" href="/memories?tab=schedule" linkLabel="Full schedule">
+ {loading ? (
+ <RowsSkeleton />
+ ) : next.length === 0 ? (
+ <Empty>Nothing scheduled yet. Briefs and check-ins appear here once they&apos;re set up.</Empty>
+ ) : (
+ <ul>
+ {next.map((a) => {
+ const meta = metaFor(a);
+ const followUp = a.kind === "ad_hoc";
+ return (
+ <PreviewRow
+ key={a.id}
+ upcoming
+ when={upcomingLabel(a.run_at)}
+ title={
+ followUp
+ ? a.intent_text
+ : meta.group === "departments" && a.department
+ ? `${meta.label}: ${a.department}`
+ : meta.label
+ }
+ detail={followUp ? undefined : meta.blurb}
+ chip={followUp ? "Follow-up" : undefined}
+ />
+ );
+ })}
+ </ul>
+ )}
+ </PreviewCard>
+ );
+}
+
+function capitalise(text: string): string {
+ return text.charAt(0).toUpperCase() + text.slice(1);
+}
+
+/** The last few things it did on its own. */
+export function DoneRecently() {
+ const [items, setItems] = useState<ActivityItem[] | null>(null);
+
+ useEffect(() => {
+ let cancelled = false;
+ getActivity(PREVIEW_ROWS)
+ .then((res) => {
+ if (!cancelled) setItems(res.items.slice(0, PREVIEW_ROWS));
+ })
+ .catch(() => {
+ if (!cancelled) setItems([]);
+ });
+ return () => {
+ cancelled = true;
+ };
+ }, []);
+
+ return (
+ <PreviewCard title="Done recently" href="/memories?tab=activity" linkLabel="All activity">
+ {items === null ? (
+ <RowsSkeleton />
+ ) : items.length === 0 ? (
+ <Empty>Nothing yet. What it does on its own shows up here as it happens.</Empty>
+ ) : (
+ <ul>
+ {items.map((it, i) => {
+ const { verb, subject } = activityLine(it);
+ // For summary-style kinds the subject IS the summary, so the
+ // detail line says only what kind of thing it was.
+ // A plain "action" has nothing to add beyond its summary.
+ const detail =
+ it.kind === "action"
+ ? undefined
+ : SUMMARY_KINDS.has(it.kind)
+ ? capitalise(verb.replace(/:$/, ""))
+ : capitalise(`${verb} ${subject}`);
+ return (
+ <PreviewRow
+ key={`${it.at}-${it.kind}-${i}`}
+ upcoming={false}
+ when={whenLabel(it.at)}
+ title={it.summary || detail || capitalise(verb)}
+ detail={it.summary ? detail : undefined}
+ />
+ );
+ })}
+ </ul>
+ )}
+ </PreviewCard>
+ );
+}
+
+interface TileSpec {
+ view: MemoryView;
+ label: string;
+ count: number | null;
+ detail?: string;
+ flag?: string;
+}
+
+function Tile({ spec, wide }: { spec: TileSpec; wide: boolean }) {
+ return (
+ <Link
+ href={`/memories?tab=${spec.view}`}
+ className={`group rounded-2xl border border-line bg-surface p-4 sm:p-5 min-w-0 hover:border-accent/50 hover:bg-surface-overlay transition-colors ${
+ wide ? "col-span-2 sm:col-span-1" : ""
+ }`}
+ >
+ <div className="text-3xl font-bold tabular-nums text-fg leading-tight">
+ {spec.count === null ? <Skeleton className="h-8 w-10" /> : spec.count}
+ </div>
+ <div className="mt-1 text-[15px] font-semibold text-fg">{spec.label}</div>
+ {spec.flag ? (
+ <span className="mt-2 inline-block rounded-full bg-amber-500/15 px-2.5 py-0.5 text-xs font-semibold text-amber-500">
+ {spec.flag}
+ </span>
+ ) : (
+ spec.detail && (
+ <div className="mt-1 text-sm text-fg-muted line-clamp-2" title={spec.detail}>
+ {spec.detail}
+ </div>
+ )
+ )}
+ </Link>
+ );
+}
+
+/** Newest first by an ISO timestamp field. */
+function newest<T>(rows: T[], at: (row: T) => string): T | null {
+ return rows.reduce<T | null>((best, r) => (!best || at(r) > at(best) ? r : best), null);
+}
+
+/** A tile per kind of memory; each opens its list. */
+export function MemoryTiles({ pulse }: { pulse: PulseData }) {
+ const { data } = pulse;
+ const [facts, setFacts] = useState<{ active: number; toApprove: number } | null>(null);
+ // undefined while loading; null when this viewer has no notes (the tile goes).
+ const [notes, setNotes] = useState<number | null | undefined>(undefined);
+
+ useEffect(() => {
+ let cancelled = false;
+ listStandingFacts()
+ .then((page) => {
+ if (cancelled) return;
+ setFacts({
+ active: page.facts.filter((f) => f.status === "active").length,
+ toApprove: page.can_review ? page.facts.filter((f) => f.status === "proposed").length : 0,
+ });
+ })
+ .catch(() => {
+ if (!cancelled) setFacts({ active: 0, toApprove: 0 });
+ });
+ getHistory()
+ .then((state) => {
+ if (!cancelled) setNotes(state ? state.notes.length : null);
+ })
+ .catch(() => {
+ if (!cancelled) setNotes(null);
+ });
+ return () => {
+ cancelled = true;
+ };
+ }, []);
+
+ const latestDecision = data ? newest(data.decisions, (d) => d.timestamp) : null;
+ const latestAdvice = data ? newest(data.advice, (a) => a.timestamp) : null;
+ const tiles: TileSpec[] = [
+ {
+ view: "decisions",
+ label: "Decisions",
+ count: data ? data.decisions.length : null,
+ detail: latestDecision ? `Latest: ${latestDecision.summary}` : undefined,
+ },
+ {
+ view: "initiatives",
+ label: "Projects",
+ count: data ? data.initiatives.length : null,
+ detail: data
+ ? `${data.initiatives.filter((i) => i.status === "active").length} active`
+ : undefined,
+ },
+ {
+ view: "advice",
+ label: "Advice",
+ count: data ? data.advice.length : null,
+ detail: latestAdvice ? `Latest: ${latestAdvice.query_summary}` : undefined,
+ },
+ {
+ view: "corrections",
+ label: "Facts you taught it",
+ count: facts ? facts.active : null,
+ flag: facts && facts.toApprove > 0 ? `${facts.toApprove} to approve` : undefined,
+ detail: "Used in every answer",
+ },
+ ];
+ if (notes !== null) {
+ tiles.push({
+ view: "history",
+ label: "Your notes",
+ count: notes ?? null,
+ detail: "Only you see these",
+ });
+ }
+
+ return (
+ <section aria-labelledby="pulse-memory-heading">
+ <h2 id="pulse-memory-heading" className="text-lg font-semibold text-fg mb-3">
+ What it remembers
+ </h2>
+ <div className="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 gap-3">
+ {tiles.map((t, i) => (
+ // An odd last tile spans the phone's two columns.
+ <Tile key={t.view} spec={t} wide={tiles.length % 2 === 1 && i === tiles.length - 1} />
+ ))}
+ </div>
+ </section>
+ );
+}
+
+/** A focused screen behind the overview: a way back, a title, one job. */
+export function FocusedScreen({
+ title,
+ description,
+ children,
+}: {
+ title: string;
+ description: string;
+ children: ReactNode;
+}) {
+ return (
+ <div className="space-y-5">
+ <header>
+ <Link
+ href="/memories"
+ className="inline-flex h-10 items-center gap-1 rounded-xl px-2 -ml-2 text-sm font-semibold text-accent hover:bg-surface-overlay transition-colors"
+ >
+ <Icon name="arrow-left" size="w-4 h-4" />
+ Pulse
+ </Link>
+ <h1 className="text-2xl sm:text-3xl font-bold tracking-tight text-fg mt-1">{title}</h1>
+ <p className="text-[15px] text-fg-muted mt-1.5 max-w-2xl">{description}</p>
+ </header>
+ {children}
+ </div>
+ );
+}
diff --git a/packages/ui/src/components/memories/PulsePage.tsx b/packages/ui/src/components/memories/PulsePage.tsx
index 69d655f0..9a0be9ab 100644
--- a/packages/ui/src/components/memories/PulsePage.tsx
+++ b/packages/ui/src/components/memories/PulsePage.tsx
@@ -1,12 +1,13 @@
"use client";
-import { useEffect, useState } from "react";
+import { useEffect, useRef } from "react";
import { useRouter, useSearchParams } from "next/navigation";
-import SectionTabs from "@/components/ui/SectionTabs";
+import { isMemoryView, pulseViewFor, type PulseView } from "@/lib/pulseView";
import RhythmSection, { FollowUpsCard, RecentActivity } from "./CadenceSection";
-import MemorySection, { MEMORY_TABS } from "./MemorySection";
-import { HeartbeatCard, PulseSummary, usePulseData } from "./PulseHeader";
+import MemoryList from "./MemorySection";
+import { HeartbeatCard, usePulseData } from "./PulseHeader";
+import { ComingUp, DoneRecently, FocusedScreen, MemoryTiles } from "./PulseOverview";
// The Pulse page is the Executive's memory + heartbeat: what it knows
// (durable episodic memory) and the rhythm it runs on (recurring briefs,
@@ -14,82 +15,98 @@ import { HeartbeatCard, PulseSummary, usePulseData } from "./PulseHeader";
// built from data that already exists — episodic memory rows and the
// scheduled_actions queue grouped by `kind`.
//
-// Layout: three headline numbers (the rest under "More stats"), then two
-// tabs. Heartbeat holds the heatmap and Activity · Rhythm · Follow-ups;
-// Memory holds what it knows (decisions, initiatives, advice, corrections,
-// history). What it has learned about the signed-in person is theirs alone,
-// so it lives in Settings → About you, not here.
+// Layout: one overview with no tabs (the heartbeat card with its numbers,
+// Coming up beside Done recently, then a tile per kind of memory), and a
+// focused screen behind each link, picked by `?tab=` so the older tab links
+// still land (lib/pulseView.ts). What it has learned about the signed-in
+// person is theirs alone, so it lives in Settings → About you, not here.
-type PulseTab = "heartbeat" | "memory";
-type BeatView = "activity" | "rhythm" | "followups";
+const SCREENS: Record<Exclude<PulseView, "overview">, { title: string; description: string }> = {
+ schedule: {
+ title: "Schedule",
+ description: "Everything the Executive will do on its own, soonest first.",
+ },
+ activity: {
+ title: "Activity",
+ description: "What the Executive did on its own, newest first.",
+ },
+ decisions: {
+ title: "Decisions",
+ description: "Decisions picked up from your chats. Future answers build on them.",
+ },
+ initiatives: {
+ title: "Projects",
+ description: "The projects it's tracking, from planned to completed.",
+ },
+ advice: {
+ title: "Advice",
+ description: "Advice its specialists gave, by topic.",
+ },
+ corrections: {
+ title: "Facts you taught it",
+ description: "Facts and corrections you asked it to keep.",
+ },
+ history: {
+ title: "Your notes",
+ description: "What you said, in chat and in replies you approved. Only you see these.",
+ },
+};
export default function PulsePage() {
- const pulse = usePulseData();
const router = useRouter();
- // `/memories?tab=corrections` (the chat chip after remember_fact) and the
- // other memory tab names open the Memory tab; MemorySection picks the
- // inner tab from the same parameter.
+ // `/memories?tab=corrections` (the chat chip after remember_fact),
+ // `?tab=history` (Settings) and the other screen names open that screen.
const wanted = useSearchParams().get("tab");
- const [tab, setTab] = useState<PulseTab>(() =>
- wanted === "memory" || (MEMORY_TABS as readonly string[]).includes(wanted ?? "")
- ? "memory"
- : "heartbeat",
- );
- const [beatView, setBeatView] = useState<BeatView>("activity");
+ const view = pulseViewFor(wanted);
+ const top = useRef<HTMLDivElement>(null);
+
// The People tab moved to Settings → About you; old links follow it there.
useEffect(() => {
if (wanted === "people") router.replace("/settings/memory");
}, [router, wanted]);
- const pending = pulse.data?.pending;
- const followups = pending ? pending.filter((a) => a.kind === "ad_hoc").length : null;
+ // Moving between the overview and a screen starts at the top.
+ useEffect(() => {
+ top.current?.scrollIntoView({ block: "start" });
+ }, [view]);
return (
- <div className="max-w-5xl mx-auto px-4 sm:px-6 py-6 sm:py-8 space-y-6">
+ <div ref={top} className="max-w-5xl mx-auto px-4 sm:px-6 py-6 sm:py-8 space-y-6">
+ {view === "overview" ? (
+ <Overview />
+ ) : (
+ <FocusedScreen {...SCREENS[view]}>
+ {view === "schedule" && (
+ <div className="space-y-5">
+ <RhythmSection />
+ <FollowUpsCard />
+ </div>
+ )}
+ {view === "activity" && <RecentActivity />}
+ {isMemoryView(view) && <MemoryList view={view} />}
+ </FocusedScreen>
+ )}
+ </div>
+ );
+}
+
+/** Loaded each time it's shown, so counts reflect edits made on a list. */
+function Overview() {
+ const pulse = usePulseData();
+ return (
+ <>
<header>
<h1 className="text-2xl sm:text-3xl font-bold tracking-tight text-fg">Pulse</h1>
<p className="text-[15px] text-fg-muted mt-1.5 max-w-2xl">
- What the Executive knows, and the rhythm it runs on — the briefs,
- reflections, and check-ins that fire on their own while you&apos;re away.
+ What your Executive does on its own, and what it remembers.
</p>
</header>
-
- <PulseSummary pulse={pulse} />
-
- <SectionTabs
- label="Pulse"
- active={tab}
- onChange={setTab}
- tabs={[
- { id: "heartbeat", label: "Heartbeat" },
- { id: "memory", label: "Memory" },
- ]}
- />
-
- {tab === "heartbeat" && (
- <div className="space-y-5">
- <HeartbeatCard pulse={pulse} />
- <SectionTabs
- label="Heartbeat"
- active={beatView}
- onChange={setBeatView}
- tabs={[
- { id: "activity", label: "Activity" },
- { id: "rhythm", label: "Rhythm" },
- { id: "followups", label: "Follow-ups", badge: followups },
- ]}
- />
- {beatView === "activity" && <RecentActivity />}
- {beatView === "rhythm" && <RhythmSection />}
- {beatView === "followups" && <FollowUpsCard />}
- </div>
- )}
-
- {/* Kept mounted while hidden so its tab counts load once and its
- `?tab=` deep link is read on first render. */}
- <div className={tab === "memory" ? "" : "hidden"}>
- <MemorySection />
+ <HeartbeatCard pulse={pulse} />
+ <div className="grid gap-6 md:grid-cols-2">
+ <ComingUp pulse={pulse} />
+ <DoneRecently />
</div>
- </div>
+ <MemoryTiles pulse={pulse} />
+ </>
);
}
diff --git a/packages/ui/src/components/memories/shared.tsx b/packages/ui/src/components/memories/shared.tsx
index 84564bdc..7ec78d63 100644
--- a/packages/ui/src/components/memories/shared.tsx
+++ b/packages/ui/src/components/memories/shared.tsx
@@ -3,7 +3,7 @@
// sections — and the redesigned PulseHeader — can reuse them without
// duplication. Holds three things: domain/format helpers, the scheduled-action
// "rhythm" taxonomy (used by both the header stat strip and CadenceSection),
-// and a handful of presentational primitives (StatTile, LivePulse, etc.).
+// and a handful of presentational primitives (LivePulse, SectionHeading, etc.).
import Icon, { type IconName } from "@/components/Icon";
import type { ScheduledAction, WorkspaceMode } from "@/lib/api";
@@ -173,29 +173,6 @@ export const STAT_VALUE_TONE: Record<StatTone, string> = {
amber: "text-amber-500",
};
-/** A single at-a-glance metric: label, big number, optional hint. */
-export function StatTile({
- label,
- value,
- hint,
- tone = "default",
-}: {
- label: string;
- value: string | number;
- hint?: string;
- tone?: StatTone;
-}) {
- return (
- <div className="rounded-2xl border border-line bg-surface-elevated px-3 py-3 sm:px-5 sm:py-4 min-w-0">
- <div className="text-sm font-medium text-fg-muted leading-snug">{label}</div>
- <div className={`mt-1 text-2xl sm:text-3xl font-bold tracking-tight tabular-nums leading-tight break-words ${STAT_VALUE_TONE[tone]}`}>
- {value}
- </div>
- {hint && <div className="text-sm text-fg-subtle mt-0.5 leading-snug line-clamp-2">{hint}</div>}
- </div>
- );
-}
-
/**
* "Live" indicator: a beating emerald dot + optional label. The ping animation
* is disabled under `prefers-reduced-motion` via Tailwind's `motion-reduce`
diff --git a/packages/ui/src/lib/pulseView.ts b/packages/ui/src/lib/pulseView.ts
new file mode 100644
index 00000000..9c0f6101
--- /dev/null
+++ b/packages/ui/src/lib/pulseView.ts
@@ -0,0 +1,86 @@
+// Pure helpers for the Pulse page: which screen a `?tab=` link opens, and the
+// short "when" labels on its Coming up and Done recently lists. Kept free of
+// React so scripts/pulseView.test.mjs can run them under plain node.
+
+/** The Pulse overview, or one of the focused screens it links to. */
+export type PulseView =
+ | "overview"
+ | "schedule"
+ | "activity"
+ | "decisions"
+ | "initiatives"
+ | "advice"
+ | "corrections"
+ | "history";
+
+export const MEMORY_VIEWS = ["decisions", "initiatives", "advice", "corrections", "history"] as const;
+export type MemoryView = (typeof MEMORY_VIEWS)[number];
+
+/**
+ * The screen a `?tab=` value opens. The page used to have tabs, so older
+ * links (the chat chip's `?tab=corrections`, Settings' `?tab=history`, the
+ * old Heartbeat views) still land on the matching screen; anything else is
+ * the overview.
+ */
+export function pulseViewFor(tab: string | null | undefined): PulseView {
+ switch (tab) {
+ case "schedule":
+ case "rhythm":
+ case "followups":
+ return "schedule";
+ case "activity":
+ return "activity";
+ case "decisions":
+ case "initiatives":
+ case "advice":
+ case "corrections":
+ case "history":
+ return tab;
+ default:
+ return "overview";
+ }
+}
+
+export function isMemoryView(view: PulseView): view is MemoryView {
+ return (MEMORY_VIEWS as readonly string[]).includes(view);
+}
+
+const WEEKDAY = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
+const MONTH = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
+const DAY_MS = 86_400_000;
+
+/** "9 am", "6:30 pm" in local time; a no-break space keeps "am" with its time. */
+export function clockLabel(d: Date): string {
+ const h = d.getHours();
+ const m = d.getMinutes();
+ const hour = h % 12 === 0 ? 12 : h % 12;
+ return `${hour}${m ? `:${String(m).padStart(2, "0")}` : ""}\u00a0${h < 12 ? "am" : "pm"}`;
+}
+
+function startOfDay(d: Date): number {
+ return new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime();
+}
+
+/**
+ * A short label for when something happened or will happen, in local time:
+ * the clock time today ("6 pm"), "Yesterday", a weekday and time within the
+ * coming week ("Fri 9 am"), a weekday within the past week ("Tue"), else the
+ * date ("Oct 3"). Empty for an unparseable time.
+ */
+export function whenLabel(iso: string, now: Date = new Date()): string {
+ const d = new Date(iso);
+ if (Number.isNaN(d.getTime())) return "";
+ const days = Math.round((startOfDay(d) - startOfDay(now)) / DAY_MS);
+ if (days === 0) return clockLabel(d);
+ if (days === -1) return "Yesterday";
+ if (days > 0 && days < 7) return `${WEEKDAY[d.getDay()]} ${clockLabel(d)}`;
+ if (days < 0 && days > -7) return WEEKDAY[d.getDay()];
+ return `${MONTH[d.getMonth()]} ${d.getDate()}`;
+}
+
+/** whenLabel for something still to come: one already due reads "Now". */
+export function upcomingLabel(iso: string, now: Date = new Date()): string {
+ const at = new Date(iso).getTime();
+ if (!Number.isNaN(at) && at <= now.getTime()) return "Now";
+ return whenLabel(iso, now);
+}