Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 54 additions & 48 deletions app/scaling/components/Work.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import { Card } from '../../components/ui/Card';
import { cn } from '../../components/ui/cn';
import { EmptyState } from '../../components/ui/EmptyState';
import { Text } from '../../components/ui/Text';
import { WORK_STATUSES } from '../snapshot.mjs';
import { WORK_CATEGORIES, WORK_STATUSES } from '../snapshot.mjs';
import type { Area, Link, WorkCategory, WorkItem } from '../snapshot.mjs';
import { Info } from './Info';

// Status labels follow Linear's project states.
const STATUS: Record<string, string> = { 'in-progress': 'In Progress', planned: 'Planned', done: 'Completed' };
const STATUS: Record<string, string> = { 'in-progress': 'In progress', planned: 'Planned', done: 'Completed', discarded: 'Discarded' };
const DOT: Record<string, string> = { 'in-progress': 'bg-bds-blue-60', planned: 'bg-bds-yellow-50', done: 'bg-bds-green-60', discarded: 'bg-bds-gray-40' };
// Older entries name an area instead of a category.
const CATEGORY: Record<Area, WorkCategory> = { da: 'DA', execution: 'Execution', state: 'Disk', networking: 'Latency' };
const TH = 'px-3 py-2 text-left text-[11px] font-[600] uppercase tracking-wide text-bds-gray-60';
const TD = 'px-3 py-2.5 align-top';
const CATEGORY: Record<Area, WorkCategory> = { da: 'DA', execution: 'Execution', state: 'Disk', networking: 'Infra' };

