@startsimpli/integrations 0.2.134 → 0.2.135

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.
Files changed (31) hide show
  1. package/package.json +2 -2
  2. package/src/__tests__/corpus-planning.test.tsx +13 -3
  3. package/src/__tests__/corpus-tracker.test.tsx +53 -69
  4. package/src/__tests__/focus-standings.test.tsx +3 -1
  5. package/src/__tests__/home-brief.test.tsx +84 -0
  6. package/src/__tests__/project-surfaces.test.tsx +1 -1
  7. package/src/__tests__/work-groups.test.ts +181 -0
  8. package/src/components/index.ts +1 -0
  9. package/src/components/pages/ConnectionsPage.tsx +7 -1402
  10. package/src/components/pages/PlanningPage.tsx +129 -67
  11. package/src/components/pages/TrackerPage.tsx +174 -149
  12. package/src/components/pages/connections/CapabilityPicker.tsx +75 -0
  13. package/src/components/pages/connections/CatalogCard.tsx +300 -0
  14. package/src/components/pages/connections/ConnectionCard.tsx +489 -0
  15. package/src/components/pages/connections/ConnectionForms.tsx +215 -0
  16. package/src/components/pages/connections/MemberPolicyToggle.tsx +106 -0
  17. package/src/components/pages/connections/bound-api.ts +175 -0
  18. package/src/components/pages/connections/copy.ts +74 -0
  19. package/src/components/pages/home/BriefCard.tsx +84 -0
  20. package/src/components/pages/home/CompactItemRow.tsx +61 -0
  21. package/src/components/pages/home/DueAcrossProjects.tsx +74 -0
  22. package/src/components/pages/home/HomeBriefPage.tsx +112 -0
  23. package/src/components/pages/home/RecentNotes.tsx +69 -0
  24. package/src/components/pages/home/index.ts +10 -0
  25. package/src/components/pages/home/useProjectNames.ts +23 -0
  26. package/src/components/pages/work-items.tsx +15 -9
  27. package/src/corpus/due-groups.ts +81 -0
  28. package/src/corpus/focus-overview.ts +54 -0
  29. package/src/corpus/index.ts +10 -0
  30. package/src/corpus/note-actions.ts +44 -0
  31. package/src/corpus/tracker-groups.ts +84 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startsimpli/integrations",
3
- "version": "0.2.134",
3
+ "version": "0.2.135",
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",
@@ -99,9 +99,9 @@
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.171",
102
103
  "@startsimpli/ui-native": "0.1.14",
103
104
  "@startsimpli/auth": "0.4.50",
104
- "@startsimpli/ui": "0.4.171",
105
105
  "@startsimpli/utils": "0.4.17"
106
106
  },
