@startsimpli/integrations 0.2.200 → 0.2.201

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 (70) hide show
  1. package/package.json +6 -6
  2. package/src/__tests__/briefing-actions.test.ts +11 -0
  3. package/src/__tests__/briefing-edits.test.ts +98 -0
  4. package/src/__tests__/converse-brain.test.ts +64 -1
  5. package/src/__tests__/converse-handoff.test.ts +8 -0
  6. package/src/__tests__/converse-meeting-brief.test.ts +72 -8
  7. package/src/__tests__/converse-meeting-duplex.test.ts +132 -0
  8. package/src/__tests__/converse-meeting-keep-speech.test.ts +87 -0
  9. package/src/__tests__/converse-meeting-vad.test.ts +1 -1
  10. package/src/__tests__/converse-spoken-form.test.ts +10 -0
  11. package/src/__tests__/converse-spoken-summary.test.ts +27 -6
  12. package/src/__tests__/converse.test.ts +29 -2
  13. package/src/__tests__/corpus-ask.test.ts +22 -0
  14. package/src/__tests__/corpus-tracker.test.tsx +12 -0
  15. package/src/__tests__/extract-classify.test.ts +17 -0
  16. package/src/__tests__/fleet-page.test.tsx +57 -0
  17. package/src/__tests__/fleet-view.test.ts +149 -0
  18. package/src/__tests__/project-basis-entity.test.ts +19 -0
  19. package/src/__tests__/project-basis.test.ts +21 -0
  20. package/src/__tests__/relay-cli.test.ts +10 -1
  21. package/src/__tests__/task-detail-project-guess.test.tsx +46 -0
  22. package/src/components/index.ts +2 -0
  23. package/src/components/pages/FleetPage.tsx +115 -0
  24. package/src/components/pages/TaskDetailPage.tsx +27 -1
  25. package/src/components/pages/TrackerPage.tsx +1 -1
  26. package/src/components/pages/task-tracker/ProjectGuess.tsx +42 -0
  27. package/src/corpus/ask-items.ts +7 -4
  28. package/src/corpus/ask.ts +1 -1
  29. package/src/corpus/briefing/actions/confirm.ts +9 -1
  30. package/src/corpus/briefing/actions/execute.ts +71 -11
  31. package/src/corpus/briefing/actions/log.ts +1 -1
  32. package/src/corpus/briefing/actions/seam.ts +18 -2
  33. package/src/corpus/briefing/actions/types.ts +14 -0
  34. package/src/corpus/briefing/intent/describe.ts +5 -1
  35. package/src/corpus/briefing/intent/edits.ts +92 -0
  36. package/src/corpus/briefing/intent/grammar.ts +3 -0
  37. package/src/corpus/briefing/intent/ground.ts +5 -1
  38. package/src/corpus/briefing/intent/match.ts +3 -1
  39. package/src/corpus/briefing/intent/model.ts +36 -3
  40. package/src/corpus/briefing/intent/resolve.ts +12 -1
  41. package/src/corpus/briefing/intent/types.ts +8 -0
  42. package/src/corpus/briefing/speak.ts +13 -0
  43. package/src/corpus/client.ts +2 -0
  44. package/src/corpus/converse/brain.ts +41 -13
  45. package/src/corpus/converse/briefing-queue.ts +105 -27
  46. package/src/corpus/converse/client.ts +6 -0
  47. package/src/corpus/converse/fleet-view.ts +126 -0
  48. package/src/corpus/converse/fleet.ts +18 -5
  49. package/src/corpus/converse/followups.ts +12 -2
  50. package/src/corpus/converse/handle.ts +21 -12
  51. package/src/corpus/converse/handoff.ts +7 -2
  52. package/src/corpus/converse/index.ts +5 -3
  53. package/src/corpus/converse/meeting-config.ts +8 -4
  54. package/src/corpus/converse/meeting.ts +66 -11
  55. package/src/corpus/converse/respond.ts +14 -2
  56. package/src/corpus/converse/spoken-form.ts +9 -2
  57. package/src/corpus/converse/spoken-summary.ts +30 -8
  58. package/src/corpus/converse/store.ts +2 -0
  59. package/src/corpus/converse/types.ts +14 -1
  60. package/src/corpus/entities.ts +2 -0
  61. package/src/corpus/extract.ts +9 -4
  62. package/src/corpus/project-basis.ts +23 -0
  63. package/src/corpus/types.ts +6 -0
  64. package/src/native/app/converseServices.ts +5 -3
  65. package/src/native/app/device.ts +2 -0
  66. package/src/native/converse/ConverseScreen.tsx +28 -0
  67. package/src/native/converse/__tests__/liveScreen.test.tsx +35 -2
  68. package/src/native/converse/__tests__/meetingIO.test.ts +55 -1
  69. package/src/native/converse/format.ts +2 -2
  70. package/src/native/converse/io.ts +15 -5
@@ -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
  });
