@startsimpli/integrations 0.2.179 → 0.2.180

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 (68) hide show
  1. package/package.json +3 -3
  2. package/src/__tests__/converse-handoff.test.ts +129 -0
  3. package/src/__tests__/converse-meeting.test.ts +41 -0
  4. package/src/__tests__/converse-relay.test.ts +19 -3
  5. package/src/__tests__/home-brief.test.tsx +12 -24
  6. package/src/__tests__/home-needs-your-call.test.tsx +13 -16
  7. package/src/__tests__/plan-shell.test.tsx +160 -0
  8. package/src/components/DocumentDetail.tsx +15 -4
  9. package/src/components/documentText.ts +24 -0
  10. package/src/components/index.ts +1 -0
  11. package/src/components/pages/LibraryPage.tsx +4 -0
  12. package/src/components/pages/PlanningPage.tsx +20 -10
  13. package/src/components/pages/TrackerPage.tsx +16 -3
  14. package/src/components/pages/home/DueSoonLine.tsx +28 -0
  15. package/src/components/pages/home/HomeBriefPage.tsx +19 -52
  16. package/src/components/pages/home/index.ts +1 -3
  17. package/src/components/pages/plan/ProjectsPage.tsx +54 -0
  18. package/src/components/pages/plan/TalkPage.tsx +48 -0
  19. package/src/components/pages/plan/TimelinePage.tsx +33 -0
  20. package/src/components/pages/plan/index.ts +6 -0
  21. package/src/corpus/converse/handle.ts +10 -3
  22. package/src/corpus/converse/handled-asks.ts +29 -0
  23. package/src/corpus/converse/handoff.ts +52 -0
  24. package/src/corpus/converse/index.ts +4 -2
  25. package/src/corpus/converse/meeting.ts +23 -7
  26. package/src/corpus/converse/relay.ts +8 -4
  27. package/src/corpus/converse/store.ts +2 -0
  28. package/src/corpus/converse/transcript.ts +9 -0
  29. package/src/corpus/converse/types.ts +14 -0
  30. package/src/corpus/index.ts +2 -0
  31. package/src/corpus/nav-copy.ts +31 -0
  32. package/src/corpus/view-text.ts +3 -2
  33. package/src/native/__tests__/design-screens.test.tsx +3 -2
  34. package/src/native/app/FoundryApp.tsx +1 -1
  35. package/src/native/app/__tests__/plan-talk-registry.test.tsx +74 -0
  36. package/src/native/app/briefingServices.ts +1 -0
  37. package/src/native/app/config/defaults.ts +8 -2
  38. package/src/native/app/config/types.ts +1 -1
  39. package/src/native/app/converseServices.ts +1 -0
  40. package/src/native/app/registry.tsx +26 -6
  41. package/src/native/app/services.ts +3 -2
  42. package/src/native/components/NoteDetailScreen.tsx +16 -4
  43. package/src/native/components/__tests__/notes-screens.test.tsx +8 -8
  44. package/src/native/converse/ConverseScreen.tsx +24 -5
  45. package/src/native/converse/__tests__/liveScreen.test.tsx +15 -2
  46. package/src/native/home/HomeScreen.tsx +20 -7
  47. package/src/native/home/controller.ts +15 -5
  48. package/src/native/home/tab.tsx +31 -6
  49. package/src/native/plan/NewProjectRow.tsx +30 -0
  50. package/src/native/plan/PlanTab.tsx +105 -0
  51. package/src/native/plan/ProjectTodos.tsx +24 -0
  52. package/src/native/plan/TimelineScreen.tsx +68 -0
  53. package/src/native/plan/__tests__/plan-tab.test.tsx +76 -0
  54. package/src/native/plan/index.ts +5 -0
  55. package/src/native/plan/timeline.ts +56 -0
  56. package/src/native/recording/__tests__/recorderAudio.test.ts +10 -2
  57. package/src/native/recording/recorderAudio.ts +6 -2
  58. package/src/native/screens/__tests__/tabs.test.tsx +13 -0
  59. package/src/native/screens/ask/AskScreen.tsx +4 -2
  60. package/src/native/screens/library/LibraryDetailScreen.tsx +11 -4
  61. package/src/native/screens/planning/PlanningScreens.tsx +30 -13
  62. package/src/native/screens/tabs.tsx +5 -4
  63. package/src/native/talk/TalkTab.tsx +62 -0
  64. package/src/native/talk/__tests__/talk-tab.test.tsx +57 -0
  65. package/src/native/tracker/TrackerListScreen.tsx +7 -3
  66. package/src/native/tracker/tab.tsx +33 -8
  67. package/src/components/pages/home/DueAcrossProjects.tsx +0 -76
  68. package/src/components/pages/home/RecentNotes.tsx +0 -69
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startsimpli/integrations",
3
- "version": "0.2.179",
3
+ "version": "0.2.180",
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
53
  "@startsimpli/ui": "^0.4.186",
55
- "@startsimpli/utils": "^0.4.20"
54
+ "@startsimpli/utils": "^0.4.20",
55
+ "@startsimpli/auth": "^0.4.53"
56
56
  },
