diff --git a/pm-stack/aggregator/src/assets/app.css b/pm-stack/aggregator/src/assets/app.css
index 44eadf3ec2..1df3b245e9 100644
--- a/pm-stack/aggregator/src/assets/app.css
+++ b/pm-stack/aggregator/src/assets/app.css
@@ -5130,11 +5130,6 @@ pre {
border-color: #d29922;
color: #e3b341;
}
-.badge.lapsed {
- background: #6e768133;
- border-color: #6e7681;
- color: #8b949e;
-}
.badge.conflict {
background: #bc8cff33;
border-color: #bc8cff;
@@ -6025,6 +6020,51 @@ nav {
.foot {
padding-bottom: 8px;
}
+.flow-scroll {
+ overflow-x: auto;
+}
+.flow-tp-bar {
+ fill: #58a6ff;
+}
+.flow-tp-value {
+ fill: #e6edf3;
+ font-size: 11px;
+}
+.flow-tp-week-label {
+ fill: #8b949e;
+ font-size: 9px;
+}
+.flow-axis {
+ stroke: #30363d;
+ stroke-width: 1;
+}
+.flow-tis-0 {
+ fill: #58a6ff;
+}
+.flow-tis-1 {
+ fill: #3fb950;
+}
+.flow-tis-2 {
+ fill: #d29922;
+}
+.flow-tis-3 {
+ fill: #bc8cff;
+}
+.flow-tis-4 {
+ fill: #f778ba;
+}
+.flow-tis-5 {
+ fill: #79c0ff;
+}
+html[data-theme="light"] .flow-tp-value {
+ fill: #1f2328;
+}
+html[data-theme="light"] .flow-tp-week-label {
+ fill: #59636e;
+}
+html[data-theme="light"] .flow-axis {
+ stroke: #d1d9e0;
+}
@layer base {
:where(:root),:root:has(input.theme-controller[value=dark]:checked),[data-theme=dark] {
color-scheme: dark;
diff --git a/pm-stack/aggregator/src/flow-charts.ts b/pm-stack/aggregator/src/flow-charts.ts
new file mode 100644
index 0000000000..7309e494b8
--- /dev/null
+++ b/pm-stack/aggregator/src/flow-charts.ts
@@ -0,0 +1,117 @@
+// Flow analytics charts (#4830, step 3 of the #1281 split): the
+// server-rendered charts for the #4829 flow-analytics JSON twin
+// (/api/flow-analytics.json). Rendering only — this module computes
+// nothing: every number it draws is read from the twin object the
+// endpoint serves, so the charts can never disagree with the JSON
+// (one computation path, #4829).
+//
+// Honesty rules, carried from the twin onto the page:
+// - The computation window is stated on the section (first/last
+// cutoff, complete cutoffs of total), never left implicit.
+// - Coverage gaps are named on the chart (cutoff + incomplete /
+// unavailable): intervals spanning a gap are excluded by the twin,
+// and the page says so instead of smoothing over them.
+// - A complete week with zero completions renders as a zero bar with
+// a visible 0 — preserved by the twin, never dropped here.
+
+import type { FlowAnalytics, FlowGroup, FlowWindow } from "./flow-analytics.ts";
+
+function esc(s: unknown): string {
+ return String(s ?? "")
+ .replace(/&/g, "&")
+ .replace(//g, ">")
+ .replace(/"/g, """)
+ .replace(/'/g, "'");
+}
+
+/** Days as the twin states them: integers plain, fractions to 2dp. */
+function fmtDays(v: number): string {
+ return Number.isInteger(v) ? String(v) : v.toFixed(2);
+}
+
+const TP_WIDTH = 560;
+const TP_HEIGHT = 110;
+const TP_BASELINE = 92;
+
+/** The stated window + named coverage gaps for the whole twin. */
+export function flowWindowHtml(window: FlowWindow): string {
+ if (window.fromCutoff === null || window.toCutoff === null) {
+ return `
Flow analytics window: no item history stored yet — no cutoffs, no charts.
`;
+ }
+ const gaps = window.gaps.length
+ ? `
Coverage gaps in this window: ${window.gaps
+ .map(
+ (g) =>
+ `${esc(g.cutoffAt)} (${g.unavailable ? "unavailable" : "incomplete"})`,
+ )
+ .join(", ")} — intervals spanning a gap are excluded from every number below; nothing is zero-filled or smoothed over.
`
+ : "";
+ return `
Computation window: ${esc(window.fromCutoff)} → ${esc(window.toCutoff)} · ${window.completeCutoffs} of ${window.cutoffCount} cutoffs complete. Source: /api/flow-analytics.json — the charts below render that JSON twin and nothing else.
${gaps}
`;
+}
+
+const TP_SLOT = 56;
+
+/** Weekly throughput bar chart for one group, from the twin series.
+ * The chart grows with the retained history (a full store holds a
+ * year or more of weekly cutoffs): every week keeps a full slot and
+ * its date label, and the container scrolls horizontally instead of
+ * squeezing labels together. No week is ever dropped or merged. */
+export function throughputChartHtml(group: FlowGroup): string {
+ const weeks = group.throughput;
+ if (weeks.length === 0) {
+ return `
`;
+}
+
+/** The full flow-analytics section for the Projects/Roadmap pages. */
+export function flowChartsHtml(analytics: FlowAnalytics): string {
+ const groups = analytics.groups.map(flowGroupHtml).join("");
+ return `
Flow analytics
${flowWindowHtml(analytics.window)}${groups || '
No groups observed in this window.
'}`;
+}
diff --git a/pm-stack/aggregator/src/render.ts b/pm-stack/aggregator/src/render.ts
index 493396ac22..adb555dd78 100644
--- a/pm-stack/aggregator/src/render.ts
+++ b/pm-stack/aggregator/src/render.ts
@@ -27,6 +27,8 @@ import { diffCoverage, staleIssueState, type CoverageSnapshotFile } from "./cove
import { DIGEST_SECTION_LIMIT, type Digest, type DigestKind } from "./digest.ts";
import { registryQueryString, type RegistryView } from "./registry-view.ts";
import { formatForecastSummary, type ForecastContract } from "./forecast-contract.ts";
+import type { FlowAnalytics } from "./flow-analytics.ts";
+import { flowChartsHtml } from "./flow-charts.ts";
import { latestInFamily, newClientToken, type DashAction } from "./actions.ts";
import { applyBoardDonePolicy, DONE_STRIP_RENDER_LIMIT, selectVisibleDoneCards } from "./board-policy.ts";
import { summarizeWipLanes } from "./wip-limits.ts";
@@ -1770,6 +1772,7 @@ export function renderRoadmap(
viewQuery = "",
briefs?: Map,
forecasts?: Map,
+ flowAnalytics?: FlowAnalytics,
): string {
// #1144: when the Grist rows and the Project's Kind=Epic pool items
// disagree, say so on the page itself — drift the reader can see,
@@ -1823,7 +1826,7 @@ export function renderRoadmap(
}
return layout(
"Roadmap",
- `
Roadmap
Grist's Program roadmap table at every grain — one data model, switchable horizon. Rows with a calendar date land on their day; quarter-labelled rows stay at quarter grain. Every row remains visible at every grain.
${chips}
${driftFlag}${horizonFlag}${body}`,
+ `
Roadmap
Grist's Program roadmap table at every grain — one data model, switchable horizon. Rows with a calendar date land on their day; quarter-labelled rows stay at quarter grain. Every row remains visible at every grain.
${chips}
${driftFlag}${horizonFlag}${body}${flowAnalytics ? flowChartsHtml(flowAnalytics) : ""}`,
provenance,
"/roadmap",
"",
@@ -6604,6 +6607,8 @@ export function renderProgram(
/** Prebuilt briefs (#1279), e.g. with comment activity folded in. */
briefs?: Map;
forecasts?: Map;
+ /** The #4829 flow twin the #4830 charts render on this page. */
+ flowAnalytics?: FlowAnalytics;
} | null,
): string {
const poolSectionHtml = poolSection
@@ -6632,7 +6637,7 @@ ${poolSummaryHtml(live)}
${orchestrationHtml(live)}
The PM dashboard's own record
This dashboard's architecture, what's built, what's next, and its long-term roadmap live on its project page: PM dashboard →. Its tracked issues, resolved live:
-${trackedTable(live.tracked)}${poolSectionHtml}`;
+${trackedTable(live.tracked)}${poolSectionHtml}${poolSection?.flowAnalytics ? flowChartsHtml(poolSection.flowAnalytics) : ""}`;
return layout(
"Program status",
body,
diff --git a/pm-stack/aggregator/src/server.ts b/pm-stack/aggregator/src/server.ts
index b96722f82f..4efd6c9dca 100644
--- a/pm-stack/aggregator/src/server.ts
+++ b/pm-stack/aggregator/src/server.ts
@@ -1700,6 +1700,9 @@ async function handler(req: Request): Promise {
orchestrationStatus,
});
const forecasts = (await allForecastContracts(pool)).byRef;
+ // #4830: the same twin /api/flow-analytics.json serves, computed
+ // the same way — the Roadmap charts render exactly this object.
+ const flowAnalytics = computeFlowAnalytics(await itemHistoryStore.readAll().catch(() => []));
const g = url.searchParams.get("h") ?? "quarter";
const grain: RoadmapGrain = GRAINS.has(g) ? (g as RoadmapGrain) : "quarter";
const resolved = await resolveView(url);
@@ -1731,6 +1734,7 @@ async function handler(req: Request): Promise {
viewQuery,
briefs,
forecasts,
+ flowAnalytics,
),
);
}
@@ -1768,6 +1772,7 @@ async function handler(req: Request): Promise {
viewQuery,
briefs,
forecasts,
+ flowAnalytics,
),
);
}
@@ -2037,6 +2042,10 @@ async function handler(req: Request): Promise {
identities: formOpts.identities,
briefs,
forecasts: (await allForecastContracts(viewPool)).byRef,
+ // #4830: the Projects page (merged into /program, #1497)
+ // renders the #4829 twin as charts, computed as the endpoint
+ // computes it.
+ flowAnalytics: computeFlowAnalytics(await itemHistoryStore.readAll().catch(() => [])),
}),
);
}
diff --git a/pm-stack/aggregator/src/ui.css b/pm-stack/aggregator/src/ui.css
index 79cb2d245f..bf43b0e92d 100644
--- a/pm-stack/aggregator/src/ui.css
+++ b/pm-stack/aggregator/src/ui.css
@@ -434,3 +434,19 @@ html[data-theme="dark"] a { color: #58a6ff; }
nav { z-index: 40; backdrop-filter: blur(6px); }
.theme-toggle-wrap { margin-left: auto; display: inline-flex; align-items: center; }
.foot { padding-bottom: 8px; }
+
+/* --- Flow analytics charts (#4830) --- */
+.flow-scroll { overflow-x: auto; }
+.flow-tp-bar { fill: #58a6ff; }
+.flow-tp-value { fill: #e6edf3; font-size: 11px; }
+.flow-tp-week-label { fill: #8b949e; font-size: 9px; }
+.flow-axis { stroke: #30363d; stroke-width: 1; }
+.flow-tis-0 { fill: #58a6ff; }
+.flow-tis-1 { fill: #3fb950; }
+.flow-tis-2 { fill: #d29922; }
+.flow-tis-3 { fill: #bc8cff; }
+.flow-tis-4 { fill: #f778ba; }
+.flow-tis-5 { fill: #79c0ff; }
+html[data-theme="light"] .flow-tp-value { fill: #1f2328; }
+html[data-theme="light"] .flow-tp-week-label { fill: #59636e; }
+html[data-theme="light"] .flow-axis { stroke: #d1d9e0; }
diff --git a/pm-stack/aggregator/test/flow-charts-4830.test.ts b/pm-stack/aggregator/test/flow-charts-4830.test.ts
new file mode 100644
index 0000000000..02056f03c7
--- /dev/null
+++ b/pm-stack/aggregator/test/flow-charts-4830.test.ts
@@ -0,0 +1,127 @@
+// Fixture tests for the flow-analytics charts (#4830, step 3 of the
+// #1281 split): the rendered charts must carry exactly the #4829
+// twin's values for the same window — every throughput count and
+// time-in-status value present, the window stated, gaps named (not
+// smoothed over), and zero-completion weeks rendered as zeros.
+import { describe, expect, test } from "bun:test";
+import { computeFlowAnalytics } from "../src/flow-analytics.ts";
+import { flowChartsHtml } from "../src/flow-charts.ts";
+import type {
+ ItemHistoryCoverage,
+ ItemHistoryCutoff,
+ ItemHistoryItem,
+} from "../src/item-history.ts";
+
+const REPO = "developing-today/code";
+const W1 = "2026-10-05T00:00:00Z";
+const W2 = "2026-10-12T00:00:00Z";
+const W3 = "2026-10-19T00:00:00Z";
+const W4 = "2026-10-26T00:00:00Z";
+const EPIC = `${REPO}#100`;
+
+function coverage(partial: Partial = {}): ItemHistoryCoverage {
+ return { source: "projects-pool", fetchedAt: W1, complete: true, unavailable: false, ...partial };
+}
+
+function item(number: number, partial: Partial = {}): ItemHistoryItem {
+ return {
+ ref: `${REPO}#${number}`,
+ repo: REPO,
+ number,
+ kind: "issue",
+ state: "open",
+ status: "In Progress",
+ effort: null,
+ blockedBy: [],
+ ...partial,
+ };
+}
+
+function cutoff(cutoffAt: string, items: ItemHistoryItem[], cov?: Partial): ItemHistoryCutoff {
+ return { schemaVersion: 1, cutoffAt, coverage: coverage(cov), items };
+}
+
+function completeWindow(): ItemHistoryCutoff[] {
+ const a = (p: Partial) => item(1, { parentRef: EPIC, ...p });
+ const b = (p: Partial) => item(2, { parentRef: EPIC, ...p });
+ return [
+ cutoff(W1, [a({}), b({ status: "Todo" }), item(3, {})]),
+ cutoff(W2, [a({}), b({ state: "closed", status: "Done" }), item(3, {})]),
+ cutoff(W3, [a({ state: "closed", status: "Done" }), b({ state: "closed", status: "Done" }), item(3, {})]),
+ cutoff(W4, [a({ state: "closed", status: "Done" }), b({ state: "closed", status: "Done" }), item(3, {})]),
+ ];
+}
+
+describe("flow charts (#4830)", () => {
+ test("complete window: rendered values match the JSON twin exactly", () => {
+ const twin = computeFlowAnalytics(completeWindow());
+ const html = flowChartsHtml(twin);
+
+ // The window is stated on the section.
+ expect(html).toContain(`data-from="${W1}"`);
+ expect(html).toContain(`data-to="${W4}"`);
+ expect(html).toContain("4 of 4 cutoffs complete");
+ expect(html).not.toContain("flow-gap");
+
+ // Every group, week, and status value in the twin appears in the
+ // render with the twin's own number — no second computation.
+ for (const group of twin.groups) {
+ expect(html).toContain(`data-group="${group.groupRef ?? ""}"`);
+ for (const week of group.throughput) {
+ expect(html).toContain(`data-cutoff="${week.cutoffAt}" data-completed="${week.completed}"`);
+ }
+ for (const s of group.timeInStatus) {
+ expect(html).toContain(`data-status="${s.status}" data-item-days="${s.itemDays}"`);
+ }
+ }
+
+ // The known fixture values (same expectations as the #4829 test):
+ // B completes in W2, A in W3, W4 is a preserved zero week.
+ expect(html).toContain(`data-cutoff="${W2}" data-completed="1"`);
+ expect(html).toContain(`data-cutoff="${W3}" data-completed="1"`);
+ expect(html).toContain(`data-cutoff="${W4}" data-completed="0"`);
+ expect(html).toContain('data-status="Done" data-item-days="21"');
+ expect(html).toContain('data-status="In Progress" data-item-days="14"');
+ expect(html).toContain('data-status="Todo" data-item-days="7"');
+ });
+
+ test("gappy window: the gap is named on the chart, never smoothed over", () => {
+ const cutoffs = [
+ cutoff(W1, [item(1, { parentRef: EPIC })]),
+ cutoff(W2, [item(1, { parentRef: EPIC })], { complete: false }),
+ cutoff(W3, [item(1, { parentRef: EPIC, state: "closed", status: "Done" })]),
+ ];
+ const twin = computeFlowAnalytics(cutoffs);
+ expect(twin.window.gaps).toEqual([{ cutoffAt: W2, complete: false, unavailable: false }]);
+
+ const html = flowChartsHtml(twin);
+ expect(html).toContain("2 of 3 cutoffs complete");
+ expect(html).toContain(`data-gap="${W2}"`);
+ expect(html).toContain("(incomplete)");
+ expect(html).toContain("intervals spanning a gap are excluded");
+ // The gap cutoff is not drawn as a throughput week for any group.
+ expect(html).not.toContain(`data-cutoff="${W2}"`);
+ });
+
+ test("wide history: the chart grows per week and keeps every week (Codex P2)", () => {
+ const base = Date.parse(W1);
+ const cutoffs = Array.from({ length: 60 }, (_, i) =>
+ cutoff(new Date(base + i * 7 * 86_400_000).toISOString(), [item(1, { parentRef: EPIC })]),
+ );
+ const twin = computeFlowAnalytics(cutoffs);
+ const html = flowChartsHtml(twin);
+ const epic = twin.groups.find((g) => g.groupRef === EPIC)!;
+ // 60 cutoffs bound 59 weekly intervals in the twin; the chart
+ // draws every one of them, at a full slot per week.
+ expect(epic.throughput.length).toBe(59);
+ expect((html.match(/data-cutoff=/g) ?? []).length).toBe(59);
+ expect(html).toContain('viewBox="0 0 3304 110"');
+ expect(html).toContain('class="flow-scroll"');
+ });
+
+ test("empty history: the section states the empty window, no charts invented", () => {
+ const html = flowChartsHtml(computeFlowAnalytics([]));
+ expect(html).toContain("no item history stored yet");
+ expect(html).not.toContain("flow-tp-week");
+ });
+});