@@ -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
+ });
@@ -808,3 +808,15 @@ describe('TrackerPage — 400+ open to-dos, paged by the server (bd startsim-768
808
808
  expect(queries.filter((q) => q.page).map((q) => q.page)).toEqual([2, 3]);
809
809
  });
810
810
  });
811
+
812
+ describe('TrackerPage — a guessed project (bd startsim-tmrvi.22)', () => {
813
+ it('marks a project that was only guessed from the topic, and leaves a named one plain', async () => {
814
+ const rows = [
815
+ commitment({ externalId: 'commit:g1', title: 'Send the lease paperwork', focusId: 'f1', projectBasis: 'guessed from the topic' }),
816
+ commitment({ externalId: 'commit:g2', title: 'Call the plumber', focusId: 'f1' }),
817
+ ];
818
+ render(<TrackerPage api={makeApi({ rows })} scope={SCOPE} now={NOW} projectNames={{ f1: 'Home admin' }} />);
819
+ expect(await screen.findByText('Home admin (guessed)')).toBeInTheDocument();
820
+ expect(screen.getAllByText('Home admin')).toHaveLength(1);
821
+ });
822
+ });
@@ -227,3 +227,20 @@ describe('the model adapter', () => {
227
227
  expect(bad.chat).toHaveBeenCalledTimes(2);
228
228
  });
229
229
  });
