From ae46cb99b3537d4c086c6aa7cd913fff179c4817 Mon Sep 17 00:00:00 2001 From: Croissant Le Doux Date: Thu, 9 Jul 2026 00:00:00 -0400 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20real=20Runway=20=E2=80=94=20per-mil?= =?UTF-8?q?estone=20Monte=20Carlo=20forecasts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Runway milestone list is now real. Each open gitea milestone's open scope gets its own Monte Carlo forecast (reusing the P2 engine); the p80 landing range is shown, and compared to the milestone's due date (on track / at risk) when one exists. Ranges, never point dates. - backlog.ts: runwayView(issues, milestones, deps) → RunwayMilestone[] — per milestone: forecast its open scope, map p50..p90 to a date range, normalize the RunwayBar band across a shared horizon, tone/ note from due-vs-p80. Milestones with no open scope (shipped) are omitted; empty → the demo fixture. - RunwayScreen takes optional `milestones`; AppShell feeds runwayView. The header's calibration note was already real (#1). Scope: each milestone forecasts its remaining work *from today* independently — they aren't scheduled relative to each other yet (so a smaller later phase can show an earlier date). Cross-milestone sequencing is a refinement. Capacity stays fixture — true per-person capacity (focus factor, allocation) is #8, config-driven. Verified: desktop typecheck clean, 14 fixture e2e green. Live: Runway shows the real P1/P2/P4/P5 milestones with per-milestone forecasts (e.g. "P2 — Scheduler + Monte Carlo · 80% Aug 14–25 · 32d of work"); the fixture lists Beta/Pilot/v1.0, so the real names prove it (new assertion + screenshot). Co-Authored-By: Claude Opus 4.8 (1M context) --- apps/desktop/e2e/live-backlog.spec.ts | 4 ++ .../src/components/screens/runway-screen.tsx | 10 ++- .../src/components/shell/app-shell.tsx | 11 +++- apps/desktop/src/renderer/src/lib/backlog.ts | 62 ++++++++++++++++++- 4 files changed, 81 insertions(+), 6 deletions(-) diff --git a/apps/desktop/e2e/live-backlog.spec.ts b/apps/desktop/e2e/live-backlog.spec.ts index a88e740..695ee6a 100644 --- a/apps/desktop/e2e/live-backlog.spec.ts +++ b/apps/desktop/e2e/live-backlog.spec.ts @@ -41,6 +41,10 @@ test.describe('live backlog', () => { await expect( win.getByText(/cold-start priors · \d+\/20 closed issues estimated|calibrated on \d+ closed/), ).toBeVisible() + // Real per-milestone forecasts — these milestone names come from gitea, not the + // fixture (which lists Beta / Pilot-ready / v1.0). + await expect(win.getByText(/P2 — Scheduler/)).toBeVisible() + await win.screenshot({ path: join(here, '.artifacts', 'screens', 'live-runway.png'), fullPage: true, animations: 'disabled' }) await win.getByRole('button', { name: 'Full report' }).click() await expect(win.getByText(/cold-start · \d+\/20|curve active · n ≥ 20/)).toBeVisible() await win.screenshot({ path: join(here, '.artifacts', 'screens', 'live-calibration.png'), fullPage: true, animations: 'disabled' }) diff --git a/apps/desktop/src/renderer/src/components/screens/runway-screen.tsx b/apps/desktop/src/renderer/src/components/screens/runway-screen.tsx index ad060b0..d8f0944 100644 --- a/apps/desktop/src/renderer/src/components/screens/runway-screen.tsx +++ b/apps/desktop/src/renderer/src/components/screens/runway-screen.tsx @@ -2,18 +2,22 @@ import React from 'react' import { RunwayBar } from '../charts/chart.js' import { Card, Badge, Tag, Icon, IconButton } from '../ui/index.js' -import { RUNWAY, CAPACITY } from '../../data/fixtures.js' +import { RUNWAY, CAPACITY, type RunwayMilestone } from '../../data/fixtures.js' -// Runway — capacity vs milestone dates; ranges, never points +// Runway — capacity vs milestone dates; ranges, never points. +// `milestones` (real per-milestone forecasts) overrides the demo when present. export function RunwayScreen({ onOpenCalibration, onOpenMilestone, calibration, + milestones, }: { onOpenCalibration: () => void onOpenMilestone: () => void calibration?: { n: number; coldStart: boolean } + milestones?: RunwayMilestone[] }) { + const rows = milestones && milestones.length ? milestones : RUNWAY const calibNote = calibration ? calibration.coldStart ? `cold-start priors · ${calibration.n}/20 closed issues estimated` @@ -28,7 +32,7 @@ export function RunwayScreen({
- {RUNWAY.map((m, i) => ( + {rows.map((m, i) => (
{ document.documentElement.setAttribute('data-theme', dark ? 'dark' : 'light') @@ -196,6 +204,7 @@ export function AppShell() { onOpenCalibration={() => setView('calibration')} onOpenMilestone={() => setView('milestone')} calibration={calibration ? { n: calibration.model.n, coldStart: calibration.model.coldStart } : undefined} + milestones={runwayMilestones} /> ) case 'calibration': diff --git a/apps/desktop/src/renderer/src/lib/backlog.ts b/apps/desktop/src/renderer/src/lib/backlog.ts index 5aec932..ba21ff7 100644 --- a/apps/desktop/src/renderer/src/lib/backlog.ts +++ b/apps/desktop/src/renderer/src/lib/backlog.ts @@ -7,6 +7,7 @@ import { fitCalibration, forecast, type GiteaIssue, + type GiteaMilestone, inferLifecycle, type LifecycleColumn, type LifecycleEvent, @@ -16,10 +17,17 @@ import { type ScheduledItem, selectFocus, toDurationModel, + workingDaysBetween, } from '@commitea/core' -import { type BoardColumn, type BoardIssue, type CalibrationData, type FocusIssue } from '../data/fixtures.js' -import { type BurnUpData, buildBurnUpData } from './dates.js' +import { + type BoardColumn, + type BoardIssue, + type CalibrationData, + type FocusIssue, + type RunwayMilestone, +} from '../data/fixtures.js' +import { addWorkingDays, type BurnUpData, buildBurnUpData, formatRange, formatShort } from './dates.js' type Timelines = Record @@ -232,3 +240,53 @@ export function scheduleFocus( later: toFocusIssue(f.later, inf), } } + +/** + * Per-milestone Monte Carlo forecast for the Runway screen — each open milestone's + * open scope gets its own cone, and the p80 landing is compared to the milestone's + * due date (ok/at-risk). Ranges, never point dates. Milestones with no open scope + * (already shipped) are omitted. Falls back to the demo when there's nothing real. + */ +export function runwayView( + issues: GiteaIssue[], + milestones: GiteaMilestone[], + deps: DependencyEdge[], + today: Date = new Date(), +): RunwayMilestone[] { + const open = issues.filter((i) => i.state === 'open') + const rows = milestones + .filter((m) => m.state === 'open') + .map((m) => ({ m, scope: open.filter((i) => i.milestone?.id === m.id) })) + .filter((x) => x.scope.length > 0) + .map(({ m, scope }) => { + const f = forecast( + scope.map((i) => ({ + number: i.number, + title: i.title, + labels: i.labels, + estimateDays: i.facts.estimateDays, + priority: i.facts.priority, + })), + deps, + ) + const p90 = f.curve.length ? f.curve[f.curve.length - 1].p90Day : f.p95Day + const dueDay = m.dueOn ? workingDaysBetween(today, new Date(m.dueOn)) : null + return { m, p50: f.p50Day, p80: f.p80Day, p90, dueDay } + }) + + const horizon = Math.max(1, ...rows.map((r) => Math.max(r.p90, r.dueDay ?? 0))) + + return rows.map(({ m, p50, p80, p90, dueDay }) => { + const onTrack = dueDay == null || p80 <= dueDay + return { + name: m.title, + due: m.dueOn ? formatShort(new Date(m.dueOn)) : 'no date', + hard: false, + p80: formatRange(addWorkingDays(today, p50), addWorkingDays(today, p90)), + pos: p80 / horizon, + spread: Math.min(0.6, (p90 - p50) / horizon), + tone: onTrack ? ('ok' as const) : ('warn' as const), + note: dueDay == null ? `${Math.ceil(p80)}d of work` : onTrack ? 'on track' : 'at risk', + } + }) +} From 57595852a460c93abc9e9c440f0c61049a2f7dcf Mon Sep 17 00:00:00 2001 From: Croissant Le Doux Date: Thu, 9 Jul 2026 00:12:11 -0400 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20real=20Milestone=20drill-in=20?= =?UTF-8?q?=E2=80=94=20completes=20the=20Runway=20story?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Clicking a milestone on Runway now opens its real detail: scope + done %, a Monte Carlo cone over the remaining open work, and the milestone's issues grouped by lifecycle column. Threaded the gitea milestone id through the Runway row → AppShell → a milestoneView(). - backlog.ts: milestoneView(id, ...) → { name, due, scope/done, forecast cone + range, groups by lifecycle column }. Reuses forecast + buildBurnUpData + lifecycle inference. null for an unknown id → the screen shows the demo fixture. - RunwayMilestone gains an `id`; runwayView sets it; RunwayScreen.onOpenMilestone(id). - MilestoneScreen takes optional `data`; renders real header/stats/cone/issue-groups when present, fixture otherwise. Verified: desktop typecheck clean, 14 fixture e2e green. Live: clicking "P2 — Scheduler + Monte Carlo" opens a real detail — 7 issues · est 20d, 0/7 done, cone "80% Aug 17–26", issues in Triage/In-review from the real event stream (screenshot). Co-Authored-By: Claude Opus 4.8 (1M context) --- apps/desktop/e2e/live-backlog.spec.ts | 8 ++ .../components/screens/milestone-screen.tsx | 56 +++++++++---- .../src/components/screens/runway-screen.tsx | 4 +- .../src/components/shell/app-shell.tsx | 20 ++++- .../desktop/src/renderer/src/data/fixtures.ts | 2 + apps/desktop/src/renderer/src/lib/backlog.ts | 80 +++++++++++++++++++ 6 files changed, 151 insertions(+), 19 deletions(-) diff --git a/apps/desktop/e2e/live-backlog.spec.ts b/apps/desktop/e2e/live-backlog.spec.ts index 695ee6a..1da6fa4 100644 --- a/apps/desktop/e2e/live-backlog.spec.ts +++ b/apps/desktop/e2e/live-backlog.spec.ts @@ -45,6 +45,14 @@ test.describe('live backlog', () => { // fixture (which lists Beta / Pilot-ready / v1.0). await expect(win.getByText(/P2 — Scheduler/)).toBeVisible() await win.screenshot({ path: join(here, '.artifacts', 'screens', 'live-runway.png'), fullPage: true, animations: 'disabled' }) + + // Milestone drill-in — clicking a real milestone opens its real detail + await win.getByText(/P2 — Scheduler/).click() + await expect(win.getByRole('heading', { name: 'P2 — Scheduler + Monte Carlo' })).toBeVisible() + await expect(win.getByText(/\d+ issues · est \d+d/)).toBeVisible() + await win.screenshot({ path: join(here, '.artifacts', 'screens', 'live-milestone.png'), fullPage: true, animations: 'disabled' }) + await rail.getByRole('button', { name: 'Runway' }).click() + await win.getByRole('button', { name: 'Full report' }).click() await expect(win.getByText(/cold-start · \d+\/20|curve active · n ≥ 20/)).toBeVisible() await win.screenshot({ path: join(here, '.artifacts', 'screens', 'live-calibration.png'), fullPage: true, animations: 'disabled' }) diff --git a/apps/desktop/src/renderer/src/components/screens/milestone-screen.tsx b/apps/desktop/src/renderer/src/components/screens/milestone-screen.tsx index fd9930b..9348dbc 100644 --- a/apps/desktop/src/renderer/src/components/screens/milestone-screen.tsx +++ b/apps/desktop/src/renderer/src/components/screens/milestone-screen.tsx @@ -1,22 +1,44 @@ import React from 'react' import { COLUMNS, type IssueRef } from '../../data/fixtures.js' +import { type MilestoneView } from '../../lib/backlog.js' import { BurnUpCone } from '../charts/chart.js' import { Badge, Button, Card, Icon, Tag } from '../ui/index.js' -// Milestone detail — scope, cone, issues; forecasts stay ranges -export function MilestoneScreen({ onBack, onOpenIssue }: { onBack: () => void; onOpenIssue: (issue: IssueRef) => void }) { +// Milestone detail — scope, cone, issues; forecasts stay ranges. +// `data` (real milestone forecast) overrides the demo fixture when present. +export function MilestoneScreen({ + onBack, + onOpenIssue, + data, +}: { + onBack: () => void + onOpenIssue: (issue: IssueRef) => void + data?: MilestoneView +}) { const cols = COLUMNS const byState = (ids: number[]) => cols.flatMap((c) => c.issues.map((i) => ({ ...i, col: c.label }))).filter((i) => ids.includes(i.id)) - const groups = [ + const fixtureGroups = [ { label: 'Steeping', issues: byState([87, 84]) }, { label: 'In review', issues: byState([92]) }, { label: 'Queued', issues: byState([102, 103, 99, 96, 78]) }, { label: 'Done', issues: byState([71, 69, 65]), muted: true }, ] + // real or demo, in one shape the render loop understands + const groups = data + ? data.groups.map((g) => ({ label: g.label, issues: g.issues, muted: g.label === 'Done' })) + : fixtureGroups + const name = data ? data.name : 'Beta' + const dueLine = data + ? `milestone · due ${data.due} · ${data.soft ? 'soft — scope may flex' : 'hard deadline'}` + : 'milestone · due Mar 15 · soft — scope may flex' + const forecastLabel = data ? (data.forecastRange ? `80% ${data.forecastRange}` : 'all shipped') : '80% Mar 3–12' + const scopeStat = data ? `${data.scopeCount} issues · est ${data.scopeEstDays}d` : '42 issues · est 61d' + const doneStat = data ? `${data.doneCount} · ${data.donePct}%` : '24 · 57%' + const Stat = ({ label, value, tone }: { label: string; value: string; tone?: string }) => (
{label}
@@ -36,12 +58,12 @@ export function MilestoneScreen({ onBack, onOpenIssue }: { onBack: () => void; o

- milestone · due Mar 15 · soft — scope may flex + {dueLine}

-

Beta

+

{name}

- ahead of forecast - 80% Mar 3–12 + {data ? `${data.doneCount}/${data.scopeCount} done` : 'ahead of forecast'} + {forecastLabel}
@@ -51,21 +73,25 @@ export function MilestoneScreen({ onBack, onOpenIssue }: { onBack: () => void; o {/* stats strip */}
- - - + + +
-
Drift · 7d
-
−2d · cone narrowed
+
Remaining
+
{data ? `${data.scopeCount - data.doneCount} open` : '−2d · cone narrowed'}
- 80% this lands Mar 3–12} jade> - + 80% this lands {data ? (data.forecastRange ?? 'shipped') : 'Mar 3–12'}} jade> +

- Comfortably ahead. Beta needs #87 more than it needs my commentary. + {data + ? data.cone + ? `${data.scopeCount - data.doneCount} open of ${data.scopeCount}. Cone over what's left.` + : 'Everything here has shipped.' + : 'Comfortably ahead. Beta needs #87 more than it needs my commentary.'}

diff --git a/apps/desktop/src/renderer/src/components/screens/runway-screen.tsx b/apps/desktop/src/renderer/src/components/screens/runway-screen.tsx index d8f0944..cb3ac21 100644 --- a/apps/desktop/src/renderer/src/components/screens/runway-screen.tsx +++ b/apps/desktop/src/renderer/src/components/screens/runway-screen.tsx @@ -13,7 +13,7 @@ export function RunwayScreen({ milestones, }: { onOpenCalibration: () => void - onOpenMilestone: () => void + onOpenMilestone: (id?: number) => void calibration?: { n: number; coldStart: boolean } milestones?: RunwayMilestone[] }) { @@ -33,7 +33,7 @@ export function RunwayScreen({
{rows.map((m, i) => ( -
onOpenMilestone(m.id)} style={{ display: 'grid', gridTemplateColumns: '160px 1fr 150px 90px', gap: 16, alignItems: 'center', cursor: 'pointer', padding: '14px 20px', borderTop: i === 0 ? 'none' : '1px solid var(--line-1)', }} diff --git a/apps/desktop/src/renderer/src/components/shell/app-shell.tsx b/apps/desktop/src/renderer/src/components/shell/app-shell.tsx index ec12bdd..7355ed5 100644 --- a/apps/desktop/src/renderer/src/components/shell/app-shell.tsx +++ b/apps/desktop/src/renderer/src/components/shell/app-shell.tsx @@ -8,6 +8,7 @@ import { backlogCalibration, forecastBacklog, issuesToBoardColumns, + milestoneView, runwayView, scheduleFocus, } from '../../lib/backlog.js' @@ -93,6 +94,7 @@ export function AppShell() { const [offline, setOffline] = useState(false) const [issue, setIssue] = useState(null) const [readIds, setReadIds] = useState([]) + const [milestoneId, setMilestoneId] = useState(null) const [backlog, refetchBacklog] = useBacklog() const boardColumns = backlog.status === 'ready' ? issuesToBoardColumns(backlog.issues, backlog.timelines) : undefined @@ -106,6 +108,17 @@ export function AppShell() { : undefined const runwayMilestones = backlog.status === 'ready' ? runwayView(backlog.issues, backlog.milestones, backlog.deps) : undefined + const milestone = + backlog.status === 'ready' && milestoneId != null + ? (milestoneView( + milestoneId, + backlog.issues, + backlog.milestones, + backlog.deps, + backlog.timelines, + calibration?.model, + ) ?? undefined) + : undefined useEffect(() => { document.documentElement.setAttribute('data-theme', dark ? 'dark' : 'light') @@ -202,7 +215,10 @@ export function AppShell() { return ( setView('calibration')} - onOpenMilestone={() => setView('milestone')} + onOpenMilestone={(id) => { + setMilestoneId(id ?? null) + setView('milestone') + }} calibration={calibration ? { n: calibration.model.n, coldStart: calibration.model.coldStart } : undefined} milestones={runwayMilestones} /> @@ -210,7 +226,7 @@ export function AppShell() { case 'calibration': return setView('runway')} data={calibration?.data} /> case 'milestone': - return setView('runway')} onOpenIssue={openIssue} /> + return setView('runway')} onOpenIssue={openIssue} data={milestone} /> case 'inbox': return ( { const onTrack = dueDay == null || p80 <= dueDay return { + id: m.id, name: m.title, due: m.dueOn ? formatShort(new Date(m.dueOn)) : 'no date', hard: false, @@ -290,3 +291,82 @@ export function runwayView( } }) } + +export interface MilestoneGroup { + label: string + issues: { id: number; title: string; labels: string[]; days?: string }[] +} + +export interface MilestoneView { + name: string + due: string + soft: boolean + scopeCount: number + scopeEstDays: number + doneCount: number + donePct: number + /** p50..p90 landing range for the remaining open scope; null when nothing's open. */ + forecastRange: string | null + cone: BurnUpData | null + groups: MilestoneGroup[] +} + +/** + * The Milestone drill-in: real scope, done %, a Monte Carlo cone over the + * milestone's remaining open work, and its issues grouped by lifecycle column. + * Returns null for an unknown id — the screen then shows the demo fixture. + */ +export function milestoneView( + id: number, + issues: GiteaIssue[], + milestones: GiteaMilestone[], + deps: DependencyEdge[], + timelines: Timelines = {}, + calibration?: CalibrationModel, + today: Date = new Date(), +): MilestoneView | null { + const m = milestones.find((x) => x.id === id) + if (!m) return null + const all = issues.filter((i) => i.milestone?.id === id) + const open = all.filter((i) => i.state === 'open') + const done = all.filter((i) => i.state === 'closed') + const scopeEstDays = all.reduce((sum, i) => sum + (i.facts.estimateDays ?? 2), 0) + + const model = calibration ? toDurationModel(calibration) : undefined + const f = forecast( + open.map((i) => ({ + number: i.number, + title: i.title, + labels: i.labels, + estimateDays: i.facts.estimateDays, + priority: i.facts.priority, + })), + deps, + model ? { model } : {}, + ) + const cone = buildBurnUpData(f, today) + + const inf = inferAll(all, timelines, today) + const groups: MilestoneGroup[] = COLUMN_ORDER.map((key) => ({ + label: COLUMN_LABELS[key], + issues: all + .filter((i) => inf.get(i.number)!.column === key) + .map((i) => { + const days = inf.get(i.number)!.steepingDays + return { id: i.number, title: i.title, labels: i.labels, days: days != null ? `${days}d` : undefined } + }), + })).filter((g) => g.issues.length > 0) + + return { + name: m.title, + due: m.dueOn ? formatShort(new Date(m.dueOn)) : 'no date', + soft: true, + scopeCount: all.length, + scopeEstDays, + doneCount: done.length, + donePct: all.length ? Math.round((done.length / all.length) * 100) : 0, + forecastRange: cone ? cone.rangeLabel : null, + cone, + groups, + } +}