57
57
  "peerDependenciesMeta": {
58
58
  "react": {
@@ -0,0 +1,129 @@
1
+ // @vitest-environment node
2
+ /** End files a conversation like a voice note: asks become to-do extraction input, the transcript goes under a project (bd startsim-67jle). */
3
+ import { describe, expect, it, vi } from 'vitest';
4
+
5
+ import { createConverseHandoff, handleConverseEnd, handleConverseTurn, renderNextSteps, type ConverseDeps } from '../corpus/converse';
6
+ import { rulesExtract } from '../corpus/extract';
7
+
8
+ function tenant() {
9
+ const rows = new Map<string, any>();
10
+ const edges: any[] = [];
11
+ const http = {
12
+ get: vi.fn(async (path: string, options?: { params?: Record<string, unknown> }) => {
13
+ if (path === 'api/v1/relationships') return { results: edges.filter((e) => e.source === options?.params?.source) };
14
+ return { results: [...rows.values()].filter((r) => r.external_id === options?.params?.external_id__in) };
15
+ }),
16
+ post: vi.fn(async (path: string, body: any) => {
17
+ if (path === 'api/v1/relationships') { edges.push({ id: `e${edges.length}`, ...body }); return body; }
18
+ const prev = rows.get(body.external_id);
19
+ const row = { id: prev?.id ?? String(900 + rows.size), external_id: body.external_id, name: body.name, data: { ...(prev?.data ?? {}), ...body.data } };
20
+ rows.set(body.external_id, row);
21
+ return row;
22
+ }),
23
+ delete: vi.fn(async () => undefined),
24
+ };
25
+ return { rows, edges, http };
26
+ }
27
+
28
+ function setup(handoffOver: Partial<Parameters<typeof createConverseHandoff>[0]> = {}) {
29
+ const t = tenant();
30
+ const extractTodos = vi.fn(async () => undefined);
31
+ const analyzer = { analyze: vi.fn(async () => ({ title: 't', summary: 's', focusId: 'f1' })) };
32
+ const handoff = createConverseHandoff({
33
+ http: t.http as never, analyzer, listFocuses: async () => [{ id: 'f1', title: 'Hours' }, { id: 'f2', title: 'Other' }], extractTodos, ...handoffOver,
34
+ });
35
+ const deps: ConverseDeps = {
36
+ http: t.http as never, ownerSub: 'me', brain: async ({ utterance }) => ({ text: `ok ${utterance}` }),
37
+ extract: async () => ({ asks: ['Email Michelle about the Hours import', 'Fix it'], decisions: ['Ship Friday'] }), handoff,
38
+ };
39
+ return { t, deps, extractTodos, analyzer };
40
+ }
41
+
42
+ describe('End hands the conversation on', () => {
43
+ it('saves the asks as a Next steps summary that the to-do extraction reads', async () => {
44
+ const { t, deps } = setup();
45
+ const a = await handleConverseTurn(deps, { text: 'plan the hours import' });
46
+ await handleConverseEnd(deps, { conversationId: a.conversation_id });
47
+ const data = [...t.rows.values()][0].data;
48
+ expect(data.summary).toBe('## Next steps\n- **Email Michelle about the Hours import**\n- **Fix it**');
49
+ const drafts = rulesExtract({ id: '900', title: 't', source: 'conversation', summary: data.summary, body: data.body, sections: [] } as never);
50
+ expect(drafts.map((d) => d.title)).toEqual(['Email Michelle about the Hours import']);
51
+ });
52
+
53
+ it('files the transcript under the chosen project and runs the to-do extraction on the saved row', async () => {
54
+ const { t, deps, extractTodos } = setup();
55
+ const a = await handleConverseTurn(deps, { text: 'plan the hours import' });
56
+ await handleConverseEnd(deps, { conversationId: a.conversation_id });
57
+ expect(t.edges).toEqual([expect.objectContaining({ rel_type: 'about_focus', source: '900', target: 'f1' })]);
58
+ expect(extractTodos).toHaveBeenCalledWith('900');
59
+ });
60
+
61
+ it('a project the model invented files nothing; no asks means no extraction', async () => {
62
+ const t1 = setup({ analyzer: { analyze: async () => ({ title: 't', summary: 's', focusId: 'nope' }) } });
63
+ const a = await handleConverseTurn(t1.deps, { text: 'hi there' });
64
+ await handleConverseEnd(t1.deps, { conversationId: a.conversation_id });
65
+ expect(t1.t.edges).toEqual([]);
66
+ const t2 = setup();
67
+ t2.deps.extract = async () => ({ asks: [], decisions: [] });
68
+ const b = await handleConverseTurn(t2.deps, { text: 'hi there' });
69
+ await handleConverseEnd(t2.deps, { conversationId: b.conversation_id });
70
+ expect(t2.extractTodos).not.toHaveBeenCalled();
71
+ });
72
+
73
+ it('a failing handoff never fails End, and a second End does not run it again', async () => {
74
+ const { t, deps, analyzer } = setup({ extractTodos: vi.fn(async () => { throw new Error('boom'); }) });
75
+ const a = await handleConverseTurn(deps, { text: 'plan' });
76
+ const end = await handleConverseEnd(deps, { conversationId: a.conversation_id });
77
+ expect(end.saved).toBe(true);
78
+ await handleConverseEnd(deps, { conversationId: a.conversation_id });
79
+ expect(analyzer.analyze).toHaveBeenCalledTimes(1);
80
+ expect([...t.rows.values()][0].data.status).toBe('ended');
81
+ });
82
+
83
+ it('renderNextSteps strips bold markers and is empty with no asks', () => {
84
+ expect(renderNextSteps([])).toBe('');
85
+ expect(renderNextSteps(['Do **this** now'])).toBe('## Next steps\n- **Do this now**');
86
+ });
87
+ });
88
+
89
+ describe('an ask the assistant already added during the conversation is not filed twice', () => {
90
+ it('drops asks matching an "Added ..." turn from the Next steps and the extraction (seen live with the real model)', async () => {
91
+ const t = tenant();
92
+ const extractTodos = vi.fn(async () => undefined);
93
+ const handoff = createConverseHandoff({ http: t.http as never, analyzer: null, listFocuses: async () => [], extractTodos });
94
+ const deps: ConverseDeps = {
95
+ http: t.http as never, ownerSub: 'me',
96
+ brain: async () => ({ text: 'Added Call the landlord about the lease for Thursday. Added Draft the Q4 board update for the Close.', did: ['Added Call the landlord about the lease for Thursday.', 'Added Draft the Q4 board update for the Close.'] }),
97
+ extract: async () => ({
98
+ asks: ['Call the landlord about the lease by Thursday', 'Draft the Q4 board update for the Close the books for Q4 project', 'Order new badges for the team'],
99
+ decisions: [],
100
+ }),
101
+ handoff,
102
+ };
103
+ const a = await handleConverseTurn(deps, { text: 'call the landlord and draft the board update, and order badges' });
104
+ const end = await handleConverseEnd(deps, { conversationId: a.conversation_id });
105
+ const data = [...t.rows.values()][0].data;
106
+ expect(data.summary).toBe('## Next steps\n- **Order new badges for the team**');
107
+ expect(extractTodos).toHaveBeenCalledWith('900');
108
+ expect(end.asks).toHaveLength(3); // the record still says everything that was asked
109
+ });
110
+
111
+ it('matches an ask against the spoken line even when the line adds a date ("... for Monday the twenty-third")', async () => {
112
+ const { unhandledAsks } = await import('../corpus/converse/handled-asks');
113
+ const turns = [{ n: 1, turn_id: 't', at: '', user: { text: '' }, assistant: { text: '' }, did: ['Added Renew the domain name for Monday the twenty-third.'] }] as never;
114
+ expect(unhandledAsks(['Renew the domain name by Monday', 'Renew the passport'], turns)).toEqual(['Renew the passport']);
115
+ });
116
+
117
+ it('when every ask was already added there is nothing left to extract', async () => {
118
+ const t = tenant();
119
+ const extractTodos = vi.fn(async () => undefined);
120
+ const handoff = createConverseHandoff({ http: t.http as never, analyzer: null, listFocuses: async () => [], extractTodos });
121
+ const deps: ConverseDeps = {
122
+ http: t.http as never, ownerSub: 'me', brain: async () => ({ text: 'Added Email Michelle.', did: ['Added Email Michelle.'] }),
123
+ extract: async () => ({ asks: ['Email Michelle'], decisions: [] }), handoff,
124
+ };
125
+ const a = await handleConverseTurn(deps, { text: 'email michelle' });
126
+ await handleConverseEnd(deps, { conversationId: a.conversation_id });
127
+ expect(extractTodos).not.toHaveBeenCalled();
128
+ });
129
+ });
@@ -46,6 +46,30 @@ describe('meeting controller without a microphone', () => {
46
46
  });
47
47
  });