230
+
231
+ describe('a project placed only by topic is marked as a guess (bd startsim-tmrvi.22)', () => {
232
+ it('marks classifier-placed items, never a personal one', async () => {
233
+ const { corpus, saves } = world();
234
+ await extractCommitments({ scope: SCOPE }, { corpus, extractor: extractor(reader()) });
235
+ const items = saves[0].items;
236
+ const placed = items.filter((i) => i.focusId);
237
+ expect(placed.length).toBeGreaterThan(0);
238
+ for (const item of placed) {
239
+ const title = NOV5_CANDIDATES.find((c) => c.id === item.focusId)!.title.toLowerCase();
240
+ const named = `${item.title} ${item.detail ?? ''} ${item.mentions.map((m) => m.quote).join(' ')}`.toLowerCase().includes(title);
241
+ expect(item.projectBasis, item.title).toBe(named ? undefined : 'guessed from the topic');
242
+ }
243
+ expect(placed.some((i) => i.projectBasis === 'guessed from the topic')).toBe(true);
244
+ expect(byTitle(items, 'bench').projectBasis).toBeUndefined();
245
+ });
246
+ });
@@ -0,0 +1,57 @@
1
+ // @vitest-environment jsdom
2
+ import { cleanup, render, screen, waitFor } from '@testing-library/react';
3
+ import * as React from 'react';
4
+ import { afterEach, describe, expect, it, vi } from 'vitest';
5
+
6
+ import { FleetPage, type FleetPayload } from '../components/pages/FleetPage';
7
+
8
+ afterEach(cleanup);
9
+ const s = (id: string, name: string, goal = '') => ({ id, name, goal, machine: 'Mac/x', repo: 'r', branch: 'b', status: 'live' as const });
10
+ const view = {
11
+ relay: s('7afdf27a', 'Relay: fleet manager', 'Runs the fleet'),
12
+ leads: [
13
+ { role: 'Tandem coordinator', notes: 'owns stack', session: s('0ec3d1ff', 'Tandem coordinator', 'Coordinate Tandem'), children: [s('9eb03770', 'lane two', 'Voice notes')] },
14
+ { role: 'Platform coordinator', notes: 'PR waits', session: null, children: [] },
15
+ ],
16
+ others: [s('11112222', 'stray', 'Something else')],
17
+ waitingOnQuinn: ['Sidebar name?'], waitingOnSessions: ['platform f7ebc9cc: proof'], rolesUpdated: 'x', loopsUpdated: '2026-11-16', unparsed: ['a stray line'], sections: [{ title: 'State 11-18', items: ['Crochets live'] }],
18
+ ports: [{ project: 'Tandem', range: '4300-4309', base: '4300', url: 'http://localhost:4300', notes: '' }],
19
+ };
20
+ const payload = (over: Partial<FleetPayload> = {}): FleetPayload => ({ snapshot: { text: 'notes', updatedAt: new Date().toISOString(), view }, ...over });
21
+
22
+ describe('FleetPage', () => {
23
+ it('shows what waits on Quinn first, then relay, leads, children, others', async () => {
24
+ render(<FleetPage load={async () => payload()} />);
25
+ await waitFor(() => expect(screen.getByTestId('fleet-waiting-quinn')).toBeTruthy());
26
+ expect(screen.getByTestId('fleet-waiting-quinn').textContent).toContain('Sidebar name?');
27
+ expect(screen.getByTestId('fleet-relay').textContent).toContain('Runs the fleet');
28
+ const lead = screen.getByTestId('fleet-lead-Tandem coordinator');
29
+ expect(lead.textContent).toContain('Coordinate Tandem');
30
+ expect(lead.textContent).toContain('Voice notes');
31
+ expect(screen.getByTestId('fleet-lead-Platform coordinator').textContent).toContain('No live session');
32
+ expect(screen.getByTestId('fleet-others').textContent).toContain('Something else');
33
+ });
34
+ it('lists local stack URLs and the lines it could not place', async () => {
35
+ render(<FleetPage load={async () => payload()} />);
36
+ await waitFor(() => expect(screen.getByTestId('fleet-ports')).toBeTruthy());
37
+ expect(screen.getByTestId('fleet-ports').querySelector('a')?.getAttribute('href')).toBe('http://localhost:4300');
38
+ expect(screen.getByTestId('fleet-sections').textContent).toContain('State 11-18');
39
+ expect(screen.getByTestId('fleet-unparsed').textContent).toContain('a stray line');
40
+ });
41
+ it('flags an old snapshot as stale', async () => {
42
+ render(<FleetPage load={async () => payload({ snapshot: { text: 'n', updatedAt: new Date(Date.now() - 3 * 3600_000).toISOString(), view } })} />);
43
+ await waitFor(() => expect(screen.getByTestId('fleet-age').textContent).toMatch(/3 hours ago/));
44
+ expect(screen.getByTestId('fleet-age').getAttribute('data-stale')).toBe('true');
45
+ });
46
+ it('says so when the relay has not posted, and falls back to text without a view', async () => {
47
+ const { rerender } = render(<FleetPage load={async () => ({ snapshot: null })} />);
48
+ await waitFor(() => expect(screen.getByTestId('fleet-empty')).toBeTruthy());
49
+ rerender(<FleetPage load={async () => payload({ snapshot: { text: 'plain notes', updatedAt: new Date().toISOString(), view: null } })} key="b" />);
50
+ await waitFor(() => expect(screen.getByTestId('fleet-text').textContent).toContain('plain notes'));
51
+ });
52
+ it('shows a load error with retry', async () => {
53
+ const load = vi.fn().mockRejectedValueOnce(new Error('boom')).mockResolvedValue(payload());
54
+ render(<FleetPage load={load} />);
55
+ await waitFor(() => expect(screen.getByTestId('load-error')).toBeTruthy());
56
+ });
57
+ });
@@ -0,0 +1,149 @@
1
+ // @vitest-environment node
2
+ /** The structured fleet view (Tandem /fleet): roles.md + open-loops ledger + `bridge find` -> relay, leads, children. */
3
+ import { describe, expect, it, vi } from 'vitest';
4
+
5
+ import { buildFleetView, parseBridgeFind, parseLoops, parseRoles } from '../corpus/converse';
6
+
7
+ const ROLES = `# Role registry
8
+ Updated 2026-11-18 ~12:30 MT
9
+
10
+ | Role | Live session | Notes |
11
+ |---|---|---|
12
+ | Tandem coordinator | 0ec3d1ff | owns Tandem stack; lane 2 = 9eb03770 reports to it |
13
+ | Crochets coordinator | a90ab874 (spawn daf13afc, live) | no live children; old c91210f5 ended |
14
+ | DebuggAI platform coordinator | none live (abe4c934 ended) | PR 837 await promote |
15
+ | Relay | 7afdf27a | relay.json current |
16
+
17
+ Rules: message only these.`;
18
+
19
+ const LOOPS = `# Relay open loops
20
+ Updated 2026-11-16 ~11:10 MT.
21
+
22
+ ## Waiting on Quinn (restate in full when asking)
23
+ - Sidebar name: "Plan" or "Strategy"?
24
+ - Unpause crochet-patterns later?
25
+
26
+ ## Waiting on sessions (I follow up if silent)
27
+ - platform f7ebc9cc: crawl guard proof
28
+ `;
29
+
30
+ const FIND = [
31
+ '[live] `Mac/last-chance · Relay: Quinn\'s fleet manager · 7afdf27a` Quinn\'s relay start-simpli@green/x',
32
+ '[live] `Mac/last-chance · Tandem coordinator: assistant · 0ec3d1ff` Coordinate Tandem work start-simpli@spawn/86b8 [model claude-sonnet-5-5]',
33
+ '[live] `Mac/last-chance · lane two · 9eb03770` Voice notes start-simpli@spawn/x',
34
+ '[live] `Mac/last-chance · Crochets coordinator · a90ab874` Fix patterns start-simpli@spawn/daf1',
35
+ '[live] `Mac/last-chance · spawn runner · runner-l` starts sessions spawn-runner',
36
+ '[live] `Mac/last-chance · stray · 11112222` Something else crochet@main',
37
+ '[dormant] `Mac/last-chance · asleep · 33334444` Napping start-simpli@y',
38
+ ' resume (on last-chance@debugg.ai): claude --resume 33334444',
39
+ ].join('\n');
40
+
41
+ describe('parsers', () => {
42
+ it('reads roles', () => {
43
+ const r = parseRoles(ROLES);
44
+ expect(r.updated).toBe('2026-11-18 ~12:30 MT');
45
+ expect(r.rows.map((x) => [x.role, x.sessionId])).toEqual([['Tandem coordinator', '0ec3d1ff'], ['Crochets coordinator', 'a90ab874'], ['DebuggAI platform coordinator', null], ['Relay', '7afdf27a']]);
46
+ expect(r.rows[0].childIds).toEqual(['9eb03770']);
47
+ expect(r.rows[1].childIds).toEqual(['daf13afc', 'c91210f5'].filter((x) => x !== 'daf13afc'));
48
+ });
49
+ it('reads loops by section', () => {
50
+ const l = parseLoops(LOOPS);
51
+ expect(l.updated).toBe('2026-11-16 ~11:10 MT.');
52
+ expect(l.waitingOnQuinn).toEqual(['Sidebar name: "Plan" or "Strategy"?', 'Unpause crochet-patterns later?']);
53
+ expect(l.waitingOnSessions).toEqual(['platform f7ebc9cc: crawl guard proof']);
54
+ });
55
+ it('reads bridge find, skipping runners and resume lines', () => {
56
+ const s = parseBridgeFind(FIND);
57
+ expect(s.map((x) => x.id)).toEqual(['7afdf27a', '0ec3d1ff', '9eb03770', 'a90ab874', '11112222', '33334444']);
58
+ expect(s[1]).toMatchObject({ name: 'Tandem coordinator: assistant', goal: 'Coordinate Tandem work', repo: 'start-simpli', branch: 'spawn/86b8', status: 'live', machine: 'Mac/last-chance' });
59
+ expect(s[5].status).toBe('dormant');
60
+ });
61
+ });
62
+
63
+ const PORTS = `# Local dev port ranges
64
+ | Project | Range | Base (staging) | Notes |
65
+ |---|---|---|---|
66
+ | Tandem | 4300-4309 | 4300 gateway (tandem-web) | 4303 fast loop |
67
+ | Other | 4360+ | ask relay | |`;
68
+
69
+ describe('tolerance', () => {
70
+ it('keeps lines it cannot place instead of failing', () => {
71
+ const v = buildFleetView({ roles: ROLES + '\nsomeone typed a stray note here\n| broken row |', loops: LOOPS + '\nfree text under the ledger\n## Misc\n- random\n## PRIORITIES (Quinn, today)\n- one', ports: PORTS, sessions: 'garbage\n[live] `no id here` x' });
72
+ expect(v.unparsed).toEqual(expect.arrayContaining(['Rules: message only these.', 'someone typed a stray note here', '| broken row |']));
73
+ expect(v.waitingOnSessions).toContain('free text under the ledger'); // stays in the section it was written under
74
+ expect(v.sections).toEqual([{ title: 'Misc', items: ['random'] }, { title: 'PRIORITIES (Quinn, today)', items: ['one'] }]);
75
+ expect(v.waitingOnQuinn).toHaveLength(2);
76
+ expect(v.leads.length).toBe(3);
77
+ });
78
+ it('lists per-project base URLs from ports.md', () => {
79
+ const v = buildFleetView({ ports: PORTS });
80
+ expect(v.ports).toEqual([
81
+ { project: 'Tandem', range: '4300-4309', base: '4300 gateway (tandem-web)', url: 'http://localhost:4300', notes: '4303 fast loop' },
82
+ { project: 'Other', range: '4360+', base: 'ask relay', url: null, notes: '' },
83
+ ]);
84
+ });
85
+ });
86
+
87
+ describe('buildFleetView', () => {
88
+ it('nests relay -> leads -> children and lists the rest', () => {
89
+ const v = buildFleetView({ roles: ROLES, loops: LOOPS, sessions: FIND });
90
+ expect(v.relay?.id).toBe('7afdf27a');
91
+ expect(v.leads.map((l) => l.role)).toEqual(['Tandem coordinator', 'Crochets coordinator', 'DebuggAI platform coordinator']);
92
+ expect(v.leads[0].session?.id).toBe('0ec3d1ff');
93
+ expect(v.leads[0].children.map((c) => c.id)).toEqual(['9eb03770']);
94
+ expect(v.leads[2].session).toBeNull();
95
+ expect(v.others.map((o) => o.id)).toEqual(['11112222', '33334444']);
96
+ expect(v.waitingOnQuinn).toHaveLength(2);
97
+ expect(v.rolesUpdated).toBe('2026-11-18 ~12:30 MT');
98
+ });
99
+ it('falls back to a live session named for the role when the listed id is not live', () => {
100
+ const v = buildFleetView({ roles: ROLES.replace('0ec3d1ff', 'deadbeef'), sessions: FIND });
101
+ expect(v.leads[0].session?.id).toBe('0ec3d1ff');
102
+ expect(v.leads[0].listedId).toBe('deadbeef');
103
+ });
104
+ it('survives empty inputs', () => {
105
+ const v = buildFleetView({});
106
+ expect(v).toMatchObject({ relay: null, leads: [], others: [], waitingOnQuinn: [], waitingOnSessions: [] });
107
+ });
108
+ });
109
+
110
+ describe('fleet-status round trip', () => {
111
+ it('stores the raw inputs and serves the parsed view', async () => {
112
+ const { converseFleetStatusResponse, converseFleetViewResponse } = await import('../corpus/converse');
113
+ const rows: any[] = [];
114
+ const http = {
115
+ get: vi.fn(async () => ({ results: rows })),
116
+ post: vi.fn(async (_p: string, body: any) => { const r = { id: 1, external_id: body.external_id, data: body.data }; rows.splice(0, rows.length, r); return r; }),
117
+ };
118
+ const deps: any = { http, ownerSub: 'me', now: () => Date.UTC(2026, 10, 19) };
119
+ const empty = await converseFleetViewResponse(deps);
120
+ expect(await empty.json()).toEqual({ snapshot: null });
121
+ const post = await converseFleetStatusResponse(new Request('http://x', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ text: 'notes', inputs: { roles: ROLES, loops: LOOPS, sessions: FIND, junk: 'x' } }) }), deps);
122
+ expect(post.status).toBe(200);
123
+ expect(Object.keys(rows[0].data.fleet_inputs).sort()).toEqual(['loops', 'roles', 'sessions']);
124
+ const body: any = await (await converseFleetViewResponse(deps)).json();
125
+ expect(body.snapshot.text).toBe('notes');
126
+ expect(body.snapshot.view.leads).toHaveLength(3);
127
+ expect(body.snapshot.view.waitingOnQuinn).toHaveLength(2);
128
+ });
129
+ it('old snapshots without inputs give view: null', async () => {
130
+ const { converseFleetStatusResponse, converseFleetViewResponse } = await import('../corpus/converse');
131
+ const rows: any[] = [];
132
+ const http = { get: vi.fn(async () => ({ results: rows })), post: vi.fn(async (_p: string, b: any) => { const r = { id: 1, external_id: b.external_id, data: b.data }; rows.splice(0, rows.length, r); return r; }) };
133
+ const deps: any = { http, ownerSub: 'me' };
134
+ await converseFleetStatusResponse(new Request('http://x', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ text: 'only text' }) }), deps);
135
+ expect(((await (await converseFleetViewResponse(deps)).json()) as any).snapshot.view).toBeNull();
136
+ });
137
+ });
138
+
139
+ describe('converse client fleet()', () => {
140
+ it('GETs fleet-status with the bearer', async () => {
141
+ const { createConverseClient } = await import('../corpus/converse');
142
+ const f = vi.fn(async () => Response.json({ snapshot: null }));
143
+ const c = createConverseClient({ getToken: async () => 'tok', fetch: f as any });
144
+ expect(await c.fleet()).toEqual({ snapshot: null });
145
+ const [url, init] = f.mock.calls[0] as any;
146
+ expect(url).toBe('/corpus/converse/fleet-status');
147
+ expect(init.headers.authorization).toBe('Bearer tok');
148
+ });
149
+ });
@@ -0,0 +1,19 @@
1
+ import { describe, expect, it } from 'vitest';
2
+
3
+ import { commitmentToEntity, toCommitment } from '../corpus/entities';
4
+ import type { Commitment } from '../corpus/types';
5
+
6
+ const scope = { orgId: 'o', userId: 'u' } as never;
7
+ const base = { externalId: 'commit:x', title: 'Send paperwork', mentions: [], status: 'open', subjectKey: 's', actionKey: 'a', dedupeKey: 'd' } as unknown as Commitment;
8
+
9
+ describe('projectBasis on a commitment', () => {
10
+ it('is written to the row and read back', () => {
11
+ const wire = commitmentToEntity({ ...base, projectBasis: 'guessed from the topic' });
12
+ expect(wire.data.project_basis).toBe('guessed from the topic');
13
+ const back = toCommitment({ id: '1', external_id: 'commit:x', entity_type: 'commitment', name: 'x', data: wire.data } as never, scope);
14
+ expect(back.projectBasis).toBe('guessed from the topic');
15
+ });
16
+ it('is absent when nothing was guessed', () => {
17
+ expect('project_basis' in commitmentToEntity(base).data).toBe(false);
18
+ });
19
+ });
@@ -0,0 +1,21 @@
1
+ import { describe, expect, it } from 'vitest';
2
+
3
+ import { PROJECT_GUESSED, projectBasisFor } from '../corpus/project-basis';
4
+
5
+ const item = { title: 'Send the lease paperwork', detail: '', mentions: [{ quote: 'send the lease paperwork to the landlord' }] };
6
+
7
+ describe('projectBasisFor', () => {
8
+ it('marks a project that the item never names as a guess from the topic', () => {
9
+ expect(projectBasisFor(item, 'Home admin', 'I need to send the lease paperwork to the landlord.')).toBe(PROJECT_GUESSED);
10
+ });
11
+ it('leaves it unmarked when the project is named in what was said', () => {
12
+ expect(projectBasisFor(item, 'Home admin', 'For home admin: send the lease paperwork to the landlord.')).toBeUndefined();
13
+ });
14
+ it('leaves it unmarked when the item itself names the project', () => {
15
+ expect(projectBasisFor({ ...item, title: 'Home admin: lease paperwork' }, 'Home admin', '')).toBeUndefined();
16
+ });
17
+ it('ignores case and a missing project title', () => {
18
+ expect(projectBasisFor(item, 'HOME ADMIN', 'home admin first')).toBeUndefined();
19
+ expect(projectBasisFor(item, '', 'anything')).toBeUndefined();
20
+ });
21
+ });
@@ -6,7 +6,7 @@ import { join } from 'node:path';
6
6
  import { describe, expect, it, vi } from 'vitest';