107
107
  "scripts": {
@@ -18,6 +18,7 @@
18
18
  */
19
19
  import * as React from 'react';
20
20
  import { render, screen, waitFor } from '@testing-library/react';
21
+ import userEvent from '@testing-library/user-event';
21
22
  import { describe, expect, it, vi } from 'vitest';
22
23
 
23
24
  import { PlanningPage } from '../components/pages/PlanningPage';
@@ -184,10 +185,11 @@ describe('an authored item', () => {
184
185
  render(
185
186
  <PlanningPage
186
187
  api={fakeApi({
188
+ focuses: [FOCUS],
187
189
  items: [
188
- commitment({ externalId: 'commit:a', title: 'Chase the inventor for 2148' }),
190
+ commitment({ externalId: 'commit:a', title: 'Chase the inventor for 2148', focusId: 'f1' }),
189
191
  {
190
- ...commitment({ externalId: 'item:b', title: 'Renew the office lease' }),
192
+ ...commitment({ externalId: 'item:b', title: 'Renew the office lease', focusId: 'f1' }),
191
193
  mentions: [], origin: ORIGIN.authored, firstSeenAt: null, lastSeenAt: null,
192
194
  },
193
195
  ],
@@ -196,6 +198,7 @@ describe('an authored item', () => {
196
198
  now={NOW}
197
199
  />,
198
200
  );
201
+ await userEvent.click(await screen.findByRole('button', { name: /Close the Series A/ }));
199
202
  expect(await screen.findByText('Chase the inventor for 2148')).toBeTruthy();
200
203
  expect(screen.getByText('Renew the office lease')).toBeTruthy();
201
204
  expect(screen.getByText('Added by hand')).toBeTruthy();
@@ -469,6 +472,8 @@ describe('PlanningPage', () => {
469
472
  />,
470
473
  );
471
474
  expect(await screen.findByText('Close the Series A')).toBeTruthy();
475
+ expect(screen.getByText('Nothing open')).toBeTruthy();
476
+ await userEvent.click(screen.getByRole('button', { name: /Close the Series A/ }));
472
477
  await waitFor(() => expect(screen.getByText('Nothing filed under this yet')).toBeTruthy());
473
478
  });
474
479
 
@@ -483,6 +488,7 @@ describe('PlanningPage', () => {
483
488
  now={NOW}
484
489
  />,
485
490
  );
491
+ await userEvent.click(await screen.findByRole('button', { name: /Close the Series A/ }));
486
492
  await waitFor(() => expect(screen.getByText(/12 of 40 done/)).toBeTruthy());
487
493
  expect(screen.getByText(/3 overdue/)).toBeTruthy();
488
494
  });
@@ -508,7 +514,11 @@ describe('PlanningPage', () => {
508
514
  it('confesses when the server ignored a filter it was given', async () => {
509
515
  const api = fakeApi({ focuses: [FOCUS], items: [], applied: [] });
510
516
  render(<PlanningPage api={api} scope={SCOPE} now={NOW} />);
511
- await waitFor(() => expect(screen.getByText(/did not filter by status/)).toBeTruthy());
517
+ // Collapsed to one chip; the sentence is in the drawer, not on the page.
518
+ const chip = await screen.findByRole('button', { name: '1 warning' });
519
+ expect(screen.queryByText(/did not filter by status/)).toBeNull();
520
+ await userEvent.click(chip);
521
+ expect(await screen.findByText(/did not filter by status/)).toBeTruthy();
512
522
  });
513
523
 
514
524
  it('does not loop even when the app hands it a NEW api object every render', async () => {
@@ -144,11 +144,15 @@ describe('TrackerPage — it must not loop', () => {
144
144
 
145
145
  it('DOES re-read when the user actually changes something', async () => {
146
146
  let calls = 0;
147
- render(<TrackerPage api={makeApi({ onQuery: () => { calls += 1; } })} scope={SCOPE} now={NOW} />);
147
+ const updated: string[] = [];
148
+ const api = makeApi({ onQuery: () => { calls += 1; } });
149
+ api.updateCommitment = async (item, patch) => { updated.push(`${item.externalId}:${patch.status}`); return item; };
150
+ render(<TrackerPage api={api} scope={SCOPE} now={NOW} />);
148
151
  await screen.findByText('Chase the inventor for comments on 2148');
149
152
  expect(calls).toBe(1);
150
- await userEvent.click(screen.getByRole('tab', { name: 'Overdue' }));
153
+ await userEvent.click(screen.getAllByRole('button', { name: 'Done' })[0]);
151
154
  await new Promise((resolve) => setTimeout(resolve, 150));
155
+ expect(updated).toHaveLength(1);
152
156
  expect(calls).toBe(2);
153
157
  });
154
158
  });
@@ -176,9 +180,9 @@ describe('TrackerPage — what is outstanding', () => {
176
180
  render(<TrackerPage api={makeApi()} scope={SCOPE} now={NOW} />);
177
181
  // The Library's `appliedFilters` contract, owed here about status — a
178
182
  // status filter that silently does nothing breaks the screen's only claim.
179
- expect(
180
- await screen.findByText(/did not filter by .*status/i),
181
- ).toBeInTheDocument();
183
+ // Collapsed to a chip; the sentence is inside it.
184
+ expect(await screen.findByText('1 warning')).toBeInTheDocument();
185
+ expect(screen.getByText(/did not filter by .*status/i)).toBeInTheDocument();
182
186
  });
183
187
 
184
188
  it('does NOT nag when the API reports it applied them', async () => {
@@ -193,59 +197,52 @@ describe('TrackerPage — what is outstanding', () => {
193
197
  expect(screen.queryByText(/did not filter by/i)).not.toBeInTheDocument();
194
198
  });
195
199
 
196
- it('puts an overdue item above one with no due date', async () => {
197
- render(<TrackerPage api={makeApi()} scope={SCOPE} now={NOW} />);
200
+ it('groups the list: overdue sits in Today, undated work in Later, each with a count', async () => {
201
+ render(<TrackerPage api={makeApi()} scope={SCOPE} now={NOW} timeZone="UTC" />);
198
202
  await screen.findByText('Chase the inventor for comments on 2148');
199
- const titles = screen.getAllByRole('article').map((node) => within(node).getByRole('heading').textContent);
200
- expect(titles[0]).toBe('Send the equity sheet to Harry Holcomb');
201
- });
202
-
203
- it('says an item is overdue, with the date', async () => {
204
- render(<TrackerPage api={makeApi()} scope={SCOPE} now={NOW} />);
205
- expect(await screen.findByText(/Overdue/)).toBeInTheDocument();
206
- });
207
-
208
- it('says how long something has been open, which is the point of the screen', async () => {
209
- render(<TrackerPage api={makeApi()} scope={SCOPE} now={NOW} />);
210
- // Raised 2026-08-01, read 2026-08-10 — nine calendar days, eight elapsed.
211
- expect(await screen.findAllByText(/open for 8 days/)).not.toHaveLength(0);
212
- });
213
-
214
- it('states that nobody was named rather than rendering a blank', async () => {
215
- render(<TrackerPage api={makeApi()} scope={SCOPE} now={NOW} />);
216
- // "Nobody said who owns this" is a fact about the meeting, and it is the
217
- // most actionable thing on the screen. A blank cell hides it.
218
- expect(await screen.findByText('No owner named')).toBeInTheDocument();
219
- expect(screen.getByText('Rae')).toBeInTheDocument();
220
- });
221
-
222
- it('renders every row with the meeting it came from and a verbatim quote', async () => {
223
- render(<TrackerPage api={makeApi()} scope={SCOPE} now={NOW} />);
203
+ const today = screen.getByRole('region', { name: 'Today' });
204
+ expect(within(today).getByText('Send the equity sheet to Harry Holcomb')).toBeInTheDocument();
205
+ expect(within(today).getByText('5d late')).toBeInTheDocument();
206
+ const later = screen.getByRole('region', { name: 'Later' });
207
+ expect(within(later).getByText('Chase the inventor for comments on 2148')).toBeInTheDocument();
208
+ expect(screen.getByTestId('tracker-summary')).toHaveTextContent('2 owed · 1 today');
209
+ });
210
+
211
+ it('keeps meeting statements off the list and behind a fold', async () => {
212
+ const rows = [
213
+ ...ROWS,
214
+ commitment({ externalId: 'commit:dec', title: 'We decided to move the beta', subtype: 'decision' }),
215
+ ];
216
+ render(<TrackerPage api={makeApi({ rows })} scope={SCOPE} now={NOW} />);
224
217
  await screen.findByText('Chase the inventor for comments on 2148');
225
- for (const article of screen.getAllByRole('article')) {
226
- expect(within(article).getByText(/From 1 meeting/)).toBeInTheDocument();
227
- expect(within(article).getByText(/Status in the system reads/)).toBeInTheDocument();
228
- }
218
+ expect(screen.getByText(/Decisions and questions \(1\)/)).toBeInTheDocument();
219
+ expect(within(screen.getByRole('region', { name: 'Later' })).queryByText('We decided to move the beta')).toBeNull();
229
220
  });
230
221
 
231
- it('shows the closed tab with the sentence that closed it', async () => {
232
- render(<TrackerPage api={makeApi()} scope={SCOPE} now={NOW} />);
222
+ it('hides undated items nobody touched in 90 days behind Stale, and archives them in one click', async () => {
223
+ const stale = commitment({
224
+ externalId: 'commit:stale', title: 'An old promise', lastSeenAt: '2026-04-01T00:00:00Z', firstSeenAt: '2026-03-01T00:00:00Z',
225
+ });
226
+ const patches: Array<[string, unknown]> = [];
227
+ const api = makeApi({ rows: [...ROWS, stale] });
228
+ api.updateCommitment = async (item, patch) => { patches.push([item.externalId, patch.status]); return item; };
229
+ render(<TrackerPage api={api} scope={SCOPE} now={NOW} />);
233
230
  await screen.findByText('Chase the inventor for comments on 2148');
234
- await userEvent.click(screen.getByRole('tab', { name: 'Closed' }));
235
-
236
- expect(await screen.findByText('File the PCT for 2205')).toBeInTheDocument();
237
- // "Why does it say this is done" has to be answerable without opening the
238
- // meeting, or nobody trusts a single closed row.
239
- expect(screen.getByText(/Closed by: .*filed as first PCT/)).toBeInTheDocument();
231
+ expect(screen.getByText(/Stale \(1\)/)).toBeInTheDocument();
232
+ expect(within(screen.getByRole('region', { name: 'Later' })).queryByText('An old promise')).toBeNull();
233
+ await userEvent.click(screen.getByRole('button', { name: 'Archive' }));
234
+ expect(patches).toEqual([['commit:stale', 'dropped']]);
240
235
  });
241
236
 
242
- it('filters by owner', async () => {
243
- render(<TrackerPage api={makeApi()} scope={SCOPE} now={NOW} />);
237
+ it('reads finished items only when the Done fold is opened, with the sentence that closed them', async () => {
238
+ const queries: CommitmentQuery[] = [];
239
+ const api = makeApi({ onQuery: (query) => queries.push(query) });
240
+ render(<TrackerPage api={api} scope={SCOPE} now={NOW} />);
244
241
  await screen.findByText('Chase the inventor for comments on 2148');
245
- await userEvent.type(screen.getByPlaceholderText('Owner'), 'Rae');
246
-
247
- expect(screen.getByText('Chase the inventor for comments on 2148')).toBeInTheDocument();
248
- expect(screen.queryByText('Send the equity sheet to Harry Holcomb')).not.toBeInTheDocument();
242
+ expect(queries.some((q) => Array.isArray(q.status) && q.status.includes('done'))).toBe(false);
243
+ await userEvent.click(screen.getByText('Done'));
244
+ expect(await screen.findByText('File the PCT for 2205')).toBeInTheDocument();
245
+ expect(queries.some((q) => Array.isArray(q.status) && q.status.includes('done'))).toBe(true);
249
246
  });
250
247
 
251
248
  it('tells a fresh workspace what to do instead of showing an empty page', async () => {
@@ -253,34 +250,21 @@ describe('TrackerPage — what is outstanding', () => {
253
250
  expect(await screen.findByText(/Nothing has been pulled out of your meetings yet/)).toBeInTheDocument();
254
251
  });
255
252
 
256
- it('does NOT say the workspace is empty when a VIEW is empty', async () => {
257
- // Browser-verified failure on the deployed tenant: the Overdue tab said
258
- // "Nothing has been pulled out of your meetings yet" over ninety-seven open
259
- // items, because nothing carried a due date. Advice that is false is worse
260
- // than no advice.
261
- const rows = [commitment({ externalId: 'commit:x', title: 'An open item' })];
253
+ it('does NOT say the workspace is empty when nothing is owed but it holds rows', async () => {
254
+ // Advice that is false is worse than no advice (browser-verified failure on the deployed tenant).
262
255
  const api: CommitmentTrackerApi = {
263
256
  async listCommitments(query: CommitmentQuery = {}) {
264
- // The server filters: the overdue query matches nothing, an unfiltered
265
- // count-only probe still reports the workspace has rows.
266
- const filtered = Boolean(query.dueBefore);
267
- return {
268
- count: filtered ? 0 : rows.length,
269
- next: null, previous: null,
270
- results: filtered ? [] : rows,
271
- appliedFilters: ['status', 'dueBefore'],
272
- };
257
+ const probe = query.pageSize === 1;
258
+ return { count: probe ? 5 : 0, next: null, previous: null, results: [], appliedFilters: ['status'] };
273
259
  },
274
260
  };
275
261
  render(<TrackerPage api={api} scope={SCOPE} now={NOW} />);
276
- await screen.findByText('An open item');
277
- await userEvent.click(screen.getByRole('tab', { name: 'Overdue' }));
278
-
279
- expect(await screen.findByText(/Nothing matches this view/)).toBeInTheDocument();
262
+ expect(await screen.findByText('Nothing is owed right now.')).toBeInTheDocument();
280
263
  expect(screen.queryByText(/Nothing has been pulled out of your meetings yet/)).not.toBeInTheDocument();
281
264
  });
282
265
  });
283
266
 
267
+
284
268
  describe('TrackerPage — running the extraction', () => {
285
269
  const RESULT = {
286
270
  documentsProcessed: 16,
@@ -1,4 +1,4 @@
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, vi } from 'vitest';
3
3
  import { PlanningPage } from '../components/pages/PlanningPage';
4
4
  import { createPlanningApi } from '../corpus/client';
@@ -103,6 +103,8 @@ describe('PlanningPage standings', () => {
103
103
  it('uses ONE batched read for every card', async () => {
104
104
  const focusStandings = vi.fn(async (): Promise<Record<string, FocusStanding>> => ({ f1: { focusId: 'f1', total: 40, done: 12, overdue: 3 } }));
105
105
  render(<PlanningPage api={planning({ focusStandings })} scope={SCOPE} now={NOW} />);
106
+ // The overview lists focuses; a focus's done-over-total shows when it is opened.
107
+ fireEvent.click(await screen.findByText('Crochets'));
106
108
  await waitFor(() => expect(screen.getByText(/12 of 40 done/)).toBeInTheDocument());
107
109
  expect(focusStandings).toHaveBeenCalledTimes(1);
108
110
  });
@@ -0,0 +1,84 @@
1
+ /**
2
+ * HOME (bd startsim-cpzoz): the brief shows the stored text verbatim, the due
3
+ * list is grouped, and each recent note lists the actions it produced.
4
+ */
5
+ import * as React from 'react';
6
+ import { render, screen, within } from '@testing-library/react';
7
+ import userEvent from '@testing-library/user-event';
8
+ import { describe, expect, it, vi } from 'vitest';
9
+
10
+ import { HomeBriefPage } from '../components/pages/home';
11
+ import type { BriefingResult } from '../corpus/briefing';
12
+ import type { Commitment, CorpusApi, CommitmentApi, SourceDocument } from '../corpus/types';
13
+
14
+ const NOW = Date.parse('2026-11-06T17:00:00Z');
15
+ const TEXT = 'Good morning Quinn. Two things are overdue.\nFirst, send the term sheet.';
16
+ const RESULT = {
17
+ briefingId: 'b1', text: TEXT, audioUrl: '/corpus/briefing/b1/audio', items: [], remaining: 0,
18
+ context: { itemIds: [], localDate: '2026-11-06', timeZone: 'UTC', offsets: [] }, scriptSource: 'template', cached: true, ms: 1,
19
+ } as unknown as BriefingResult;
20
+
21
+ const mention = (documentId: string) => ({ documentId, originKey: 'k', occurredAt: null, quote: '', extractor: 'model' as const });
22
+ function item(id: string, over: Partial<Commitment> = {}): Commitment {
23
+ return {
24
+ id, externalId: `commit:${id}`, dedupeKey: id, subtype: 'action', title: id, detail: '', status: 'open', subjectKey: '', actionKey: '',
25
+ mentions: [], firstSeenAt: null, lastSeenAt: null, extractorVersion: 't', source: 'granola', sourceLabel: 'G', scope: { orgId: 'o' }, ...over,
26
+ } as Commitment;
27
+ }
28
+ const DOC = { id: 'n1', title: 'Weekly sync', body: '', summary: 'We agreed to ship Friday.', sections: [], occurredAt: '2026-11-05T10:00:00Z', source: 'granola', sourceLabel: 'G', subtype: 'meeting', sourceRef: 'x' } as unknown as SourceDocument;
29
+
30
+ function corpus(): CorpusApi & CommitmentApi {
31
+ const open = [
32
+ item('late', { dueAt: '2026-11-03', focusId: 'f1', mentions: [mention('n1')] }),
33
+ item('soon', { dueAt: '2026-11-09' }),
34
+ ];
35
+ return {
36
+ async listCommitments(q = {}) {
37
+ const results = Array.isArray(q.status) ? open : [...open, item('done1', { status: 'done', mentions: [mention('n1')] })];
38
+ return { count: results.length, next: null, previous: null, results };
39
+ },
40
+ async listDocuments() { return { count: 1, next: null, previous: null, results: [DOC] }; },
41
+ } as unknown as CorpusApi & CommitmentApi;
42
+ }
43
+
44
+ describe('HomeBriefPage', () => {
45
+ it('shows the stored brief text unchanged and never forces a regeneration', async () => {
46
+ const fetch = vi.fn(async () => RESULT);
47
+ render(<HomeBriefPage brief={{ fetch }} corpus={corpus()} now={NOW} timeZone="UTC" />);
48
+ expect((await screen.findByTestId('brief-text')).textContent).toBe(TEXT);
49
+ expect(fetch).toHaveBeenCalledTimes(1);
50
+ expect(fetch.mock.calls[0]).toHaveLength(0);
51
+ });
52
+
53
+ it('groups what is due with the project as a chip', async () => {
54
+ render(
55
+ <HomeBriefPage
56
+ brief={{ fetch: async () => RESULT }} corpus={corpus()} now={NOW} timeZone="UTC"
57
+ listFocuses={async () => ({ count: 1, next: null, previous: null, results: [{ id: 'f1', title: 'Launch v2' } as never] })}
58
+ />,
59
+ );
60
+ const overdue = await screen.findByRole('region', { name: 'Overdue' });
61
+ expect(within(overdue).getByText('late')).toBeInTheDocument();
62
+ expect(await within(overdue).findByText('Launch v2')).toBeInTheDocument();
63
+ expect(within(screen.getByRole('region', { name: 'This week' })).getByText('soon')).toBeInTheDocument();
64
+ });
65
+
66
+ it('lists each recent note with the to-dos that came out of it, linking back', async () => {
67
+ const onOpenNote = vi.fn();
68
+ render(<HomeBriefPage brief={{ fetch: async () => RESULT }} corpus={corpus()} now={NOW} timeZone="UTC" onOpenNote={onOpenNote} />);
69
+ const note = await screen.findByText('Weekly sync');
70
+ expect(screen.getByText('2 to-dos · 1 open')).toBeInTheDocument();
71
+ await userEvent.click(note);
72
+ expect(screen.getByText('We agreed to ship Friday.')).toBeInTheDocument();
73
+ await userEvent.click(screen.getByRole('button', { name: 'Open the full note' }));
74
+ expect(onOpenNote).toHaveBeenCalledWith('n1');
75
+ });
76
+
77
+ it('says plainly when the brief cannot load, with a retry', async () => {
78
+ const fetch = vi.fn().mockRejectedValueOnce(new Error('nope')).mockResolvedValue(RESULT);
79
+ render(<HomeBriefPage brief={{ fetch }} corpus={corpus()} now={NOW} />);
80
+ expect(await screen.findByRole('alert')).toHaveTextContent('nope');
81
+ await userEvent.click(screen.getByRole('button', { name: 'Try again' }));
82
+ expect(await screen.findByTestId('brief-text')).toBeInTheDocument();
83
+ });
84
+ });
@@ -254,7 +254,7 @@ describe('about_focus never changes a focus’s standing', () => {
254
254
  await screen.findByText('Standup note');
255
255
  expect(screen.getByText(/12 of 40 done/)).toBeInTheDocument();
256
256
  // Documents are not items: the item heading counts commitments only.
257
- expect(screen.getByText(/0 items in Crochets/)).toBeInTheDocument();
257
+ expect(screen.getByText(/0 items/)).toBeInTheDocument();
258
258
  });
259
259
  });
260
260
 
@@ -0,0 +1,181 @@
1
+ /**
2
+ * The pure grouping rules behind Home's "Due across projects", the Tracker's
3
+ * Today / In progress / Up next / Later list and Planning's focus overview
4
+ * (bd startsim-cpzoz, startsim-u57lr). Written before the code: each case is a
5
+ * way the list could mislead a person scanning it.
6
+ */
7
+ import { describe, expect, it } from 'vitest';
8
+
9
+ import { groupDue } from '../corpus/due-groups';
10
+ import { groupTracker, isTask } from '../corpus/tracker-groups';
11
+ import { summarizeFocuses } from '../corpus/focus-overview';
12
+ import type { Commitment, Focus } from '../corpus/types';
13
+
14
+ // Friday 2026-11-06 midday in New York.
15
+ const NOW = Date.parse('2026-11-06T17:00:00Z');
16
+ const TZ = 'America/New_York';
17
+
18
+ function item(id: string, over: Partial<Commitment> = {}): Commitment {
19
+ return {
20
+ id, externalId: `commit:${id}`, dedupeKey: id, subtype: 'action', title: id, detail: '',
21
+ status: 'open', subjectKey: '', actionKey: '', mentions: [], firstSeenAt: '2026-10-30T00:00:00Z',
22
+ lastSeenAt: '2026-11-05T00:00:00Z', extractorVersion: 't', source: 'granola', sourceLabel: 'Granola',
23
+ scope: { orgId: 'o' }, ownerName: 'Quinn', ...over,
24
+ } as Commitment;
25
+ }
26
+
27
+ describe('groupDue', () => {
28
+ it('buckets by the reader day: overdue, today, this week (next 7 days), later', () => {
29
+ const items = [
30
+ item('late', { dueAt: '2026-11-04' }),
31
+ item('today', { dueAt: '2026-11-06' }),
32
+ item('mon', { dueAt: '2026-11-09' }),
33
+ item('edge', { dueAt: '2026-11-13' }),
34
+ item('far', { dueAt: '2026-11-14' }),
35
+ ];
36
+ const g = groupDue(items, { now: NOW, timeZone: TZ });
37
+ expect(g.groups.map((x) => [x.bucket, x.entries.map((e) => e.item.id)])).toEqual([
38
+ ['overdue', ['late']], ['today', ['today']], ['week', ['mon', 'edge']], ['later', ['far']],
39
+ ]);
40
+ });
41
+
42
+ it('reads a UTC-midnight stored date as a date, not as the evening before', () => {
43
+ const g = groupDue([item('x', { dueAt: '2026-11-06T00:00:00Z' })], { now: NOW, timeZone: TZ });
44
+ expect(g.groups.find((x) => x.bucket === 'today')?.entries).toHaveLength(1);
45
+ });
46
+
47
+ it('leaves out finished and undated items and counts the undated', () => {
48
+ const g = groupDue([
49
+ item('done', { status: 'done', dueAt: '2026-11-01' }),
50
+ item('dropped', { status: 'dropped', dueAt: '2026-11-01' }),
51
+ item('nodate'),
52
+ item('ok', { dueAt: '2026-11-07' }),
53
+ ], { now: NOW, timeZone: TZ });
54
+ expect(g.total).toBe(1);
55
+ expect(g.undated).toBe(1);
56
+ expect(g.groups.map((x) => x.bucket)).toEqual(['week']);
57
+ });
58
+
59
+ it('orders overdue oldest first and breaks ties by priority', () => {
60
+ const g = groupDue([
61
+ item('b', { dueAt: '2026-11-03', priority: 3 }),
62
+ item('a', { dueAt: '2026-11-01' }),
63
+ item('c', { dueAt: '2026-11-03', priority: 1 }),
64
+ ], { now: NOW, timeZone: TZ });
65
+ expect(g.groups[0].entries.map((e) => e.item.id)).toEqual(['a', 'c', 'b']);
66
+ });
67
+
68
+ it('says how many days late or ahead each row is', () => {
69
+ const g = groupDue([item('late', { dueAt: '2026-11-04' }), item('soon', { dueAt: '2026-11-08' })], { now: NOW, timeZone: TZ });
70
+ expect(g.groups[0].entries[0].days).toBe(-2);
71
+ expect(g.groups[1].entries[0].days).toBe(2);
72
+ });
73
+ });
74
+
75
+ describe('isTask', () => {
76
+ it('shows actions, hides meeting statements, keeps a statement that someone owns and dates', () => {
77
+ expect(isTask(item('a'))).toBe(true);
78
+ expect(isTask(item('d', { subtype: 'decision', ownerName: undefined }))).toBe(false);
79
+ expect(isTask(item('q', { subtype: 'question', ownerName: 'Dana' }))).toBe(false);
80
+ expect(isTask(item('r', { subtype: 'risk', ownerName: 'Dana', dueAt: '2026-11-10' }))).toBe(true);
81
+ });
82
+ });
83
+
84
+ describe('groupTracker', () => {
85
+ const opts = { now: NOW, timeZone: TZ };
86
+
87
+ it('puts overdue and due-today in Today, started work in In progress, next 7 days in Up next, the rest in Later', () => {
88
+ const g = groupTracker([
89
+ item('late', { dueAt: '2026-11-02' }),
90
+ item('today', { dueAt: '2026-11-06' }),
91
+ item('wip', { status: 'in_progress' }),
92
+ item('soon', { dueAt: '2026-11-10' }),
93
+ item('far', { dueAt: '2026-12-10' }),
94
+ item('undated'),
95
+ ], opts);
96
+ expect(g.today.map((e) => e.item.id)).toEqual(['late', 'today']);
97
+ expect(g.inProgress.map((e) => e.item.id)).toEqual(['wip']);
98
+ expect(g.upNext.map((e) => e.item.id)).toEqual(['soon']);
99
+ expect(g.later.map((e) => e.item.id)).toEqual(['far', 'undated']);
100
+ });
101
+
102
+ it('keeps an overdue in-progress item in Today, once', () => {
103
+ const g = groupTracker([item('x', { status: 'in_progress', dueAt: '2026-11-01' })], opts);
104
+ expect(g.today).toHaveLength(1);
105
+ expect(g.inProgress).toHaveLength(0);
106
+ });
107
+
108
+ it('hides undated items nobody touched in 90 days behind Stale, but never an item with a due date', () => {
109
+ const g = groupTracker([
110
+ item('old', { lastSeenAt: '2026-06-01T00:00:00Z', firstSeenAt: '2026-05-01T00:00:00Z' }),
111
+ item('oldDated', { lastSeenAt: '2026-06-01T00:00:00Z', dueAt: '2026-06-10' }),
112
+ item('fresh'),
113
+ ], opts);
114
+ expect(g.stale.map((e) => e.item.id)).toEqual(['old']);
115
+ expect(g.today.map((e) => e.item.id)).toEqual(['oldDated']);
116
+ expect(g.later.map((e) => e.item.id)).toEqual(['fresh']);
117
+ });
118
+
119
+ it('collects finished items in Done and meeting statements apart from the tasks', () => {
120
+ const g = groupTracker([
121
+ item('d', { status: 'done' }),
122
+ item('x', { status: 'dropped' }),
123
+ item('dec', { subtype: 'decision', ownerName: undefined }),
124
+ ], opts);
125
+ expect(g.done.map((e) => e.item.id).sort()).toEqual(['d', 'x']);
126
+ expect(g.statements.map((e) => e.item.id)).toEqual(['dec']);
127
+ expect(g.counts).toEqual({ today: 0, inProgress: 0, upNext: 0, later: 0, stale: 0, done: 2, statements: 1 });
128
+ });
129
+ });
130
+
131
+ describe('summarizeFocuses', () => {
132
+ const focus = (id: string, over: Partial<Focus> = {}): Focus => ({
133
+ id, externalId: `focus:${id}`, title: id, detail: '', status: 'active', scope: { orgId: 'o' }, ...over,
134
+ } as Focus);
135
+
136
+ it('counts open and overdue per focus and names the next due item', () => {
137
+ const rows = summarizeFocuses(
138
+ [focus('a'), focus('b')],
139
+ [
140
+ item('1', { focusId: 'a', dueAt: '2026-11-02' }),
141
+ item('2', { focusId: 'a', dueAt: '2026-11-09' }),
142
+ item('3', { focusId: 'a', status: 'done' }),
143
+ item('4', { focusId: 'b' }),
144
+ ],
145
+ { now: NOW, timeZone: TZ },
146
+ );
147
+ const a = rows.find((r) => r.focus.id === 'a')!;
148
+ expect(a).toMatchObject({ open: 2, overdue: 1 });
149
+ expect(a.next?.id).toBe('1');
150
+ expect(rows.find((r) => r.focus.id === 'b')).toMatchObject({ open: 1, overdue: 0, next: null });
151
+ });
152
+
153
+ it('drops closed focuses and lists the most overdue first', () => {
154
+ const rows = summarizeFocuses(
155
+ [focus('quiet'), focus('hot'), focus('shut', { status: 'completed' })],
156
+ [item('1', { focusId: 'hot', dueAt: '2026-10-01' }), item('2', { focusId: 'quiet' })],
157
+ { now: NOW, timeZone: TZ },
158
+ );
159
+ expect(rows.map((r) => r.focus.id)).toEqual(['hot', 'quiet']);
160
+ });
161
+ });
162
+
163
+ import { actionsByNote } from '../corpus/note-actions';
164
+
165
+ describe('actionsByNote', () => {
166
+ const mention = (documentId: string) => ({ documentId, originKey: 'k', occurredAt: null, quote: '', extractor: 'model' as const });
167
+
168
+ it('lists the to-dos each note produced, newest-needed first, and counts the statements apart', () => {
169
+ const items = [
170
+ item('1', { mentions: [mention('n1')], dueAt: '2026-11-09' }),
171
+ item('2', { mentions: [mention('n1')], status: 'done' }),
172
+ item('3', { mentions: [mention('n1'), mention('n2')], subtype: 'decision', ownerName: undefined }),
173
+ item('4', { mentions: [mention('n2')] }),
174
+ item('5', { mentions: [] }),
175
+ ];
176
+ const by = actionsByNote([...items, items[0]], ['n1', 'n2', 'n3']); // a repeated row is counted once
177
+ expect(by.get('n1')).toMatchObject({ tasks: [{ id: '1' }, { id: '2' }], statements: 1, open: 1 });
178
+ expect(by.get('n2')).toMatchObject({ tasks: [{ id: '4' }], statements: 1, open: 1 });
179
+ expect(by.get('n3')).toMatchObject({ tasks: [], statements: 0, open: 0 });
180
+ });
181
+ });
@@ -68,3 +68,4 @@ export type { WorkItemSlot } from './pages/work-items';
68
68
  export * from './pages/VoiceNotesPage';
69
69
  export { VoiceRecordButton, VOICE_MIME_CANDIDATES } from './pages/VoiceRecordButton';
70
70
  export type { VoiceRecordButtonProps, VoiceRecordClassNames } from './pages/VoiceRecordButton';
71
+ export * from './pages/home';