// Links in the entry's order, then its Linear project and evidence when an older entry carries them.
const linksOf = (w: WorkItem): Link[] => {
Expand All @@ -21,54 +19,62 @@ const linksOf = (w: WorkItem): Link[] => {
return links;
};

// In progress first, then planned, then done; entries with any other status are not shown.
function Item({ w }: { w: WorkItem }) {
const effect = w.effect ?? w.expected ?? null;
const about = [w.hypothesis && `Hypothesis: ${w.hypothesis}`, w.change && `Change: ${w.change}`, `Owner: ${w.owner ?? 'none assigned'}`].filter(Boolean);
const links = linksOf(w);
return (
<li className="grid grid-cols-[1fr_auto] gap-x-3 gap-y-0.5 border-t border-bds-gray-10 py-2 dark:border-white/10">
<span className="inline-flex items-center gap-1.5">
<span className={cn('h-2 w-2 shrink-0 rounded-full', DOT[w.status])} title={STATUS[w.status]} aria-label={STATUS[w.status]} role="img" />
<span className={cn(w.status === 'discarded' && 'text-bds-gray-60 line-through')}>{w.title}</span>
<Info label={`About ${w.title}`}>{about.join(' ')}</Info>
{w.owner ? <span className="text-bds-gray-60">· {w.owner}</span> : null}
</span>
<span className="row-span-2 self-center whitespace-nowrap text-[12px]">
{links.map((l, i) => (
<span key={l.url}>
{i > 0 ? ' · ' : null}
<a className="underline" href={l.url} target="_blank" rel="noreferrer">{l.label}</a>
</span>
))}
</span>
<span className="pl-3.5 text-[12px] text-bds-gray-60">{effect ?? 'not measured yet'}</span>
</li>
);
}

// One collapsible group per category, in WORK_CATEGORIES order; groups with entries start open.
// Within a group: in progress, then planned, done and discarded; entries with any other status are not shown.
export function Work({ work }: { work: WorkItem[] }) {
const rows = work.filter((w) => WORK_STATUSES.includes(w.status)).toSorted((a, b) => WORK_STATUSES.indexOf(a.status) - WORK_STATUSES.indexOf(b.status));
const shown = work.filter((w) => WORK_STATUSES.includes(w.status)).toSorted((a, b) => WORK_STATUSES.indexOf(a.status) - WORK_STATUSES.indexOf(b.status));
const categoryOf = (w: WorkItem) => w.category ?? (w.area ? CATEGORY[w.area] : undefined);
const groups = WORK_CATEGORIES.map((c) => ({ category: c, items: shown.filter((w) => categoryOf(w) === c) }));
return (
<section className="flex flex-col gap-3">
<Text as="h2" variant="headline">Work log</Text>
{rows.length === 0 ? (
{shown.length === 0 ? (
<EmptyState description="No work in progress or planned for this snapshot." />
) : (
<Card className="overflow-x-auto bg-background dark:bg-white/5">
<table className="w-full min-w-[640px] border-collapse text-[13px]">
<thead>
<tr className="border-b border-bds-gray-10 dark:border-white/10">
{['Status', 'Work', 'Impact category', 'Effect', 'Links'].map((h) => <th key={h} className={TH}>{h}</th>)}
</tr>
</thead>
<tbody>
{rows.map((w) => {
const effect = w.effect ?? w.expected ?? null;
const about = [w.hypothesis && `Hypothesis: ${w.hypothesis}`, w.change && `Change: ${w.change}`, `Owner: ${w.owner ?? 'none assigned'}`].filter(Boolean);
const links = linksOf(w);
return (
<tr key={w.title} className="border-b border-bds-gray-10 last:border-0 dark:border-white/10">
<td className={cn(TD, 'whitespace-nowrap')}>
<span className="rounded-md border border-bds-gray-30 px-1.5 py-px text-[12px] text-bds-gray-70 dark:text-bds-gray-30">{STATUS[w.status]}</span>
</td>
<td className={TD}>
<span className="inline-flex items-center gap-1">
{w.title}
<Info label={`About ${w.title}`}>{about.join(' ')}</Info>
</span>
</td>
<td className={cn(TD, 'whitespace-nowrap')}>{w.category ?? (w.area ? CATEGORY[w.area] : '—')}</td>
<td className={cn(TD, effect === null && 'text-bds-gray-60')}>{effect ?? 'not measured yet'}</td>
<td className={cn(TD, 'whitespace-nowrap')}>
{links.length === 0 ? <span className="text-bds-gray-60">—</span> : links.map((l, i) => (
<span key={l.url}>
{i > 0 ? ' · ' : null}
<a className="underline" href={l.url} target="_blank" rel="noreferrer">{l.label}</a>
</span>
))}
</td>
</tr>
);
})}
</tbody>
</table>
</Card>
<div className="flex flex-col gap-2 text-[13px]">
{groups.map(({ category, items }) => {
const counts = WORK_STATUSES.map((s) => [s, items.filter((w) => w.status === s).length] as const).filter(([, n]) => n > 0);
return (
<details key={category} open={items.length > 0} className="rounded-lg border border-bds-gray-10 dark:border-white/10">
<summary className="flex cursor-pointer list-none items-center gap-3 px-3.5 py-2.5 [&::-webkit-details-marker]:hidden">
<span className="min-w-20 font-[600]">{category}</span>
<span className="flex h-1.5 flex-1 overflow-hidden rounded-full bg-bds-gray-10 dark:bg-white/10" aria-hidden="true">
{counts.map(([s, n]) => <span key={s} className={DOT[s]} style={{ width: `${(n / items.length) * 100}%` }} />)}
</span>
<span className="text-bds-gray-60">{counts.length ? counts.map(([s, n]) => `${n} ${STATUS[s].toLowerCase()}`).join(' · ') : 'no entries'}</span>
</summary>
<div className="px-3.5 pb-2">
{items.length ? <ul>{items.map((w) => <Item key={w.title} w={w} />)}</ul> : <p className="py-2 text-[12px] italic text-bds-gray-60">No {category} work logged yet.</p>}
</div>
</details>
);
})}
</div>
)}
</section>
);
Expand Down
28 changes: 19 additions & 9 deletions app/scaling/components/scorecard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -712,15 +712,22 @@ describe('guardrails summary and work', () => {
expect(text(guardrails(BENCH))).toContain('Met 5');
});

it('logs work in progress, then planned, then done, hiding other statuses', () => {
// Category summaries and items of the work log, without the mocked help popovers.
const groups = (html: string) => html.split('<summary').slice(1).map((g) => text(`<summary${g.split('</summary>')[0]}`));
const items = (html: string) => html.replace(/ ?<span class="help">[^<]*<\/span>/g, '').split('<li').slice(1).map((r) => text(`<li${r.split('</li>')[0]}`));

it('groups work by category, in progress before planned before done, hiding other statuses', () => {
const work = render({}).work;
expect(text(work.split('</thead>')[0])).toContain('StatusWorkImpact categoryEffectLinks');
expect(groups(work)).toEqual(['Execution1 in progress', 'DA1 planned', 'Diskno entries', 'Infrano entries']);
// Groups with entries start open; empty ones start closed.
expect(work.match(/<details[^>]*open=""/g)).toHaveLength(2);
// The legacy "Research-derived proposal" entry is not shown; the Linear project and evidence of an older entry become links.
expect(rows(work)).toEqual([
'In ProgressSynthetic unified binaryExecutionabout 20% faster block processing (synthetic demo)Linear · Synthetic run',
'PlannedSynthetic blob batching changeDAnot measured yetSynthetic doc',
expect(items(work)).toEqual([
'Synthetic unified binary· Synthetic ownerLinear · Synthetic runabout 20% faster block processing (synthetic demo)',
'Synthetic blob batching changeSynthetic docnot measured yet',
]);
expect(work).toContain('<a class="underline" href="https://example.com/synthetic/linear/project" target="_blank" rel="noreferrer">Linear</a>');
expect(text(work)).toContain('No Disk work logged yet.');
expect(text(work)).not.toMatch(/legacy proposal|Expected effects are not summed/);
});

Expand All @@ -729,12 +736,15 @@ describe('guardrails summary and work', () => {
const [first, second] = snapshot.work;
snapshot.work = [
{ ...second, status: 'done', category: undefined, links: [{ label: 'Doc', url: 'https://example.com/doc' }, { label: 'Linear', url: 'https://example.com/linear' }] },
{ ...first, effect: undefined, expected: 'about 10% faster' },
{ ...first, effect: undefined, expected: 'about 10% faster', status: 'discarded' },
];
expect(rows(render({}, snapshot).work)).toEqual([
'In ProgressSynthetic unified binaryExecutionabout 10% fasterLinear · Synthetic run',
'CompletedSynthetic blob batching changeDAnot measured yetDoc · Linear',
const work = render({}, snapshot).work;
expect(groups(work)).toEqual(['Execution1 discarded', 'DA1 completed', 'Diskno entries', 'Infrano entries']);
expect(items(work)).toEqual([
'Synthetic unified binary· Synthetic ownerLinear · Synthetic runabout 10% faster',
'Synthetic blob batching changeDoc · Linearnot measured yet',
]);
expect(work).toContain('line-through">Synthetic unified binary');
snapshot.work = [{ ...first, status: 'Proposed' }];
expect(text(render({}, snapshot).work)).toContain('No work in progress or planned for this snapshot.');
});
Expand Down
6 changes: 3 additions & 3 deletions app/scaling/snapshot.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* projectId: string, issueId?: string, state: string, progress: number, scopeDone: number,
* scopeTotal: number, targetDate?: string, updatedAt: string, url: string
* }} LinearStatus
* @typedef {'DA' | 'Disk' | 'Execution' | 'Proving' | 'Latency'} WorkCategory
* @typedef {'Execution' | 'DA' | 'Disk' | 'Infra'} WorkCategory
* @typedef {{
* title: string, status: string, category?: WorkCategory, effect?: string | null, links?: Link[],
* owner?: string | null, area?: Area, hypothesis?: string, change?: string,
Expand All @@ -62,8 +62,8 @@ const TAGS = ['measured', 'modeled', 'estimated', 'not-measured', 'not-modeled',
const VALUED_TAGS = ['measured', 'modeled', 'estimated'];
const AREAS = ['da', 'execution', 'state', 'networking'];
// Work log statuses follow Linear's project states; impact categories are the page's limit names.
export const WORK_STATUSES = ['in-progress', 'planned', 'done'];
export const WORK_CATEGORIES = ['DA', 'Disk', 'Execution', 'Proving', 'Latency'];
export const WORK_STATUSES = ['in-progress', 'planned', 'done', 'discarded'];
export const WORK_CATEGORIES = ['Execution', 'DA', 'Disk', 'Infra'];
// Each section renders on its area page, or on the guardrails page for outcomes.
const SECTION_IDS = ['da', 'execution', 'state', 'outcomes'];
const INPUT_STATUSES = ['observed', 'configured', 'provisional', 'pending'];
Expand Down
2 changes: 1 addition & 1 deletion app/scaling/snapshot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ describe('parseSnapshot', () => {
{ title: 'Bad link', status: 'planned', category: 'DA', effect: 3, links: [{ label: 'Doc', url: 'http://example.com' }] },
);
expect(errorsOf(data)).toEqual([
'work[4].category: expected one of DA, Disk, Execution, Proving, Latency',
'work[4].category: expected one of Execution, DA, Disk, Infra',
'work[5].category: required without area',
'work[6].effect: expected string or null',
'work[6].links[0].url: expected https URL',
Expand Down
Loading