7
7
 
8
8
  // @ts-expect-error plain .mjs scripts
9
- import { composeSnapshot, loadNotes, parseSessions, saveNotes } from '../../../../scripts/relay-converse/fleet.mjs';
9
+ import { composeSnapshot, loadNotes, parseSessions, readFleetInputs, saveNotes } from '../../../../scripts/relay-converse/fleet.mjs';
10
10
  // @ts-expect-error plain .mjs scripts
11
11
  import { accessToken, saveState } from '../../../../scripts/relay-converse/oauth.mjs';
12
12
  // @ts-expect-error plain .mjs scripts
@@ -28,6 +28,15 @@ describe('fleet snapshot composition', () => {
28
28
  });
29
29
  });
30
30
 
31
+ describe('fleet inputs for the /fleet page', () => {
32
+ it('reads roles.md, the loops ledger and the raw bridge listing; leaves out what is missing', async () => {
33
+ const dir = mkdtempSync(join(tmpdir(), 'rc-'));
34
+ writeFileSync(join(dir, 'roles.md'), '| Role | s | n |');
35
+ const env = { RELAY_ROLES_FILE: join(dir, 'roles.md'), RELAY_LOOPS_FILE: join(dir, 'nope.md'), RELAY_PORTS_FILE: join(dir, 'nope2.md') };
36
+ expect(await readFleetInputs(env, '[live] `a · b · 12345678` g')).toEqual({ roles: '| Role | s | n |', sessions: '[live] `a · b · 12345678` g' });
37
+ });
38
+ });
39
+
31
40
  describe('shared access token', () => {
32
41
  it('reuses an unexpired access token for the same base and rotates the refresh token only once when expired', async () => {
33
42
  const dir = mkdtempSync(join(tmpdir(), 'rc-'));
@@ -0,0 +1,46 @@
1
+ import { describe, expect, it, vi } from 'vitest';
2
+ import { render, screen, waitFor, fireEvent } from '@testing-library/react';
3
+
4
+ import { TaskDetailPage } from '../components/pages/TaskDetailPage';
5
+ import { toCommitment, type TenantEntity } from '../corpus/entities';
6
+ import type { Commitment } from '../corpus/types';
7
+
8
+ const make = (data: Record<string, unknown>): Commitment => ({
9
+ ...toCommitment({
10
+ id: 'a', external_id: 'commit:a', name: 'a', entity_type: 'commitment', version: 1,
11
+ data: { title: 'Send the lease paperwork', status: 'open', subtype: 'action', mentions: [], ...data },
12
+ } as unknown as TenantEntity, { orgId: 'o' }), focusId: 'f1' });
13
+
14
+ function setup(item: Commitment, withFiling = true) {
15
+ const api = {
16
+ listCommitments: vi.fn(async (q: { page?: number } = {}) => ({ results: (q.page ?? 1) === 1 ? [item] : [], count: 1 })) as never,
17
+ updateCommitment: vi.fn(async (i: Commitment, patch: object) => ({ ...i, ...patch })) as never,
18
+ ...(withFiling ? { fileCommitment: vi.fn(async () => undefined) } : {}),
19
+ };
20
+ render(<TaskDetailPage api={api} scope={{ orgId: 'o' } as never} itemId="commit:a" projectNames={{ f1: 'Home admin', f2: 'Tandem' }} />);
21
+ return api as typeof api & { fileCommitment: ReturnType<typeof vi.fn> };
22
+ }
23
+
24
+ describe('a project that was only guessed', () => {
25
+ it('says so next to the project and offers a one-tap change', async () => {
26
+ const api = setup(make({ project_basis: 'guessed from the topic' }));
27
+ expect(await screen.findByTestId('project-guess')).toBeInTheDocument();
28
+ expect(screen.getByText(/guessed from the topic/i)).toBeInTheDocument();
29
+ fireEvent.change(screen.getByLabelText(/change project/i), { target: { value: 'f2' } });
30
+ await waitFor(() => expect(api.fileCommitment).toHaveBeenCalledWith(expect.anything(), 'f2'));
31
+ await waitFor(() => expect(api.updateCommitment).toHaveBeenCalledWith(expect.anything(), { projectBasis: null }));
32
+ });
33
+
34
+ it('"That is right" keeps the project and clears the guess marker', async () => {
35
+ const api = setup(make({ project_basis: 'guessed from the topic' }));
36
+ fireEvent.click(await screen.findByRole('button', { name: /that.s right/i }));
37
+ await waitFor(() => expect(api.updateCommitment).toHaveBeenCalledWith(expect.anything(), { projectBasis: null }));
38
+ expect(api.fileCommitment).not.toHaveBeenCalled();
39
+ });
40
+
41
+ it('shows nothing extra for a project that was named', async () => {
42
+ setup(make({}));
43
+ expect(await screen.findByText(/home admin/i)).toBeInTheDocument();
44
+ expect(screen.queryByText(/guessed from the topic/i)).toBeNull();
45
+ });
46
+ });
@@ -76,6 +76,8 @@ export { ConnectorPage } from './pages/ConnectorPage';
76
76
  export type { ConnectorPageProps, ConnectorClassNames } from './pages/ConnectorPage';
77
77
  export { DecisionsPage } from './pages/DecisionsPage';
78
78
  export type { DecisionsPageProps, DecisionsClassNames } from './pages/DecisionsPage';
79
+ export { FleetPage } from './pages/FleetPage';
80
+ export type { FleetPageProps, FleetPayload } from './pages/FleetPage';
79
81
  export type { VoiceRecordButtonProps, VoiceRecordClassNames } from './pages/VoiceRecordButton';
80
82
  export * from './pages/home';
81
83
  export * from './pages/questions';
@@ -0,0 +1,115 @@
1
+ 'use client';
2
+
3
+ /**
4
+ * FLEET (Tandem /fleet, read-only): relay -> project leads -> their sessions, what each is for, and what waits on the
5
+ * person. The data is the relay's synced snapshot (`GET /corpus/converse/fleet-status`), parsed in the package
6
+ * (`buildFleetView`); this only draws it. Re-reads every 30s and says how old the snapshot is.
7
+ */
8
+ import * as React from 'react';
9
+
10
+ import { ageWords, FLEET_FRESH_MS } from '../../corpus/converse/fleet';
11
+ import type { FleetSession, FleetView } from '../../corpus/converse/fleet-view';
12
+ import { LoadError } from '../LoadError';
13
+
14
+ export interface FleetPayload { snapshot: { text: string; updatedAt: string; view: FleetView | null } | null }
15
+ export interface FleetPageProps { load: () => Promise<FleetPayload>; refreshMs?: number }
16
+
17
+ function SessionRow({ s, testId }: { s: FleetSession; testId?: string }) {
18
+ return (
19
+ <div className="flex flex-col gap-0.5 py-2" data-testid={testId}>
20
+ <div className="flex items-center gap-2">
21
+ <span className={`h-2 w-2 shrink-0 rounded-full ${s.status === 'live' ? 'bg-green-500' : 'bg-gray-300'}`} title={s.status} />
22
+ <span className="font-medium text-gray-900">{s.name || s.id}</span>
23
+ <span className="font-mono text-xs text-gray-400">{s.id}</span>
24
+ </div>
25
+ {s.goal ? <p className="pl-4 text-sm text-gray-700">{s.goal}</p> : null}
26
+ {s.repo ? <p className="pl-4 text-xs text-gray-400">{s.repo}{s.branch ? `@${s.branch}` : ''} · {s.machine}</p> : null}
27
+ </div>
28
+ );
29
+ }
30
+
31
+ const Card = ({ title, children, testId, tone = 'border-gray-200 bg-white' }: { title: string; children: React.ReactNode; testId?: string; tone?: string }) => (
32
+ <section className={`rounded-xl border p-4 ${tone}`} data-testid={testId}>
33
+ <h2 className="mb-1 text-sm font-semibold uppercase tracking-wide text-gray-500">{title}</h2>
34
+ {children}
35
+ </section>
36
+ );
37
+
38
+ function FleetBody({ view }: { view: FleetView }) {
39
+ return (
40
+ <div className="space-y-4">
41
+ <Card title={`Waiting on you (${view.waitingOnQuinn.length})`} testId="fleet-waiting-quinn" tone="border-amber-300 bg-amber-50">
42
+ {view.waitingOnQuinn.length ? <ul className="list-disc space-y-1 pl-5 text-sm text-gray-900">{view.waitingOnQuinn.map((t) => <li key={t}>{t}</li>)}</ul> : <p className="text-sm text-gray-600">Nothing is waiting on you.</p>}
43
+ {view.loopsUpdated ? <p className="mt-2 text-xs text-gray-500">Ledger updated {view.loopsUpdated}</p> : null}
44
+ </Card>
45
+ {view.relay ? <Card title="Relay" testId="fleet-relay"><SessionRow s={view.relay} /></Card> : null}
46
+ {view.leads.map((l) => (
47
+ <Card key={l.role} title={l.role} testId={`fleet-lead-${l.role}`}>
48
+ {l.session ? <SessionRow s={l.session} /> : <p className="py-2 text-sm text-gray-500">No live session{l.listedId ? ` (notes list ${l.listedId}, which is not on the bridge)` : ''}.</p>}
49
+ {l.session && l.listedId ? <p className="text-xs text-amber-700">Notes list {l.listedId}; this live session matches the role by name.</p> : null}
50
+ {l.notes ? <p className="pb-2 text-xs text-gray-500">{l.notes}</p> : null}
51
+ {l.children.length ? <div className="ml-3 divide-y divide-gray-100 border-l border-gray-200 pl-3">{l.children.map((c) => <SessionRow key={c.id} s={c} />)}</div> : null}
52
+ </Card>
53
+ ))}
54
+ {view.waitingOnSessions.length ? (
55
+ <Card title="Relay is waiting on sessions" testId="fleet-waiting-sessions">
56
+ <ul className="list-disc space-y-1 pl-5 text-sm text-gray-800">{view.waitingOnSessions.map((t) => <li key={t}>{t}</li>)}</ul>
57
+ </Card>
58
+ ) : null}
59
+ {view.sections?.length ? (
60
+ <Card title="Relay's notes" testId="fleet-sections">
61
+ <div className="space-y-2">
62
+ {view.sections.map((sec) => (
63
+ <details key={sec.title} className="rounded-md border border-gray-100 px-3 py-2">
64
+ <summary className="cursor-pointer text-sm font-medium text-gray-800">{sec.title} <span className="text-xs text-gray-400">({sec.items.length})</span></summary>
65
+ <ul className="mt-2 list-disc space-y-1 pl-5 text-sm text-gray-700">{sec.items.map((t, i) => <li key={i}>{t}</li>)}</ul>
66
+ </details>
67
+ ))}
68
+ </div>
69
+ </Card>
70
+ ) : null}
71
+ {view.ports?.length ? (
72
+ <Card title="Local stacks" testId="fleet-ports">
73
+ <ul className="divide-y divide-gray-100 text-sm">
74
+ {view.ports.map((p) => (
75
+ <li key={p.project} className="flex flex-wrap items-baseline gap-x-2 py-1.5">
76
+ <span className="font-medium text-gray-900">{p.project}</span>
77
+ {p.url ? <a className="text-indigo-600 underline" href={p.url} target="_blank" rel="noreferrer">{p.url}</a> : <span className="text-gray-500">{p.base}</span>}
78
+ <span className="text-xs text-gray-400">{p.range}{p.notes ? ` · ${p.notes}` : ''}</span>
79
+ </li>
80
+ ))}
81
+ </ul>
82
+ </Card>
83
+ ) : null}
84
+ {view.unparsed?.length ? (
85
+ <Card title="Other lines in the notes" testId="fleet-unparsed">
86
+ <ul className="space-y-1 text-xs text-gray-600">{view.unparsed.map((t, i) => <li key={i} className="whitespace-pre-wrap">{t}</li>)}</ul>
87
+ </Card>
88
+ ) : null}
89
+ {view.others.length ? <Card title={`Other sessions (${view.others.length})`} testId="fleet-others"><div className="divide-y divide-gray-100">{view.others.map((s) => <SessionRow key={s.id} s={s} />)}</div></Card> : null}
90
+ </div>
91
+ );
92
+ }
93
+
94
+ export function FleetPage({ load, refreshMs = 30000 }: FleetPageProps) {
95
+ const [data, setData] = React.useState<FleetPayload | undefined>();
96
+ const [error, setError] = React.useState<string | null>(null);
97
+ const [, tick] = React.useState(0);
98
+ const run = React.useCallback(() => { load().then((d) => { setData(d); setError(null); }).catch((e) => setError(e instanceof Error ? e.message : 'Could not load.')); }, [load]);
99
+ React.useEffect(() => { run(); const t = setInterval(() => { run(); tick((n) => n + 1); }, refreshMs); return () => clearInterval(t); }, [run, refreshMs]);
100
+ const snap = data?.snapshot;
101
+ const stale = snap ? Date.now() - Date.parse(snap.updatedAt) > FLEET_FRESH_MS : false;
102
+ return (
103
+ <div className="space-y-4">
104
+ {error ? <LoadError what="the fleet" message={error} onRetry={run} /> : null}
105
+ {data && !snap ? <div className="rounded-xl border border-gray-200 bg-white p-6 text-center" data-testid="fleet-empty"><p className="font-medium text-gray-900">The relay has not posted a fleet snapshot yet.</p></div> : null}
106
+ {snap ? (
107
+ <p className="text-sm text-gray-600" data-testid="fleet-age" data-stale={stale ? 'true' : 'false'}>
108
+ Snapshot from {ageWords(snap.updatedAt, Date.now()) || 'an unknown time'}{stale ? ' — older than 10 minutes, so this is where things stood, not now.' : '.'}
109
+ </p>
110
+ ) : null}
111
+ {snap?.view ? <FleetBody view={snap.view} /> : null}
112
+ {snap && !snap.view ? <pre className="whitespace-pre-wrap rounded-xl border border-gray-200 bg-white p-4 text-sm text-gray-800" data-testid="fleet-text">{snap.text}</pre> : null}
113
+ </div>
114
+ );
115
+ }