AI-powered virtual executive team — a single coherent executive persona backed by 8 specialist agents (FastAPI + Next.js).
feat(ui): sum up Home under At a glance with more tiles (#633)
Rufus6d20d9c73383
diff --git a/packages/core/openexecutive/guide/prebuilt/today.json b/packages/core/openexecutive/guide/prebuilt/today.jsonindex 161cd48d..300e8325 100644--- a/packages/core/openexecutive/guide/prebuilt/today.json+++ b/packages/core/openexecutive/guide/prebuilt/today.json@@ -1,7 +1,7 @@{"section_id": "today","title": "Today / Morning Brief",- "markdown": "**What it is:** A single screen of *what needs you right now* — the proactive digest the Executive prepares so you're not the one chasing status. In the app it's **Home**, the screen the app opens on.\n\n**What it does:**\n\n- Opens with a greeting, one line summing up the day (click a part of it — *2 awaiting reply*, *1 department at risk* — to open that list), and an **Ask your Executive anything…** box that starts a chat. On a quiet day the line names one **Move today:** instead.\n- Puts what's waiting on your call up front under **Needs you**: the first card large, the next two below it, and **Show N more** for the rest.\n- Gathers everything else under **Everything else** as a row of count tiles — **Departments**, **People**, **Across the team** (waiting on someone else), **Under way**, **Handled**, **Monitoring**, and **Across your clients** when you look after client companies — shown only when they have something in them. Click a tile to open its full list in a side panel.\n- The **Departments** tile shows each department's goal health — on-track, at-risk, or off-track — with the at-risk goals called out and who each is on. Goals with no department appear there too, as **Other goals**; click it to open **Goals**.\n- The **People** tile lists people with open items, their reply counts, SLA status, and whether they're on leave.\n- In your first week, a **Your first week** card at the top asks for one goal with a date (**Set a goal** opens the add form on **Goals**) until you have one, lists up to two things the Executive found when it researched your company and industry during setup, and links to the **Watch list** with what it keeps watching for you. It goes away after seven days, or sooner once you have a goal and there's nothing to show.\n- **Right now**, above **Needs you**, is the Executive's read of the day, rewritten as things change: when it was updated, one line on what matters most, and the top points, each with the time it came in. Points that came in since you last looked get a green dot, with *N new since …* beside the title. **See the whole picture** opens all of it in a side panel: what's new, what's still open, the **Move today** line, what's next on your calendar and, under **Earlier today**, the morning brief you were sent. Tap a point there to talk it through.\n- If your latest morning brief, end-of-day digest or weekly review couldn't be sent to you, a line at the top says why and what to connect. It goes away once that's fixed.\n- When your morning brief or end-of-day digest left out lines that named people or figures the Executive couldn't match to your data, **Left out of your brief** under **Needs you** lists them for a day. **Hide** clears it.\n- With **Delegate → Act as me → What it writes as you** at **Draft replies automatically**, the replies the Executive wrote as you for mail that needs you come first in **Needs you**, marked **Reply waiting** (or **Follow-up waiting** when nobody answered an email you sent). Only you see them.\n- With **Read my calendar** on, a meeting invite from someone you know appears as a card in **Needs you**, marked **Invite**: the meeting, when it is, who invited you and anything on your calendar it clashes with (only the times). **Accept** or **Decline** answers it in your own calendar, and your calendar lets them know; **Dismiss** removes the card without answering. While replies are still being learned, ticking **Accept from <name> on its own next time** before **Accept** lets it accept their invites on its own when nothing clashes. If your calendar sign-in can't answer invites yet, the card says to connect again under **Read my calendar** instead. Only you see them.\n- Actions the Executive suggested from your email (a meeting, a message to someone, a new contact, a rename or move of files in your Drive) appear as cards in **Needs you**, each spelled out with a box to untick. **Approve** does the ticked ones (**Approve N** when you untick some), ticking **Do this on its own next time** first (shown while it is still learning) also lets it do that kind of action on its own from now on, and **Dismiss** drops the card. Only you see them.\n- A send or edit a team member asked for in chat that their department held waits as a card marked **Waiting on you**, with the reason and the exact details. **Approve** carries it out as shown; **Decline** drops it.\n- An item a team member asked the Executive to raise starts with **Raised by** and their name. It goes to a person or a department, never to the whole company. Team members can dismiss only items assigned to them; the owner can dismiss any item.\n- Under **Take the lead**, something the Executive wanted to do on its own that you haven't allowed yet comes as a card: **Approve** does it once (tick **Do this on its own next time** first and it does the same thing with the same person on its own from now on), **Edit** changes it first (tick **Do it like this next time** to keep your edit as an example and allow it), and **Decline** drops it.\n- Surfaces proposals and alerts you can click to open a chat thread with full context.\n\n**How to use:**\n\n1. Click **Home** in the sidebar (or the Open Executive logo). On a phone, **Home** is the first button in the bar at the bottom.\n2. Work **Needs you** from the top. Each card has one main button and **Discuss**; everything else is in the card's **⋯** menu:\n - **Approve** — accept the recommendation; the Executive carries it out right away. A line at the top of **Needs you** shows it working and then done, with a link to the chat where it did the work. If it didn't work, **Try again** is on that line. Usually the main button.\n - **Discuss** — open a chat with the context already filled in.\n - **Edit & approve** (in **⋯**) — reword the action first, then **Send approval**; your text is used exactly as written.\n - **Dismiss** (in **⋯**) — drop it and stay on Home. When the Executive thinks a card is stale, **Dismiss** is the main button instead.\n - **Snooze until …** (in **⋯**) — three hours from now (while that is still today), **tomorrow 9:00**, or **Monday 9:00** (not offered on a Sunday). The card leaves Home and comes back on its own then; *Snoozed until …* with **Undo** under **Needs you** brings it back now.\n - **Nudge *name*** — the main button when the best move is chasing someone for a reply; **Run *workflow*** when the best move is a workflow.\n - **Open *name*'s page** (in **⋯**) — the person the item is waiting on.\n - A **Monitoring** signal leads with **Discuss**; its **⋯** has **Dismiss signal**.\n3. Some cards are simpler: when a scheduled run didn't finish (a department check-in, or a workflow you set to run on a schedule), its card's main button is **Run again**, which runs it now and sends the result where it normally goes (**Open the run** in **⋯** shows what went wrong); a document card's main button is **Open document** (**Mark reviewed** is in its **⋯**, and **Open in app** when the document lives in another app), and a calendar-booking card books (or declines) the meeting directly when you click Approve or Dismiss. Only the person a booking was sent to for approval, or the owner, can approve or decline it.\n4. Keep it tidy from the **⋯** next to **Needs you**: **Dismiss N older than 7 days** clears stale items, and **Re-check relevance** asks the Executive to review every open item now.\n5. Open the **Departments** tile and click a department to ask for its status in chat.\n6. Work the replies waiting to be sent (they come first in **Needs you**). Each card starts closed: who wrote (and *Address not verified* when the address couldn't be confirmed), a line or two on what they asked and what your draft says, how many things are left to decide and who it goes to, with **Send** when nothing is left (or **Review** when something is) and **Dismiss**. Click the card or **Review** to open it. Open, it shows **Decide before sending** first, then **Your draft** with who it goes to, **What they wrote** (click to open), and **More** (click to open) with **Reply to**, the questions you already answered and *Why it waited for you* when Handle it for me left it for you. **Decide before sending** is (what the draft leaves for you to answer, with short answers to tap. Tap one, or **Something else…** to type your own, and the draft is rewritten with it; the new words are lightly marked. For a time it can offer free slots from your calendar, when Read my calendar is on, and for a document one from your documents to say you'll send. **Send** waits until each of these is answered, or until you change the words with **Edit**) and any warnings. The buttons:\n - **Send** asks once, naming who the reply goes to, then **Send now** sends it from your own mailbox (Gmail or Outlook). If the recipients changed or they wrote again since, it asks again, says what changed, and offers **Send anyway**.\n - **Reply to <name> on its own next time** (a tick shown while replies are still being learned): tick it before **Send** and replies to that person go on their own from now on while Handle it for me is on.\n - **Edit** changes the words right on the card; **Save** keeps them (and updates the draft in your mailbox when it is kept there too). When it is learning how you write, **Do it like this next time (if you changed it)** appears as you send.\n - **Open in Gmail** (or Outlook) opens the draft there, when it is kept in your Drafts.\n - **Dismiss** drops the card, and deletes the draft from your Drafts unless you changed it there.\n On a server, Send needs signed sign-ins; until they're set up, send from your mailbox. A card goes away on its own once you send or delete the draft in your mailbox, or reply yourself, and after 7 days.\n\n**Example:** in a Discuss thread, just say *\"go ahead\"* to approve the proposal or *\"drop it\"* to dismiss it — no need to go back to the card. (Calendar bookings still need the Approve button. When you asked for the meeting in a chat, its card is under that reply too.)\n\n**Just for yourself?** If you use Open Executive just for yourself (**Settings → Workspace → Personal**), Home leaves out the team parts: there are no Departments, People or Across the team tiles — everything that needs a decision is in **Needs you**. When a goal is slipping, the summary line at the top says how many goals are at risk; click it to open **Goals**. Instead, the tiles are **Due soon**, **Your projects** and **This week's review**, each opening its list in a side panel. **Your projects** lists the projects the Executive is tracking for you. Click **Done** when one is finished, or **Drop** to stop tracking it (it asks first, and removes the project from Pulse). **Due soon** lists what you've promised by a date and what others have asked of you, due in the next week — say *\"I'll send Northwind the proposal by Friday\"* in the web chat or your own Slack or Discord and it shows up here, and the Executive reminds you when it's due. Click **Done** once it's handled; **All open items** opens the full list. **Top three today**, right under **Needs you**, shows the three things to focus on today — the same three your morning brief opens with — each with a free slot in today's working hours when the Executive can read your calendar. **This week's review** shows your latest weekly review: when it ran and next week's top three. Click **Read the review** to see all of it.\n\nYour morning brief also opens with a **top three for today**, picked from what's overdue or due, goals that are slipping and the projects you're driving. When Google Workspace is connected and the Executive can read your calendar (it is your own account, or you shared your calendar with it), each of the three gets a free slot in today's working hours and the brief lists today's meetings; otherwise the three come without times. Every Friday afternoon (in your time zone) a **weekly review** arrives the same way: your goals graded by area, what's due or overdue, projects that went quiet, the week's decisions, a few older decisions to look back on, and next week's top three. Both also show up on Home (see above), so you see them even when no chat app or email is connected. When it asks how an older decision turned out, just tell the Executive in the web chat or your own Slack or Discord and it records the outcome against that decision.\n\n*Note: proposals are routed to the right person automatically based on who has authority over them.*",+ "markdown": "**What it is:** A single screen of *what needs you right now* — the proactive digest the Executive prepares so you're not the one chasing status. In the app it's **Home**, the screen the app opens on.\n\n**What it does:**\n\n- Opens with a greeting, one line summing up the day (click a part of it — *2 awaiting reply*, *1 department at risk* — to open that list), and an **Ask your Executive anything…** box that starts a chat. On a quiet day the line names one **Move today:** instead.\n- Puts what's waiting on your call up front under **Needs you**: the first card large, the next two below it, and **Show N more** for the rest.\n- Sums up the rest under **At a glance** as a row of count tiles, shown only when they have something in them: **Act as me** (what it sent or accepted for you this week), **Due soon** (what you owe by a date), **Goals** (how many, and how many are at risk), **Workflows** (yours that run on a schedule, and how often they ran this week), **Watching** (what's on your watch list, and any new signals), **Handled**, **Departments**, **People**, **Across the team** (waiting on someone else), **Under way**, and **Across your clients** when you look after client companies. Click a tile to open its list in a side panel, or its page (**Act as me**, **Goals**, **Workflows**, **Watch list**).\n- The **Departments** tile appears once you have departments. It shows each department's goal health — on-track, at-risk, or off-track — with the at-risk goals called out and who each is on. Goals with no department appear there too, as **Other goals**; click it to open **Goals**.\n- The **People** tile lists people with open items, their reply counts, SLA status, and whether they're on leave.\n- In your first week, a **Your first week** card at the top asks for one goal with a date (**Set a goal** opens the add form on **Goals**) until you have one, lists up to two things the Executive found when it researched your company and industry during setup, and links to the **Watch list** with what it keeps watching for you. It goes away after seven days, or sooner once you have a goal and there's nothing to show.\n- **Right now**, above **Needs you**, is the Executive's read of the day, rewritten as things change: when it was updated, one line on what matters most, and the top points, each with the time it came in. Points that came in since you last looked get a green dot, with *N new since …* beside the title. **See the whole picture** opens all of it in a side panel: what's new, what's still open, the **Move today** line, what's next on your calendar and, under **Earlier today**, the morning brief you were sent. Tap a point there to talk it through.\n- If your latest morning brief, end-of-day digest or weekly review couldn't be sent to you, a line at the top says why and what to connect. It goes away once that's fixed.\n- When your morning brief or end-of-day digest left out lines that named people or figures the Executive couldn't match to your data, **Left out of your brief** under **Needs you** lists them for a day. **Hide** clears it.\n- With **Delegate → Act as me → What it writes as you** at **Draft replies automatically**, the replies the Executive wrote as you for mail that needs you come first in **Needs you**, marked **Reply waiting** (or **Follow-up waiting** when nobody answered an email you sent). Only you see them.\n- With **Read my calendar** on, a meeting invite from someone you know appears as a card in **Needs you**, marked **Invite**: the meeting, when it is, who invited you and anything on your calendar it clashes with (only the times). **Accept** or **Decline** answers it in your own calendar, and your calendar lets them know; **Dismiss** removes the card without answering. While replies are still being learned, ticking **Accept from <name> on its own next time** before **Accept** lets it accept their invites on its own when nothing clashes. If your calendar sign-in can't answer invites yet, the card says to connect again under **Read my calendar** instead. Only you see them.\n- Actions the Executive suggested from your email (a meeting, a message to someone, a new contact, a rename or move of files in your Drive) appear as cards in **Needs you**, each spelled out with a box to untick. **Approve** does the ticked ones (**Approve N** when you untick some), ticking **Do this on its own next time** first (shown while it is still learning) also lets it do that kind of action on its own from now on, and **Dismiss** drops the card. Only you see them.\n- A send or edit a team member asked for in chat that their department held waits as a card marked **Waiting on you**, with the reason and the exact details. **Approve** carries it out as shown; **Decline** drops it.\n- An item a team member asked the Executive to raise starts with **Raised by** and their name. It goes to a person or a department, never to the whole company. Team members can dismiss only items assigned to them; the owner can dismiss any item.\n- Under **Take the lead**, something the Executive wanted to do on its own that you haven't allowed yet comes as a card: **Approve** does it once (tick **Do this on its own next time** first and it does the same thing with the same person on its own from now on), **Edit** changes it first (tick **Do it like this next time** to keep your edit as an example and allow it), and **Decline** drops it.\n- Surfaces proposals and alerts you can click to open a chat thread with full context.\n\n**How to use:**\n\n1. Click **Home** in the sidebar (or the Open Executive logo). On a phone, **Home** is the first button in the bar at the bottom.\n2. Work **Needs you** from the top. Each card has one main button and **Discuss**; everything else is in the card's **⋯** menu:\n - **Approve** — accept the recommendation; the Executive carries it out right away. A line at the top of **Needs you** shows it working and then done, with a link to the chat where it did the work. If it didn't work, **Try again** is on that line. Usually the main button.\n - **Discuss** — open a chat with the context already filled in.\n - **Edit & approve** (in **⋯**) — reword the action first, then **Send approval**; your text is used exactly as written.\n - **Dismiss** (in **⋯**) — drop it and stay on Home. When the Executive thinks a card is stale, **Dismiss** is the main button instead.\n - **Snooze until …** (in **⋯**) — three hours from now (while that is still today), **tomorrow 9:00**, or **Monday 9:00** (not offered on a Sunday). The card leaves Home and comes back on its own then; *Snoozed until …* with **Undo** under **Needs you** brings it back now.\n - **Nudge *name*** — the main button when the best move is chasing someone for a reply; **Run *workflow*** when the best move is a workflow.\n - **Open *name*'s page** (in **⋯**) — the person the item is waiting on.\n - A **Monitoring** signal leads with **Discuss**; its **⋯** has **Dismiss signal**.\n3. Some cards are simpler: when a scheduled run didn't finish (a department check-in, or a workflow you set to run on a schedule), its card's main button is **Run again**, which runs it now and sends the result where it normally goes (**Open the run** in **⋯** shows what went wrong); a document card's main button is **Open document** (**Mark reviewed** is in its **⋯**, and **Open in app** when the document lives in another app), and a calendar-booking card books (or declines) the meeting directly when you click Approve or Dismiss. Only the person a booking was sent to for approval, or the owner, can approve or decline it.\n4. Keep it tidy from the **⋯** next to **Needs you**: **Dismiss N older than 7 days** clears stale items, and **Re-check relevance** asks the Executive to review every open item now.\n5. Open the **Departments** tile and click a department to ask for its status in chat.\n6. Work the replies waiting to be sent (they come first in **Needs you**). Each card starts closed: who wrote (and *Address not verified* when the address couldn't be confirmed), a line or two on what they asked and what your draft says, how many things are left to decide and who it goes to, with **Send** when nothing is left (or **Review** when something is) and **Dismiss**. Click the card or **Review** to open it. Open, it shows **Decide before sending** first, then **Your draft** with who it goes to, **What they wrote** (click to open), and **More** (click to open) with **Reply to**, the questions you already answered and *Why it waited for you* when Handle it for me left it for you. **Decide before sending** is (what the draft leaves for you to answer, with short answers to tap. Tap one, or **Something else…** to type your own, and the draft is rewritten with it; the new words are lightly marked. For a time it can offer free slots from your calendar, when Read my calendar is on, and for a document one from your documents to say you'll send. **Send** waits until each of these is answered, or until you change the words with **Edit**) and any warnings. The buttons:\n - **Send** asks once, naming who the reply goes to, then **Send now** sends it from your own mailbox (Gmail or Outlook). If the recipients changed or they wrote again since, it asks again, says what changed, and offers **Send anyway**.\n - **Reply to <name> on its own next time** (a tick shown while replies are still being learned): tick it before **Send** and replies to that person go on their own from now on while Handle it for me is on.\n - **Edit** changes the words right on the card; **Save** keeps them (and updates the draft in your mailbox when it is kept there too). When it is learning how you write, **Do it like this next time (if you changed it)** appears as you send.\n - **Open in Gmail** (or Outlook) opens the draft there, when it is kept in your Drafts.\n - **Dismiss** drops the card, and deletes the draft from your Drafts unless you changed it there.\n On a server, Send needs signed sign-ins; until they're set up, send from your mailbox. A card goes away on its own once you send or delete the draft in your mailbox, or reply yourself, and after 7 days.\n\n**Example:** in a Discuss thread, just say *\"go ahead\"* to approve the proposal or *\"drop it\"* to dismiss it — no need to go back to the card. (Calendar bookings still need the Approve button. When you asked for the meeting in a chat, its card is under that reply too.)\n\n**Just for yourself?** If you use Open Executive just for yourself (**Settings → Workspace → Personal**), Home leaves out the team parts: there are no Departments, People or Across the team tiles — everything that needs a decision is in **Needs you**. When a goal is slipping, the summary line at the top says how many goals are at risk; click it to open **Goals**. Instead, it adds the **Your projects** and **This week's review** tiles, each opening its list in a side panel. **Your projects** lists the projects the Executive is tracking for you. Click **Done** when one is finished, or **Drop** to stop tracking it (it asks first, and removes the project from Pulse). **Due soon** (on every Home) lists what you've promised by a date and what others have asked of you, due in the next week — say *\"I'll send Northwind the proposal by Friday\"* in the web chat or your own Slack or Discord and it shows up here, and the Executive reminds you when it's due. Click **Done** once it's handled; **All open items** opens the full list. **Top three today**, right under **Needs you**, shows the three things to focus on today — the same three your morning brief opens with — each with a free slot in today's working hours when the Executive can read your calendar. **This week's review** shows your latest weekly review: when it ran and next week's top three. Click **Read the review** to see all of it.\n\nYour morning brief also opens with a **top three for today**, picked from what's overdue or due, goals that are slipping and the projects you're driving. When Google Workspace is connected and the Executive can read your calendar (it is your own account, or you shared your calendar with it), each of the three gets a free slot in today's working hours and the brief lists today's meetings; otherwise the three come without times. Every Friday afternoon (in your time zone) a **weekly review** arrives the same way: your goals graded by area, what's due or overdue, projects that went quiet, the week's decisions, a few older decisions to look back on, and next week's top three. Both also show up on Home (see above), so you see them even when no chat app or email is connected. When it asks how an older decision turned out, just tell the Executive in the web chat or your own Slack or Discord and it records the outcome against that decision.\n\n*Note: proposals are routed to the right person automatically based on who has authority over them.*","mermaid": null,"generated_at": "2026-10-21T00:00:00Z"}diff --git a/packages/ui/scripts/glance.test.mjs b/packages/ui/scripts/glance.test.mjsnew file mode 100644index 00000000..3b0953f0--- /dev/null+++ b/packages/ui/scripts/glance.test.mjs@@ -0,0 +1,63 @@+import assert from "node:assert/strict";+import test from "node:test";+import {+ goalTotals,+ handledThisWeek,+ realDepartments,+ scheduledNames,+ scheduledWorkflows,+ watching,+} from "../src/lib/glance.ts";++const NOW = new Date("2026-10-25T12:00:00Z");+const daysAgo = (n) => new Date(NOW.getTime() - n * 24 * 60 * 60 * 1000).toISOString();++const dept = (slug, goals, atRisk = 0, offTrack = 0) => ({+ slug,+ title: slug || "Other goals",+ authority_level: "draft",+ goal_count: goals,+ at_risk_count: atRisk,+ off_track_count: offTrack,+ awaiting_count: 0,+});++test("the row of goals with no department is not a department", () => {+ const rows = [dept("", 2), dept("sales", 1)];+ assert.deepEqual(realDepartments(rows).map((d) => d.slug), ["sales"]);+ assert.deepEqual(realDepartments([dept("", 3)]), []);+});++test("goal totals count every goal, with or without a department", () => {+ assert.deepEqual(goalTotals([dept("", 2, 1), dept("sales", 3, 0, 1)]), { goals: 5, atRisk: 2 });+ assert.deepEqual(goalTotals([]), { goals: 0, atRisk: 0 });+});++test("Act as me counts what it handled in the last seven days", () => {+ const replies = [{ sent_at: daysAgo(1) }, { sent_at: daysAgo(6.9) }, { sent_at: daysAgo(8) }, { sent_at: "" }];+ assert.equal(handledThisWeek(replies, NOW), 2);+});++test("workflows count your active scheduled ones and only their runs", () => {+ const defs = [+ { name: "weekly", cadence: "weekly", is_active: true },+ { name: "paused", cadence: "daily", is_active: false },+ { name: "manual", cadence: null },+ ];+ const runs = [+ { workflow_name: "weekly", created_at: daysAgo(2) },+ { workflow_name: "weekly", created_at: daysAgo(10) },+ { workflow_name: "morning_brief", created_at: daysAgo(1) },+ ];+ assert.deepEqual(scheduledNames(defs), ["weekly"]);+ assert.deepEqual(scheduledWorkflows(defs, runs, NOW), { scheduled: 1, runsThisWeek: 1 });+});++test("watching counts enabled entries and those that fired this week", () => {+ const items = [+ { enabled: true, last_fired_at: daysAgo(3) },+ { enabled: true, last_fired_at: null },+ { enabled: false, last_fired_at: daysAgo(1) },+ ];+ assert.deepEqual(watching(items, NOW), { watched: 2, firedThisWeek: 1 });+});diff --git a/packages/ui/src/components/Briefing.tsx b/packages/ui/src/components/Briefing.tsxindex bcbaff89..a3c89fe9 100644--- a/packages/ui/src/components/Briefing.tsx+++ b/packages/ui/src/components/Briefing.tsx@@ -23,6 +23,7 @@ import type { AlertApproval } from "@/lib/approvals";import { briefingSummary, greeting, type SummaryPart } from "@/lib/briefingSummary";import { FIRST_RUN_LINKS } from "@/lib/firstRun";import { principalIdOf } from "@/lib/dueSoon";+import { goalTotals, realDepartments } from "@/lib/glance";import { groupHandled } from "@/lib/handled";import {BRIEFING_REFRESH_INTERVAL_MS,@@ -48,6 +49,7 @@ import {} from "./briefing/AwarenessPanels";import ApprovedRow from "./briefing/ApprovedRow";import FirstWeekCard from "./briefing/FirstWeekCard";+import { useGlance } from "./briefing/Glance";import { RightNowBody, RightNowCard } from "./briefing/RightNow";import { isHeldAction } from "./briefing/HeldActionCard";import { isLeadTraining } from "./briefing/LeadTrainingCard";@@ -78,9 +80,9 @@ export { ProposalCard };export { DeptCard } from "./briefing/TeamPanels";// Home, the briefing: a greeting and one summary line, the Ask box, the-// "Needs you" queue as large cards, then a row of count tiles — one per-// awareness section with something in it — each opening its full list in a-// side panel. Today's written brief ("What's going on") opens in a panel too.+// "Needs you" queue as large cards, then "At a glance": a row of count tiles —+// one per section with something in it — each opening its full list in a+// side panel or its page. Today's written brief ("What's going on") opens in a panel too.// "Needs you" shows this many cards before a "Show N more" toggle.const NEEDS_YOU_VISIBLE = 3;@@ -101,7 +103,12 @@ type PanelKey =| "weeklyReview";interface Tile {- key: PanelKey;+ key: string;+ // A tile opens its side panel, or else goes to its page.+ panel?: PanelKey;+ href?: string;+ // The small heading over the number.+ kicker: string;value: string;label: string;sub: string;@@ -411,7 +418,10 @@ export default function Briefing({ onContinue, showHeader = false, firstName, ba// Solo's own sections load on their own, so their tiles can count them.const principalId = solo ? principalIdOf(today?.people ?? []) : null;const projects = useActiveProjects(solo);- const openLoops = useOpenLoops(principalId);+ // Due soon is the caller's own (the owner's, in solo).+ const loopOwnerId = solo ? principalId : (today?.caller_person_id ?? null);+ const openLoops = useOpenLoops(loopOwnerId);+ const glance = useGlance(today !== null);const weeklyReview = useWeeklyReview(solo);// Hand an Ask-box question to chat as the user's own words.@@ -443,6 +453,11 @@ export default function Briefing({ onContinue, showHeader = false, firstName, baconst attentionDepts = activeDepts.filter((d) => d.at_risk_count > 0 || d.off_track_count > 0 || d.awaiting_count > 0,);+ // The Departments tile counts only real departments, not the row that holds+ // the goals with no department.+ const activeRealDepts = realDepartments(activeDepts);+ const attentionRealDepts = realDepartments(attentionDepts);+ const goals = goalTotals(departments);const isQuiet =today !== null &&@@ -489,13 +504,16 @@ export default function Briefing({ onContinue, showHeader = false, firstName, baconst practiceClients = today?.practice_clients ?? [];// Summary-line inputs. Solo has no Departments or People tiles, so it says- // how many goals need attention instead, linking to /goals.+ // how many goals need attention instead, linking to /goals. A team counts+ // its departments at risk, and the goals with no department on their own.const deptAtRiskCount = solo? 0- : attentionDepts.filter((d) => d.at_risk_count > 0 || d.off_track_count > 0).length;+ : attentionRealDepts.filter((d) => d.at_risk_count > 0 || d.off_track_count > 0).length;const peopleNeedReply = solo ? 0 : (today?.people ?? []).filter((p) => p.status === "needs_reply").length;const peopleOverdue = solo ? 0 : (today?.people ?? []).filter((p) => p.overdue).length;- const goalsAtRisk = solo ? departments.reduce((n, d) => n + d.at_risk_count + d.off_track_count, 0) : 0;+ const goalsAtRisk = solo+ ? goals.atRisk+ : goalTotals(departments.filter((d) => d.slug === "")).atRisk;// The top three words a commitment as the owner's ("you").const principalName =(principalId != null && today?.people.find((p) => p.id === principalId)?.full_name) || "";@@ -514,97 +532,159 @@ export default function Briefing({ onContinue, showHeader = false, firstName, ba}): [];- // The count tiles — only those with something to show.+ // At a glance — only the tiles with something to show, what's yours first.const tiles: Tile[] = [];if (today) {+ if (glance.actAsMe)+ tiles.push({+ key: "actAsMe",+ href: "/settings/act-as-me",+ kicker: "Act as me",+ value: String(glance.actAsMe),+ label: "handled for you",+ sub: "this week",+ subTone: "emerald",+ });+ const view = openLoops.view;+ if (loopOwnerId != null && (openLoops.error || (view && (view.items.length > 0 || view.later > 0)))) {+ const overdue = view?.items.filter((i) => i.overdue).length ?? 0;+ tiles.push({+ key: "dueSoon",+ panel: "dueSoon",+ kicker: "Due soon",+ value: String(view?.items.length ?? "–"),+ label: "open loops",+ sub: overdue > 0 ? `${overdue} overdue` : view && view.items.length > 0 ? "this week" : `${view?.later ?? 0} later`,+ subTone: overdue > 0 ? "amber" : undefined,+ });+ }+ if (goals.goals > 0)+ tiles.push({+ key: "goals",+ href: "/goals",+ kicker: "Goals",+ value: String(goals.goals),+ label: goals.goals === 1 ? "goal" : "goals",+ sub: goals.atRisk > 0 ? `${goals.atRisk} at risk` : "on track",+ subTone: goals.atRisk > 0 ? "amber" : "emerald",+ });+ if (glance.workflows && glance.workflows.scheduled > 0) {+ const runs = glance.workflows.runsThisWeek;+ tiles.push({+ key: "workflows",+ href: "/jobs",+ kicker: "Workflows",+ value: String(glance.workflows.scheduled),+ label: "on a schedule",+ sub: runs > 0 ? `${runs} ${runs === 1 ? "run" : "runs"} this week` : "no runs yet this week",+ });+ }+ // Watching: what's on the watchlist, with the signals waiting to be read.+ const signals = monitoringProposals.length;+ if ((glance.watching && glance.watching.watched > 0) || signals > 0) {+ const fired = glance.watching?.firedThisWeek ?? 0;+ tiles.push({+ key: "watching",+ ...(signals > 0 ? { panel: "monitoring" as const } : { href: "/watchlist" }),+ kicker: "Watching",+ value: String(glance.watching?.watched || signals),+ label: glance.watching?.watched ? "things" : signals === 1 ? "signal" : "signals",+ sub:+ signals > 0+ ? `${signals} new ${signals === 1 ? "signal" : "signals"}`+ : fired > 0+ ? `${fired} spoke up this week`+ : "quiet",+ subTone: signals > 0 ? "amber" : undefined,+ });+ }+ if (handledRows.length > 0)+ tiles.push({+ key: "handled",+ panel: "handled",+ kicker: "Handled",+ value: String(handledRows.length),+ label: "by the Executive",+ sub: "since your last brief",+ subTone: "emerald",+ });if (solo) {- const view = openLoops.view;- if (principalId != null && (openLoops.error || (view && (view.items.length > 0 || view.later > 0)))) {- const overdue = view?.items.filter((i) => i.overdue).length ?? 0;- tiles.push({- key: "dueSoon",- value: String(view?.items.length ?? "–"),- label: "Due soon",- sub: overdue > 0 ? `${overdue} overdue` : view && view.items.length > 0 ? "this week" : `${view?.later ?? 0} later`,- subTone: overdue > 0 ? "amber" : undefined,- });- }if (projects.error || (projects.projects && projects.projects.length > 0)) {tiles.push({key: "projects",+ panel: "projects",+ kicker: "Your projects",value: String(projects.projects?.length ?? "–"),- label: "Your projects",- sub: "active",+ label: "active",+ sub: "",});}if (weeklyReview) {tiles.push({key: "weeklyReview",+ panel: "weeklyReview",+ kicker: "This week's review",value: "Ready",- label: "This week's review",+ label: "next week's top three",sub: reviewRanLabel(weeklyReview.completed_at) || weeklyReview.period || "",});}} else {- const deptValue = attentionDepts.length > 0 ? attentionDepts.length : activeDepts.length || departments.length;- tiles.push({- key: "departments",- value: String(deptValue),- label: "Departments",- sub:- attentionDepts.length > 0- ? deptAtRiskCount > 0- ? "at risk"- : "need attention"- : activeDepts.length > 0- ? "on track"- : "not set up yet",- subTone: attentionDepts.length > 0 ? "amber" : activeDepts.length > 0 ? "emerald" : undefined,- });+ // Only once departments are set up: the goals with no department are on+ // the Goals tile.+ if (activeRealDepts.length > 0)+ tiles.push({+ key: "departments",+ panel: "departments",+ kicker: "Departments",+ value: String(attentionRealDepts.length > 0 ? attentionRealDepts.length : activeRealDepts.length),+ label: "departments",+ sub:+ attentionRealDepts.length > 0 ? (deptAtRiskCount > 0 ? "at risk" : "need attention") : "on track",+ subTone: attentionRealDepts.length > 0 ? "amber" : "emerald",+ });if (showPeople && today) {const people = today.people;const busy = people.filter((p) => p.status === "needs_reply" || p.status === "awaiting").length;const s = peopleSummary(people);tiles.push({key: "people",+ panel: "people",+ kicker: "People",value: String(busy > 0 ? busy : people.length),- label: "People",+ label: busy > 0 ? "to follow up" : "people",sub: busy > 0 ? s.text : "all clear",subTone: s.hasOverdue ? "rose" : busy > 0 ? "amber" : "emerald",});}}if (otherProposals.length > 0)- tiles.push({ key: "team", value: String(otherProposals.length), label: "Across the team", sub: "with teammates" });+ tiles.push({+ key: "team",+ panel: "team",+ kicker: "Across the team",+ value: String(otherProposals.length),+ label: "with teammates",+ sub: "waiting on someone else",+ });if (inFlight.length > 0)tiles.push({key: "inFlight",+ panel: "inFlight",+ kicker: "Under way",value: String(inFlight.length),- label: "Under way",+ label: "in progress",sub: inFlightNext(inFlight),subTone: inFlight.some((f) => f.overdue) ? "amber" : undefined,});- if (handledRows.length > 0)- tiles.push({- key: "handled",- value: String(handledRows.length),- label: "Handled",- sub: "by the Executive",- subTone: "emerald",- });- if (monitoringProposals.length > 0)- tiles.push({- key: "monitoring",- value: String(monitoringProposals.length),- label: "Monitoring",- sub: monitoringProposals.length === 1 ? "signal" : "signals",- });if (practiceClients.length > 0)tiles.push({key: "clients",+ panel: "clients",+ kicker: "Across your clients",value: String(practiceClients.length),- label: "Across your clients",- sub: "parked clients",+ label: "parked clients",+ sub: "",});}@@ -930,30 +1010,45 @@ export default function Briefing({ onContinue, showHeader = false, firstName, ba)}{tiles.length > 0 && (- <section aria-labelledby="sec-everything-else" className="mb-8">- <h2 id="sec-everything-else" className="mb-3 text-lg font-semibold text-fg">- Everything else+ <section aria-labelledby="sec-at-a-glance" className="mb-8">+ <h2 id="sec-at-a-glance" className="mb-3 text-lg font-semibold text-fg">+ At a glance</h2><div className="grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4">- {tiles.map((t) => (- <button- key={t.key}- type="button"- onClick={() => setOpenPanel(t.key)}- aria-haspopup="dialog"- className="flex min-h-[7.5rem] flex-col items-start rounded-2xl border border-line bg-surface-elevated p-4 text-left transition-colors hover:border-line-strong hover:bg-surface-hover focus:outline-none focus-visible:ring-2 focus-visible:ring-accent/50"- >- <span className="text-2xl sm:text-3xl font-bold tracking-tight text-fg tabular-nums">- {t.value}- </span>- <span className="mt-1 text-[15px] font-medium text-fg">{t.label}</span>- {t.sub && (- <span className={`mt-0.5 text-sm ${t.subTone ? TONE_TEXT[t.subTone] : "text-fg-muted"}`}>- {t.sub}+ {tiles.map((t) => {+ const body = (+ <>+ <span className="text-sm text-fg-muted">{t.kicker}</span>+ <span className="mt-1 text-2xl sm:text-3xl font-bold tracking-tight text-fg tabular-nums">+ {t.value}</span>- )}- </button>- ))}+ <span className="mt-1 text-[15px] font-medium text-fg">{t.label}</span>+ {t.sub && (+ <span className={`mt-0.5 text-sm ${t.subTone ? TONE_TEXT[t.subTone] : "text-fg-muted"}`}>+ {t.sub}+ </span>+ )}+ </>+ );+ const cls =+ "flex min-h-[7.5rem] flex-col items-start rounded-2xl border border-line bg-surface-elevated p-4 text-left transition-colors hover:border-line-strong hover:bg-surface-hover focus:outline-none focus-visible:ring-2 focus-visible:ring-accent/50";+ const panel = t.panel;+ return panel ? (+ <button+ key={t.key}+ type="button"+ onClick={() => setOpenPanel(panel)}+ aria-haspopup="dialog"+ className={cls}+ >+ {body}+ </button>+ ) : (+ <Link key={t.key} href={t.href ?? "/"} className={cls}>+ {body}+ </Link>+ );+ })}</div></section>)}@@ -1047,6 +1142,14 @@ export default function Briefing({ onContinue, showHeader = false, firstName, ba><PracticeClientsPanelBody clients={practiceClients} /></SidePanel>+ <SidePanel+ open={openPanel === "dueSoon"}+ onClose={() => setOpenPanel(null)}+ title="Due soon"+ footer={loopOwnerId != null ? panelFooterLink(`/people/${loopOwnerId}`, "All open items") : undefined}+ >+ <DueSoonPanelBody state={openLoops} />+ </SidePanel>{solo && (<><SidePanel@@ -1057,14 +1160,6 @@ export default function Briefing({ onContinue, showHeader = false, firstName, ba><ProjectsPanelBody state={projects} /></SidePanel>- <SidePanel- open={openPanel === "dueSoon"}- onClose={() => setOpenPanel(null)}- title="Due soon"- footer={principalId != null ? panelFooterLink(`/people/${principalId}`, "All open items") : undefined}- >- <DueSoonPanelBody state={openLoops} />- </SidePanel>{weeklyReview && (<SidePanelopen={openPanel === "weeklyReview"}diff --git a/packages/ui/src/components/briefing/Glance.tsx b/packages/ui/src/components/briefing/Glance.tsxnew file mode 100644index 00000000..746678e6--- /dev/null+++ b/packages/ui/src/components/briefing/Glance.tsx@@ -0,0 +1,53 @@+"use client";++import { useEffect, useState } from "react";++import { getHandledReplies, listCustomWorkflows, listWatchlist, listWorkflowRuns } from "@/lib/api";+import { handledThisWeek, scheduledNames, scheduledWorkflows, watching } from "@/lib/glance";++// The counts behind Home's "At a glance" tiles that /today doesn't carry:+// what Act as me handled this week, your scheduled workflows, and the+// watchlist. Each is null when it can't be read (not allowed for this viewer,+// or the call failed), and its tile stays hidden.+export interface Glance {+ actAsMe: number | null;+ workflows: { scheduled: number; runsThisWeek: number } | null;+ watching: { watched: number; firedThisWeek: number } | null;+}++const NONE: Glance = { actAsMe: null, workflows: null, watching: null };++export function useGlance(enabled: boolean): Glance {+ const [glance, setGlance] = useState<Glance>(NONE);++ useEffect(() => {+ if (!enabled) return;+ const controller = new AbortController();+ let cancelled = false;+ const now = new Date();+ const set = (part: Partial<Glance>) => {+ if (!cancelled) setGlance((g) => ({ ...g, ...part }));+ };+ getHandledReplies(controller.signal)+ .then((replies) => set({ actAsMe: replies ? handledThisWeek(replies, now) : null }))+ .catch(() => {});+ // Each scheduled workflow's own runs: the unfiltered list is the latest+ // 100 of every workflow, which the system's own runs can fill.+ listCustomWorkflows()+ .then(async (defs) => {+ const names = scheduledNames(defs);+ const runs = (await Promise.all(names.map((name) => listWorkflowRuns(name)))).flat();+ set({ workflows: scheduledWorkflows(defs, runs, now) });+ })+ .catch(() => {});+ listWatchlist({ enabledOnly: true })+ .then((items) => set({ watching: watching(items, now) }))+ .catch(() => {});+ return () => {+ cancelled = true;+ controller.abort();+ };+ }, [enabled]);++ return glance;+}diff --git a/packages/ui/src/components/briefing/SoloPanels.tsx b/packages/ui/src/components/briefing/SoloPanels.tsxindex c236ac14..f6c9b60d 100644--- a/packages/ui/src/components/briefing/SoloPanels.tsx+++ b/packages/ui/src/components/briefing/SoloPanels.tsx@@ -23,8 +23,9 @@ import { reviewExcerpt, reviewRanLabel, topThreeSlot, topThreeWhy } from "@/lib/import { PanelIntro, RankBadge, TONE_TEXT } from "./shared";-// Solo-only parts of Home. Each loads its own data through a hook here, so-// the tile row can count it before its side panel is opened.+// Solo's parts of Home (Due soon is on every Home). Each loads its own data+// through a hook here, so the tile row can count it before its side panel is+// opened.// ── Your projects ─────────────────────────────────────────────────────────// The projects (initiatives) the Executive is tracking as active — the solodiff --git a/packages/ui/src/lib/glance.ts b/packages/ui/src/lib/glance.tsnew file mode 100644index 00000000..a38c47f8--- /dev/null+++ b/packages/ui/src/lib/glance.ts@@ -0,0 +1,57 @@+// Pure counting behind Home's "At a glance" tiles (components/Briefing.tsx,+// components/briefing/Glance.tsx). No React here so `npm test` can exercise+// it directly (scripts/glance.test.mjs).+import type { DepartmentBriefItem, DynamicWorkflowDef, HandledReply, WatchlistItem, WorkflowRunSummary } from "./api";++const WEEK_MS = 7 * 24 * 60 * 60 * 1000;++function withinWeek(iso: string | null | undefined, now: Date): boolean {+ if (!iso) return false;+ const t = Date.parse(iso);+ return Number.isFinite(t) && t <= now.getTime() && now.getTime() - t < WEEK_MS;+}++// The briefing's real departments. The row with slug "" holds the goals that+// have no department ("Other goals"); it is not a department.+export function realDepartments(departments: DepartmentBriefItem[]): DepartmentBriefItem[] {+ return departments.filter((d) => d.slug !== "");+}++// Every goal on the briefing, with or without a department.+export function goalTotals(departments: DepartmentBriefItem[]): { goals: number; atRisk: number } {+ let goals = 0;+ let atRisk = 0;+ for (const d of departments) {+ goals += d.goal_count;+ atRisk += d.at_risk_count + d.off_track_count;+ }+ return { goals, atRisk };+}++// What Act as me sent or accepted for you in the last seven days.+export function handledThisWeek(replies: HandledReply[], now: Date): number {+ return replies.filter((r) => withinWeek(r.sent_at, now)).length;+}++// The workflows of your own that run on a schedule.+export function scheduledNames(defs: DynamicWorkflowDef[]): string[] {+ return defs.filter((d) => d.is_active !== false && Boolean(d.cadence)).map((d) => d.name);+}++// Workflows of your own that run on a schedule, and how many times they ran+// this week (runs of anything else, like the system's own, don't count).+export function scheduledWorkflows(+ defs: DynamicWorkflowDef[],+ runs: WorkflowRunSummary[],+ now: Date,+): { scheduled: number; runsThisWeek: number } {+ const names = new Set(scheduledNames(defs));+ const runsThisWeek = runs.filter((r) => names.has(r.workflow_name) && withinWeek(r.created_at, now)).length;+ return { scheduled: names.size, runsThisWeek };+}++// What's on the watchlist, and how many of those spoke up this week.+export function watching(items: WatchlistItem[], now: Date): { watched: number; firedThisWeek: number } {+ const on = items.filter((i) => i.enabled);+ return { watched: on.length, firedThisWeek: on.filter((i) => withinWeek(i.last_fired_at, now)).length };+}