AI-powered virtual executive team — a single coherent executive persona backed by 8 specialist agents (FastAPI + Next.js).
fix(ui): show last period's count instead of a signed change on Done for you (#552)
Rufus15964d9f8703
diff --git a/packages/ui/scripts/valueSummary.test.mjs b/packages/ui/scripts/valueSummary.test.mjsindex 06061d2b..c21625f9 100644--- a/packages/ui/scripts/valueSummary.test.mjs+++ b/packages/ui/scripts/valueSummary.test.mjs@@ -1,6 +1,6 @@import assert from "node:assert/strict";import test from "node:test";-import { deltaLabel, headline, visibleLines } from "../src/lib/valueSummary.ts";+import { headline, periodNames, visibleLines } from "../src/lib/valueSummary.ts";const line = (key, count, previous = 0) => ({ key, label: key, count, previous });@@ -16,11 +16,21 @@ test("headline names the first three non-zero lines in order", () => {assert.equal(headline([line("reports", 0)]), "");});-test("deltaLabel compares with the period before", () => {- assert.equal(deltaLabel(5, 2), "+3");- assert.equal(deltaLabel(1, 4), "−3");- assert.equal(deltaLabel(2, 2), "same");- assert.equal(deltaLabel(0, 0), "");+test("periodNames names the month shown and the one before", () => {+ assert.deepEqual(periodNames("month", "October 2026"), {+ current: "October",+ previous: "September",+ previousShort: "Sep",+ heading: "October",+ });+ assert.equal(periodNames("month", "January 2027").previous, "December");+});++test("periodNames names a week against the week before", () => {+ const names = periodNames("week", "Week of 12 October");+ assert.equal(names.current, "Week of 12 October");+ assert.equal(names.previousShort, "Week before");+ assert.equal(names.heading, "the week of 12 October");});test("visibleLines drops lines that are zero in both periods", () => {diff --git a/packages/ui/src/components/memories/ValueSection.tsx b/packages/ui/src/components/memories/ValueSection.tsxindex c1c09665..05f82c62 100644--- a/packages/ui/src/components/memories/ValueSection.tsx+++ b/packages/ui/src/components/memories/ValueSection.tsx@@ -4,7 +4,7 @@ import Link from "next/link";import { useEffect, useState } from "react";import Icon from "@/components/Icon";import { getValueSummary, type ValueSummary } from "@/lib/api";-import { deltaLabel, headline, visibleLines } from "@/lib/valueSummary";+import { headline, periodNames, visibleLines } from "@/lib/valueSummary";import { Skeleton } from "./shared";// What the Executive did for the owner this month (GET /today/value): the@@ -67,7 +67,8 @@ export function ValueScreen() {const [period, setPeriod] = useState<Period>("month");const [offset, setOffset] = useState(0);const { summary, error } = useValueSummary(period, offset);- const before = period === "month" ? "last month" : "last week";++ const names = (s: ValueSummary) => periodNames(s.period, s.label);function pick(next: Period) {setPeriod(next);@@ -128,26 +129,36 @@ export function ValueScreen() {{visibleLines(summary.lines).length === 0 ? (<p className="text-[15px] text-fg-muted">Nothing counted for {summary.label}.</p>) : (- <table className="w-full text-[15px]">- <thead>- <tr className="text-left text-sm text-fg-subtle">- <th className="font-medium pb-2">What it did</th>- <th className="font-medium pb-2 text-right">Count</th>- <th className="font-medium pb-2 text-right">vs {before}</th>- </tr>- </thead>- <tbody>- {visibleLines(summary.lines).map((l) => (- <tr key={l.key} className="border-t border-line">- <td className="py-2.5 text-fg">{l.label}</td>- <td className="py-2.5 text-right tabular-nums font-semibold text-fg">{l.count}</td>- <td className="py-2.5 text-right tabular-nums text-fg-muted">- {deltaLabel(l.count, l.previous)}- </td>+ <>+ <h2 className="text-sm font-medium text-fg-subtle mb-1 sm:hidden">+ What it did in {names(summary).heading}+ </h2>+ <table className="w-full text-[15px]">+ <thead className="max-sm:sr-only">+ <tr className="text-left text-sm text-fg-subtle">+ <th className="font-medium pb-2">What it did</th>+ <th className="font-medium pb-2 pl-3 text-right">{names(summary).current}</th>+ <th className="font-medium pb-2 pl-3 text-right">{names(summary).previous}</th></tr>- ))}- </tbody>- </table>+ </thead>+ <tbody>+ {visibleLines(summary.lines).map((l) => (+ <tr key={l.key} className="border-t border-line max-sm:first:border-t-0">+ <td className="py-3 text-fg">{l.label}</td>+ <td className="py-3 pl-3 text-right align-middle">+ <span className="block text-2xl leading-tight font-bold tabular-nums text-fg">{l.count}</span>+ <span className="block text-sm tabular-nums text-fg-muted sm:hidden">+ {names(summary).previousShort} {l.previous}+ </span>+ </td>+ <td className="py-3 pl-3 text-right tabular-nums text-fg-muted max-sm:hidden">+ {l.previous}+ </td>+ </tr>+ ))}+ </tbody>+ </table>+ </>)}</section>{summary.deliverables.length > 0 && (diff --git a/packages/ui/src/lib/valueSummary.ts b/packages/ui/src/lib/valueSummary.tsindex a092f9bf..9da86089 100644--- a/packages/ui/src/lib/valueSummary.ts+++ b/packages/ui/src/lib/valueSummary.ts@@ -35,12 +35,34 @@ export function headline(lines: ValueLineLike[], max = 3): string {return parts.join(", ");}-/** "+3", "−2" or "same" against the period before; "" when both are zero. */-export function deltaLabel(count: number, previous: number): string {- if (count === 0 && previous === 0) return "";- const diff = count - previous;- if (diff === 0) return "same";- return diff > 0 ? `+${diff}` : `−${Math.abs(diff)}`;+const MONTHS = [+ "January", "February", "March", "April", "May", "June",+ "July", "August", "September", "October", "November", "December",+];++/** How the screen names the period shown and the one before it, from the+ * summary's label ("October 2026", "Week of 12 October"): `current` and+ * `previous` head the columns, `previousShort` goes before last period's+ * count on a phone row ("Sep"), and `heading` follows "What it did in". */+export function periodNames(+ period: "month" | "week",+ label: string,+): { current: string; previous: string; previousShort: string; heading: string } {+ if (period === "month") {+ const i = MONTHS.findIndex((m) => label.startsWith(m));+ const month = MONTHS[i];+ const prev = MONTHS[(i + 11) % 12];+ if (month && prev) {+ return { current: month, previous: prev, previousShort: prev.slice(0, 3), heading: month };+ }+ return { current: "This month", previous: "Month before", previousShort: "Month before", heading: label };+ }+ return {+ current: label || "This week",+ previous: "Week before",+ previousShort: "Week before",+ heading: label ? `the ${label.charAt(0).toLowerCase()}${label.slice(1)}` : "this week",+ };}/** Lines with something in this period or the one before; the rest is noise. */