@startsimpli/integrations 0.2.201 → 0.2.203

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 (85) hide show
  1. package/package.json +6 -6
  2. package/src/__tests__/briefing-markdown.test.ts +64 -0
  3. package/src/__tests__/converse-cards.test.ts +53 -0
  4. package/src/__tests__/converse-page.test.tsx +148 -37
  5. package/src/__tests__/converse-roci.test.ts +22 -0
  6. package/src/__tests__/converse-structure.test.ts +27 -0
  7. package/src/__tests__/converse-view.test.ts +46 -0
  8. package/src/__tests__/corpus-tracker.test.tsx +32 -176
  9. package/src/__tests__/data-table-logic.test.ts +75 -0
  10. package/src/__tests__/data-table.test.tsx +133 -0
  11. package/src/__tests__/home-brief.test.tsx +25 -40
  12. package/src/__tests__/library-call-shape.test.tsx +164 -0
  13. package/src/__tests__/load-error.test.tsx +1 -1
  14. package/src/__tests__/mini-markdown.test.tsx +24 -0
  15. package/src/__tests__/overview-page.test.tsx +36 -6
  16. package/src/__tests__/plan-shell.test.tsx +6 -4
  17. package/src/__tests__/timeline-events.test.ts +65 -0
  18. package/src/__tests__/timeline-table.test.tsx +66 -0
  19. package/src/__tests__/todo-table-model.test.ts +75 -0
  20. package/src/__tests__/todo-table.test.tsx +202 -0
  21. package/src/__tests__/tracker-timeline-component.test.tsx +4 -4
  22. package/src/__tests__/tracker-timeline-reader.test.ts +1 -1
  23. package/src/comms/__tests__/app-sends-page.test.tsx +69 -0
  24. package/src/comms/api/comms.ts +23 -0
  25. package/src/comms/components/ResultsPanel.tsx +2 -2
  26. package/src/comms/components/SendLog.tsx +20 -8
  27. package/src/comms/components/index.ts +1 -0
  28. package/src/comms/components/pages/AppSendsPage.tsx +58 -0
  29. package/src/comms/hooks/index.ts +8 -3
  30. package/src/components/FolderTree.tsx +12 -3
  31. package/src/components/index.ts +2 -1
  32. package/src/components/pages/ConversePage.tsx +114 -105
  33. package/src/components/pages/LibraryPage.tsx +63 -24
  34. package/src/components/pages/TrackerPage.tsx +170 -474
  35. package/src/components/pages/converse/CardView.tsx +72 -0
  36. package/src/components/pages/converse/SettingsMenu.tsx +37 -0
  37. package/src/components/pages/converse/Thread.tsx +48 -33
  38. package/src/components/pages/converse/useNeedsYou.ts +60 -0
  39. package/src/components/pages/home/BriefCard.tsx +16 -7
  40. package/src/components/pages/home/HomeBriefPage.tsx +6 -91
  41. package/src/components/pages/home/MiniMarkdown.tsx +51 -0
  42. package/src/components/pages/home/{DueSoonLine.tsx → dueSoonText.ts} +2 -11
  43. package/src/components/pages/home/index.ts +1 -1
  44. package/src/components/pages/overview/OverviewPage.tsx +46 -83
  45. package/src/components/pages/plan/TalkPage.tsx +5 -14
  46. package/src/components/pages/plan/TimelinePage.tsx +4 -2
  47. package/src/components/pages/tracker/SweepPanel.tsx +108 -0
  48. package/src/components/pages/tracker/TimelineTable.tsx +70 -0
  49. package/src/components/pages/tracker/TrackerTimeline.tsx +32 -15
  50. package/src/components/table/DataTable.tsx +92 -0
  51. package/src/components/table/RowMenu.tsx +35 -0
  52. package/src/components/table/TablePagination.tsx +63 -0
  53. package/src/components/table/TableToolbar.tsx +56 -0
  54. package/src/components/table/TodoTable.tsx +142 -0
  55. package/src/components/table/index.ts +10 -0
  56. package/src/components/table/table-logic.ts +60 -0
  57. package/src/components/table/todo-model.ts +93 -0
  58. package/src/corpus/briefing/generate-weekly.ts +4 -0
  59. package/src/corpus/briefing/generate.ts +4 -0
  60. package/src/corpus/briefing/index.ts +1 -0
  61. package/src/corpus/briefing/markdown.ts +71 -0
  62. package/src/corpus/client.ts +38 -146
  63. package/src/corpus/converse/cards.ts +69 -0
  64. package/src/corpus/converse/index.ts +6 -0
  65. package/src/corpus/converse/roci.ts +13 -0
  66. package/src/corpus/converse/structure.ts +39 -0
  67. package/src/corpus/converse/view.ts +34 -0
  68. package/src/corpus/index.ts +2 -0
  69. package/src/corpus/participants.ts +220 -0
  70. package/src/corpus/timeline-events.ts +83 -0
  71. package/src/corpus/tracker-sort.ts +9 -3
  72. package/src/corpus/tracker-timeline-client.ts +2 -0
  73. package/src/corpus/tracker-timeline.ts +4 -0
  74. package/src/corpus/types.ts +32 -5
  75. package/src/native/app/__tests__/plan-talk-registry.test.tsx +2 -1
  76. package/src/native/converse/ConverseScreen.tsx +3 -5
  77. package/src/native/home/HomeScreen.tsx +1 -1
  78. package/src/native/home/tab.tsx +1 -2
  79. package/src/native/plan/PlanTab.tsx +1 -2
  80. package/src/native/plan/__tests__/plan-tab.test.tsx +5 -5
  81. package/src/native/talk/TalkTab.tsx +1 -1
  82. package/src/native/talk/__tests__/talk-tab.test.tsx +1 -1
  83. package/src/__tests__/home-needs-your-call.test.tsx +0 -65
  84. package/src/components/pages/tracker/TrackerBoard.tsx +0 -45
  85. 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.201",
3
+ "version": "0.2.203",
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/utils": "^0.4.21",
54
- "@startsimpli/ui": "^0.4.192",
55
- "@startsimpli/auth": "^0.4.54"
53
+ "@startsimpli/auth": "^0.4.56",
54
+ "@startsimpli/ui": "^0.4.194",
55
+ "@startsimpli/utils": "^0.4.21"
56
56
  },
57
57
  "peerDependenciesMeta": {
58
58
  "react": {
@@ -99,9 +99,9 @@
99
99
  "react-native": "0.85.3",
100
100
  "react-native-safe-area-context": "~5.7.0",
101
101
  "@startsimpli/llm": "0.4.31",
102
- "@startsimpli/ui": "0.4.192",
102
+ "@startsimpli/ui": "0.4.194",
103
103
  "@startsimpli/ui-native": "0.1.15",
104
- "@startsimpli/auth": "0.4.54",
104
+ "@startsimpli/auth": "0.4.56",
105
105
  "@startsimpli/utils": "0.4.21"
106
106
  },
107
107
  "scripts": {
@@ -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
+ });
@@ -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
+ });
@@ -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
+ });
@@ -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
+ });