48
48
 
49
+ describe('a typed turn or Replay while the microphone is open', () => {
50
+ it('stops listening before the reply is spoken, then listens again', async () => {
51
+ const heard: Array<{ signal: AbortSignal; abortedAtSpeak?: boolean }> = [];
52
+ const speak = vi.fn(async () => { heard.forEach((h) => { h.abortedAtSpeak = h.signal.aborted; }); });
53
+ const { c, io } = rig({ utterances: [], speak });
54
+ (io.listen as any).mockImplementation((signal: AbortSignal) => new Promise((resolve) => {
55
+ heard.push({ signal });
56
+ signal.addEventListener('abort', () => resolve({ audio: null, cancelled: true }));
57
+ }));
58
+ c.start();
59
+ await settle(() => heard.length >= 1);
60
+ await c.sendText('what is due this week');
61
+ expect(speak).toHaveBeenCalledTimes(1);
62
+ expect(heard[0].abortedAtSpeak).toBe(true);
63
+ await settle(() => heard.length >= 2);
64
+ expect(heard.length).toBe(2);
65
+ expect(c.state().phase).toBe('listening');
66
+ await c.replay();
67
+ expect(speak).toHaveBeenCalledTimes(2);
68
+ expect(heard[1].abortedAtSpeak).toBe(true);
69
+ await c.end();
70
+ });
71
+ });
72
+
49
73
  describe('starting again after End or a stop', () => {
50
74
  it('a second start() is a NEW conversation: no old id, lines, saved or noAudio', async () => {
51
75
  const { c, client } = rig({ utterances: [blob()] });
@@ -195,6 +219,23 @@ describe('meeting controller', () => {
195
219
  });
196
220
  });
197
221
 
222
+ describe('typed text before Start', () => {
223
+ it('speaks the reply and goes back to idle, instead of staying on Thinking in silence', async () => {
224
+ const { c, speak } = rig({ utterances: [] });
225
+ await c.sendText('hello there');
226
+ expect((speak as any).mock.calls.length).toBe(1);
227
+ expect(c.state().phase).toBe('idle');
228
+ expect(c.state().lines.map((l) => l.text)).toEqual(['said 1', 'reply 1']);
229
+ });
230
+
231
+ it('a failed playback shows why and still returns to idle', async () => {
232
+ const { c } = rig({ utterances: [], speak: vi.fn(async () => { throw new Error('audio route failed'); }) });
233
+ await c.sendText('hello there');
234
+ expect(c.state().noAudio).toMatch(/audio route failed/);
235
+ expect(c.state().phase).toBe('idle');
236
+ });
237
+ });
238
+
198
239
  describe('the relay writes into an open meeting', () => {
199
240
  const thread = (turns: any[]) => ({ conversation_id: 'c1c1c1c1', status: 'open' as const, updated_at: 't', turns });
200
241
  const relayTurn = (n: number, text: string, audio = true) => ({ turn: n, turn_id: `r${n}rrrrrrr`, at: 't', who: 'relay' as const, transcript: '', reply_text: text, audio_url: audio ? `/a/${n}` : null, audio_reason: audio ? null : 'no tts', for_relay: false });
@@ -53,18 +53,34 @@ describe('relay reply', () => {
53
53
  expect((await handleThread(deps, { conversationId: first.conversation_id })).turns).toHaveLength(2);
54
54
  });
55
55
 
56
- it('refuses empty text, another owner, an ended conversation', async () => {
56
+ it('refuses empty text and another owner', async () => {
57
57
  const { deps, rows } = setup();
58
58
  const first = await handleConverseTurn(deps, { text: 'hello there' });
59
59
  await expect(handleRelayReply(deps, { conversationId: first.conversation_id, text: ' ' })).rejects.toMatchObject({ status: 400 });
60
60
  const stranger: ConverseDeps = { ...deps, ownerSub: 'someone-else' };
61
61
  await expect(handleRelayReply(stranger, { conversationId: first.conversation_id, text: 'hi' })).rejects.toMatchObject({ status: 404 });
62
62
  await expect(handleThread(stranger, { conversationId: first.conversation_id })).rejects.toMatchObject({ status: 404 });
63
- await handleConverseEnd(deps, { conversationId: first.conversation_id });
64
- await expect(handleRelayReply(deps, { conversationId: first.conversation_id, text: 'late' })).rejects.toMatchObject({ status: 409, code: 'ended' });
65
63
  expect(rows.size).toBe(1);
66
64
  });
67
65
 
66
+ it('delivers a reply to a conversation that already ended: appended, still ended, orders cleared, the person is told', async () => {
67
+ const told: Array<{ conversationId: string; text: string }> = [];
68
+ const { deps } = setup('me', { onRelayReplyAfterEnd: async (i: { conversationId: string; text: string }) => { told.push(i); } });
69
+ const first = await handleConverseTurn(deps, { text: 'hello there' });
70
+ await handleConverseEnd(deps, { conversationId: first.conversation_id });
71
+ const out = await handleRelayReply(deps, { conversationId: first.conversation_id, text: 'late but here' });
72
+ expect(out).toMatchObject({ reply_text: 'late but here', after_end: true });
73
+ expect(told).toEqual([{ conversationId: first.conversation_id, text: 'late but here' }]);
74
+ const thread = await handleThread(deps, { conversationId: first.conversation_id });
75
+ expect(thread.status).toBe('ended');
76
+ expect(thread.turns.map((t) => t.reply_text)).toContain('late but here');
77
+ // a failing notice never fails the delivery
78
+ const { deps: d2 } = setup('me', { onRelayReplyAfterEnd: async () => { throw new Error('push down'); } });
79
+ const f2 = await handleConverseTurn(d2, { text: 'hello there' });
80
+ await handleConverseEnd(d2, { conversationId: f2.conversation_id });
81
+ await expect(handleRelayReply(d2, { conversationId: f2.conversation_id, text: 'again' })).resolves.toMatchObject({ after_end: true });
82
+ });
83
+
68
84
  it('shows the relay in the transcript and in the brain history, and the Response wrappers answer JSON', async () => {
69
85
  const seen: string[] = [];
70
86
  const { deps, rows } = setup('me', { brain: async ({ utterance, history }) => { seen.push(...history.map((h) => h.text)); return { text: `ok: ${utterance}` }; } });
@@ -1,6 +1,6 @@
1
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.
2
+ * TODAY (bd startsim-cpzoz): the brief shows the stored text verbatim, and the only to-do
3
+ * content is one due-soon line with the way into Plan (the list itself is Plan's).
4
4
  */
5
5
  import * as React from 'react';
6
6
  import { render, screen, within } from '@testing-library/react';
@@ -60,28 +60,16 @@ describe('HomeBriefPage', () => {
60
60
  expect(weekly).toHaveBeenCalledTimes(1);
61
61
  });
62
62
 
63
- it('groups what is due with the project as a chip', async () => {
64
- render(
65
- <HomeBriefPage
66
- brief={{ fetch: async () => RESULT }} corpus={corpus()} now={NOW} timeZone="UTC"
67
- listFocuses={async () => ({ count: 1, next: null, previous: null, results: [{ id: 'f1', title: 'Launch v2' } as never] })}
68
- />,
69
- );
70
- const overdue = await screen.findByRole('region', { name: 'Overdue' });
71
- expect(within(overdue).getByText('late')).toBeInTheDocument();
72
- expect(await within(overdue).findByText('Launch v2')).toBeInTheDocument();
73
- expect(within(screen.getByRole('region', { name: 'This week' })).getByText('soon')).toBeInTheDocument();
74
- });
75
-
76
- it('lists each recent note with the to-dos that came out of it, linking back', async () => {
77
- const onOpenNote = vi.fn();
78
- render(<HomeBriefPage brief={{ fetch: async () => RESULT }} corpus={corpus()} now={NOW} timeZone="UTC" onOpenNote={onOpenNote} />);
79
- const note = await screen.findByText('Weekly sync');
80
- expect(screen.getByText('2 to-dos · 1 open')).toBeInTheDocument();
81
- await userEvent.click(note);
82
- expect(screen.getByText('We agreed to ship Friday.')).toBeInTheDocument();
83
- await userEvent.click(screen.getByRole('button', { name: 'Open the full note' }));
84
- expect(onOpenNote).toHaveBeenCalledWith('n1');
63
+ it('keeps one due-soon line with the way into Plan, and no to-do rows', async () => {
64
+ const onOpenPlan = vi.fn();
65
+ render(<HomeBriefPage brief={{ fetch: async () => RESULT }} corpus={corpus()} now={NOW} timeZone="UTC" onOpenPlan={onOpenPlan} />);
66
+ const line = await screen.findByTestId('due-soon');
67
+ expect(line).toHaveTextContent('1 overdue · 1 due this week');
68
+ expect(screen.queryByText('late')).toBeNull();
69
+ expect(screen.queryByTestId('item-row')).toBeNull();
70
+ expect(screen.queryByText('Weekly sync')).toBeNull();
71
+ await userEvent.click(within(line).getByRole('button', { name: 'Open Plan' }));
72
+ expect(onOpenPlan).toHaveBeenCalledTimes(1);
85
73
  });
86
74
 
87
75
  it('says plainly when the brief cannot load, with a retry', async () => {
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Home with "Needs your call" (bd startsim-tmrvi.7): an answer shows on the to-do it was about
3
- * straight away, a guessed date reads quietly, and a failed save puts everything back.
2
+ * Today with "Needs your call" (bd startsim-tmrvi.7): an answer moves its to-do into the due-soon line
3
+ * straight away, and a failed save puts everything back. Today draws no to-do rows of its own.
4
4
  */
5
5
  import * as React from 'react';
6
- import { render, screen, waitFor, within } from '@testing-library/react';
6
+ import { render, screen } from '@testing-library/react';
7
7
  import userEvent from '@testing-library/user-event';
8
8
  import { describe, expect, it, vi } from 'vitest';
9
9
 
@@ -23,32 +23,30 @@ function item(id: string, over: Partial<Commitment> = {}): Commitment {
23
23
  } as Commitment;
24
24
  }
25
25
  const corpus = (): CorpusApi & CommitmentApi => ({
26
- async listCommitments() { return { count: 1, next: null, previous: null, results: [item('Send the term sheet', { dueAt: '2026-11-13' })] }; },
26
+ async listCommitments() { return { count: 1, next: null, previous: null, results: [item('Send the term sheet', { dueAt: '2026-11-30' })] }; },
27
27
  async listDocuments() { return { count: 0, next: null, previous: null, results: [] }; },
28
28
  }) as unknown as CorpusApi & CommitmentApi;
29
29
 
30
30
  const QUESTION: OpenQuestion = {
31
31
  id: 'q1', itemId: 'Send the term sheet', kind: 'due_date', question: 'Is next Friday right?', status: 'open', score: 80,
32
- assumed: { value: '2026-11-13', confidence: 0.4, reason: '' }, candidates: [{ value: '2026-11-09', confidence: 0.3, reason: '' }],
32
+ assumed: { value: '2026-11-30', confidence: 0.4, reason: '' }, candidates: [{ value: '2026-11-09', confidence: 0.3, reason: '' }],
33
33
  ownerSub: 'u1', createdAt: '', updatedAt: '',
34
34
  };
35
35
  const questions = (answer: NeedsYourCallApi['answer']): NeedsYourCallApi => ({ list: async () => [QUESTION], answer, skip: async () => undefined });
36
36
  const page = (api: NeedsYourCallApi) => <HomeBriefPage brief={{ fetch: async () => RESULT }} corpus={corpus()} now={NOW} timeZone="UTC" questions={api} />;
37
37
 
38
- describe('Home: Needs your call', () => {
39
- it('marks a guessed date lightly on its to-do', async () => {
38
+ describe('Today: Needs your call', () => {
39
+ it('draws no to-do rows, only the due-soon line', async () => {
40
40
  render(page(questions(async () => undefined)));
41
- const row = await screen.findByTestId('item-row');
42
- await waitFor(() => expect(within(row).getByText('~in 7d')).toHaveAttribute('data-guess', 'true'));
41
+ expect(await screen.findByTestId('due-soon')).toHaveTextContent('Nothing is due soon.');
42
+ expect(screen.queryByTestId('item-row')).toBeNull();
43
43
  });
44
44
 
45
- it('moves the to-do to the answered day at once, and the guess mark goes', async () => {
45
+ it('moves the to-do into the due-soon line at once', async () => {
46
46
  render(page(questions(async () => undefined)));
47
47
  await screen.findByText('Is next Friday right?');
48
48
  await userEvent.click(screen.getByRole('button', { name: /^Mon, Nov 9$/ }));
49
- const row = await screen.findByTestId('item-row');
50
- expect(within(row).getByText('in 3d')).toBeInTheDocument();
51
- expect(row.querySelector('[data-guess]')).toBeNull();
49
+ expect(await screen.findByText('1 due this week')).toBeInTheDocument();
52
50
  });
53
51
 
54
52
  it('puts the date back when the save fails', async () => {
@@ -56,13 +54,12 @@ describe('Home: Needs your call', () => {
56
54
  await screen.findByText('Is next Friday right?');
57
55
  await userEvent.click(screen.getByRole('button', { name: /^Mon, Nov 9$/ }));
58
56
  expect(await screen.findByRole('alert')).toBeInTheDocument();
59
- const row = screen.getByTestId('item-row');
60
- expect(within(row).getByText('~in 7d')).toBeInTheDocument();
57
+ expect(screen.getByTestId('due-soon')).toHaveTextContent('Nothing is due soon.');
61
58
  });
62
59
 
63
60
  it('shows no section without a questions api', async () => {
64
61
  render(<HomeBriefPage brief={{ fetch: async () => RESULT }} corpus={corpus()} now={NOW} timeZone="UTC" />);
65
- await screen.findByTestId('item-row');
62
+ await screen.findByTestId('due-soon');
66
63
  expect(screen.queryByTestId('needs-your-call')).toBeNull();
67
64
  });
68
65
  });
@@ -0,0 +1,160 @@
1
+ /**
2
+ * PLAN, TALK and the shared copy (Quinn, 2026-11-16): the to-do list is one component that can hide the
3
+ * timeline and filter to a project; Projects opens a project onto that same list; Talk toggles Ask in place;
4
+ * every tab and sub-tab carries its one-line subtitle.
5
+ */
6
+ import * as React from 'react';
7
+ import { fireEvent, render, screen, waitFor } from '@testing-library/react';
8
+ import { describe, expect, it, vi } from 'vitest';
9
+
10
+ import { ProjectsPage, TalkPage, TimelinePage } from '../components/pages/plan';
11
+ import { TrackerPage } from '../components/pages/TrackerPage';
12
+ import { MORE_ENTRIES, PLAN_TABS, TAB_COPY, TALK_MODES } from '../corpus/nav-copy';
13
+ import type { Commitment, CommitmentQuery, CommitmentTrackerApi, CorpusPage, Focus, PlanningApi } from '../corpus/types';
14
+
15
+ const SCOPE = { orgId: 'tandem' };
16
+ const NOW = Date.parse('2026-11-16T12:00:00Z');
17
+
18
+ const todo = (id: string, over: Partial<Commitment> = {}): Commitment => ({
19
+ id, externalId: `commit:${id}`, dedupeKey: id, subtype: 'action', title: `Todo ${id}`, detail: '', status: 'open', subjectKey: '', actionKey: '',
20
+ mentions: [], firstSeenAt: null, lastSeenAt: null, extractorVersion: 't', source: 'voice', sourceLabel: 'V', scope: SCOPE, ...over,
21
+ }) as Commitment;
22
+ const page = <T,>(results: T[]): CorpusPage<T> => ({ count: results.length, next: null, previous: null, results, appliedFilters: [] });
23
+
24
+ function trackerApi(onQuery: (q: CommitmentQuery) => void = () => undefined, create = vi.fn(async (d) => todo('new', { title: d.title }))): CommitmentTrackerApi {
25
+ return {
26
+ async listCommitments(q: CommitmentQuery = {}) { onQuery(q); return page([todo('a')]); },
27
+ createCommitment: create,
28
+ updateCommitment: vi.fn(),
29
+ timeline: vi.fn(async () => ({ anchor: '2026-11-16', created: [], done: [], overdue: [], items: [], truncated: false })) as never,
30
+ } as unknown as CommitmentTrackerApi;
31
+ }
32
+
33
+ describe('copy', () => {
34
+ it('gives every tab and sub-tab one plain line', () => {
35
+ expect(TAB_COPY.today.subtitle).toBe('Your morning brief and what is due soon.');
36
+ expect(TAB_COPY.talk.subtitle).toBe('Talk or type to Tandem: plans, questions, and notes. Asks you make become to-dos.');
37
+ expect(TAB_COPY.plan.subtitle).toBe('Everything you owe, and what you are aiming for.');
38
+ expect(TAB_COPY.more.subtitle).toBe('Library, Decisions, Connections, Admin.');
39
+ expect(PLAN_TABS.map((t) => [t.label, t.subtitle])).toEqual([
40
+ ['To-dos', 'The one list of everything you owe: add, tick off, filter.'],
41
+ ['Timeline', 'What was created, finished and overdue over time.'],
42
+ ['Projects', 'Your projects and goals, with progress. Open one to see its to-dos.'],
43
+ ]);
44
+ expect(MORE_ENTRIES.map((e) => e.label)).toEqual(['Library', 'Decisions', 'Connections', 'Admin']);
45
+ for (const line of [...Object.values(TAB_COPY), ...PLAN_TABS, ...MORE_ENTRIES, ...TALK_MODES]) expect(line.subtitle).toMatch(/\.$/);
46
+ });
47
+ });
48
+
49
+ describe('the to-do list as the Plan sub-tab', () => {
50
+ it('can leave the timeline to its own sub-tab', async () => {
51
+ const api = trackerApi();
52
+ render(<TrackerPage api={api} scope={SCOPE} now={NOW} showTimeline={false} />);
53
+ await screen.findByText('Todo a');
54
+ expect(api.timeline).not.toHaveBeenCalled();
55
+ });
56
+
57
+ it('filters to a project on the server and files a new to-do under it', async () => {
58
+ const queries: CommitmentQuery[] = [];
59
+ const create = vi.fn(async (d: { title: string }) => todo('new', { title: d.title }));
60
+ render(<TrackerPage api={trackerApi((q) => queries.push(q), create)} scope={SCOPE} now={NOW} showTimeline={false} focusId="focus:p1" />);
61
+ await screen.findByText('Todo a');
62
+ expect(queries[0]).toMatchObject({ focus: 'focus:p1' });
63
+ fireEvent.change(screen.getByLabelText('Add a to-do'), { target: { value: 'Ship it' } });
64
+ fireEvent.click(screen.getByRole('button', { name: 'Add' }));
65
+ await waitFor(() => expect(create).toHaveBeenCalledWith({ title: 'Ship it', focusId: 'focus:p1' }));
66
+ });
67
+
68
+ it('timeline sub-tab reads the timeline and nothing else', async () => {
69
+ const api = trackerApi();
70
+ render(<TimelinePage api={api} scope={SCOPE} now={NOW} />);
71
+ await waitFor(() => expect(api.timeline).toHaveBeenCalled());
72
+ });
73
+ });
74
+
75
+ describe('Projects', () => {
76
+ const focus = (id: string, over: Partial<Focus> = {}): Focus => ({ id, externalId: `focus:${id}`, title: `Goal ${id}`, detail: '', status: 'active', scope: SCOPE, ...over }) as Focus;
77
+ const planning = (): PlanningApi => ({
78
+ listFocuses: vi.fn(async () => page([focus('p1', { targetValue: 10, currentValue: 4 })])),
79
+ createFocus: vi.fn(async (d: { title: string }) => focus('new', { title: d.title })),
80
+ listCommitments: vi.fn(async () => page([])),
81
+ }) as unknown as PlanningApi;
82
+
83
+ it('lists projects with progress and a create form; a row opens that project', async () => {
84
+ const onFocusChange = vi.fn();
85
+ render(<ProjectsPage api={planning()} scope={SCOPE} focusId={null} onFocusChange={onFocusChange} renderTodos={() => null} now={NOW} />);
86
+ expect(await screen.findByText('Goal p1')).toBeTruthy();
87
+ expect(screen.getByRole('button', { name: 'New project' })).toBeTruthy();
88
+ fireEvent.click(screen.getByText('Goal p1'));
89
+ expect(onFocusChange).toHaveBeenCalledWith('p1');
90
+ });
91
+
92
+ it('creates a new project from the list', async () => {
93
+ const api = planning();
94
+ render(<ProjectsPage api={api} scope={SCOPE} focusId={null} onFocusChange={() => undefined} renderTodos={() => null} now={NOW} />);
95
+ await screen.findByText('Goal p1');
96
+ fireEvent.click(screen.getByRole('button', { name: 'New project' }));
97
+ fireEvent.change(screen.getByPlaceholderText('What are you trying to achieve?'), { target: { value: 'Launch v3' } });
98
+ fireEvent.click(screen.getByRole('button', { name: 'Add project' }));
99
+ await waitFor(() => expect(api.createFocus).toHaveBeenCalledWith({ title: 'Launch v3', status: 'active' }));
100
+ });
101
+
102
+ it('shows the shared to-do list for an open project, not an item list of its own', async () => {
103
+ const api = planning();
104
+ render(<ProjectsPage api={api} scope={SCOPE} focusId="p1" onFocusChange={() => undefined} renderTodos={(f) => <p>shared list for {f.id}</p>} now={NOW} />);
105
+ expect(await screen.findByText('shared list for p1')).toBeTruthy();
106
+ expect(screen.queryByPlaceholderText('Owner')).toBeNull();
107
+ });
108
+ });
109
+
110
+ describe('Talk', () => {
111
+ it('toggles Ask in place and says what each mode is for', () => {
112
+ const onModeChange = vi.fn();
113
+ const { rerender } = render(<TalkPage mode="talk" onModeChange={onModeChange} talk={<p>talk body</p>} ask={<p>ask body</p>} />);
114
+ expect(screen.getByText('talk body')).toBeTruthy();
115
+ expect(screen.getByTestId('talk-mode-subtitle').textContent).toBe(TAB_COPY.talk.subtitle);
116
+ fireEvent.click(screen.getByRole('tab', { name: 'Ask' }));
117
+ expect(onModeChange).toHaveBeenCalledWith('ask');
118
+ rerender(<TalkPage mode="ask" onModeChange={onModeChange} talk={<p>talk body</p>} ask={<p>ask body</p>} />);
119
+ expect(screen.getByText('ask body')).toBeTruthy();
120
+ expect(screen.queryByText('talk body')).toBeNull();
121
+ });
122
+ });
123
+
124
+ describe('notes and library text never carry their own to-do list', () => {
125
+ it('strips the Next steps section and counts its bullets, leaving the rest of the prose', async () => {
126
+ const { withoutNextSteps, todosInPlanText } = await import('../components/documentText');
127
+ const md = '## Decisions\n\nAcme renews at $4,800.\n\n## Next steps\n\n- Send the order form\n- Confirm the start date\n\n## Risks\n\nNone.';
128
+ const out = withoutNextSteps(md);
129
+ expect(out.todos).toBe(2);
130
+ expect(out.text).toContain('Acme renews');
131
+ expect(out.text).toContain('## Risks');
132
+ expect(out.text).not.toContain('Send the order form');
133
+ expect(out.text).not.toContain('Next steps');
134
+ expect(withoutNextSteps('Just prose.')).toEqual({ text: 'Just prose.', todos: 0 });
135
+ expect(todosInPlanText(1)).toBe('1 to-do from this note is in Plan.');
136
+ expect(todosInPlanText(2)).toBe('2 to-dos from this note are in Plan.');
137
+ });
138
+ });
139
+
140
+ describe('the web Library record', () => {
141
+ it('shows the note prose, no Next steps bullets, and a link into Plan', async () => {
142
+ const { DocumentDetail } = await import('../components/DocumentDetail');
143
+ const doc = { id: 'n1', title: 'Weekly sync', body: '', summary: 'We agreed to ship.\n\n## Next steps\n\n- Send the order form\n- Confirm the date', sections: [], participants: [], occurredAt: '2026-11-05T10:00:00Z', source: 'granola', sourceLabel: 'G', subtype: 'meeting', sourceRef: 'x', scope: SCOPE } as never;
144
+ const onOpenPlan = vi.fn();
145
+ render(<DocumentDetail document={doc} scope={SCOPE} api={{} as never} classNames={{} as never} onClose={() => undefined} onFilterByParty={() => undefined} onOpenPlan={onOpenPlan} />);
146
+ expect(screen.getByText('We agreed to ship.')).toBeTruthy();
147
+ expect(screen.queryByText(/Send the order form/)).toBeNull();
148
+ expect(screen.getByTestId('todos-in-plan').textContent).toContain('2 to-dos from this note are in Plan.');
149
+ fireEvent.click(screen.getByRole('button', { name: 'Open Plan' }));
150
+ expect(onOpenPlan).toHaveBeenCalled();
151
+ });
152
+ });
153
+
154
+ describe('library row preview', () => {
155
+ it('leaves the Next steps bullets out of the one-line preview', async () => {
156
+ const { documentPreview } = await import('../corpus/view-text');
157
+ const doc = { id: 'n', title: 't', body: 'full transcript', summary: 'We agreed to ship.\n\n## Next steps\n\n- Send the order form', sections: [] } as never;
158
+ expect(documentPreview(doc)).toBe('We agreed to ship.');
159
+ });
160
+ });
@@ -7,13 +7,13 @@ import * as React from 'react';
7
7
 
8
8
  import { Markdown } from './Markdown';
9
9
  import { FiledUnder } from './FiledUnder';
10
- import { formatDate, fullTextOf, summaryOf } from './documentText';
10
+ import { formatDate, fullTextOf, summaryOf, todosInPlanText, withoutNextSteps } from './documentText';
11
11
  import type { CorpusApi, CorpusScope, SourceDocument } from '../corpus/types';
12
12
 
13
13
  type DetailSlots = Record<'card' | 'heading' | 'badge' | 'button' | 'input' | 'muted' | 'error' | 'warning', string>;
14
14
 
15
15
  export function DocumentDetail({
16
- document, scope, api, classNames: cn, onClose, onFilterByParty,
16
+ document, scope, api, classNames: cn, onClose, onFilterByParty, onOpenPlan,
17
17
  }: {
18
18
  document: SourceDocument;
19
19
  scope: CorpusScope;
@@ -21,6 +21,8 @@ export function DocumentDetail({
21
21
  classNames: DetailSlots;
22
22
  onClose: () => void;
23
23
  onFilterByParty: (partyId: string) => void;
24
+ /** Open Plan, where this note's to-dos are listed. */
25
+ onOpenPlan?: () => void;
24
26
  }) {
25
27
  // Defense in depth. The API scopes reads and Postgres RLS scopes them again,
26
28
  // but a record that reached this component from the wrong workspace must not
@@ -33,6 +35,9 @@ export function DocumentDetail({
33
35
  );
34
36
  }
35
37
 
38
+ // The to-dos live only in Plan: the note shows its prose and a link, not its own list.
39
+ const summary = withoutNextSteps(summaryOf(document));
40
+
36
41
  return (
37
42
  <section className={cn.card} aria-label="Record detail">
38
43
  <div className="flex items-start justify-between gap-4">
@@ -85,15 +90,21 @@ export function DocumentDetail({
85
90
  delivered a full text. The moment `ingest_transcripts` lands, `body` is
86
91
  forty minutes of verbatim speech, and it would have appeared on this
87
92
  screen labelled "Summary" while the actual summary appeared nowhere. */}
88
- {summaryOf(document) ? (
93
+ {summary.text ? (
89
94
  <div className="mt-3">
90
95
  <p className="text-sm font-medium text-gray-900">Summary</p>
91
96
  {/* Sources write Markdown — a literal "## Decisions" on the screen
92
97
  reads as a broken product, not as the source's punctuation. */}
93
- <Markdown text={summaryOf(document)} className="mt-1 text-sm text-gray-700" />
98
+ <Markdown text={summary.text} className="mt-1 text-sm text-gray-700" />
94
99
  </div>
95
100
  ) : null}
96
101
 
102
+ {summary.todos > 0 ? (
103
+ <p className="mt-3 text-sm text-gray-700" data-testid="todos-in-plan">
104
+ {todosInPlanText(summary.todos)}{onOpenPlan ? <>{' '}<button type="button" className="text-blue-700 underline" onClick={onOpenPlan}>Open Plan</button></> : null}
105
+ </p>
106
+ ) : null}
107
+
97
108
  {/* The FULL text, collapsed, next to the source's other long-form. Behind
98
109
  a disclosure and not open by default, for the same reason a transcript
99
110
  is opt-in at all: verbatim speech is a different data class from a
@@ -29,3 +29,27 @@ export function fullTextOf(document: SourceDocument): string {
29
29
  const body = document.body ?? '';
30
30
  return body && body !== summaryOf(document) ? body : '';
31
31
  }
32
+
33
+ /**
34
+ * A note's markdown without its "Next steps" section, and how many to-dos that section held. The to-dos
35
+ * live only in Plan (Quinn, 2026-11-16): a note shows its prose and a link, never a second to-do list.
36
+ */
37
+ export function withoutNextSteps(markdown: string): { text: string; todos: number } {
38
+ const lines = (markdown ?? '').split('\n');
39
+ const out: string[] = [];
40
+ let skipping = false;
41
+ let todos = 0;
42
+ for (const line of lines) {
43
+ const heading = line.match(/^\s*#{1,6}\s+(.+?)\s*$/);
44
+ if (heading) skipping = /^next\s+steps?$/i.test(heading[1]);
45
+ if (skipping) {
46
+ if (/^\s*[-*]\s+\S/.test(line)) todos += 1;
47
+ continue;
48
+ }
49
+ out.push(line);
50
+ }
51
+ return { text: out.join('\n').replace(/\n{3,}/g, '\n\n').trim(), todos };
52
+ }
53
+
54
+ /** `N to-dos from this note are in Plan.` */
55
+ export const todosInPlanText = (n: number): string => `${n} to-do${n === 1 ? '' : 's'} from this note ${n === 1 ? 'is' : 'are'} in Plan.`;
@@ -80,3 +80,4 @@ export type { VoiceRecordButtonProps, VoiceRecordClassNames } from './pages/Voic
80
80
  export * from './pages/home';
81
81
  export * from './pages/questions';
82
82
  export * from './pages/task-tracker/OwnerPicker';
83
+ export * from './pages/plan';
@@ -45,6 +45,8 @@ import type {
45
45
 
46
46
  export interface LibraryPageProps {
47
47
  api: CorpusApi;
48
+ /** Open Plan: a note's to-dos are listed there, never in the note. */
49
+ onOpenPlan?: () => void;
48
50
  /** The asking principal's tenant scope. Rows outside it are never rendered. */
49
51
  scope: CorpusScope;
50
52
  /** Open straight onto one record — how a citation from the Ask surface lands. */
@@ -124,6 +126,7 @@ function relative(value: string | null | undefined, now: number): string {
124
126
 
125
127
  export function LibraryPage({
126
128
  api,
129
+ onOpenPlan,
127
130
  scope,
128
131
  initialDocumentId,
129
132
  onSelectDocument,
@@ -654,6 +657,7 @@ export function LibraryPage({
654
657
  classNames={cn}
655
658
  onClose={() => select(null)}
656
659
  onFilterByParty={(partyId) => update({ partyId })}
660
+ onOpenPlan={onOpenPlan}
657
661
  />
658
662
  ) : null}
659
663