@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
@@ -0,0 +1,87 @@
1
+ // @vitest-environment node
2
+ import { describe, expect, it, vi } from 'vitest';
3
+ import { ConverseClientError, createMeetingController, type MeetingApi, type MeetingIO } from '../corpus/converse';
4
+
5
+ const blob = () => new Blob([new Uint8Array([1])], { type: 'audio/mp4' });
6
+ const settle = async (check: () => boolean) => { for (let i = 0; i < 300 && !check(); i += 1) await new Promise((r) => setTimeout(r, 5)); };
7
+ const relayTurn = (n: number) => ({ turn: n, turn_id: `r${n}`, at: 't', who: 'relay' as const, transcript: '', reply_text: 'relay says hi', audio_url: `/a/${n}`, audio_reason: null, for_relay: false });
8
+
9
+ function rig(duplex: boolean, turn?: MeetingApi<Blob>['turn']) {
10
+ let queued: any[] = [];
11
+ const client: MeetingApi<Blob> = {
12
+ turn: turn ?? vi.fn(async () => ({ conversation_id: 'c1', turn_id: 't', turn: 1, transcript: 'said', reply_text: 'ok', audio_url: null, audio_reason: 'x' })),
13
+ end: vi.fn() as never,
14
+ thread: vi.fn(async (_id: string, after: number) => ({ conversation_id: 'c1', status: 'open' as const, updated_at: 't', turns: queued.filter((t) => t.turn > after) })),
15
+ };
16
+ const listens: Array<{ signal: AbortSignal; hooks?: { onSpeechStart?: () => void }; resolve: (v: any) => void }> = [];
17
+ const events: string[] = [];
18
+ const io: MeetingIO<Blob> = {
19
+ duplex,
20
+ listen: vi.fn((signal: AbortSignal, _c: unknown, hooks?: { onSpeechStart?: () => void }) => new Promise((resolve) => {
21
+ listens.push({ signal, hooks, resolve });
22
+ // like the phone: aborting with 'finish' while he was speaking hands back what he said; a plain abort throws it away
23
+ signal.addEventListener('abort', () => resolve(signal.reason === 'finish' && hooks && (hooks as any).__spoke ? { audio: blob() } : { audio: null, cancelled: true }));
24
+ })),
25
+ speak: vi.fn(async () => { events.push('speak'); }),
26
+ };
27
+ const ctl = createMeetingController({ client, io, config: { relayPollMs: 20, resendMs: 20 } });
28
+ return { ctl, client, io, listens, events, push: (...t: any[]) => { queued = [...queued, ...t]; } };
29
+ }
30
+
31
+ describe('an incoming relay reply never throws away what he is saying', () => {
32
+ it('a phone that cannot record and play at once finishes his utterance (sends it) instead of discarding it', async () => {
33
+ const r = rig(false);
34
+ r.ctl.start();
35
+ await settle(() => r.listens.length >= 1);
36
+ (r.listens[0].hooks as any).__spoke = true; // he is mid-sentence
37
+ await r.ctl.sendText('hello'); // establishes the conversation and starts polling
38
+ await settle(() => r.listens.length >= 2);
39
+ (r.listens[r.listens.length - 1].hooks as any).__spoke = true;
40
+ const before = r.listens.length;
41
+ r.push(relayTurn(5));
42
+ await settle(() => r.listens[before - 1].signal.aborted);
43
+ expect(r.listens[before - 1].signal.aborted).toBe(true);
44
+ expect(r.listens[before - 1].signal.reason).toBe('finish');
45
+ await r.ctl.end();
46
+ });
47
+
48
+ it('with an open mic the relay is held back while he is speaking, then read', async () => {
49
+ const r = rig(true);
50
+ r.ctl.start();
51
+ await settle(() => r.listens.length >= 1);
52
+ await r.ctl.sendText('hello'); // opens the conversation; its reply has no audio
53
+ r.listens[0].hooks?.onSpeechStart?.(); // he starts a long message
54
+ r.push(relayTurn(5));
55
+ await settle(() => r.ctl.getState().lines.some((l) => l.role === 'relay'));
56
+ await new Promise((res) => setTimeout(res, 100));
57
+ expect(r.io.speak).not.toHaveBeenCalled();
58
+ expect(r.listens[0].signal.aborted).toBe(false); // his recording is untouched
59
+ r.listens[0].resolve({ audio: blob() }); // he finishes: sent
60
+ await settle(() => (r.client.turn as any).mock.calls.length >= 2);
61
+ expect((r.client.turn as any).mock.calls.length).toBe(2);
62
+ await settle(() => (r.io.speak as any).mock.calls.length >= 1);
63
+ expect(r.io.speak).toHaveBeenCalledTimes(1);
64
+ await r.ctl.end();
65
+ });
66
+ });
67
+
68
+ describe('a turn that fails to send keeps his audio and is retried', () => {
69
+ it('the same recording is sent again until it goes through', async () => {
70
+ let calls = 0;
71
+ const turn = vi.fn(async (input: any) => {
72
+ calls += 1;
73
+ if (calls < 3) throw new ConverseClientError('network down', 0, 'network');
74
+ return { conversation_id: 'c1', turn_id: 't', turn: 1, transcript: 'said', reply_text: 'ok', audio_url: null, audio_reason: 'x', _in: input };
75
+ });
76
+ const r = rig(true, turn as never);
77
+ r.ctl.start();
78
+ await settle(() => r.listens.length >= 1);
79
+ const audio = blob();
80
+ r.listens[0].resolve({ audio });
81
+ await settle(() => calls >= 3 && r.ctl.state().lines.length >= 2, );
82
+ expect(calls).toBe(3);
83
+ expect(turn.mock.calls[2][0].audio).toBe(audio);
84
+ expect(r.ctl.state().lines[0].text).toBe('said');
85
+ await r.ctl.end();
86
+ });
87
+ });
@@ -17,7 +17,7 @@ function run(levels: Array<[level: number, ms: number]>, config = cfg) {
17
17
  describe('resolveMeetingConfig', () => {
18
18
  it('defaults, partial overrides, and ignores nonsense', () => {
19
19
  const d = resolveMeetingConfig();
20
- expect(d).toMatchObject({ silenceMs: 1200, minUtteranceMs: 400, maxUtteranceMs: 60000, interruptOnSpeech: false });
20
+ expect(d).toMatchObject({ silenceMs: 1200, minUtteranceMs: 400, maxUtteranceMs: 60000, interruptOnSpeech: true });
21
21
  expect(resolveMeetingConfig({ silenceMs: 800, interruptOnSpeech: true })).toMatchObject({ silenceMs: 800, interruptOnSpeech: true, minUtteranceMs: 400 });
22
22
  expect(resolveMeetingConfig({ silenceMs: -5, speechLevel: Number.NaN }).silenceMs).toBe(1200);
23
23
  });
@@ -1,7 +1,7 @@
1
1
  // @vitest-environment jsdom
2
2
  /**
3
- * The ONE converse screen (Talk and Ask are one thread): a readable thread, a text input with a small mic
4
- * toggle and Send beside it, a small Done. No mode toggle, no start circle, nothing laid over the thread.
3
+ * The ONE Talk screen (Roci, one thread): a big status word, a thread in time order, a type box and ONE mic that is
4
+ * the hands-free mode (Talk / Mute / Interrupt), one settings menu. No Voice/Text pills, no Done button, no subtitle.
5
5
  */
6
6
  import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react';
7
7
  import * as React from 'react';
@@ -48,48 +48,63 @@ function setup(over: Opts = {}) {
48
48
  const mic = () => screen.getByTestId('converse-mic');
49
49
  const type = (text: string) => {
50
50
  fireEvent.change(screen.getByLabelText('Type a message'), { target: { value: text } });
51
- fireEvent.click(screen.getByRole('button', { name: 'Send' }));
51
+ fireEvent.submit(screen.getByLabelText('Type a message').closest('form') as HTMLFormElement); // Enter sends: there is no Send button
52
52
  };
53
53
 
54
- describe('the one converse screen', () => {
55
- it('an empty thread offers a few things to say, and tapping one fills the input; Done is a real button', () => {
56
- setup();
57
- const hint = screen.getByTestId('converse-suggestions');
58
- fireEvent.click(within(hint).getByRole('button', { name: 'What is due today?' }));
59
- expect((screen.getByLabelText('Type a message') as HTMLInputElement).value).toBe('What is due today?');
60
- expect(screen.getByRole('button', { name: 'Done' }).className).toContain('border');
54
+ describe('the one Talk screen', () => {
55
+ it('has NO status banner or word; one mic labelled Talk whose colour is the state; no pills, no Done, no Drive, no subtitle, no wake-word claim', () => {
56
+ const { view } = setup();
57
+ expect(screen.queryByTestId('converse-status')).toBeNull();
58
+ expect(screen.queryByText(/^(READY|LISTENING|THINKING|SPEAKING)$/)).toBeNull();
59
+ expect(mic().textContent).toBe('Talk');
60
+ expect(mic().getAttribute('data-tone')).toBe('idle');
61
+ expect(screen.queryByTestId('converse-mode')).toBeNull();
62
+ expect(screen.queryByRole('button', { name: 'Done' })).toBeNull();
63
+ expect(screen.queryByText(/drive/i)).toBeNull();
64
+ expect(screen.queryByText(/talk it through/i)).toBeNull();
65
+ expect(screen.queryByText(/listening for/i)).toBeNull();
66
+ expect(screen.queryByText(/wake/i)).toBeNull();
67
+ expect(view.container.querySelectorAll('[data-testid="converse-mic"]')).toHaveLength(1);
61
68
  });
62
69
 
63
- it('has an input, a small mic and Send, and no Talk/Ask toggle and no start button', () => {
70
+ it('the assistant is Roci: the input says so, and the thread has no tabs or start button', () => {
64
71
  setup();
65
- expect(screen.getByLabelText('Type a message')).toBeTruthy();
66
- expect(mic().getAttribute('aria-pressed')).toBe('false');
67
- expect(screen.queryByRole('tablist')).toBeNull();
72
+ expect((screen.getByLabelText('Type a message') as HTMLInputElement).placeholder).toBe('Ask Roci anything…');
68
73
  expect(screen.queryAllByRole('tab')).toHaveLength(0);
69
74
  expect(screen.queryByTestId('converse-start')).toBeNull();
70
- expect(screen.queryByText(/start talking/i)).toBeNull();
71
75
  });
72
76
 
73
- it('nothing is laid over the thread: no fixed or absolute element, thread is not covered', () => {
74
- const { view } = setup();
75
- const all = Array.from(view.container.querySelectorAll<HTMLElement>('*'));
76
- const positioned = all.filter((el) => /(^|\s)(fixed|absolute|sticky)(\s|$)/.test(el.className?.toString() ?? '') || /fixed|absolute/.test(el.style.position));
77
- expect(positioned).toEqual([]);
78
- const thread = screen.getByTestId('converse-thread');
79
- expect(thread.getAttribute('aria-label')).toBe('Conversation');
80
- expect(thread.parentElement?.contains(mic())).toBe(true);
77
+ it('empty-thread suggestions send straight away', async () => {
78
+ const { client } = setup();
79
+ fireEvent.click(within(screen.getByTestId('converse-suggestions')).getByRole('button', { name: 'Read my brief' }));
80
+ await waitFor(() => expect(client.turn).toHaveBeenCalledTimes(1));
81
+ expect((client.turn as any).mock.calls[0][0].text).toBe('Read my brief');
82
+ });
83
+
84
+ it('typed "Rossi" reaches the model as Roci', async () => {
85
+ const { client } = setup();
86
+ type('Rossi, what is due today?');
87
+ await waitFor(() => expect(client.turn).toHaveBeenCalled());
88
+ expect((client.turn as any).mock.calls[0][0].text).toBe('Roci, what is due today?');
89
+ });
90
+
91
+ it("Roci's words render as structured Markdown, not a wall of asterisks", async () => {
92
+ setup({ turn: vi.fn(async () => turnResult(1, { reply_text: '## Two things\n- **Call** the landlord\n- Send the deck' })) as never });
93
+ type('plate');
94
+ await waitFor(() => expect(screen.getByText('Two things')).toBeTruthy());
95
+ expect(screen.getAllByRole('listitem').some((li) => li.querySelector('strong, b') || li.textContent === 'Send the deck')).toBe(true);
96
+ expect(screen.queryByText(/\*\*/)).toBeNull();
81
97
  });
82
98
 
83
99
  it('the mic toggles mic on and off, shows the state, and tapping it off sends what was said as the user line', async () => {
84
100
  const { client, io, listen } = setup();
85
101
  fireEvent.click(mic());
86
- await waitFor(() => expect(mic().getAttribute('aria-pressed')).toBe('true'));
102
+ await waitFor(() => expect(mic().textContent).toBe('Mute'));
87
103
  expect(io.open).toHaveBeenCalledTimes(1);
88
104
  await waitFor(() => expect(listen).toHaveBeenCalled());
89
- expect(screen.getByTestId('converse-status').textContent).toMatch(/listening/i);
105
+ expect(mic().getAttribute('data-tone')).toBe('listening');
90
106
  fireEvent.click(mic());
91
107
  await waitFor(() => expect(client.turn).toHaveBeenCalledTimes(1));
92
- expect(mic().getAttribute('aria-pressed')).toBe('false');
93
108
  expect((client.turn as any).mock.calls[0][0].audio).toBeInstanceOf(Blob);
94
109
  await waitFor(() => expect(screen.getByText('said 1')).toBeTruthy());
95
110
  expect(screen.getByText('reply 1')).toBeTruthy();
@@ -154,33 +169,32 @@ describe('the one converse screen', () => {
154
169
  expect(chips.map((c) => c.textContent)).toEqual(['todo: Call the landlord', 'note: Monday plan']);
155
170
  });
156
171
 
157
- it('each assistant line has its own replay control that plays that line\'s audio', async () => {
172
+ it('replay lives in the settings menu: it plays the last reply again; user lines have no player', async () => {
158
173
  const { speak } = setup();
159
174
  type('one');
160
175
  await waitFor(() => expect(screen.getByText('reply 1')).toBeTruthy());
161
176
  type('two');
162
177
  await waitFor(() => expect(screen.getByText('reply 2')).toBeTruthy());
163
- const buttons = screen.getAllByRole('button', { name: 'Play this reply' });
164
- expect(buttons).toHaveLength(2);
178
+ expect(screen.queryByRole('button', { name: 'Play this reply' })).toBeNull();
165
179
  speak.mockClear();
166
- fireEvent.click(buttons[0]);
180
+ fireEvent.click(screen.getByTestId('converse-settings'));
181
+ fireEvent.click(screen.getByRole('menuitem', { name: 'Replay last reply' }));
167
182
  await waitFor(() => expect(speak).toHaveBeenCalledTimes(1));
168
- expect((speak.mock.calls[0] as any)[0].audioUrl).toBe('/corpus/converse/conversation-1/turn/1/audio');
169
- // user lines have none
170
- expect(within(screen.getByText('said 1').closest('li') as HTMLElement).queryByRole('button', { name: 'Play this reply' })).toBeNull();
183
+ expect((speak.mock.calls[0] as any)[0].audioUrl).toBe('/corpus/converse/conversation-1/turn/2/audio');
171
184
  });
172
185
 
173
186
  it('a reply with no sound says so and why', async () => {
174
187
  setup({ turn: vi.fn(async () => turnResult(1, { audio_url: null, audio_reason: 'speech is not configured' })) as never });
175
188
  type('hi');
176
- await waitFor(() => expect(screen.getByTestId('converse-status').textContent).toMatch(/no spoken reply.*speech is not configured/i));
189
+ await waitFor(() => expect(screen.getByTestId('converse-no-audio').textContent).toMatch(/no spoken reply.*speech is not configured/i));
177
190
  });
178
191
 
179
- it('Done saves the conversation and the next message starts fresh; the thread stays', async () => {
192
+ it('Save this conversation (settings menu) saves it and the next message starts fresh; the thread stays', async () => {
180
193
  const { client } = setup();
181
194
  type('hi');
182
195
  await waitFor(() => expect(screen.getByText('reply 1')).toBeTruthy());
183
- fireEvent.click(screen.getByRole('button', { name: 'Done' }));
196
+ fireEvent.click(screen.getByTestId('converse-settings'));
197
+ fireEvent.click(screen.getByRole('menuitem', { name: 'Save this conversation' }));
184
198
  await waitFor(() => expect(client.end).toHaveBeenCalledWith('conversation-1'));
185
199
  await waitFor(() => expect(screen.getByTestId('converse-saved').textContent).toMatch(/Saved 1 turn/));
186
200
  expect(screen.getByText('reply 1')).toBeTruthy();
@@ -199,13 +213,14 @@ describe('the one converse screen', () => {
199
213
  await waitFor(() => expect(screen.getByText('Ship it')).toBeTruthy());
200
214
  const li = screen.getByText('Ship it').closest('li') as HTMLElement;
201
215
  expect(li.getAttribute('data-from')).toBe('relay');
202
- expect(li.textContent).toMatch(/^Relay:/);
216
+ expect(li.textContent).toMatch(/Relay.*Ship it/);
203
217
  });
204
218
 
205
219
  it('speech speed defaults to 1.25x, is remembered, and applies to the open conversation', async () => {
206
220
  const store = new Map<string, string>();
207
221
  vi.stubGlobal('localStorage', { getItem: (k: string) => store.get(k) ?? null, setItem: (k: string, v: string) => { store.set(k, v); } });
208
222
  const { io } = setup();
223
+ fireEvent.click(screen.getByTestId('converse-settings'));
209
224
  const sel = screen.getByTestId('converse-speed') as HTMLSelectElement;
210
225
  expect(sel.value).toBe('1.25');
211
226
  fireEvent.click(mic());
@@ -215,4 +230,100 @@ describe('the one converse screen', () => {
215
230
  expect(store.get('tandem.converse.speed')).toBe('2');
216
231
  vi.unstubAllGlobals();
217
232
  });
233
+
234
+ describe('the one mic: Talk, Mute, Interrupt', () => {
235
+ const holdSpeak = (speak: ReturnType<typeof vi.fn>) => speak.mockImplementation((_t: unknown, signal: AbortSignal) => new Promise<void>((resolve) => { signal.addEventListener('abort', () => resolve()); }));
236
+
237
+ it('while Roci speaks the SAME mic says Interrupt, is blue (speaking), cuts the reply off and goes back to READY', async () => {
238
+ const { speak } = setup();
239
+ holdSpeak(speak);
240
+ type('hello');
241
+ await waitFor(() => expect(mic().textContent).toBe('Interrupt'));
242
+ expect(mic().getAttribute('data-tone')).toBe('speaking');
243
+ expect(screen.queryByTestId('converse-stop')).toBeNull();
244
+ fireEvent.click(mic());
245
+ await waitFor(() => expect(mic().textContent).toBe('Talk'));
246
+ expect(screen.getByText('reply 1')).toBeTruthy();
247
+ });
248
+
249
+ it('while the reply is being thought about the mic is amber and says Interrupt', async () => {
250
+ let release: (v: ReturnType<typeof turnResult>) => void = () => undefined;
251
+ setup({ turn: vi.fn(() => new Promise((r) => { release = r as never; })) as never });
252
+ type('hello');
253
+ await waitFor(() => expect(mic().getAttribute('data-tone')).toBe('thinking'));
254
+ expect(mic().textContent).toBe('Interrupt');
255
+ release(turnResult(1));
256
+ await waitFor(() => expect(mic().textContent).toBe('Talk'));
257
+ });
258
+ });
259
+
260
+ describe('needs-you cards live in the thread', () => {
261
+ const pending = [{ id: 'd1', title: 'Which build first?', status: 'pending' as const, created_at: '2026-11-20T10:42:00Z' }];
262
+ const record = (over: object = {}) => ({ id: 'd1', title: 'Which build first?', status: 'pending' as const, created_at: '2026-11-20T10:42:00Z', questions: [{ n: 1, text: 'iOS or web first?', options: ['iOS 0.9.2', 'Web staging'] }], answers: [], ...over });
263
+ const notifyFor = (rows = pending, rec: object = record()) => ({
264
+ pending: vi.fn(async () => rows), decision: vi.fn(async () => rec),
265
+ answer: vi.fn(async (_id: string, a: Array<{ n: number; answer: string }>) => record({ status: 'answered', answers: a.map((x) => ({ ...x, answered_at: 't' })) })),
266
+ settings: vi.fn(async () => ({ push: true, devices: 0 })), setPush: vi.fn(),
267
+ });
268
+ const withNotify = (notify: ReturnType<typeof notifyFor>) => {
269
+ const client = { turn: vi.fn(), end: vi.fn(), audioUrl: vi.fn(), thread: vi.fn() } as unknown as ConverseClient;
270
+ return render(<ConversePage client={client} notify={notify as never} />);
271
+ };
272
+
273
+ it('a real pending decision is a question card with who asked and one primary action', async () => {
274
+ withNotify(notifyFor());
275
+ const card = await screen.findByTestId('thread-card');
276
+ expect(card.getAttribute('data-card-type')).toBe('question');
277
+ expect(within(card).getByText('QUESTION')).toBeTruthy();
278
+ expect(within(card).getByText(/from Tandem/)).toBeTruthy();
279
+ expect(within(card).getByText('Which build first?')).toBeTruthy();
280
+ expect(within(card).getByRole('button', { name: 'iOS 0.9.2' })).toBeTruthy();
281
+ expect(within(card).getByRole('button', { name: 'Web staging' })).toBeTruthy();
282
+ expect(card.closest('[data-testid="converse-thread"]')).toBeTruthy();
283
+ });
284
+
285
+ it('tapping an option answers it inline and the card resolves in place', async () => {
286
+ const notify = notifyFor();
287
+ withNotify(notify);
288
+ fireEvent.click(await screen.findByRole('button', { name: 'Web staging' }));
289
+ await waitFor(() => expect(screen.getByTestId('card-resolved').textContent).toBe('Answered: Web staging'));
290
+ expect(notify.answer).toHaveBeenCalledWith('d1', [{ n: 1, answer: 'Web staging' }]);
291
+ expect(screen.queryByRole('button', { name: 'iOS 0.9.2' })).toBeNull();
292
+ expect(screen.getAllByTestId('thread-card')).toHaveLength(1);
293
+ });
294
+
295
+ it('a question with no options takes a typed reply', async () => {
296
+ const notify = notifyFor(pending, record({ questions: [{ n: 1, text: 'What should we call it?' }] }));
297
+ withNotify(notify);
298
+ fireEvent.change(await screen.findByLabelText('Reply to Which build first?'), { target: { value: 'Tandem Go' } });
299
+ fireEvent.click(within(screen.getByTestId('thread-card')).getByRole('button', { name: 'Send' }));
300
+ await waitFor(() => expect(notify.answer).toHaveBeenCalledWith('d1', [{ n: 1, answer: 'Tandem Go' }]));
301
+ });
302
+
303
+ it('a failed answer says so on the card and keeps it open', async () => {
304
+ const notify = notifyFor();
305
+ notify.answer.mockRejectedValueOnce(new Error('Could not send.'));
306
+ withNotify(notify);
307
+ fireEvent.click(await screen.findByRole('button', { name: 'iOS 0.9.2' }));
308
+ await waitFor(() => expect(screen.getByRole('alert').textContent).toBe('Could not send.'));
309
+ expect(screen.queryByTestId('card-resolved')).toBeNull();
310
+ });
311
+
312
+ it('nothing pending means no cards and no placeholder', async () => {
313
+ const notify = notifyFor([]);
314
+ withNotify(notify);
315
+ await waitFor(() => expect(notify.pending).toHaveBeenCalled());
316
+ expect(screen.queryByTestId('thread-card')).toBeNull();
317
+ expect(screen.queryByText(/nothing is waiting/i)).toBeNull();
318
+ });
319
+
320
+ it('a host-supplied brief card reads aloud through the same thread; sample cards are labelled TEST SAMPLE', async () => {
321
+ const client = { turn: vi.fn(async () => turnResult(1)), end: vi.fn(), audioUrl: vi.fn(async (p: string) => p), thread: vi.fn(async () => ({ conversation_id: 'c', status: 'open', updated_at: 't', turns: [] })) } as unknown as ConverseClient;
322
+ render(<ConversePage client={client} createIO={() => ({ open: vi.fn(), unlockPlayback: vi.fn(), close: vi.fn(), setSpeed: vi.fn(), listen: vi.fn(), speak: vi.fn(async () => undefined) }) as never}
323
+ cards={[{ id: 'brief:1', type: 'brief', from: 'Roci', at: '2026-11-20T07:00:00Z', title: 'Morning brief', body: '- **Calendar** — 3 events', actions: [{ id: 'read', label: 'Read it aloud', primary: true }], sample: true }]} />);
324
+ expect(screen.getByTestId('card-sample').textContent).toBe('TEST SAMPLE');
325
+ fireEvent.click(screen.getByRole('button', { name: 'Read it aloud' }));
326
+ await waitFor(() => expect((client.turn as any).mock.calls[0][0].text).toBe('Read my brief'));
327
+ });
328
+ });
218
329
  });
@@ -0,0 +1,22 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { ASSISTANT_NAME, normalizeAssistantName } from '../corpus/converse/roci';
3
+
4
+ describe('normalizeAssistantName: the assistant is Roci; there is no wake word', () => {
5
+ it('is named Roci', () => { expect(ASSISTANT_NAME).toBe('Roci'); });
6
+ it('turns the whole word Rossi into Roci, in any case', () => {
7
+ expect(normalizeAssistantName('Rossi, what is due today?')).toBe('Roci, what is due today?');
8
+ expect(normalizeAssistantName('hey rossi read my brief')).toBe('hey Roci read my brief');
9
+ expect(normalizeAssistantName('ROSSI what is on my plate')).toBe('Roci what is on my plate');
10
+ });
11
+ it('leaves Rocky, Roxy, Rosie (real names and words) and words that merely contain Rossi alone', () => {
12
+ const same = ['Rocky, read my brief', 'book the Rocky Mountain trip', 'Roxy called', 'ask Rosie', 'Rossiter and the Rossini deal'];
13
+ for (const t of same) expect(normalizeAssistantName(t)).toBe(t);
14
+ });
15
+ it('leaves Roci and empty text alone', () => {
16
+ expect(normalizeAssistantName('Roci is here')).toBe('Roci is here');
17
+ expect(normalizeAssistantName('')).toBe('');
18
+ });
19
+ it('uses the configured assistant name', () => {
20
+ expect(normalizeAssistantName('Rossi, hi', 'Ava')).toBe('Ava, hi');
21
+ });
22
+ });
@@ -16,4 +16,14 @@ describe('what the voice says: dates, ticket ids and markup are said the way a p
16
16
  it('leaves a plain sentence alone (null = nothing to change)', () => {
17
17
  expect(toSpoken('Yesterday you added 12 new to-dos.', TODAY)).toBeNull();
18
18
  });
19
+ it('drops leading filler on the voice only', () => {
20
+ expect(toSpoken('Yes, the to-do Order the bench is due Friday.', TODAY)).toBe('Order the bench is due Friday.');
21
+ expect(toSpoken('Sure, it is done.', TODAY)).toBe('It is done.');
22
+ expect(toSpoken('Okay. Moved it to Friday.', TODAY)).toBe('Moved it to Friday.');
23
+ expect(toSpoken('Yes you have three items.', TODAY)).toBe('You have three items.');
24
+ });
25
+ it('does not strip a word that is part of the sentence', () => {
26
+ expect(toSpoken('Yesterday you added 12 new to-dos.', TODAY)).toBeNull();
27
+ expect(toSpoken('Okayama trip is due 2026-11-20.', TODAY)).toBe('Okayama trip is due Friday.');
28
+ });
19
29
  });
@@ -1,6 +1,6 @@
1
1
  // @vitest-environment node
2
2
  import { describe, expect, it } from 'vitest';
3
- import { spokenSummary } from '../corpus/converse/spoken-summary';
3
+ import { spokenRest, spokenSummary, WANTS_THE_REST } from '../corpus/converse/spoken-summary';
4
4
 
5
5
  describe('what is said aloud for a long answer', () => {
6
6
  it('a short answer is said whole', () => {
@@ -10,21 +10,42 @@ describe('what is said aloud for a long answer', () => {
10
10
 
11
11
  it('a numbered list: the lead-in, three items, and N more', () => {
12
12
  const said = spokenSummary('This week, the following tasks are due: 1. Plan out the week ahead (due 2026-11-20). 2. Build lead QC on staging. 3. Launch lead for Crochet V2. 4. Order the bench. 5. Call the bank. 6. Pay the rent.');
13
- expect(said).toBe('This week, the following tasks are due. Plan out the week ahead (due 2026-11-20). Build lead QC on staging. Launch lead for Crochet V2. And 3 more.');
13
+ expect(said).toBe('This week, the following tasks are due. Plan out the week ahead (due 2026-11-20). Build lead QC on staging. Launch lead for Crochet V2. And 3 more. Want the rest?');
14
14
  });
15
15
 
16
16
  it('a long run-on list is cut at a comma and points to the screen', () => {
17
17
  const long = 'Today, you have tasks that include checking the debug AI backend and UI updates, completing two sessions of 15 minutes on the debug UI, completing two sessions of 15 minutes on the marketing agent UI, running a quick check of the V2 marketing agent deployed app, reviewing and providing feedback on the animated video builder, creating two videos for top articles and one video for landing pages';
18
18
  const said = spokenSummary(long)!;
19
- expect(said.split(/\s+/).length).toBeLessThan(50);
20
- expect(said).toMatch(/The rest is on your screen\.$/);
19
+ expect(said.split(/\s+/).length).toBeLessThan(35);
20
+ expect(said).toMatch(/Want the rest\?$/);
21
21
  expect(said.startsWith('Today, you have tasks that include')).toBe(true);
22
22
  });
23
23
 
24
24
  it('long prose is cut at a sentence', () => {
25
25
  const prose = `${'The relay shipped the combined roll and verified production across every service. '.repeat(5)}`;
26
26
  const said = spokenSummary(prose)!;
27
- expect(said).toMatch(/The rest is on your screen\.$/);
28
- expect(said.split(/\s+/).length).toBeLessThanOrEqual(60);
27
+ expect(said).toMatch(/Want the rest\?$/);
28
+ expect(said.split(/\s+/).length).toBeLessThanOrEqual(35);
29
+ });
30
+
31
+ it('spokenRest is what was not said: the other list items, the other sentences', () => {
32
+ const list = 'This week: 1. Plan. 2. Build. 3. Launch. 4. Order the bench. 5. Call the bank.';
33
+ expect(spokenRest(list)).toBe('Order the bench. Call the bank.');
34
+ const prose = 'The relay shipped the combined roll and verified production across every service. '.repeat(4).trim();
35
+ expect(spokenRest(prose)).toBe('The relay shipped the combined roll and verified production across every service. The relay shipped the combined roll and verified production across every service.');
36
+ expect(spokenRest('Two things are due today.')).toBeUndefined();
37
+ });
38
+
39
+ it('a long remainder is itself said short, so "yes" walks through the answer a piece at a time', () => {
40
+ let left: string | undefined = 'This is a sentence that carries a handful of words in it. '.repeat(12).trim();
41
+ let pieces = 0;
42
+ while (left && pieces < 20) { const next = spokenRest(left); pieces += 1; left = next; }
43
+ expect(pieces).toBeGreaterThan(2);
44
+ expect(left).toBeUndefined();
45
+ });
46
+
47
+ it('recognizes the yes that asks for the rest, and nothing else', () => {
48
+ for (const y of ['yes', 'Yeah, go on.', 'the rest', 'yes please', 'read the rest', 'continue']) expect(WANTS_THE_REST.test(y)).toBe(true);
49
+ for (const n of ['yes move the car service to friday', 'what is due tomorrow', 'no']) expect(WANTS_THE_REST.test(n)).toBe(false);
29
50
  });
30
51
  });
@@ -0,0 +1,27 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { structureReply } from '../corpus/converse/structure';
3
+
4
+ describe('structureReply: Roci never shows a wall of text', () => {
5
+ it('leaves text that is already Markdown alone', () => {
6
+ const md = '## Today\n- **Call** the landlord\n- Send the deck';
7
+ expect(structureReply(md)).toBe(md);
8
+ });
9
+ it('leaves a short single sentence alone', () => {
10
+ expect(structureReply('Nothing is due today.')).toBe('Nothing is due today.');
11
+ });
12
+ it('turns an inline numbered run into bullets, with the lead-in kept as its own line', () => {
13
+ const out = structureReply('Here is what to do. 1. Complete the open task "Check Sentry" (). 2. Work on "CI covers PRs" (). 3. Address "Missing recordings" (). There are 4 more tasks to consider');
14
+ expect(out).toBe('Here is what to do.\n\n- Complete the open task "Check Sentry"\n- Work on "CI covers PRs"\n- Address "Missing recordings"\n\nThere are 4 more tasks to consider');
15
+ });
16
+ it('fixes one line that starts with a bullet but holds a whole numbered run', () => {
17
+ expect(structureReply("- Complete the open task 'A' (PR 744). 2. Work on 'B'. 3. Investigate 'C'. There are 4 more tasks to address today"))
18
+ .toBe("- Complete the open task 'A' (PR 744)\n- Work on 'B'\n- Investigate 'C'\n\nThere are 4 more tasks to address today");
19
+ });
20
+ it('drops empty parentheses left by stripped ticket codes', () => {
21
+ expect(structureReply('Work on the deck ().')).toBe('Work on the deck.');
22
+ });
23
+ it('breaks a long paragraph into a lead sentence and short bullets', () => {
24
+ const out = structureReply('You have three things after lunch. The vendor call is at 2. The deck is due at 4. Rent is overdue.');
25
+ expect(out).toBe('You have three things after lunch.\n\n- The vendor call is at 2.\n- The deck is due at 4.\n- Rent is overdue.');
26
+ });
27
+ });
@@ -0,0 +1,46 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { MIC_COLORS, converseView } from '../corpus/converse/view';
3
+
4
+ describe('converseView', () => {
5
+ it('Stop is offered only while thinking or speaking', () => {
6
+ for (const phase of ['thinking', 'speaking'] as const) expect(converseView({ phase, micOn: true }).canStop).toBe(true);
7
+ for (const phase of ['idle', 'listening', 'ending', 'ended', 'stopped'] as const) expect(converseView({ phase, micOn: true }).canStop).toBe(false);
8
+ });
9
+ it('listening needs the mic on and a running conversation; the mic stays live while thinking and speaking', () => {
10
+ expect(converseView({ phase: 'idle', micOn: true }).listening).toBe(false);
11
+ expect(converseView({ phase: 'listening', micOn: false }).listening).toBe(false);
12
+ for (const phase of ['listening', 'thinking', 'speaking'] as const) expect(converseView({ phase, micOn: true })).toMatchObject({ listening: true, mode: 'voice' });
13
+ expect(converseView({ phase: 'speaking', micOn: false }).mode).toBe('text');
14
+ });
15
+ it('busy while saving', () => { expect(converseView({ phase: 'ending', micOn: false }).busy).toBe(true); });
16
+ });
17
+
18
+ describe('converseView: the one mic and the big status word', () => {
19
+ it('READY with the mic offering Talk when nothing is running', () => {
20
+ expect(converseView({ phase: 'idle', micOn: false })).toMatchObject({ status: 'READY', micAction: 'talk' });
21
+ expect(converseView({ phase: 'ended', micOn: false })).toMatchObject({ status: 'READY', micAction: 'talk' });
22
+ });
23
+ it('LISTENING offers Mute', () => {
24
+ expect(converseView({ phase: 'listening', micOn: true })).toMatchObject({ status: 'LISTENING', micAction: 'mute' });
25
+ });
26
+ it('THINKING and SPEAKING both offer Interrupt', () => {
27
+ expect(converseView({ phase: 'thinking', micOn: false })).toMatchObject({ status: 'THINKING', micAction: 'interrupt' });
28
+ expect(converseView({ phase: 'speaking', micOn: true })).toMatchObject({ status: 'SPEAKING', micAction: 'interrupt' });
29
+ });
30
+ it('saving reads as THINKING and cannot be interrupted', () => {
31
+ expect(converseView({ phase: 'ending', micOn: false })).toMatchObject({ status: 'THINKING', micAction: 'talk', busy: true });
32
+ });
33
+ });
34
+
35
+ describe('converseView: the mic itself carries the state (same colours as the phone)', () => {
36
+ it('idle is blue, listening green, thinking amber, speaking blue, muted grey', () => {
37
+ expect(converseView({ phase: 'idle', micOn: false }).micTone).toBe('idle');
38
+ expect(converseView({ phase: 'listening', micOn: true }).micTone).toBe('listening');
39
+ expect(converseView({ phase: 'thinking', micOn: true }).micTone).toBe('thinking');
40
+ expect(converseView({ phase: 'speaking', micOn: true }).micTone).toBe('speaking');
41
+ expect(converseView({ phase: 'listening', micOn: false }).micTone).toBe('muted');
42
+ });
43
+ it('lifts the phone\'s colours', () => {
44
+ expect(MIC_COLORS).toMatchObject({ listening: '#0B6E3A', thinking: '#9A4A06', speaking: '#1D4ED8' });
45
+ });
46
+ });
@@ -164,10 +164,10 @@ describe('what is said after wrapping up', () => {
164
164
  const { deps, t } = setup();
165
165
  const asks = ['Call the bank', 'Review the checkout copy', 'Order the bench', 'Pay rent', 'Check the greenhouse'];
166
166
  const brains = [{ text: 'Got it.', intent: 'note' as const }, { text: 'Filing it now.', intent: 'note' as const, finish: true }];
167
- const withBrain = { ...deps, brain: async () => brains.shift()!, extract: async () => ({ asks, decisions: [] }), handoff: async () => undefined };
167
+ const withBrain = { ...deps, brain: async () => brains.shift()!, extract: async () => ({ asks, decisions: [] }), handoff: async () => ({ project: 'Hours' }) };
168
168
  const first = await handleConverseTurn(withBrain as never, { text: 'a long note about my day' });
169
169
  const last = await handleConverseTurn(withBrain as never, { text: 'parse that note', conversationId: first.conversation_id });
170
- expect(last.reply_text).toBe('Filed the note and 5 to-dos: Call the bank, Review the checkout copy, Order the bench, and 2 more.');
170
+ expect(last.reply_text).toBe('Filed the note under Hours and 5 to-dos: Call the bank, Review the checkout copy, Order the bench, and 2 more.');
171
171
  const row = [...t.rows.values()].find((r) => r.data.source === 'conversation')!;
172
172
  expect(row.data.status).toBe('ended');
173
173
  expect(row.data.turns).toHaveLength(2);
@@ -181,6 +181,15 @@ describe('what is said after wrapping up', () => {
181
181
  const last = await handleConverseTurn(withBrain as never, { text: "that's it", conversationId: first.conversation_id });
182
182
  expect(last.reply_text).toBe('Filed the note.');
183
183
  });
184
+ it('says when no project fit, and counts only what was really filed (not an ask already added during the talk)', async () => {
185
+ const { deps } = setup();
186
+ const brains = [{ text: 'Added Call the bank.', intent: 'command' as const, did: ['Added Call the bank.'] }, { text: 'Filing it now.', intent: 'note' as const, finish: true }];
187
+ const withBrain = { ...deps, brain: async () => brains.shift()!, extract: async () => ({ asks: ['Call the bank', 'Pay rent'], decisions: [] }), handoff: async () => ({ project: null }) };
188
+ const first = await handleConverseTurn(withBrain as never, { text: 'call the bank' });
189
+ const last = await handleConverseTurn(withBrain as never, { text: 'parse that note', conversationId: first.conversation_id });
190
+ expect(last.reply_text).toBe('Filed the note with no project and 1 to-do: Pay rent.');
191
+ expect(last.filed).toEqual({ note: true, todos: 1 });
192
+ });
184
193
  });
185
194
 
186
195
  describe('the turn wraps the conversation up itself', () => {
@@ -232,6 +241,24 @@ describe('the items an answer listed are kept for follow-ups', () => {
232
241
  });
233
242
  });
234
243
 
244
+ describe('a which-one question is kept for the next turn (startsim-ym54h.31)', () => {
245
+ it('the next turn gets it, and it is gone after that turn and after End', async () => {
246
+ const { deps, t } = setup();
247
+ const seen: unknown[] = [];
248
+ const pending = { utterance: 'move the bench one', question: 'Which one: A or B?' };
249
+ const turns = [{ text: pending.question, pending }, { text: 'Moved.', pending: null }, { text: 'ok' }];
250
+ const withBrain = { ...deps, brain: async (input: any) => { seen.push(input.pending); return turns.shift()!; } };
251
+ const first = await handleConverseTurn(withBrain as never, { text: pending.utterance });
252
+ const row = () => [...t.rows.values()].find((r) => r.data.source === 'conversation');
253
+ expect(row().data.pending).toEqual(pending);
254
+ await handleConverseTurn(withBrain as never, { text: 'the A one', conversationId: first.conversation_id });
255
+ expect(seen[1]).toEqual(pending);
256
+ expect(row().data.pending).toBeNull();
257
+ await handleConverseTurn(withBrain as never, { text: 'thanks', conversationId: first.conversation_id });
258
+ expect(seen[2]).toBeNull();
259
+ });
260
+ });
261
+
235
262
  describe('the voice says dates and ids the way a person would, the screen keeps the text', () => {
236
263
  it('speaks "Friday" for an ISO date and drops the ticket id; stores the text as written', async () => {
237
264
  const { deps, t } = setup();
@@ -345,3 +345,25 @@ describe('generate mode', () => {
345
345
  expect(result.citations[0].document.source).toBe('dropbox');
346
346
  });
347
347
  });
348
+
349
+ describe('project names are read beside the item list, not before it (startsim-ym54h.23)', () => {
350
+ it('the commitments read starts while the project names are still loading, and the names still reach the item records', async () => {
351
+ const NOW = Date.parse('2026-11-16T17:00:00Z');
352
+ let release: (v: Record<string, string>) => void = () => undefined;
353
+ const names = new Promise<Record<string, string>>((resolve) => { release = resolve; });
354
+ let listed = false;
355
+ const commitments = {
356
+ listCommitments: async () => {
357
+ listed = true;
358
+ release({ f1: 'Website' });
359
+ return { count: 1, next: null, previous: null, results: [{ id: 'c1', externalId: 'c1', title: 'Fix header', status: 'open', dueAt: '2026-11-17', focusId: 'f1', firstSeenAt: '2026-11-15T16:00:00Z', lastSeenAt: '2026-11-15T16:00:00Z', source: 'voice', scope: { orgId: FIXTURE_ORG } }] };
360
+ },
361
+ } as never;
362
+ const calls: any[] = [];
363
+ const corpus = createFixtureCorpusApi({ scope: SCOPE });
364
+ await askCorpus(ask('what is due tomorrow'), { corpus, llm: scriptedLlm({ answer: 'ok', citations: [] }, calls), commitments }, { now: NOW, timeZone: 'America/Denver', focusNames: names });
365
+ expect(listed).toBe(true);
366
+ const item = calls[0].documents.find((d: any) => d.id === 'item:c1');
367
+ expect(item.text).toContain('Project: Website');
368
+ });
369
+ });