@startsimpli/integrations 0.2.191 → 0.2.193

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startsimpli/integrations",
3
- "version": "0.2.191",
3
+ "version": "0.2.193",
4
4
  "description": "Provider-agnostic types, API clients, hooks, and UI primitives for email + calendar integrations across StartSimpli apps, plus foundry customer email (subpath ./comms).",
5
5
  "license": "MIT",
6
6
  "homepage": "https://startsimpli.com",
@@ -50,9 +50,9 @@
50
50
  "react-native": ">=0.74.0",
51
51
  "@startsimpli/ui-native": ">=0.1.12",
52
52
  "react-native-safe-area-context": ">=4.0.0",
53
- "@startsimpli/auth": "^0.4.53",
54
- "@startsimpli/ui": "^0.4.188",
55
- "@startsimpli/utils": "^0.4.20"
53
+ "@startsimpli/utils": "^0.4.20",
54
+ "@startsimpli/ui": "^0.4.189",
55
+ "@startsimpli/auth": "^0.4.53"
56
56
  },
57
57
  "peerDependenciesMeta": {
58
58
  "react": {
@@ -99,10 +99,10 @@
99
99
  "react-native": "0.85.3",
100
100
  "react-native-safe-area-context": "~5.7.0",
101
101
  "@startsimpli/llm": "0.4.31",
102
- "@startsimpli/ui": "0.4.188",
103
- "@startsimpli/utils": "0.4.20",
102
+ "@startsimpli/ui": "0.4.189",
103
+ "@startsimpli/ui-native": "0.1.15",
104
104
  "@startsimpli/auth": "0.4.53",
105
- "@startsimpli/ui-native": "0.1.15"
105
+ "@startsimpli/utils": "0.4.20"
106
106
  },
107
107
  "scripts": {
108
108
  "type-check": "tsc --noEmit && tsc --noEmit -p tsconfig.native.json",
@@ -1,20 +1,38 @@
1
- import { render, screen, waitFor } from '@testing-library/react';
1
+ import { fireEvent, render, screen, waitFor } from '@testing-library/react';
2
2
  import { describe, expect, it } from 'vitest';
3
3
 
4
4
  import { OverviewPage } from '../components/pages/overview/OverviewPage';
5
5
 
6
6
  const page = <T,>(results: T[]) => ({ count: results.length, next: null, previous: null, results });
7
- const people = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'];
7
+ const item = (i: number, owner: string | undefined, focusId: string, due: string | null = null) => ({ id: String(i), externalId: `c${i}`, title: `task ${i}`, status: 'open', ownerName: owner, focusId, mentions: [], dueAt: due, lastSeenAt: null });
8
8
  const api = {
9
- listFocuses: async () => page([{ id: 'f1', title: 'Alpha', status: 'active' }]),
10
- listCommitments: async () => page(people.map((n, i) => ({ id: String(i), externalId: `c${i}`, title: `task ${n}`, status: 'open', ownerName: n, focusId: 'f1', mentions: [], dueAt: null, lastSeenAt: null }))),
9
+ listFocuses: async () => page([{ id: 'f1', title: 'Alpha', status: 'active' }, { id: 'f2', title: 'Beta', status: 'at_risk' }]),
10
+ listCommitments: async () => page([item(1, 'Sam', 'f1', '2030-01-02T00:00:00Z'), item(2, 'Riley', 'f1'), item(3, 'Riley', 'f2')]),
11
11
  } as never;
12
12
 
13
- describe('OverviewPage with many people', () => {
14
- it('shows a few columns plus Others, and every person still has a chip', async () => {
13
+ describe('OverviewPage', () => {
14
+ it('is one row per project with Waiting on, Next step and Open columns, not a column per person', async () => {
15
15
  render(<OverviewPage api={api} scope={{} as never} onOpenProject={() => {}} />);
16
16
  await waitFor(() => expect(screen.getAllByText('Alpha').length).toBeGreaterThan(0));
17
- expect(screen.getAllByRole('columnheader').map((h) => h.textContent)).toEqual(['Project', 'A', 'B', 'C', 'D', 'E', 'Others (3)', 'Last activity']);
18
- for (const n of people) expect(screen.getByRole('button', { name: new RegExp(`^${n} · 1$`) })).toBeTruthy();
17
+ expect(screen.getAllByRole('columnheader').map((h) => h.textContent?.replace(/\s*[↑↓]$/, ''))).toEqual(['Project', 'Status', 'Waiting on', 'Next step', 'Open', 'Last activity']);
18
+ // the project whose most pressing item is dated shows that item and its owner, with the other person as +1
19
+ expect(screen.getAllByText('task 1').length).toBeGreaterThan(0);
20
+ expect(screen.getAllByText('+ 1 more').length).toBeGreaterThan(0);
21
+ });
22
+
23
+ it('a Waiting-on chip shows only that person\'s projects', async () => {
24
+ render(<OverviewPage api={api} scope={{} as never} onOpenProject={() => {}} />);
25
+ await waitFor(() => expect(screen.getAllByText('Alpha').length).toBeGreaterThan(0));
26
+ fireEvent.click(screen.getByRole('button', { name: /^Sam · 1$/ }));
27
+ expect(screen.queryAllByText('Beta').length).toBe(0);
28
+ expect(screen.getAllByText('Alpha').length).toBeGreaterThan(0);
29
+ });
30
+
31
+ it('with nobody named there is no Waiting-on filter and the column says so plainly', async () => {
32
+ const nobody = { listFocuses: async () => page([{ id: 'f1', title: 'Alpha', status: 'active' }]), listCommitments: async () => page([item(1, undefined, 'f1')]) } as never;
33
+ render(<OverviewPage api={nobody} scope={{} as never} onOpenProject={() => {}} />);
34
+ await waitFor(() => expect(screen.getAllByText('Alpha').length).toBeGreaterThan(0));
35
+ expect(screen.queryByRole('group', { name: 'Waiting on' })).toBeNull();
36
+ expect(screen.getAllByText('Nobody named').length).toBeGreaterThan(0);
19
37
  });
20
38
  });
@@ -0,0 +1,21 @@
1
+ import { fireEvent, render, screen, waitFor } from '@testing-library/react';
2
+ import { describe, expect, it, vi } from 'vitest';
3
+
4
+ import { ProjectWaitingBar } from '../components/pages/overview/ProjectWaitingBar';
5
+
6
+ const item = (i: number, owner?: string) => ({ id: String(i), externalId: `c${i}`, title: `t${i}`, status: 'open', ownerName: owner, mentions: [] });
7
+ const api = { listCommitments: async () => ({ count: 4, next: null, previous: null, results: [item(1, 'Sam'), item(2, 'Sam'), item(3, 'Quinn'), item(4)] }) } as never;
8
+
9
+ describe('ProjectWaitingBar', () => {
10
+ it('shows a segment per owner with counts, Me first, and filters by clicking one', async () => {
11
+ const onSelect = vi.fn();
12
+ render(<ProjectWaitingBar api={api} focusId="f1" meNames={['quinn']} selected={null} onSelect={onSelect} />);
13
+ await waitFor(() => expect(screen.getByTestId('waiting-bar')).toBeTruthy());
14
+ expect(screen.getByRole('button', { name: 'Me, 1 open' })).toBeTruthy();
15
+ expect(screen.getByRole('button', { name: 'Sam, 2 open' })).toBeTruthy();
16
+ fireEvent.click(screen.getByRole('button', { name: 'Sam, 2 open' }));
17
+ expect(onSelect).toHaveBeenCalledWith('sam', 'Sam');
18
+ fireEvent.click(screen.getByRole('button', { name: 'Me, 1 open' }));
19
+ expect(onSelect).toHaveBeenLastCalledWith('quinn', 'quinn');
20
+ });
21
+ });
@@ -135,11 +135,17 @@ export interface PlanningPageProps {
135
135
  * this project, so a project never carries a second list of its own.
136
136
  */
137
137
  renderItems?: (focus: Focus) => React.ReactNode;
138
+ /** Label of the back button on a project's page. Default '← All projects'. */
139
+ backLabel?: string;
140
+ /** Content between the back button and the project card (e.g. the waiting-on bar). */
141
+ renderSummary?: (focus: Focus) => React.ReactNode;
142
+ /** Show the project's NAME as the page title (with status chip and one line of context) instead of the compact card. */
143
+ pageTitle?: boolean;
138
144
  classNames?: Partial<Record<PlanningSlot, string>>;
139
145
  }
140
146
 
141
147
  export function PlanningPage({
142
- api, scope, onOpenDocument, now, timeZone, focusId, onFocusChange, renderItems, classNames = {},
148
+ api, scope, onOpenDocument, now, timeZone, focusId, onFocusChange, renderItems, backLabel, renderSummary, pageTitle, classNames = {},
143
149
  }: PlanningPageProps) {
144
150
  const cn = { ...PLANNING_DEFAULTS, ...classNames };
145
151
 
@@ -390,17 +396,34 @@ export function PlanningPage({
390
396
  <section className={cn.section} aria-label="Focus">
391
397
  <div className="flex flex-wrap items-center gap-2">
392
398
  <button type="button" className={cn.secondaryButton} onClick={() => { setSelected(null); setShowDone(false); }}>
393
- ← All projects
399
+ {backLabel ?? '← All projects'}
394
400
  </button>
395
401
  {warningChip}
396
402
  </div>
397
- <FocusCard
398
- focus={selectedFocus}
399
- standing={standings[selectedFocus.id] ?? null}
400
- selected
401
- classNames={cn}
402
- onSelect={() => { setSelected(null); setShowDone(false); }}
403
- />
403
+ {pageTitle ? (
404
+ <div>
405
+ <div className="flex flex-wrap items-center gap-3">
406
+ <h1 className="text-2xl font-bold text-gray-900">{selectedFocus.title}</h1>
407
+ <span className={cn.badge}>{focusStatusLabel(selectedFocus.status)}</span>
408
+ </div>
409
+ <p className="mt-1 text-sm text-gray-500">
410
+ {[
411
+ selectedFocus.ownerName ? `Owner: ${selectedFocus.ownerName}` : null,
412
+ standings[selectedFocus.id] ? `${standings[selectedFocus.id].total - standings[selectedFocus.id].done} open${standings[selectedFocus.id].overdue ? `, ${standings[selectedFocus.id].overdue} overdue` : ''}` : null,
413
+ ].filter(Boolean).join(' · ')}
414
+ </p>
415
+ </div>
416
+ ) : null}
417
+ {renderSummary ? renderSummary(selectedFocus) : null}
418
+ {pageTitle ? null : (
419
+ <FocusCard
420
+ focus={selectedFocus}
421
+ standing={standings[selectedFocus.id] ?? null}
422
+ selected
423
+ classNames={cn}
424
+ onSelect={() => { setSelected(null); setShowDone(false); }}
425
+ />
426
+ )}
404
427
  <FocusProgressHistory focus={selectedFocus} api={api} />
405
428
  <ProjectTimeline focus={selectedFocus} className={`${cn.card}`} />
406
429
  {error ? <p className={cn.error} role="alert">{error}</p> : null}
@@ -1,9 +1,9 @@
1
1
  'use client';
2
2
 
3
3
  /**
4
- * OVERVIEW: many projects, many stakeholders, one screen. Rows are the account's projects, columns are whoever
5
- * the open items belong to, each cell a count and the most pressing item. Click a project to open it. The
6
- * numbers come from `buildOverview` (pure); nothing about people, areas or workflow is built in.
4
+ * OVERVIEW: every project on one row: who it is waiting on, the next step, how much is open. Click a heading to sort,
5
+ * click a Waiting-on chip to see only that person's projects, click a row to open the project. The numbers come from
6
+ * `buildOverview` (pure); nothing about people, areas or workflow is built in.
7
7
  */
8
8
  import * as React from 'react';
9
9
 
@@ -13,7 +13,7 @@ import type { Commitment, CorpusScope, Focus, PlanningApi } from '../../../corpu
13
13
  export interface OverviewPageProps {
14
14
  api: PlanningApi;
15
15
  scope: CorpusScope;
16
- /** Names that mean the signed-in user, so their column reads "Me". */
16
+ /** Names that mean the signed-in user, so they read "Me". */
17
17
  meNames?: string[];
18
18
  onOpenProject: (focusId: string, owner?: string) => void;
19
19
  now?: number;
@@ -27,7 +27,8 @@ const STATUS: Record<string, { label: string; cls: string }> = {
27
27
  draft: { label: 'Draft', cls: 'bg-gray-100 text-gray-700' },
28
28
  };
29
29
 
30
- const OTHERS = '__others__';
30
+ type SortKey = 'project' | 'status' | 'waiting' | 'open' | 'activity';
31
+ const dueText = (iso?: string | null) => (iso ? new Date(iso).toLocaleDateString(undefined, { month: 'short', day: 'numeric' }) : null);
31
32
 
32
33
  async function readAll<T>(read: (page: number) => Promise<{ results: T[]; next: string | null }>, maxPages = 20): Promise<T[]> {
33
34
  const out: T[] = [];
@@ -43,6 +44,7 @@ export function OverviewPage({ api, scope, meNames, onOpenProject, now }: Overvi
43
44
  const [data, setData] = React.useState<{ focuses: Focus[]; items: Array<Commitment & { focusId?: string }> } | null>(null);
44
45
  const [error, setError] = React.useState('');
45
46
  const [who, setWho] = React.useState<string | null>(null);
47
+ const [sort, setSort] = React.useState<{ key: SortKey; dir: 1 | -1 } | null>(null);
46
48
 
47
49
  React.useEffect(() => {
48
50
  let live = true;
@@ -64,71 +66,72 @@ export function OverviewPage({ api, scope, meNames, onOpenProject, now }: Overvi
64
66
  if (!overview) return <p className="text-sm text-gray-500">Loading…</p>;
65
67
  if (!overview.rows.length) return <p className="text-sm text-gray-500">Nothing in flight yet. Projects and their open to-dos show up here as they are connected or planned.</p>;
66
68
 
67
- // Nobody owns anything yet (e.g. every item is unassigned): one plain "Open" column, and no Waiting-on filter that would filter nothing.
68
- const onlyUnassigned = overview.columns.length === 1 && overview.columns[0].key === '';
69
- const people = onlyUnassigned ? [{ ...overview.columns[0], label: 'Open' }] : overview.columns;
70
- // Many people would make a grid nobody can read: show the first few as columns and fold the rest into one "Others" column
71
- // (the Waiting-on chips above still list everyone, and a chip filters to that person).
72
- const MAX_COLUMNS = 5;
73
- const hidden = people.length > MAX_COLUMNS + 1 ? people.slice(MAX_COLUMNS) : [];
74
- const cols = hidden.length ? [...people.slice(0, MAX_COLUMNS), { key: OTHERS, label: `Others (${hidden.length})`, total: hidden.reduce((n, c) => n + c.total, 0), isMe: false }] : people;
75
- const cellOf = (r: OverviewRow, key: string) => {
76
- if (key !== OTHERS) return r.cells[key];
77
- const parts = hidden.map((c) => r.cells[c.key]).filter(Boolean);
78
- if (!parts.length) return undefined;
79
- const next = parts.map((c) => c.next).filter((x): x is NonNullable<typeof x> => !!x)[0] ?? null;
80
- return { count: parts.reduce((n, c) => n + c.count, 0), next };
81
- };
69
+ const people = overview.columns;
70
+ const anyOwner = people.some((c) => c.key !== '');
82
71
  const filtered = who === null ? overview.rows : overview.rows.filter((r) => r.cells[who]);
83
- // Projects with nothing open would bury the ones that matter at real volumes: fold them under one line.
84
- const rows = filtered.filter((r) => r.open > 0);
72
+ const live = filtered.filter((r) => r.open > 0);
85
73
  const idle = filtered.filter((r) => r.open === 0);
86
- // the name to pre-filter the project's to-dos by: the person's own name ("Me" is the signed-in user's), nothing for Unassigned
87
- const searchFor = (key: string) => (key === '' ? undefined : overview.columns.find((c) => c.key === key)?.isMe ? meNames?.[0] : overview.columns.find((c) => c.key === key)?.label);
88
- const open = (r: OverviewRow, ownerKey?: string) => r.id !== NO_PROJECT && onOpenProject(r.id, ownerKey === undefined ? undefined : searchFor(ownerKey));
74
+ const val = (r: OverviewRow, k: SortKey): string | number =>
75
+ k === 'project' ? r.title.toLowerCase() : k === 'status' ? r.focus?.status ?? '' : k === 'waiting' ? r.waiting?.label.toLowerCase() ?? '' : k === 'open' ? r.open : r.lastActivity ?? '';
76
+ const rows = sort ? [...live].sort((a, b) => (val(a, sort.key) < val(b, sort.key) ? -sort.dir : val(a, sort.key) > val(b, sort.key) ? sort.dir : 0)) : live;
77
+ const open = (r: OverviewRow, owner?: string) => r.id !== NO_PROJECT && onOpenProject(r.id, owner);
78
+ const head = (key: SortKey, label: string) => (
79
+ <th scope="col" className="px-4 py-3" aria-sort={sort?.key === key ? (sort.dir === 1 ? 'ascending' : 'descending') : undefined}>
80
+ <button type="button" onClick={() => setSort(sort?.key === key ? { key, dir: sort.dir === 1 ? -1 : 1 } : { key, dir: key === 'open' || key === 'activity' ? -1 : 1 })} className="uppercase tracking-wide hover:text-gray-900">
81
+ {label}{sort?.key === key ? (sort.dir === 1 ? ' ↑' : ' ↓') : ''}
82
+ </button>
83
+ </th>
84
+ );
85
+ const waitingCell = (r: OverviewRow) =>
86
+ !r.waiting ? <span className="text-gray-300">–</span> : (
87
+ <>
88
+ <div className="text-gray-900">{anyOwner || r.waiting.label !== 'Unassigned' ? r.waiting.label : <span className="text-gray-400">Nobody named</span>}</div>
89
+ {r.moreWaiting ? <div className="mt-0.5 text-xs text-gray-500">+ {r.moreWaiting} more</div> : null}
90
+ </>
91
+ );
92
+ const nextCell = (r: OverviewRow) =>
93
+ !r.next ? <span className="text-gray-300">–</span> : (
94
+ <>
95
+ <div className="text-gray-900">{r.next.title}</div>
96
+ {r.next.dueAt ? <div className={`mt-0.5 text-xs ${Date.parse(r.next.dueAt) < (now ?? Date.now()) ? 'text-red-700' : 'text-gray-500'}`}>due {dueText(r.next.dueAt)}{Date.parse(r.next.dueAt) < (now ?? Date.now()) ? ' · overdue' : ''}</div> : null}
97
+ </>
98
+ );
89
99
 
90
100
  return (
91
101
  <div className="space-y-4" data-testid="overview">
92
- {onlyUnassigned ? null : <div className="flex flex-wrap items-center gap-2" role="group" aria-label="Waiting on">
93
- <span className="text-sm font-medium text-gray-600">Waiting on</span>
94
- <Chip active={who === null} onClick={() => setWho(null)}>Everyone · {overview.columns.reduce((a, c) => a + c.total, 0)}</Chip>
95
- {people.map((c) => (
96
- <Chip key={c.key || 'unassigned'} active={who === c.key} onClick={() => setWho(who === c.key ? null : c.key)}>{c.label} · {c.total}</Chip>
97
- ))}
98
- </div>}
102
+ {anyOwner ? (
103
+ <div className="flex flex-wrap items-center gap-2" role="group" aria-label="Waiting on">
104
+ <span className="text-sm font-medium text-gray-600">Waiting on</span>
105
+ <Chip active={who === null} onClick={() => setWho(null)}>Everyone · {people.reduce((a, c) => a + c.total, 0)}</Chip>
106
+ {people.map((c) => (
107
+ <Chip key={c.key || 'unassigned'} active={who === c.key} onClick={() => setWho(who === c.key ? null : c.key)}>{c.label} · {c.total}</Chip>
108
+ ))}
109
+ </div>
110
+ ) : null}
99
111
 
100
112
  <div className="hidden overflow-x-auto rounded-xl border border-gray-200 bg-white md:block">
101
- <table className="w-full min-w-[720px] border-collapse text-sm">
113
+ <table className="w-full min-w-[760px] border-collapse text-sm">
102
114
  <thead>
103
- <tr className="bg-gray-50 text-left text-xs font-medium uppercase tracking-wide text-gray-600">
104
- <th scope="col" className="px-4 py-3">Project</th>
105
- {cols.map((c) => <th key={c.key || 'unassigned'} scope="col" className={`px-4 py-3 ${who === c.key ? 'text-indigo-700' : ''}`}>{c.label}</th>)}
106
- <th scope="col" className="px-4 py-3">Last activity</th>
115
+ <tr className="bg-gray-50 text-left text-xs font-medium text-gray-600">
116
+ {head('project', 'Project')}
117
+ {head('status', 'Status')}
118
+ {head('waiting', 'Waiting on')}
119
+ <th scope="col" className="px-4 py-3 uppercase tracking-wide">Next step</th>
120
+ {head('open', 'Open')}
121
+ {head('activity', 'Last activity')}
107
122
  </tr>
108
123
  </thead>
109
124
  <tbody>
110
125
  {rows.map((r) => (
111
126
  <tr key={r.id} className="border-t border-gray-200 align-top hover:bg-gray-50">
112
127
  <th scope="row" className="px-4 py-3 text-left font-medium text-gray-900">
113
- {r.id === NO_PROJECT ? <span>{r.title}</span> : <button type="button" onClick={() => open(r)} className="text-left hover:underline">{r.title}</button>}
114
- <div className="mt-1 flex items-center gap-2 font-normal">
115
- {r.focus && STATUS[r.focus.status] ? <span className={`rounded-full px-2 py-0.5 text-xs ${STATUS[r.focus.status].cls}`}>{STATUS[r.focus.status].label}</span> : null}
116
- <span className="text-xs text-gray-500">{r.open} open{r.overdue ? ` · ${r.overdue} overdue` : ''}</span>
117
- </div>
128
+ {r.id === NO_PROJECT ? <span>{r.title}</span> : <button type="button" onClick={() => open(r, who ?? undefined)} className="text-left hover:underline">{r.title}</button>}
118
129
  </th>
119
- {cols.map((c) => {
120
- const cell = cellOf(r, c.key);
121
- return (
122
- <td key={c.key || 'unassigned'} className="px-4 py-3 text-gray-700">
123
- {cell ? (
124
- <button type="button" onClick={() => open(r, c.key === OTHERS ? undefined : c.key)} className="text-left hover:underline" aria-label={`${r.title}, ${c.label}: ${cell.count} open`}>
125
- <b className="text-gray-900">{cell.count}</b> <span className="text-gray-600">{cell.next?.title}</span>
126
- </button>
127
- ) : <span className="text-gray-300">–</span>}
128
- </td>
129
- );
130
- })}
131
- <td className="px-4 py-3 text-gray-500">{r.lastActivity ? new Date(r.lastActivity).toLocaleDateString(undefined, { month: 'short', day: 'numeric' }) : '–'}</td>
130
+ <td className="px-4 py-3">{r.focus && STATUS[r.focus.status] ? <span className={`rounded-full px-2 py-0.5 text-xs ${STATUS[r.focus.status].cls}`}>{STATUS[r.focus.status].label}</span> : null}</td>
131
+ <td className="px-4 py-3">{waitingCell(r)}</td>
132
+ <td className="px-4 py-3">{nextCell(r)}</td>
133
+ <td className="whitespace-nowrap px-4 py-3 text-gray-900">{r.open}{r.overdue ? <div className="mt-0.5 text-xs text-red-700">{r.overdue} overdue</div> : null}</td>
134
+ <td className="px-4 py-3 text-gray-500">{dueText(r.lastActivity) ?? '–'}</td>
132
135
  </tr>
133
136
  ))}
134
137
  </tbody>
@@ -137,19 +140,18 @@ export function OverviewPage({ api, scope, meNames, onOpenProject, now }: Overvi
137
140
 
138
141
  <ul className="space-y-3 md:hidden">
139
142
  {rows.map((r) => (
140
- <li key={r.id} className="rounded-xl border border-gray-200 bg-white p-4">
143
+ <li key={r.id} className="space-y-1.5 rounded-xl border border-gray-200 bg-white p-4">
141
144
  <div className="flex items-center gap-2">
142
- {r.id === NO_PROJECT ? <span className="flex-1 font-medium">{r.title}</span> : <button type="button" onClick={() => open(r)} className="flex-1 text-left font-medium hover:underline">{r.title}</button>}
145
+ {r.id === NO_PROJECT ? <span className="flex-1 font-medium">{r.title}</span> : <button type="button" onClick={() => open(r, who ?? undefined)} className="flex-1 text-left font-medium hover:underline">{r.title}</button>}
143
146
  {r.focus && STATUS[r.focus.status] ? <span className={`rounded-full px-2 py-0.5 text-xs ${STATUS[r.focus.status].cls}`}>{STATUS[r.focus.status].label}</span> : null}
144
147
  </div>
145
- <div className="mt-2 flex flex-wrap gap-1.5 text-xs">
146
- {cols.filter((c) => cellOf(r, c.key)).map((c) => (
147
- <button key={c.key || 'unassigned'} type="button" onClick={() => open(r, c.key === OTHERS ? undefined : c.key)} className="rounded-md bg-gray-100 px-2 py-1 text-gray-800">{c.label} {cellOf(r, c.key)?.count}</button>
148
- ))}
149
- </div>
148
+ {anyOwner && r.waiting ? <div className="text-sm text-gray-700"><span className="text-gray-500">Waiting on</span> {r.waiting.label}{r.moreWaiting ? <span className="text-gray-500"> + {r.moreWaiting} more</span> : null}</div> : null}
149
+ {r.next ? <div className="text-sm text-gray-800"><span className="text-gray-500">Next</span> {r.next.title}</div> : null}
150
+ <div className={`text-xs ${r.overdue ? 'text-red-700' : 'text-gray-500'}`}>{r.open} open{r.overdue ? ` · ${r.overdue} overdue` : ''}</div>
150
151
  </li>
151
152
  ))}
152
153
  </ul>
154
+
153
155
  {idle.length ? (
154
156
  <details className="rounded-xl border border-gray-200 bg-white px-4 py-3 text-sm">
155
157
  <summary className="cursor-pointer text-gray-600">{idle.length} {idle.length === 1 ? 'project has' : 'projects have'} nothing open</summary>
@@ -0,0 +1,78 @@
1
+ 'use client';
2
+
3
+ /**
4
+ * The top of a project's page: a segmented bar of its open items by who they wait on, with counts. Clicking a segment
5
+ * (or its label) filters the list below to that person; "Show all" clears it. Generic: the segments are whoever owns
6
+ * the project's open items.
7
+ */
8
+ import * as React from 'react';
9
+
10
+ import { countByOwner } from '../../../corpus/overview';
11
+ import type { Commitment, PlanningApi } from '../../../corpus/types';
12
+
13
+ const COLORS = ['bg-indigo-600', 'bg-sky-500', 'bg-slate-400', 'bg-teal-500', 'bg-amber-500', 'bg-rose-400'];
14
+
15
+ export interface ProjectWaitingBarProps {
16
+ api: PlanningApi;
17
+ focusId: string;
18
+ meNames?: string[];
19
+ /** The selected person's key (null = everyone). */
20
+ selected: string | null;
21
+ /** Called with the person's key and the name to filter the list by (undefined for Unassigned or everyone). */
22
+ onSelect: (key: string | null, name?: string) => void;
23
+ }
24
+
25
+ export function ProjectWaitingBar({ api, focusId, meNames, selected, onSelect }: ProjectWaitingBarProps) {
26
+ const [items, setItems] = React.useState<Commitment[] | null>(null);
27
+ React.useEffect(() => {
28
+ let live = true;
29
+ (async () => {
30
+ const out: Commitment[] = [];
31
+ for (let page = 1; page <= 20; page++) {
32
+ const r = await api.listCommitments({ focus: focusId, status: ['open', 'in_progress', 'blocked'], page, pageSize: 200 } as never);
33
+ out.push(...r.results);
34
+ if (!r.next || !r.results.length) break;
35
+ }
36
+ if (live) setItems(out);
37
+ })().catch(() => live && setItems([]));
38
+ return () => {
39
+ live = false;
40
+ };
41
+ }, [api, focusId]);
42
+
43
+ const segs = React.useMemo(() => (items ? countByOwner(items, meNames) : []), [items, meNames]);
44
+ const total = segs.reduce((n, s) => n + s.total, 0);
45
+ if (!items || total === 0) return null;
46
+ const nameFor = (key: string, label: string, isMe: boolean) => (key === '' ? undefined : isMe ? meNames?.[0] : label);
47
+ return (
48
+ <div className="space-y-2 rounded-xl border border-gray-200 bg-white p-4" data-testid="waiting-bar">
49
+ <div className="flex items-center gap-2 text-sm">
50
+ <b className="text-gray-900">Waiting on</b>
51
+ <span className="text-gray-500">click a segment to filter the list below</span>
52
+ <span className="flex-1" />
53
+ {selected !== null ? <button type="button" onClick={() => onSelect(null)} className="text-indigo-700 hover:underline">Show all {total}</button> : null}
54
+ </div>
55
+ <div className="flex h-3.5 overflow-hidden rounded-full bg-gray-200" role="group" aria-label="Open items by who they wait on">
56
+ {segs.map((s, i) => (
57
+ <button
58
+ key={s.key || 'unassigned'}
59
+ type="button"
60
+ title={`${s.label}: ${s.total}`}
61
+ aria-label={`${s.label}, ${s.total} open`}
62
+ aria-pressed={selected === s.key}
63
+ onClick={() => onSelect(selected === s.key ? null : s.key, nameFor(s.key, s.label, s.isMe))}
64
+ style={{ width: `${(s.total / total) * 100}%` }}
65
+ className={`${COLORS[i % COLORS.length]} ${selected !== null && selected !== s.key ? 'opacity-30' : ''}`}
66
+ />
67
+ ))}
68
+ </div>
69
+ <div className="flex flex-wrap gap-x-4 gap-y-1 text-sm text-gray-700">
70
+ {segs.map((s, i) => (
71
+ <button key={s.key || 'unassigned'} type="button" onClick={() => onSelect(selected === s.key ? null : s.key, nameFor(s.key, s.label, s.isMe))} className={`inline-flex items-center gap-1.5 hover:underline ${selected === s.key ? 'font-semibold' : ''}`}>
72
+ <span className={`inline-block h-2.5 w-2.5 rounded-sm ${COLORS[i % COLORS.length]}`} />{s.label} {s.total}
73
+ </button>
74
+ ))}
75
+ </div>
76
+ </div>
77
+ );
78
+ }
@@ -1,2 +1,4 @@
1
1
  export { OverviewPage } from './OverviewPage';
2
2
  export type { OverviewPageProps } from './OverviewPage';
3
+ export { ProjectWaitingBar } from './ProjectWaitingBar';
4
+ export type { ProjectWaitingBarProps } from './ProjectWaitingBar';
@@ -20,19 +20,23 @@ export interface ProjectsPageProps {
20
20
  onFocusChange: (focusId: string | null) => void;
21
21
  /** The to-do list for one project: the host mounts the shared list with `focusId` set. */
22
22
  renderTodos: (focus: Focus) => React.ReactNode;
23
+ /** Back button label and a summary above the project card (the Overview passes '‹ Overview' and the waiting-on bar). */
24
+ backLabel?: string;
25
+ renderSummary?: (focus: Focus) => React.ReactNode;
26
+ pageTitle?: boolean;
23
27
  onOpenDocument?: (documentId: string) => void;
24
28
  now?: number;
25
29
  timeZone?: string;
26
30
  }
27
31
 
28
- export function ProjectsPage({ api, scope, focusId, onFocusChange, renderTodos, onOpenDocument, now, timeZone }: ProjectsPageProps) {
32
+ export function ProjectsPage({ api, scope, focusId, onFocusChange, renderTodos, backLabel, renderSummary, pageTitle, onOpenDocument, now, timeZone }: ProjectsPageProps) {
29
33
  const [epoch, setEpoch] = React.useState(0);
30
34
  const [error, setError] = React.useState('');
31
35
  if (focusId) {
32
36
  return (
33
37
  <PlanningPage
34
38
  api={api} scope={scope} focusId={focusId} onFocusChange={onFocusChange}
35
- renderItems={renderTodos} onOpenDocument={onOpenDocument} now={now} timeZone={timeZone}
39
+ renderItems={renderTodos} backLabel={backLabel} renderSummary={renderSummary} pageTitle={pageTitle} onOpenDocument={onOpenDocument} now={now} timeZone={timeZone}
36
40
  />
37
41
  );
38
42
  }
@@ -307,8 +307,8 @@ export type { DueBucket, DueEntry, DueGroup, DueGroups } from './due-groups';
307
307
  export { STALE_DAYS, groupTracker, isTask } from './tracker-groups';
308
308
  export type { TrackerEntry, TrackerGroups } from './tracker-groups';
309
309
  export { DEFAULT_TRACKER_SORT, TRACKER_SORTS, commitmentOrder, compareCommitments } from './tracker-sort';
310
- export { buildOverview, NO_PROJECT } from './overview';
311
- export type { Overview, OverviewRow, OverviewColumn, OverviewCell } from './overview';
310
+ export { buildOverview, countByOwner, NO_PROJECT } from './overview';
311
+ export type { Overview, OverviewRow, OverviewColumn, OverviewCell, OverviewWaiting } from './overview';
312
312
  export { summarizeFocuses } from './focus-overview';
313
313
  export type { FocusSummary } from './focus-overview';
314
314
  export { focusToGoalRow } from './goal-rows';
@@ -20,6 +20,11 @@ export interface OverviewColumn {
20
20
  total: number;
21
21
  isMe: boolean;
22
22
  }
23
+ export interface OverviewWaiting {
24
+ key: string;
25
+ label: string;
26
+ isMe: boolean;
27
+ }
23
28
  export interface OverviewRow {
24
29
  /** The focus id, or NO_PROJECT for items filed under no project. */
25
30
  id: string;
@@ -31,6 +36,11 @@ export interface OverviewRow {
31
36
  /** ISO instant of the newest sighting of any of its items. */
32
37
  lastActivity: string | null;
33
38
  cells: Record<string, OverviewCell>;
39
+ /** The most pressing open item across the project, and who owns it. */
40
+ next: Commitment | null;
41
+ waiting: OverviewWaiting | null;
42
+ /** How many OTHER people also have open items here (the '+N' after the name). */
43
+ moreWaiting: number;
34
44
  }
35
45
  export interface Overview {
36
46
  columns: OverviewColumn[];
@@ -85,6 +95,7 @@ export function buildOverview(focuses: Focus[], items: Array<Commitment & { focu
85
95
  t.total += 1;
86
96
  totals.set(k, t);
87
97
  }
98
+ const next = [...mine].sort(byUrgency)[0] ?? null;
88
99
  const lastActivity = mine.map((c) => c.lastSeenAt).filter(Boolean).sort().at(-1) ?? null;
89
100
  return {
90
101
  ...r,
@@ -93,6 +104,9 @@ export function buildOverview(focuses: Focus[], items: Array<Commitment & { focu
93
104
  blocked: mine.filter((c) => c.status === 'blocked').length,
94
105
  lastActivity,
95
106
  cells,
107
+ next,
108
+ waiting: next ? { key: ownerKey(next), label: '', isMe: me.has(ownerKey(next)) } : null,
109
+ moreWaiting: Math.max(0, Object.keys(cells).length - 1),
96
110
  };
97
111
  });
98
112
 
@@ -102,7 +116,23 @@ export function buildOverview(focuses: Focus[], items: Array<Commitment & { focu
102
116
  });
103
117
  columns.sort((a, b) => Number(b.isMe) - Number(a.isMe) || Number(a.key === '') - Number(b.key === '') || b.total - a.total || a.label.localeCompare(b.label));
104
118
 
119
+ const label = new Map(columns.map((c) => [c.key, c.label]));
120
+ for (const r of rows) if (r.waiting) r.waiting.label = label.get(r.waiting.key) ?? 'Unassigned';
121
+
105
122
  const attention = (r: OverviewRow) => (r.focus?.status === 'off_track' || r.focus?.status === 'at_risk' ? 0 : r.blocked ? 1 : r.overdue ? 2 : 3);
106
123
  rows.sort((a, b) => (a.id === NO_PROJECT ? 1 : 0) - (b.id === NO_PROJECT ? 1 : 0) || attention(a) - attention(b) || b.open - a.open || a.title.localeCompare(b.title));
107
124
  return { columns, rows };
108
125
  }
126
+
127
+ /** Open items by who they wait on, biggest first, 'Me' first: the segments of a project's waiting-on bar. */
128
+ export function countByOwner(items: Commitment[], meNames: string[] = []): OverviewColumn[] {
129
+ const me = new Set(meNames.map(norm).filter(Boolean));
130
+ const m = new Map<string, OverviewColumn>();
131
+ for (const c of items.filter((x) => OPEN.has(x.status))) {
132
+ const key = ownerKey(c);
133
+ const col = m.get(key) ?? { key, label: me.has(key) ? 'Me' : c.ownerName?.trim() || 'Unassigned', total: 0, isMe: me.has(key) };
134
+ col.total += 1;
135
+ m.set(key, col);
136
+ }
137
+ return [...m.values()].sort((a, b) => Number(b.isMe) - Number(a.isMe) || Number(a.key === '') - Number(b.key === '') || b.total - a.total || a.label.localeCompare(b.label));
138
+ }