@startsimpli/integrations 0.2.200 → 0.2.202

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 (147) hide show
  1. package/package.json +7 -7
  2. package/src/__tests__/briefing-actions.test.ts +11 -0
  3. package/src/__tests__/briefing-edits.test.ts +98 -0
  4. package/src/__tests__/briefing-markdown.test.ts +64 -0
  5. package/src/__tests__/converse-brain.test.ts +64 -1
  6. package/src/__tests__/converse-cards.test.ts +53 -0
  7. package/src/__tests__/converse-handoff.test.ts +8 -0
  8. package/src/__tests__/converse-meeting-brief.test.ts +72 -8
  9. package/src/__tests__/converse-meeting-duplex.test.ts +132 -0
  10. package/src/__tests__/converse-meeting-keep-speech.test.ts +87 -0
  11. package/src/__tests__/converse-meeting-vad.test.ts +1 -1
  12. package/src/__tests__/converse-page.test.tsx +148 -37
  13. package/src/__tests__/converse-roci.test.ts +22 -0
  14. package/src/__tests__/converse-spoken-form.test.ts +10 -0
  15. package/src/__tests__/converse-spoken-summary.test.ts +27 -6
  16. package/src/__tests__/converse-structure.test.ts +27 -0
  17. package/src/__tests__/converse-view.test.ts +46 -0
  18. package/src/__tests__/converse.test.ts +29 -2
  19. package/src/__tests__/corpus-ask.test.ts +22 -0
  20. package/src/__tests__/corpus-tracker.test.tsx +42 -174
  21. package/src/__tests__/data-table-logic.test.ts +75 -0
  22. package/src/__tests__/data-table.test.tsx +133 -0
  23. package/src/__tests__/extract-classify.test.ts +17 -0
  24. package/src/__tests__/fleet-page.test.tsx +57 -0
  25. package/src/__tests__/fleet-view.test.ts +149 -0
  26. package/src/__tests__/home-brief.test.tsx +25 -40
  27. package/src/__tests__/library-call-shape.test.tsx +164 -0
  28. package/src/__tests__/load-error.test.tsx +1 -1
  29. package/src/__tests__/mini-markdown.test.tsx +24 -0
  30. package/src/__tests__/overview-page.test.tsx +36 -6
  31. package/src/__tests__/plan-shell.test.tsx +6 -4
  32. package/src/__tests__/project-basis-entity.test.ts +19 -0
  33. package/src/__tests__/project-basis.test.ts +21 -0
  34. package/src/__tests__/relay-cli.test.ts +10 -1
  35. package/src/__tests__/task-detail-project-guess.test.tsx +46 -0
  36. package/src/__tests__/timeline-events.test.ts +65 -0
  37. package/src/__tests__/timeline-table.test.tsx +66 -0
  38. package/src/__tests__/todo-table-model.test.ts +75 -0
  39. package/src/__tests__/todo-table.test.tsx +202 -0
  40. package/src/__tests__/tracker-timeline-component.test.tsx +4 -4
  41. package/src/__tests__/tracker-timeline-reader.test.ts +1 -1
  42. package/src/comms/__tests__/app-sends-page.test.tsx +69 -0
  43. package/src/comms/api/comms.ts +23 -0
  44. package/src/comms/components/ResultsPanel.tsx +2 -2
  45. package/src/comms/components/SendLog.tsx +20 -8
  46. package/src/comms/components/index.ts +1 -0
  47. package/src/comms/components/pages/AppSendsPage.tsx +58 -0
  48. package/src/comms/hooks/index.ts +8 -3
  49. package/src/components/FolderTree.tsx +12 -3
  50. package/src/components/index.ts +4 -1
  51. package/src/components/pages/ConversePage.tsx +114 -105
  52. package/src/components/pages/FleetPage.tsx +115 -0
  53. package/src/components/pages/LibraryPage.tsx +63 -24
  54. package/src/components/pages/TaskDetailPage.tsx +27 -1
  55. package/src/components/pages/TrackerPage.tsx +170 -474
  56. package/src/components/pages/converse/CardView.tsx +72 -0
  57. package/src/components/pages/converse/SettingsMenu.tsx +37 -0
  58. package/src/components/pages/converse/Thread.tsx +48 -33
  59. package/src/components/pages/converse/useNeedsYou.ts +60 -0
  60. package/src/components/pages/home/BriefCard.tsx +16 -7
  61. package/src/components/pages/home/HomeBriefPage.tsx +6 -91
  62. package/src/components/pages/home/MiniMarkdown.tsx +51 -0
  63. package/src/components/pages/home/{DueSoonLine.tsx → dueSoonText.ts} +2 -11
  64. package/src/components/pages/home/index.ts +1 -1
  65. package/src/components/pages/overview/OverviewPage.tsx +46 -83
  66. package/src/components/pages/plan/TalkPage.tsx +5 -14
  67. package/src/components/pages/plan/TimelinePage.tsx +4 -2
  68. package/src/components/pages/task-tracker/ProjectGuess.tsx +42 -0
  69. package/src/components/pages/tracker/SweepPanel.tsx +108 -0
  70. package/src/components/pages/tracker/TimelineTable.tsx +70 -0
  71. package/src/components/pages/tracker/TrackerTimeline.tsx +32 -15
  72. package/src/components/table/DataTable.tsx +92 -0
  73. package/src/components/table/RowMenu.tsx +35 -0
  74. package/src/components/table/TablePagination.tsx +63 -0
  75. package/src/components/table/TableToolbar.tsx +56 -0
  76. package/src/components/table/TodoTable.tsx +142 -0
  77. package/src/components/table/index.ts +10 -0
  78. package/src/components/table/table-logic.ts +60 -0
  79. package/src/components/table/todo-model.ts +93 -0
  80. package/src/corpus/ask-items.ts +7 -4
  81. package/src/corpus/ask.ts +1 -1
  82. package/src/corpus/briefing/actions/confirm.ts +9 -1
  83. package/src/corpus/briefing/actions/execute.ts +71 -11
  84. package/src/corpus/briefing/actions/log.ts +1 -1
  85. package/src/corpus/briefing/actions/seam.ts +18 -2
  86. package/src/corpus/briefing/actions/types.ts +14 -0
  87. package/src/corpus/briefing/generate-weekly.ts +4 -0
  88. package/src/corpus/briefing/generate.ts +4 -0
  89. package/src/corpus/briefing/index.ts +1 -0
  90. package/src/corpus/briefing/intent/describe.ts +5 -1
  91. package/src/corpus/briefing/intent/edits.ts +92 -0
  92. package/src/corpus/briefing/intent/grammar.ts +3 -0
  93. package/src/corpus/briefing/intent/ground.ts +5 -1
  94. package/src/corpus/briefing/intent/match.ts +3 -1
  95. package/src/corpus/briefing/intent/model.ts +36 -3
  96. package/src/corpus/briefing/intent/resolve.ts +12 -1
  97. package/src/corpus/briefing/intent/types.ts +8 -0
  98. package/src/corpus/briefing/markdown.ts +71 -0
  99. package/src/corpus/briefing/speak.ts +13 -0
  100. package/src/corpus/client.ts +40 -146
  101. package/src/corpus/converse/brain.ts +41 -13
  102. package/src/corpus/converse/briefing-queue.ts +105 -27
  103. package/src/corpus/converse/cards.ts +69 -0
  104. package/src/corpus/converse/client.ts +6 -0
  105. package/src/corpus/converse/fleet-view.ts +126 -0
  106. package/src/corpus/converse/fleet.ts +18 -5
  107. package/src/corpus/converse/followups.ts +12 -2
  108. package/src/corpus/converse/handle.ts +21 -12
  109. package/src/corpus/converse/handoff.ts +7 -2
  110. package/src/corpus/converse/index.ts +11 -3
  111. package/src/corpus/converse/meeting-config.ts +8 -4
  112. package/src/corpus/converse/meeting.ts +66 -11
  113. package/src/corpus/converse/respond.ts +14 -2
  114. package/src/corpus/converse/roci.ts +13 -0
  115. package/src/corpus/converse/spoken-form.ts +9 -2
  116. package/src/corpus/converse/spoken-summary.ts +30 -8
  117. package/src/corpus/converse/store.ts +2 -0
  118. package/src/corpus/converse/structure.ts +39 -0
  119. package/src/corpus/converse/types.ts +14 -1
  120. package/src/corpus/converse/view.ts +34 -0
  121. package/src/corpus/entities.ts +2 -0
  122. package/src/corpus/extract.ts +9 -4
  123. package/src/corpus/index.ts +2 -0
  124. package/src/corpus/participants.ts +220 -0
  125. package/src/corpus/project-basis.ts +23 -0
  126. package/src/corpus/timeline-events.ts +83 -0
  127. package/src/corpus/tracker-sort.ts +9 -3
  128. package/src/corpus/tracker-timeline-client.ts +2 -0
  129. package/src/corpus/tracker-timeline.ts +4 -0
  130. package/src/corpus/types.ts +38 -5
  131. package/src/native/app/__tests__/plan-talk-registry.test.tsx +2 -1
  132. package/src/native/app/converseServices.ts +5 -3
  133. package/src/native/app/device.ts +2 -0
  134. package/src/native/converse/ConverseScreen.tsx +30 -4
  135. package/src/native/converse/__tests__/liveScreen.test.tsx +35 -2
  136. package/src/native/converse/__tests__/meetingIO.test.ts +55 -1
  137. package/src/native/converse/format.ts +2 -2
  138. package/src/native/converse/io.ts +15 -5
  139. package/src/native/home/HomeScreen.tsx +1 -1
  140. package/src/native/home/tab.tsx +1 -2
  141. package/src/native/plan/PlanTab.tsx +1 -2
  142. package/src/native/plan/__tests__/plan-tab.test.tsx +5 -5
  143. package/src/native/talk/TalkTab.tsx +1 -1
  144. package/src/native/talk/__tests__/talk-tab.test.tsx +1 -1
  145. package/src/__tests__/home-needs-your-call.test.tsx +0 -65
  146. package/src/components/pages/tracker/TrackerBoard.tsx +0 -45
  147. package/src/components/pages/tracker/TrackerToolbar.tsx +0 -44
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startsimpli/integrations",
3
- "version": "0.2.200",
3
+ "version": "0.2.202",
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/utils": "^0.4.20",
55
- "@startsimpli/ui": "^0.4.192"
53
+ "@startsimpli/utils": "^0.4.21",
54
+ "@startsimpli/ui": "^0.4.193",
55
+ "@startsimpli/auth": "^0.4.55"
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.192",
102
+ "@startsimpli/ui": "0.4.193",
103
103
  "@startsimpli/ui-native": "0.1.15",
104
- "@startsimpli/auth": "0.4.53",
105
- "@startsimpli/utils": "0.4.20"
104
+ "@startsimpli/auth": "0.4.55",
105
+ "@startsimpli/utils": "0.4.21"
106
106
  },
107
107
  "scripts": {
108
108
  "type-check": "tsc --noEmit && tsc --noEmit -p tsconfig.native.json",
@@ -154,6 +154,17 @@ describe('idempotency', () => {
154
154
  expect(again.replayed).toBe(true);
155
155
  });
156
156
 
157
+ it('skips survive a save and load through the tenant row', async () => {
158
+ const rows = new Map<string, any>();
159
+ const http = {
160
+ get: async (_p: string, o?: { params?: Record<string, unknown> }) => ({ results: [...rows.values()].filter((r) => r.external_id === o?.params?.external_id__in) }),
161
+ post: async (_p: string, body: any) => { const row = { id: '1', owner_sub: ME, ...body }; rows.set(body.external_id, row); return row; },
162
+ };
163
+ const log = createEntityActionLog(http as never, ME);
164
+ await log.save({ applied: {}, order: [], stack: [], skips: { date: '2026-11-16', keys: ['bench'] } });
165
+ expect((await createEntityActionLog(http as never, ME).load()).skips).toEqual({ date: '2026-11-16', keys: ['bench'] });
166
+ });
167
+
157
168
  it('the action log is a source_document with no body, so the extractor ignores it, and another owner\'s row is not read', async () => {
158
169
  const rows = new Map<string, any>();
159
170
  const http = {
@@ -0,0 +1,98 @@
1
+ // @vitest-environment node
2
+ /** More voice edits through the item seam: rename, add a note, estimate, project; one undo reverts a whole reply. */
3
+ import { describe, expect, it } from 'vitest';
4
+ import { createMemoryActionLog, executeVoiceActions, type EditableItem, type ItemEditSeam, type ItemPatch, type VoiceAction } from '../corpus/briefing';
5
+
6
+ const NOW = Date.parse('2026-11-16T17:00:00Z');
7
+ const TZ = 'America/Denver';
8
+ const FOCUSES = [{ id: 'f-croc', title: 'Crochets' }, { id: 'f-tandem', title: 'Tandem' }];
9
+
10
+ function memory(rows: EditableItem[], opts: { focuses?: boolean } = { focuses: true }) {
11
+ const items = new Map(rows.map((r) => [r.id, { ...r }]));
12
+ const seam: ItemEditSeam = {
13
+ async load(id) { return items.get(id) ? { ...items.get(id)! } : null; },
14
+ async update(item, patch: ItemPatch) {
15
+ const next = { ...items.get(item.id)!, ...patch } as EditableItem;
16
+ if (patch.estimateMinutes === null) delete next.estimateMinutes;
17
+ items.set(item.id, next);
18
+ return { ...next };
19
+ },
20
+ async create() { throw new Error('no'); },
21
+ ...(opts.focuses ? { listFocuses: async () => FOCUSES } : {}),
22
+ };
23
+ return { items, seam };
24
+ }
25
+ const run = (seam: ItemEditSeam, actions: VoiceAction[], log = createMemoryActionLog(), id = 'k1') =>
26
+ executeVoiceActions({ actions, clientActionId: id, seam, log, ownerSub: 'me', now: () => NOW, timeZone: TZ }).then((out) => ({ out, log }));
27
+ const BENCH: EditableItem = { id: 'bench', title: "Order dad's bench", status: 'open', detail: 'Walnut if possible.' };
28
+
29
+ describe('rename, note, estimate, project', () => {
30
+ it('renames, says so, and undo puts the old title back', async () => {
31
+ const m = memory([BENCH]);
32
+ const { out, log } = await run(m.seam, [{ type: 'rename', itemId: 'bench', title: 'Order the walnut bench' }]);
33
+ expect(m.items.get('bench')!.title).toBe('Order the walnut bench');
34
+ expect(out.text).toBe('Renamed it to Order the walnut bench.');
35
+ const undone = await run(m.seam, [{ type: 'undo' }], log, 'k2');
36
+ expect(m.items.get('bench')!.title).toBe("Order dad's bench");
37
+ expect(undone.out.results[0].status).toBe('applied');
38
+ });
39
+
40
+ it('adds a note after what is there; undo restores the old detail', async () => {
41
+ const m = memory([BENCH]);
42
+ const { out, log } = await run(m.seam, [{ type: 'add_detail', itemId: 'bench', detail: 'Call Pete first.' }]);
43
+ expect(m.items.get('bench')!.detail).toBe('Walnut if possible.\n\nCall Pete first.');
44
+ expect(out.text).toBe("Added a note to Order dad's bench.");
45
+ await run(m.seam, [{ type: 'undo' }], log, 'k2');
46
+ expect(m.items.get('bench')!.detail).toBe('Walnut if possible.');
47
+ });
48
+
49
+ it('sets an estimate in words a person says, and undo clears it', async () => {
50
+ const m = memory([BENCH]);
51
+ const { out, log } = await run(m.seam, [{ type: 'set_estimate', itemId: 'bench', minutes: 90 }]);
52
+ expect(m.items.get('bench')!.estimateMinutes).toBe(90);
53
+ expect(out.text).toBe("Set Order dad's bench to an hour and a half.");
54
+ await run(m.seam, [{ type: 'undo' }], log, 'k2');
55
+ expect(m.items.get('bench')!.estimateMinutes).toBeUndefined();
56
+ });
57
+
58
+ it('files under a project found by name (case and "project" ignored); undo files it back', async () => {
59
+ const m = memory([{ ...BENCH, focusId: 'f-tandem' }]);
60
+ const { out, log } = await run(m.seam, [{ type: 'set_project', itemId: 'bench', project: 'the crochets project' }]);
61
+ expect(m.items.get('bench')!.focusId).toBe('f-croc');
62
+ expect(out.text).toBe("Moved Order dad's bench to Crochets.");
63
+ await run(m.seam, [{ type: 'undo' }], log, 'k2');
64
+ expect(m.items.get('bench')!.focusId).toBe('f-tandem');
65
+ });
66
+
67
+ it('a project that does not exist, or a seam that cannot file, says so and changes nothing', async () => {
68
+ const m = memory([BENCH]);
69
+ const none = await run(m.seam, [{ type: 'set_project', itemId: 'bench', project: 'Gardening' }]);
70
+ expect(none.out.results[0]).toMatchObject({ status: 'asked' });
71
+ expect(none.out.text).toMatch(/Gardening/);
72
+ expect(m.items.get('bench')!.focusId).toBeUndefined();
73
+ const blind = memory([BENCH], { focuses: false });
74
+ const cannot = await run(blind.seam, [{ type: 'set_project', itemId: 'bench', project: 'Crochets' }]);
75
+ expect(cannot.out.results[0].status).toBe('failed');
76
+ });
77
+ });
78
+
79
+ describe('one undo reverts a whole reply', () => {
80
+ it('"mark all of those done" is undone in one go', async () => {
81
+ const rows = ['a', 'b', 'c'].map((id): EditableItem => ({ id, title: `Item ${id}`, status: 'open' }));
82
+ const m = memory(rows);
83
+ const { log } = await run(m.seam, rows.map((r): VoiceAction => ({ type: 'done', itemId: r.id })), createMemoryActionLog(), 'bulk');
84
+ expect([...m.items.values()].every((i) => i.status === 'done')).toBe(true);
85
+ const undone = await run(m.seam, [{ type: 'undo' }], log, 'u1');
86
+ expect([...m.items.values()].every((i) => i.status === 'open')).toBe(true);
87
+ expect(undone.out.text).toBe('Undid all three changes.');
88
+ });
89
+ it('a reply with one change still undoes just that one', async () => {
90
+ const rows = ['a', 'b'].map((id): EditableItem => ({ id, title: `Item ${id}`, status: 'open' }));
91
+ const m = memory(rows);
92
+ const { log } = await run(m.seam, [{ type: 'done', itemId: 'a' }], createMemoryActionLog(), 'one');
93
+ await run(m.seam, [{ type: 'done', itemId: 'b' }], log, 'two');
94
+ await run(m.seam, [{ type: 'undo' }], log, 'u1');
95
+ expect(m.items.get('a')!.status).toBe('done');
96
+ expect(m.items.get('b')!.status).toBe('open');
97
+ });
98
+ });
@@ -0,0 +1,64 @@
1
+ /** The brief on screen: a short structured markdown view of the composed items (the spoken text is separate). */
2
+ import { describe, expect, it } from 'vitest';
3
+
4
+ import { briefingMarkdown, weeklyMarkdown } from '../corpus/briefing/markdown';
5
+ import type { BriefingEntry, WeeklySummary } from '../corpus/briefing';
6
+
7
+ const e = (over: Partial<BriefingEntry>): BriefingEntry => ({ id: 'x', title: 'T', kind: 'due_today', group: 'Personal', dueDate: '2026-11-06', ...over });
8
+
9
+ describe('briefingMarkdown', () => {
10
+ it('groups by overdue, in progress, due today, one short bullet each', () => {
11
+ const md = briefingMarkdown([
12
+ e({ id: '1', title: 'Send the term sheet', kind: 'overdue', group: 'Acme', dueDate: '2026-11-03' }),
13
+ e({ id: '2', title: 'Draft the memo', kind: 'in_progress', group: 'Personal', dueDate: null }),
14
+ e({ id: '3', title: 'Call the bank', kind: 'due_today', group: 'Acme' }),
15
+ ], 0);
16
+ expect(md).toBe([
17
+ '## Overdue',
18
+ '- **Send the term sheet** · Acme · was due Nov 3',
19
+ '',
20
+ '## In progress',
21
+ '- **Draft the memo**',
22
+ '',
23
+ '## Due today',
24
+ '- **Call the bank** · Acme',
25
+ ].join('\n'));
26
+ });
27
+
28
+ it('says how many more are not listed', () => {
29
+ expect(briefingMarkdown([e({ id: '1', title: 'A' })], 4)).toContain('\n\n_4 more not shown._');
30
+ });
31
+
32
+ it('says plainly when nothing is due', () => {
33
+ expect(briefingMarkdown([], 0)).toBe('Nothing is due today, and nothing is overdue.');
34
+ });
35
+
36
+ it('keeps markdown characters in a title from breaking the layout', () => {
37
+ const md = briefingMarkdown([e({ title: '**bold** # hi\nnext' })], 0);
38
+ expect(md.split('\n')).toHaveLength(2);
39
+ expect(md).toContain('- **bold hi next**'.replace('bold hi', 'bold hi'));
40
+ });
41
+ });
42
+
43
+ describe('weeklyMarkdown', () => {
44
+ const w = (over: Partial<WeeklySummary>): WeeklySummary => ({
45
+ done: [], slipping: [], upcoming: [], counts: { done: 0, slipping: 0, upcoming: 0 }, empty: false,
46
+ window: { from: '2026-10-30', today: '2026-11-06', to: '2026-11-13', timeZone: 'UTC' }, ...over,
47
+ });
48
+ it('lists finished, slipping and coming up with counts and the overflow', () => {
49
+ const md = weeklyMarkdown(w({
50
+ done: [{ id: '1', title: 'Ship it', kind: 'done', group: 'Acme', dueDate: null, doneDate: '2026-11-04' }],
51
+ slipping: [{ id: '2', title: 'Pay rent', kind: 'slipping', group: 'Personal', dueDate: '2026-11-01' }],
52
+ upcoming: [{ id: '3', title: 'Call', kind: 'upcoming', group: 'Personal', dueDate: '2026-11-09' }],
53
+ counts: { done: 1, slipping: 5, upcoming: 1 },
54
+ }));
55
+ expect(md).toBe([
56
+ '## Finished · 1', '- **Ship it** · Acme · Nov 4', '',
57
+ '## Slipping · 5', '- **Pay rent** · was due Nov 1', '_4 more._', '',
58
+ '## Coming up · 1', '- **Call** · due Nov 9',
59
+ ].join('\n'));
60
+ });
61
+ it('says plainly when the week is empty', () => {
62
+ expect(weeklyMarkdown(w({ empty: true }))).toMatch(/Nothing finished/);
63
+ });
64
+ });
@@ -109,7 +109,18 @@ describe('long answers: whole on the screen, short aloud; Ask starts beside rout
109
109
  const brain = createConverseBrain({ ...s.deps, ask: async () => ({ answer: LIST }) });
110
110
  const out = await brain(input('what are my commitments this week'));
111
111
  expect(out.text).toContain('5. Call the bank');
112
- expect(out.spoken).toBe('This week, the following tasks are due. Plan the week. Build lead QC. Launch lead. And 2 more.');
112
+ expect(out.spoken).toBe('This week, the following tasks are due. Plan the week. Build lead QC. Launch lead. And 2 more. Want the rest?');
113
+ });
114
+
115
+ it('"yes" after a shortened answer reads the rest; "yes" after a short one is not special', async () => {
116
+ const s = setup();
117
+ const brain = createConverseBrain({ ...s.deps, ask: async () => ({ answer: 'unused' }) });
118
+ const out = await brain({ ...input('yes'), history: [{ role: 'user', text: 'what is due' }, { role: 'assistant', text: LIST }] });
119
+ expect(out.text).toBe('Order the bench. Call the bank.');
120
+ expect(out.spoken).toBeUndefined();
121
+ const ask = vi.fn(async () => ({ answer: 'Sure.' }));
122
+ await createConverseBrain({ ...s.deps, ask })({ ...input('yes'), history: [{ role: 'assistant', text: 'The bench is due today.' }] });
123
+ expect(ask).toHaveBeenCalled();
113
124
  });
114
125
 
115
126
  it('a short answer has no separate spoken version', async () => {
@@ -328,6 +339,23 @@ describe('briefing one item at a time', () => {
328
339
  expect(s.rows.get('item:bench')?.data.status).not.toBe('open');
329
340
  });
330
341
 
342
+ it('a skipped item stays out of the next briefing the same day, and comes back the next day', async () => {
343
+ const s = setup();
344
+ const rows = [
345
+ { id: 'bench', title: "Order dad's bench", status: 'open', dueAt: '2026-11-04', ownerSub: ME, focusName: 'Home' },
346
+ { id: 'lease', title: 'Call the lease office', status: 'open', dueAt: '2026-11-04', ownerSub: ME, focusName: 'Home' },
347
+ ] as never;
348
+ const brain = createConverseBrain({ ...s.deps, loadItems: async () => rows });
349
+ const started = await brain(say('brief me'));
350
+ expect(started.text).toMatch(/Order dad's bench|Call the lease office/);
351
+ const first = started.briefing!.queue[0].itemId;
352
+ await brain(say('skip', started.briefing));
353
+ const again = await brain(say('brief me'));
354
+ expect(again.briefing?.queue.map((q: any) => q.itemId)).not.toContain(first);
355
+ const tomorrow = await brain({ ...say('brief me'), now: NOW + 86_400_000 });
356
+ expect(tomorrow.briefing?.queue.map((q: any) => q.itemId)).toContain(first);
357
+ });
358
+
331
359
  it('an answer about something the relay waits on goes to the relay with the item named', async () => {
332
360
  const s = setup();
333
361
  const brain = createConverseBrain({ ...s.deps, loadItems: async () => [] as never, loadFleetStatus: async () => ({ text: '## Waiting on Quinn\n- Crochets: flip the 8 category pages Tuesday morning?', updatedAt: new Date(NOW).toISOString() }) });
@@ -506,3 +534,38 @@ describe('routing: work for the relay, fleet status, no filler', () => {
506
534
  expect(llm.write).not.toHaveBeenCalled();
507
535
  });
508
536
  });
537
+
538
+ describe('which-one clarification carries to the next turn (startsim-ym54h.31)', () => {
539
+ function twoBenches() {
540
+ const s = setup();
541
+ s.rows.set('item:bench2', { id: 'bench2', entity_type: 'commitment', external_id: 'item:bench2', name: 'Sand the garden bench', data: { title: 'Sand the garden bench', status: 'open', owner_sub: ME, subtype: 'action', due_at: '2026-11-04' } });
542
+ return s;
543
+ }
544
+ it('an ambiguous instruction asks which and keeps the question pending, not sent to Ask', async () => {
545
+ const s = twoBenches();
546
+ const out = await s.brain({ utterance: 'move the bench one to friday', history: [], timeZone: TZ, now: NOW });
547
+ expect(s.ask).not.toHaveBeenCalled();
548
+ expect(out.text).toMatch(/which/i);
549
+ expect(out.pending?.utterance).toBe('move the bench one to friday');
550
+ expect(out.pending?.question).toBe(out.text);
551
+ });
552
+ it('the next turn answers it: "the dad one" resolves with the earlier words', async () => {
553
+ const s = twoBenches();
554
+ const first = await s.brain({ utterance: 'move the bench one to friday', history: [], timeZone: TZ, now: NOW });
555
+ const out = await s.brain({ utterance: "the dad one", history: [], timeZone: TZ, now: NOW, pending: first.pending });
556
+ expect(out.text).toBe("Moved Order dad's bench to Friday.");
557
+ expect(out.pending).toBeNull();
558
+ expect(s.ask).not.toHaveBeenCalled();
559
+ });
560
+ });
561
+
562
+ describe('an Ask answer keeps its sources and the items it listed (startsim-ym54h.24, .35)', () => {
563
+ it('citations from Ask become the thread sources and the items for "the second one"', async () => {
564
+ const s = setup();
565
+ const doc = (id: string, title: string, extra = {}) => ({ id, title, ...extra });
566
+ const brain = createConverseBrain({ ...(s.deps as any), ask: async () => ({ answer: 'Two things on the website.', status: 'answered', citations: [{ document: doc('item:a', 'Fix header') }, { document: doc('item:b', 'Ship footer') }, { document: doc('doc1', 'Kickoff notes', { source: 'granola' }) }] }) });
567
+ const out = await brain({ utterance: 'what is open on the website', history: [], timeZone: TZ, now: NOW });
568
+ expect(out.sources?.map((x) => x.title)).toEqual(['Fix header', 'Ship footer', 'Kickoff notes']);
569
+ expect(out.context?.items).toEqual([{ id: 'a', title: 'Fix header' }, { id: 'b', title: 'Ship footer' }]);
570
+ });
571
+ });
@@ -0,0 +1,53 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { CARD_CHIP, briefCard, decisionCard, resolveCard, type ThreadCard } from '../corpus/converse/cards';
3
+ import type { DecisionRecord } from '../corpus/notify/types';
4
+
5
+ const decision = (over: Partial<DecisionRecord> = {}): DecisionRecord => ({
6
+ id: 'd1', title: 'Which build first?', status: 'pending', created_at: '2026-11-20T10:42:00Z',
7
+ questions: [{ n: 1, text: 'iOS or web staging first?', options: ['iOS 0.9.2', 'Web staging'] }], answers: [], ...over,
8
+ });
9
+
10
+ describe('thread cards: one shape for every kind of item', () => {
11
+ it('a pending decision is a question card with its options as actions, who asked, and the first option primary', () => {
12
+ const c = decisionCard(decision(), 'Build agent');
13
+ expect(c).toMatchObject({ id: 'decision:d1', type: 'question', from: 'Build agent', title: 'Which build first?', detail: 'iOS or web staging first?', at: '2026-11-20T10:42:00Z' });
14
+ expect(c.actions.map((a) => [a.label, !!a.primary])).toEqual([['iOS 0.9.2', true], ['Web staging', false]]);
15
+ expect(c.resolved).toBeUndefined();
16
+ expect(c.sample).toBeFalsy();
17
+ });
18
+ it('a decision whose title starts TEST SAMPLE is marked as a sample', () => {
19
+ expect(decisionCard(decision({ title: 'TEST SAMPLE: pick one' })).sample).toBe(true);
20
+ });
21
+ it('a decision with no options takes a free reply', () => {
22
+ const c = decisionCard(decision({ questions: [{ n: 1, text: 'What should we call it?' }] }), 'Roci');
23
+ expect(c.actions).toEqual([]);
24
+ expect(c.freeReply).toBe(true);
25
+ });
26
+ it('several questions in one decision keep the card to the first open one and say how many are left', () => {
27
+ const c = decisionCard(decision({ questions: [{ n: 1, text: 'A?', options: ['x'] }, { n: 2, text: 'B?' }] }), 'Roci');
28
+ expect(c.detail).toBe('A?');
29
+ expect(c.more).toBe(1);
30
+ });
31
+ it('the sender falls back to Tandem when the record does not say who asked', () => {
32
+ expect(decisionCard(decision()).from).toBe('Tandem');
33
+ });
34
+ it('an answered decision is a resolved result card', () => {
35
+ const answered = decision({ status: 'answered', answers: [{ n: 1, answer: 'iOS 0.9.2', answered_at: '2026-11-20T10:50:00Z' }], answered_at: '2026-11-20T10:50:00Z' });
36
+ const c = decisionCard(answered, 'Build agent');
37
+ expect(c.resolved).toBe('iOS 0.9.2');
38
+ expect(c.actions).toEqual([]);
39
+ });
40
+ it('resolveCard keeps the card in place and records the answer', () => {
41
+ const c = decisionCard(decision(), 'Build agent');
42
+ expect(resolveCard(c, 'Web staging')).toMatchObject({ id: c.id, type: 'question', resolved: 'Web staging', actions: [] });
43
+ });
44
+ it('a brief card is the day\'s bullets with Read it aloud as its one action', () => {
45
+ const c = briefCard({ id: 'brief:2026-11-20', title: 'Morning brief · Fri 20 Nov', bullets: ['**Calendar** — 3 events'], at: '2026-11-20T07:00:00Z' });
46
+ expect(c).toMatchObject({ type: 'brief', from: 'Roci', actions: [{ id: 'read', label: 'Read it aloud', primary: true }] });
47
+ expect(c.body).toBe('- **Calendar** — 3 events');
48
+ });
49
+ it('every type has a chip label', () => {
50
+ const types: ThreadCard['type'][] = ['question', 'approval', 'brief', 'task', 'email', 'result'];
51
+ for (const t of types) expect(CARD_CHIP[t]).toMatch(/^[A-Z]+$/);
52
+ });
53
+ });
@@ -58,6 +58,14 @@ describe('End hands the conversation on', () => {
58
58
  expect(extractTodos).toHaveBeenCalledWith('900');
59
59
  });
60
60
 
61
+ it('reports the project it filed under, by name', async () => {
62
+ const { deps } = setup();
63
+ const a = await handleConverseTurn(deps, { text: 'plan the hours import' });
64
+ const end = await handleConverseEnd(deps, { conversationId: a.conversation_id });
65
+ expect(end.project).toBe('Hours');
66
+ expect(end.filed).toEqual(['Email Michelle about the Hours import', 'Fix it']);
67
+ });
68
+
61
69
  it('a project the model invented files nothing; no asks means no extraction', async () => {
62
70
  const t1 = setup({ analyzer: { analyze: async () => ({ title: 't', summary: 's', focusId: 'nope' }) } });
63
71
  const a = await handleConverseTurn(t1.deps, { text: 'hi there' });
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import { describe, expect, it } from 'vitest';
7
7
 
8
- import { buildQueue, firstPrompt, relayItemsFrom, stepBriefing, BRIEF_ME, NEEDS_ME } from '../corpus/converse/briefing-queue';
8
+ import { buildQueue, firstPrompt, rankQueue, relayItemsFrom, startBriefing, stepBriefing, BRIEF_ME, NEEDS_ME, type BriefingState } from '../corpus/converse/briefing-queue';
9
9
  import type { BriefingItem } from '../corpus/briefing/types';
10
10
 
11
11
  const NOW = Date.parse('2026-11-16T17:00:00Z');
@@ -32,7 +32,7 @@ describe('the trigger', () => {
32
32
  describe('the queue', () => {
33
33
  it('is ordered by project, overdue and due-today items only, done items left out', () => {
34
34
  const q = buildQueue({ items: ITEMS, relayItems: [], now: NOW, timeZone: TZ });
35
- expect(q.map((i) => `${i.project}:${i.itemId}`)).toEqual(['Crochets:b', 'Crochets:a', 'Tandem:c']);
35
+ expect(q.map((i) => `${i.project}:${i.itemId}`)).toEqual(['Crochets:a', 'Crochets:b', 'Tandem:c']);
36
36
  });
37
37
 
38
38
  it('puts what the relay waits on Quinn for after his own items, under its project', () => {
@@ -63,19 +63,19 @@ describe('one item at a time', () => {
63
63
  it('says one sentence and one question, nothing else', () => {
64
64
  const s = start();
65
65
  const said = firstPrompt(s);
66
- expect(said).toBe('Crochets, item 1: Review the checkout copy, overdue. Do it today?');
66
+ expect(said).toBe('Crochets, item 1: Flip the 8 category pages on Tuesday morning, due today. Do it today?');
67
67
  expect(said.split(/[.?]\s/).length).toBeLessThanOrEqual(3);
68
68
  });
69
69
 
70
70
  it('after an answer says Noted., then the next item; on a new project says that is the project first', () => {
71
71
  let s = start();
72
72
  let r = stepBriefing(s, 'yes');
73
- expect(r.reply).toBe('Noted. Crochets, item 2: Flip the 8 category pages on Tuesday morning, due today. Do it today?');
74
- expect(r.effect).toEqual({ kind: 'todo', action: { type: 'pull_today', itemId: 'b' } });
73
+ expect(r.reply).toBe('Noted. Crochets, item 2: Review the checkout copy, overdue. Do it today?');
74
+ expect(r.effect).toEqual({ kind: 'todo', action: { type: 'pull_today', itemId: 'a' } });
75
75
  s = r.state!;
76
76
  r = stepBriefing(s, 'later');
77
77
  expect(r.reply).toBe('Noted. That is Crochets. Now Tandem, item 1: Ship the combined roll, due today. Do it today?');
78
- expect(r.effect).toEqual({ kind: 'todo', action: { type: 'defer', itemId: 'a', to: 'later' } });
78
+ expect(r.effect).toEqual({ kind: 'todo', action: { type: 'defer', itemId: 'b', to: 'later' } });
79
79
  s = r.state!;
80
80
  r = stepBriefing(s, 'done');
81
81
  expect(r.reply).toBe('Noted. That is everything.');
@@ -86,7 +86,7 @@ describe('one item at a time', () => {
86
86
  it('holds the rest until answered: "tell me more" gives the detail and asks the same question again', () => {
87
87
  const s = start();
88
88
  const r = stepBriefing(s, 'tell me more');
89
- expect(r.reply).toMatch(/^Review the checkout copy/);
89
+ expect(r.reply).toMatch(/^Flip the 8 category pages/);
90
90
  expect(r.reply).toMatch(/Do it today\?$/);
91
91
  expect(r.state?.index).toBe(0);
92
92
  expect(r.effect).toBeUndefined();
@@ -95,7 +95,7 @@ describe('one item at a time', () => {
95
95
  it('skip moves on without a change; stop ends the briefing; repeat says the item again', () => {
96
96
  const s = start();
97
97
  expect(stepBriefing(s, 'skip').reply).toMatch(/^Noted\. Crochets, item 2:/);
98
- expect(stepBriefing(s, 'skip').effect).toBeUndefined();
98
+ expect(stepBriefing(s, 'skip').effect).toEqual({ kind: 'skip', key: 'a' });
99
99
  const stop = stepBriefing(s, "that's all");
100
100
  expect(stop.reply).toBe('Okay, stopping.');
101
101
  expect(stop.state).toBeNull();
@@ -120,3 +120,67 @@ describe('one item at a time', () => {
120
120
  expect(r.state?.index).toBe(0);
121
121
  });
122
122
  });
123
+
124
+ describe('briefing quality: importance, unfiled, snoozes, skips', () => {
125
+ const day = (n: number) => new Date(Date.parse('2026-11-16T12:00:00Z') - n * 86_400_000).toISOString().slice(0, 10);
126
+ const many = [
127
+ ...Array.from({ length: 10 }, (_, n) => item(`old${n}`, `Old chore ${n}`, 'Tandem', day(30 + n))),
128
+ item('recent', 'Recent overdue chore', 'Tandem', day(2)),
129
+ item('today1', 'Due today chore', 'Tandem', day(0)),
130
+ item('urgent', 'Urgent but ancient', 'Tandem', day(90), { priority: 1 }),
131
+ item('loose', 'No project item', '', day(0)),
132
+ ];
133
+
134
+ it('does not open with a flood of old overdue items: urgent and today first, a handful of the rest, newest overdue first', () => {
135
+ const { queue, older } = rankQueue({ items: many, relayItems: [], now: NOW, timeZone: TZ });
136
+ const ids = queue.map((q) => q.itemId);
137
+ expect(ids.slice(0, 2)).toEqual(['urgent', 'today1']);
138
+ expect(ids).toContain('recent');
139
+ expect(ids.filter((id) => id?.startsWith('old')).length).toBeLessThanOrEqual(2);
140
+ expect(older).toBe(many.length - queue.length);
141
+ expect(ids.indexOf('recent')).toBeLessThan(ids.indexOf('old0') === -1 ? 99 : ids.indexOf('old0'));
142
+ });
143
+
144
+ it('names an item with no project "Unfiled", not Personal', () => {
145
+ const q = buildQueue({ items: many, relayItems: [], now: NOW, timeZone: TZ });
146
+ expect(q.find((i) => i.itemId === 'loose')?.project).toBe('Unfiled');
147
+ });
148
+
149
+ it('says how many older overdue items are still open, once, at the end', () => {
150
+ const state = startBriefing({ items: many, relayItems: [], now: NOW, timeZone: TZ })!;
151
+ expect(state.older).toBeGreaterThan(0);
152
+ let s: typeof state | null = state;
153
+ let last = '';
154
+ for (let n = 0; s && n < 20; n += 1) { const r = stepBriefing(s, 'skip', { now: NOW, timeZone: TZ }); last = r.reply; s = r.state; }
155
+ expect(last).toMatch(/older overdue items? (?:is|are) still open/);
156
+ });
157
+
158
+ it('"tomorrow" and "next week" move the item to that date; they do not clear the due date', () => {
159
+ const s = { queue: buildQueue({ items: ITEMS, relayItems: [], now: NOW, timeZone: TZ }), index: 0 };
160
+ const tomorrow = stepBriefing(s, 'tomorrow', { now: NOW, timeZone: TZ });
161
+ expect(tomorrow.effect).toEqual({ kind: 'todo', action: { type: 'defer', itemId: 'a', to: '2026-11-17', label: 'tomorrow' } });
162
+ const week = stepBriefing(s, 'next week', { now: NOW, timeZone: TZ });
163
+ expect(week.effect).toMatchObject({ kind: 'todo', action: { type: 'defer', itemId: 'a', to: '2026-11-23' } });
164
+ const friday = stepBriefing(s, 'push it to Friday', { now: NOW, timeZone: TZ });
165
+ expect(friday.effect).toMatchObject({ action: { type: 'defer', to: '2026-11-20' } });
166
+ });
167
+
168
+ it('"later today" changes nothing and asks again at the end of the walk', () => {
169
+ let s: BriefingState | null = { queue: buildQueue({ items: ITEMS, relayItems: [], now: NOW, timeZone: TZ }), index: 0 };
170
+ const r = stepBriefing(s, 'later today', { now: NOW, timeZone: TZ });
171
+ expect(r.effect).toBeUndefined();
172
+ expect(r.reply).toMatch(/^Noted, I will ask again at the end\./);
173
+ s = r.state;
174
+ s = stepBriefing(s!, 'done', { now: NOW, timeZone: TZ }).state;
175
+ s = stepBriefing(s!, 'done', { now: NOW, timeZone: TZ }).state;
176
+ const again = firstPrompt(s!);
177
+ expect(again).toMatch(/Flip the 8 category pages/);
178
+ const end = stepBriefing(s!, 'later today', { now: NOW, timeZone: TZ });
179
+ expect(end.state).toBeNull(); // asked only once more
180
+ });
181
+
182
+ it('a skipped item is left out of the next briefing today', () => {
183
+ const s = startBriefing({ items: ITEMS, relayItems: [], now: NOW, timeZone: TZ, skipped: ['a'] })!;
184
+ expect(s.queue.map((q) => q.itemId)).toEqual(['c', 'b']);
185
+ });
186
+ });
@@ -0,0 +1,132 @@
1
+ // @vitest-environment node
2
+ import { describe, expect, it, vi } from 'vitest';
3
+ import { createMeetingController, type MeetingApi, type MeetingIO, type MeetingState } from '../corpus/converse';
4
+
5
+ const blob = () => new Blob([new Uint8Array([1])], { type: 'audio/mp4' });
6
+ const turnResult = (n: number) => ({
7
+ conversation_id: 'c1', turn_id: `t${n}`, turn: n, transcript: `said ${n}`, reply_text: `reply ${n}`, audio_url: `/a/${n}`, audio_reason: null,
8
+ });
9
+ const settle = async (check: () => boolean) => { for (let i = 0; i < 300 && !check(); i += 1) await new Promise((r) => setTimeout(r, 5)); };
10
+
11
+ /** A duplex io: listen runs all the time and can be handed an utterance or told "speech started" by the test. */
12
+ function rig(opts: { speak?: MeetingIO['speak']; turn?: MeetingApi<Blob>['turn'] } = {}) {
13
+ let n = 0;
14
+ const client: MeetingApi<Blob> = { turn: opts.turn ?? vi.fn(async () => turnResult(++n)), end: vi.fn(async () => ({ saved: true as const, conversation_id: 'c1', record_id: '1', turns: n, asks: [], decisions: [] })) as never };
15
+ const heard: Array<{ signal: AbortSignal; hooks?: { onSpeechStart?: () => void }; deliver: (a: Blob | null) => void }> = [];
16
+ const io: MeetingIO<Blob> = {
17
+ duplex: true,
18
+ listen: vi.fn((signal: AbortSignal, _c: unknown, hooks?: { onSpeechStart?: () => void }) => new Promise((resolve) => {
19
+ heard.push({ signal, hooks, deliver: (a) => resolve(a ? { audio: a } : { audio: null }) });
20
+ signal.addEventListener('abort', () => resolve({ audio: null, cancelled: true }));
21
+ })),
22
+ speak: opts.speak ?? vi.fn(async () => undefined),
23
+ };
24
+ const states: MeetingState[] = [];
25
+ const c = createMeetingController({ client, io, onChange: (s) => states.push(s) });
26
+ return { c, client, io, heard, states };
27
+ }
28
+
29
+ describe('the mic never switches off while a meeting runs (duplex io)', () => {
30
+ it('keeps listening while the reply is thinking and while it is spoken', async () => {
31
+ let finishSpeak: () => void = () => undefined;
32
+ const speak = vi.fn((_r: unknown, signal: AbortSignal) => new Promise<void>((resolve) => { finishSpeak = resolve; signal.addEventListener('abort', () => resolve()); }));
33
+ const { c, heard, io } = rig({ speak });
34
+ c.start();
35
+ await settle(() => heard.length >= 1);
36
+ heard[0].deliver(blob());
37
+ await settle(() => c.state().phase === 'speaking');
38
+ // A pause sent the data; the mic is already listening again, even though the reply is being spoken.
39
+ await settle(() => heard.length >= 2);
40
+ expect(heard.length).toBe(2);
41
+ expect(heard[1].signal.aborted).toBe(false);
42
+ expect(c.state().micLive).toBe(true);
43
+ finishSpeak();
44
+ await settle(() => c.state().phase === 'listening');
45
+ expect(heard[1].signal.aborted).toBe(false);
46
+ expect((io.listen as any).mock.calls.length).toBe(2);
47
+ await c.end();
48
+ });
49
+
50
+ it('speech while the reply is spoken cuts the reply off and that utterance is the next turn', async () => {
51
+ const speak = vi.fn((_r: unknown, signal: AbortSignal) => new Promise<void>((resolve) => signal.addEventListener('abort', () => resolve())));
52
+ const { c, heard, client } = rig({ speak });
53
+ c.start();
54
+ await settle(() => heard.length >= 1);
55
+ heard[0].deliver(blob());
56
+ await settle(() => c.state().phase === 'speaking');
57
+ await settle(() => heard.length >= 2);
58
+ heard[1].hooks?.onSpeechStart?.();
59
+ await settle(() => c.state().phase !== 'speaking');
60
+ expect(c.state().phase).toBe('listening');
61
+ heard[1].deliver(blob());
62
+ await settle(() => (client.turn as any).mock.calls.length >= 2);
63
+ expect((client.turn as any).mock.calls.length).toBe(2);
64
+ await c.end();
65
+ });
66
+
67
+ it('speech while it is only thinking does not cut anything; the reply waits until he has finished, then is spoken', async () => {
68
+ const speak = vi.fn(async () => undefined);
69
+ let release: () => void = () => undefined;
70
+ const turn = vi.fn(() => new Promise<any>((resolve) => { release = () => resolve(turnResult(1)); }));
71
+ const { c, heard } = rig({ speak, turn: turn as never });
72
+ c.start();
73
+ await settle(() => heard.length >= 1);
74
+ heard[0].deliver(blob());
75
+ await settle(() => c.state().phase === 'thinking');
76
+ await settle(() => heard.length >= 2);
77
+ heard[1].hooks?.onSpeechStart?.();
78
+ release();
79
+ await new Promise((r) => setTimeout(r, 120));
80
+ expect(speak).not.toHaveBeenCalled();
81
+ heard[1].deliver(null);
82
+ await settle(() => speak.mock.calls.length >= 1);
83
+ expect(speak).toHaveBeenCalledTimes(1);
84
+ await c.end();
85
+ });
86
+ });
87
+
88
+ describe('stop()', () => {
89
+ it('stops the readout at once and listens', async () => {
90
+ const speak = vi.fn((_r: unknown, signal: AbortSignal) => new Promise<void>((resolve) => signal.addEventListener('abort', () => resolve())));
91
+ const { c, heard } = rig({ speak });
92
+ c.start();
93
+ await settle(() => heard.length >= 1);
94
+ heard[0].deliver(blob());
95
+ await settle(() => c.state().phase === 'speaking');
96
+ c.stop();
97
+ await settle(() => c.state().phase === 'listening');
98
+ expect(c.state().phase).toBe('listening');
99
+ expect(c.state().micLive).toBe(true);
100
+ await c.end();
101
+ });
102
+
103
+ it('while it is thinking, the reply that arrives is shown but not spoken', async () => {
104
+ const speak = vi.fn(async () => undefined);
105
+ let release: () => void = () => undefined;
106
+ const turn = vi.fn(() => new Promise<any>((resolve) => { release = () => resolve(turnResult(1)); }));
107
+ const { c, heard } = rig({ speak, turn: turn as never });
108
+ c.start();
109
+ await settle(() => heard.length >= 1);
110
+ heard[0].deliver(blob());
111
+ await settle(() => c.state().phase === 'thinking');
112
+ c.stop();
113
+ release();
114
+ await settle(() => c.state().lines.length >= 2);
115
+ await new Promise((r) => setTimeout(r, 30));
116
+ expect(speak).not.toHaveBeenCalled();
117
+ expect(c.state().lines.at(-1)?.text).toBe('reply 1');
118
+ expect(c.state().phase).toBe('listening');
119
+ await c.end();
120
+ });
121
+ });
122
+
123
+ describe('a typed turn with a duplex mic', () => {
124
+ it('does not stop the listening', async () => {
125
+ const { c, heard } = rig();
126
+ c.start();
127
+ await settle(() => heard.length >= 1);
128
+ await c.sendText('hello');
129
+ expect(heard[0].signal.aborted).toBe(false);
130
+ await c.end();
131
+ });
132
+ });