@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,71 @@
1
+ /**
2
+ * THE BRIEF ON SCREEN: the same composed items the spoken script is about, laid out to read at a glance
3
+ * (headings, one short bullet per item). The spoken text is NOT this: it is written for a voice and its
4
+ * offsets resolve voice replies, so it stays as it is. Pure and deterministic: no model, no clock.
5
+ */
6
+ import type { WeeklyEntry, WeeklySummary } from './weekly';
7
+ import type { BriefingEntry, BriefingKind } from './types';
8
+
9
+ const GROUPS: Array<{ kind: BriefingKind; heading: string }> = [
10
+ { kind: 'overdue', heading: 'Overdue' },
11
+ { kind: 'in_progress', heading: 'In progress' },
12
+ { kind: 'due_today', heading: 'Due today' },
13
+ ];
14
+
15
+ const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
16
+
17
+ /** `2026-11-03` -> `Nov 3`; anything else is dropped rather than shown raw. */
18
+ function shortDate(day: string | null): string {
19
+ const m = day ? /^(\d{4})-(\d{2})-(\d{2})/.exec(day) : null;
20
+ const month = m ? MONTHS[Number(m[2]) - 1] : undefined;
21
+ return m && month ? `${month} ${Number(m[3])}` : '';
22
+ }
23
+
24
+ /** One line, no markup characters: a title cannot open a heading, a list or bold. */
25
+ function plain(text: string): string {
26
+ return text.replace(/[*_#`<>[\]]/g, '').replace(/\s+/g, ' ').trim();
27
+ }
28
+
29
+ export function briefingMarkdown(items: BriefingEntry[], remaining: number): string {
30
+ if (items.length === 0 && remaining <= 0) return 'Nothing is due today, and nothing is overdue.';
31
+ const blocks: string[] = [];
32
+ for (const { kind, heading } of GROUPS) {
33
+ const rows = items.filter((i) => i.kind === kind);
34
+ if (!rows.length) continue;
35
+ const lines = rows.map((i) => {
36
+ const bits = [`**${plain(i.title) || 'Untitled'}**`];
37
+ if (i.group && i.group !== 'Personal') bits.push(plain(i.group));
38
+ const when = kind === 'overdue' ? shortDate(i.dueDate) : '';
39
+ if (when) bits.push(`was due ${when}`);
40
+ return `- ${bits.join(' · ')}`;
41
+ });
42
+ blocks.push([`## ${heading}`, ...lines].join('\n'));
43
+ }
44
+ if (remaining > 0) blocks.push(`_${remaining} more not shown._`);
45
+ return blocks.join('\n\n');
46
+ }
47
+
48
+ /** The week on screen: finished, slipping, coming up. One short bullet each, with the date that matters. */
49
+ export function weeklyMarkdown(summary: WeeklySummary): string {
50
+ if (summary.empty) return 'Nothing finished, nothing slipping and nothing due in the next week.';
51
+ const row = (e: WeeklyEntry, date: string, label: string) => {
52
+ const bits = [`**${plain(e.title) || 'Untitled'}**`];
53
+ if (e.group && e.group !== 'Personal') bits.push(plain(e.group));
54
+ const d = shortDate(date);
55
+ if (d) bits.push(`${label} ${d}`.trim());
56
+ return `- ${bits.join(' · ')}`;
57
+ };
58
+ const sections: Array<[string, WeeklyEntry[], number, (e: WeeklyEntry) => string]> = [
59
+ ['Finished', summary.done, summary.counts.done, (e) => row(e, e.doneDate ?? '', '')],
60
+ ['Slipping', summary.slipping, summary.counts.slipping, (e) => row(e, e.dueDate ?? '', 'was due')],
61
+ ['Coming up', summary.upcoming, summary.counts.upcoming, (e) => row(e, e.dueDate ?? '', 'due')],
62
+ ];
63
+ const blocks: string[] = [];
64
+ for (const [title, rows, total, line] of sections) {
65
+ if (!rows.length) continue;
66
+ const lines = rows.map(line);
67
+ if (total > rows.length) lines.push(`_${total - rows.length} more._`);
68
+ blocks.push([`## ${title} · ${total}`, ...lines].join('\n'));
69
+ }
70
+ return blocks.join('\n\n');
71
+ }
@@ -79,3 +79,16 @@ export function speakDatesIn(text: string, today: string): string {
79
79
  return month >= 1 && month <= 12 && Number(d) >= 1 && Number(d) <= 31 ? speakDate(m, today) : m;
80
80
  });
81
81
  }
82
+
83
+ /** Minutes as a person says a length of time: `an hour and a half`, `forty-five minutes`, `two hours`. */
84
+ export function spokenMinutes(total: number): string {
85
+ const n = Math.max(0, Math.round(total));
86
+ if (n === 30) return 'half an hour';
87
+ const hours = Math.floor(n / 60);
88
+ const rest = n % 60;
89
+ const h = hours === 1 ? 'an hour' : `${speakCount(hours)} hours`;
90
+ if (!hours) return `${speakCount(rest)} ${rest === 1 ? 'minute' : 'minutes'}`;
91
+ if (!rest) return h;
92
+ if (rest === 30) return `${h} and a half`;
93
+ return `${h} and ${speakCount(rest)} ${rest === 1 ? 'minute' : 'minutes'}`;
94
+ }
@@ -33,6 +33,7 @@
33
33
  import { writePossiblyDone } from './possibly-done';
34
34
  import { patchEditedItem } from './commitment-edit';
35
35
  import { readStandings } from './standings';
36
+ import { createParticipantReader } from './participants';
36
37
  import { createTimelineReader } from './tracker-timeline-client';
37
38
  import {
38
39
  DEFAULT_PARTICIPANT_EDGES,
@@ -89,6 +90,7 @@ import type {
89
90
  MoneyEvent,
90
91
  Party,
91
92
  PartyRef,
93
+ ListSourcesOptions,
92
94
  PlanningApi,
93
95
  SourceFreshness,
94
96
  } from './types';
@@ -262,11 +264,13 @@ function commitmentParams(query: CommitmentQuery, type: string): Record<string,
262
264
  ...(query.pageSize ? { page_size: Math.min(query.pageSize, 200) } : {}),
263
265
  // Oldest debt first unless the screen asks otherwise — asking the server
264
266
  // means page one is the right page one.
265
- order: commitmentOrder(query.sort),
267
+ order: commitmentOrder(query.sort, query.sortDir),
266
268
  };
267
269
  if (statuses.length === 1) out['attr.status'] = statuses[0];
268
270
  else if (statuses.length > 1) out['attr.status__in'] = statuses.join(',');
269
- if (query.subtype) out['attr.subtype'] = query.subtype;
271
+ const subtypes = Array.isArray(query.subtype) ? query.subtype : query.subtype ? [query.subtype] : [];
272
+ if (subtypes.length === 1) out['attr.subtype'] = subtypes[0];
273
+ else if (subtypes.length > 1) out['attr.subtype__in'] = subtypes.join(',');
270
274
  if (query.owner) out['attr.owner_name__icontains'] = query.owner.slice(0, TEXT_FILTER_MAX);
271
275
  if (query.dueBefore) out['attr.due_at__lte'] = query.dueBefore;
272
276
  if (query.changedAfter) out['attr.last_seen_at__gte'] = query.changedAfter;
@@ -293,7 +297,7 @@ function commitmentParams(query: CommitmentQuery, type: string): Record<string,
293
297
  /** Which server parameter carries which `CommitmentQuery` key. */
294
298
  const FILTER_PARAMS: Array<[keyof CommitmentQuery, string[]]> = [
295
299
  ['status', ['attr.status', 'attr.status__in']],
296
- ['subtype', ['attr.subtype']],
300
+ ['subtype', ['attr.subtype', 'attr.subtype__in']],
297
301
  ['owner', ['attr.owner_name__icontains']],
298
302
  ['dueBefore', ['attr.due_at__lte']],
299
303
  ['changedAfter', ['attr.last_seen_at__gte']],
@@ -589,141 +593,10 @@ export function createCorpusApi(
589
593
  }
590
594
  }
591
595
 
592
- /** Every page of a DRF list, up to the cap. Stops on the first failure. */
593
- async function readAll<T>(path: string, extra: Record<string, unknown>): Promise<T[]> {
594
- const rows: T[] = [];
595
- for (let index = 1; index <= maxGraphPages; index += 1) {
596
- const response = await http.get<DrfPage<T>>(path, { params: { ...extra, page: index } });
597
- const results = response?.results ?? [];
598
- rows.push(...results);
599
- if (!response?.next || results.length === 0) break;
600
- }
601
- return rows;
602
- }
603
-
604
- // ---------------------------------------------------------------------
605
- // the participant graph
606
- // ---------------------------------------------------------------------
607
- //
608
- // THE EDGES OF THE RECORDS ON SCREEN, AND NO OTHERS (bd startsim-o0o6o.2).
609
- // This used to be `readAll(relationships, {})` — every edge in the workspace,
610
- // twenty pages of it, on a comment saying the endpoint had no filters. It has
611
- // them: `entity__in` takes the ids of one page, bounded at `MAX_ID_LIST`,
612
- // which is the shape `RelationshipQuery`'s own docstring says it exists for.
613
- //
614
- // ONE read for a page of records, not one per record — and cached per record,
615
- // so a screen that lists, opens a row and then asks a question spends it once.
616
- // It FAILS SOFT: a tenant whose relationships endpoint is missing or refused
617
- // renders exactly what it rendered before this existed, rather than an error
618
- // where a Library used to be.
619
- let roster: { at: number; value: Promise<Party[]> } | null = null;
620
- const known = new Map<string, { at: number; value: PartyRef[] }>();
621
-
622
- /**
623
- * The people an edge can point AT, read once and reused.
624
- *
625
- * Still a walked list, because there is no id filter on `/entities/`: the
626
- * recognised set is `search`, `source`, `party`, the occurred window,
627
- * `related_*`, `order` and `attr.*`, and an unrecognised `id__in` would be
628
- * swept into `ignored_filters` and answered with the whole page. It is at
629
- * least a TYPED read — `?type=party` is applied server-side — and it is only
630
- * reached when the narrowed edge read came back with edges to resolve.
631
- */
632
- function partyRoster(): Promise<Party[]> {
633
- const now = Date.now();
634
- if (!roster || now - roster.at > graphTtlMs) {
635
- roster = {
636
- at: now,
637
- value: readAll<TenantEntity>(entities, { type: types.party })
638
- .then((rows) => rows.map((entity) => toParty(entity, scope)))
639
- .catch(() => []),
640
- };
641
- }
642
- return roster.value;
643
- }
644
-
645
- /**
646
- * The edges touching these records, or `null` when the server did not confirm
647
- * it narrowed by them.
648
- *
649
- * `null` IS NOT "NO EDGES", and the difference is the whole point. A fork
650
- * without `RelationshipQuery` accepts `entity__in`, names it in
651
- * `ignored_filters` and answers with an arbitrary page of the WHOLE edge table
652
- * (bd startsim-768w.38.39) — rows that look exactly like a narrow answer and
653
- * would put the wrong people, or a fraction of the right ones, on a record.
654
- * start-simpli#154 settled what to do with a result the server did not
655
- * confirm: do not use it. So this reports that it could not ask, and the
656
- * caller renders what it rendered before the join existed.
657
- *
658
- * `rel_type` rides along unchecked on purpose: it only ever makes the answer
659
- * SMALLER, and `indexParticipants` ranks by edge type anyway. A fork that
660
- * ignores it pays in PAGES rather than in correctness — a record with many
661
- * non-participant edges can push its people onto a second page, and the walk
662
- * below follows `next` until it has them.
663
- */
664
- async function edgesFor(recordIds: string[]): Promise<TenantRelationship[] | null> {
665
- const rows: TenantRelationship[] = [];
666
- for (let start = 0; start < recordIds.length; start += MAX_ID_LIST) {
667
- // CHUNKED, because `_uuid_list` answers a longer list with a 400 rather
668
- // than truncating it. Truncating here instead would drop the people off
669
- // the tail of a wide page silently, which is the failure being undone.
670
- const chunk = recordIds.slice(start, start + MAX_ID_LIST);
671
- const extra: Record<string, unknown> = {
672
- entity__in: chunk.join(','),
673
- page_size: MAX_ID_LIST,
674
- };
675
- if (participantEdges.length) extra.rel_type = participantEdges.join(',');
676
- for (let index = 1; index <= maxGraphPages; index += 1) {
677
- const response = await http.get<DrfPage<TenantRelationship> & ServerFilterReport>(
678
- relationships,
679
- { params: { ...extra, page: index } },
680
- );
681
- const applied = response.applied_filters ?? response.appliedFilters;
682
- if (!applied?.includes('entity__in')) return null;
683
- const results = response.results ?? [];
684
- rows.push(...results);
685
- if (!response.next || results.length === 0) break;
686
- }
687
- }
688
- return rows;
689
- }
690
-
691
- async function participantsFor(
692
- records: Array<string | number>,
693
- ): Promise<Map<string, PartyRef[]>> {
694
- const out = new Map<string, PartyRef[]>();
695
- if (!resolveParticipants) return out;
696
- const now = Date.now();
697
- const wanted: string[] = [];
698
- for (const record of records) {
699
- const id = String(record ?? '').trim();
700
- if (!id || out.has(id) || wanted.includes(id)) continue;
701
- const cached = known.get(id);
702
- if (cached && now - cached.at <= graphTtlMs) out.set(id, cached.value);
703
- else wanted.push(id);
704
- }
705
- if (wanted.length === 0) return out;
706
- try {
707
- const edges = await edgesFor(wanted);
708
- // Could not ask. Nothing is cached, so the next page asks again rather
709
- // than remembering an answer that was never given.
710
- if (!edges) return out;
711
- const parties = edges.length ? await partyRoster() : [];
712
- const indexed = edges.length
713
- ? indexParticipants(edges, parties, participantEdges)
714
- : new Map<string, PartyRef[]>();
715
- for (const id of wanted) {
716
- // A record the server confirmed has no participant edges is REMEMBERED
717
- // as having none — otherwise every page re-asks for the same silence.
718
- const people = indexed.get(id) ?? [];
719
- known.set(id, { at: now, value: people });
720
- out.set(id, people);
721
- }
722
- } catch {
723
- // The Library renders without its Parties block rather than not at all.
724
- }
725
- return out;
726
- }
596
+ const { participantsFor } = createParticipantReader({
597
+ http, entities, relationships, types, scope,
598
+ participantEdges, maxGraphPages, graphTtlMs, resolveParticipants,
599
+ });
727
600
 
728
601
  return {
729
602
  ...createFilingApi(http, { entities, relationships }),
@@ -731,11 +604,21 @@ export function createCorpusApi(
731
604
  // The Tracker timeline's server reads (grouped counts + one capped page per series).
732
605
  timeline: createTimelineReader({ http, type: types.commitment, entitiesPath: entities }),
733
606
 
734
- async listDocuments(query) {
607
+ participantsFor,
608
+
609
+ async listDocuments(query, listOptions) {
735
610
  const documents = await page<TenantEntity>(types.document, query, (entity) => entity);
611
+ // `participants: false` is the Library's first paint: the rows come back as
612
+ // soon as the ONE documents read does, and the people on them are fetched
613
+ // separately (`participantsFor`) and patched in. The default stays "with
614
+ // people" so every other caller reads exactly what it always read.
615
+ //
736
616
  // Skip the edge read entirely for an empty page: an empty corpus should
737
617
  // cost exactly the one request it costs today.
738
- const byRecord = await participantsFor(documents.results.map((entity) => entity.id));
618
+ const byRecord =
619
+ listOptions?.participants === false
620
+ ? new Map<string, PartyRef[]>()
621
+ : await participantsFor(documents.results.map((entity) => entity.id));
739
622
  return {
740
623
  ...documents,
741
624
  results: documents.results.map((entity) =>
@@ -1023,7 +906,7 @@ export function createCorpusApi(
1023
906
  * unnarrowed one, so a count it did not confirm is not reported at all —
1024
907
  * and `0` is left free to mean what it says.
1025
908
  */
1026
- async listSources(): Promise<SourceFreshness[]> {
909
+ async listSources(sourceOptions?: ListSourcesOptions): Promise<SourceFreshness[]> {
1027
910
  const connectionPage = await http
1028
911
  .get<DrfPage<Record<string, unknown>>>(connections)
1029
912
  .catch(() => EMPTY_PAGE as DrfPage<Record<string, unknown>>);
@@ -1048,11 +931,20 @@ export function createCorpusApi(
1048
931
  for (const { key } of live) {
1049
932
  if (!pending.has(key)) pending.set(key, countDocumentsFrom(key));
1050
933
  }
1051
- const counts = new Map(
1052
- await Promise.all(
1053
- [...pending].map(async ([key, count]) => [key, await count] as const),
1054
- ),
1055
- );
934
+ // THE COUNTS ARE AN ORNAMENT ON A CARD WHOSE POINT IS FRESHNESS, so a caller
935
+ // that passes `onCounts` gets the cards the moment the connections answer
936
+ // and the numbers afterwards. One COUNT per source, however many cards, is
937
+ // one more request each; on a backend that answers one at a time seven of
938
+ // them stood between the reader and the strip (measured, 2026-11-20).
939
+ const settled = Promise.all(
940
+ [...pending].map(async ([key, count]) => [key, await count] as const),
941
+ ).then((entries) => new Map(entries));
942
+ let counts = new Map<string, number | null>();
943
+ if (sourceOptions?.onCounts) {
944
+ void settled.then((resolved) => sourceOptions.onCounts?.(resolved));
945
+ } else {
946
+ counts = await settled;
947
+ }
1056
948
 
1057
949
  const now = Date.now();
1058
950
  return live.map(({ connection, key }) => {
@@ -1445,8 +1337,10 @@ export function createPlanningApi(options: CreateCorpusApiOptions): PlanningApi
1445
1337
  wire.owner_sub = patch.ownerSubs[0] ?? '';
1446
1338
  }
1447
1339
  if (patch.dueAt !== undefined) wire.due_at = patch.dueAt;
1340
+ if (patch.projectBasis !== undefined) wire.project_basis = patch.projectBasis ?? '';
1448
1341
  if (patch.subtype !== undefined) wire.subtype = patch.subtype;
1449
1342
  if (patch.priority !== undefined) wire.priority = patch.priority;
1343
+ if (patch.estimateMinutes !== undefined) wire.estimate_minutes = patch.estimateMinutes;
1450
1344
  if (patch.resolvedAt !== undefined) wire.resolved_at = patch.resolvedAt;
1451
1345
  // WHEN it was finished, stamped on the transition to done only (never on
1452
1346
  // an edit to an already-done item, never over a value the caller sent):
@@ -17,14 +17,16 @@ import { speakable } from '../briefing/speak';
17
17
  import type { BriefingItem } from '../briefing/types';
18
18
  import { FLEET_FRESH_MS, ageWords } from './fleet';
19
19
  import { routeUtterance } from './route';
20
- import { spokenSummary } from './spoken-summary';
21
- import { sourcesOfDocs } from './sources';
20
+ import { spokenRest, spokenSummary, WANTS_THE_REST } from './spoken-summary';
21
+ import { askSources, sourcesOfDocs } from './sources';
22
+ import type { SourceDocument } from '../types';
22
23
  import { WRAP_UP } from './wrap-up';
23
24
  import { itemAnswer } from './item-answers';
24
25
  import { followUp, mightFollowUp, type PlayedItem } from './followups';
25
26
  import { ACTIVITY_QUESTION, composeActivity, forOwner, type Activity, type ActivityWindow } from '../activity';
27
+ import { localDate } from '../today';
26
28
  import { questionWindow } from '../ask-items-intent';
27
- import { BRIEF_ME, NEEDS_ME, buildQueue, firstPrompt, relayItemsFrom, stepBriefing, type BriefingEffect, type BriefingState } from './briefing-queue';
29
+ import { BRIEF_ME, NEEDS_ME, buildQueue, firstPrompt, relayItemsFrom, startBriefing, stepBriefing, type BriefingEffect, type BriefingState } from './briefing-queue';
28
30
  import type { ConverseBrain, ConverseSource, HistoryLine } from './types';
29
31
 
30
32
  const MIN_AUTO = 0.85;
@@ -42,7 +44,7 @@ export interface ConverseBrainDeps {
42
44
  /** What happened in a calendar window (to-dos finished or added, conversations, notes): "what did I do yesterday". Omit: those go to Ask. */
43
45
  loadActivity?(window: ActivityWindow, timeZone: string): Promise<Activity>;
44
46
  /** Answers a question over the person's items, notes and documents; the app wires `askCorpus`. */
45
- ask(input: { question: string; timeZone: string; now: number }): Promise<{ answer: string; status?: string; sources?: ConverseSource[] }>;
47
+ ask(input: { question: string; timeZone: string; now: number }): Promise<{ answer: string; status?: string; sources?: ConverseSource[]; /** Ask's own citations: used for the sources when `sources` is not given. */ citations?: Array<{ document: SourceDocument }> }>;
46
48
  minAutoConfidence?: number;
47
49
  /** Sorts a line into work for the relay / a fleet-status question / other. Omit: everything not an item edit goes to Ask. */
48
50
  routeLlm?: BriefingScriptLlm | null;
@@ -172,6 +174,15 @@ export function createConverseBrain(deps: ConverseBrainDeps): ConverseBrain {
172
174
  const effect: BriefingEffect | undefined = step.effect;
173
175
  let text = step.reply;
174
176
  let did: string[] | undefined;
177
+ if (effect?.kind === 'skip') {
178
+ // Remembered for today only: a new day brings it back.
179
+ const today = localDate(now, timeZone);
180
+ const log = await deps.log.load().catch(() => null);
181
+ if (log) {
182
+ const kept = log.skips?.date === today ? log.skips.keys : [];
183
+ await deps.log.save({ ...log, skips: { date: today, keys: [...new Set([...kept, effect.key])].slice(-200) } }).catch(() => undefined);
184
+ }
185
+ }
175
186
  if (effect?.kind === 'todo') {
176
187
  const outcome = await timed('act', () => executeVoiceActions({
177
188
  actions: [effect.action], clientActionId: `brief-${now}-${Math.abs(hash(`${utterance}${'itemId' in effect.action ? effect.action.itemId : ''}`))}`.slice(0, 64),
@@ -183,7 +194,7 @@ export function createConverseBrain(deps: ConverseBrainDeps): ConverseBrain {
183
194
  return { text, briefing: step.state, intent: 'briefing' as const, ...(did?.length ? { did } : {}), ...(effect?.kind === 'relay' ? { forRelay: true, relayText: effect.text } : {}) };
184
195
  }
185
196
 
186
- async function run({ utterance, history, timeZone, now, briefing, context }: Parameters<ConverseBrain>[0], timed: Timed): ReturnType<ConverseBrain> {
197
+ async function run({ utterance, history, timeZone, now, briefing, context, pending }: Parameters<ConverseBrain>[0], timed: Timed): ReturnType<ConverseBrain> {
187
198
  // Lines that name the relay go first, so "add a to-do for the relay" is for the relay, not a plan item.
188
199
  if (ADDRESSES_RELAY.test(utterance)) {
189
200
  const routed = await viaRoute(utterance, history, now, timed);
@@ -191,11 +202,20 @@ export function createConverseBrain(deps: ConverseBrainDeps): ConverseBrain {
191
202
  }
192
203
  // A briefing in progress: this is the answer to the item being asked.
193
204
  if (briefing) {
194
- const step = stepBriefing(briefing, utterance);
205
+ const step = stepBriefing(briefing, utterance, { now, timeZone });
195
206
  if (!step.passThrough) return applyStep(step, utterance, now, timeZone, timed);
196
207
  }
197
208
  // "Parse that note" / "that's it" / "I'm done": he is wrapping up. The turn files the conversation through the normal End.
198
209
  if (WRAP_UP.test(utterance.trim())) return { text: 'Filing it now.', finish: true, intent: 'note' as const };
210
+ // "Yes" / "the rest" right after a shortened answer: read what was left out (itself said short, with another offer when it is long).
211
+ if (!pending && WANTS_THE_REST.test(utterance.trim())) {
212
+ const lastSaid = [...history].reverse().find((l) => l.role === 'assistant')?.text;
213
+ const rest = lastSaid ? spokenRest(lastSaid) : undefined;
214
+ if (rest) {
215
+ const short = spokenSummary(rest);
216
+ return { text: rest, intent: 'question' as const, ...(short ? { spoken: short } : {}) };
217
+ }
218
+ }
199
219
  // A follow-up about the items the last answer listed ("move the second one to Friday", "tell me more about the first").
200
220
  let itemRows: BriefingItem[] | null = null;
201
221
  if (context?.items?.length && mightFollowUp(utterance)) {
@@ -233,9 +253,10 @@ export function createConverseBrain(deps: ConverseBrainDeps): ConverseBrain {
233
253
  timed('items', () => deps.loadItems().catch(() => [] as BriefingItem[])),
234
254
  timed('fleet', async () => deps.loadFleetStatus?.().catch(() => null) ?? null),
235
255
  ]);
236
- const queue = buildQueue({ items: rows, relayItems: snap ? relayItemsFrom(snap.text) : [], now, timeZone, relayFirst: NEEDS_ME.test(utterance) });
237
- if (!queue.length) return { text: 'Nothing needs you right now.', intent: 'briefing' as const };
238
- const state: BriefingState = { queue, index: 0 };
256
+ const log = await timed('log', () => deps.log.load().catch(() => null));
257
+ const skipped = log?.skips?.date === localDate(now, timeZone) ? log.skips.keys : [];
258
+ const state = startBriefing({ items: rows, relayItems: snap ? relayItemsFrom(snap.text) : [], now, timeZone, relayFirst: NEEDS_ME.test(utterance), skipped });
259
+ if (!state) return { text: 'Nothing needs you right now.', intent: 'briefing' as const };
239
260
  return { text: firstPrompt(state), briefing: state, intent: 'briefing' as const };
240
261
  }
241
262
  // A QUESTION is almost never an item edit, and the routing model does not depend on the intent model: start it now so a
@@ -258,10 +279,16 @@ export function createConverseBrain(deps: ConverseBrainDeps): ConverseBrain {
258
279
  ]);
259
280
  const open = openRows.map(intentItem);
260
281
  const intent = asking ? null : await timed('intent', () => resolveVoiceIntent(
261
- { utterance, now, timeZone, briefed: [], open, readingId: null, hasUndo: Boolean(log?.stack.length) },
282
+ { utterance, now, timeZone, briefed: [], open, readingId: null, hasUndo: Boolean(log?.stack.length), ...(pending ? { thread: pending } : {}) },
262
283
  { llm: deps.intentLlm ?? null, ...(deps.intentTimeoutMs ? { timeoutMs: deps.intentTimeoutMs } : {}) },
263
284
  ).catch(() => null));
264
285
 
286
+ // A which-one question about an instruction is asked out loud and kept, so the next words answer it ("the dad one").
287
+ const clarify = intent?.actions.length === 1 && intent.actions[0].type === 'clarify' ? intent.actions[0].question : null;
288
+ if (clarify && !pending && /\bwhich\b/i.test(clarify) && EXPLICIT_TODO.test(utterance.trim())) {
289
+ return { text: clarify, intent: 'command' as const, pending: { utterance, question: clarify } };
290
+ }
291
+
265
292
  const real = intent?.actions.filter((a) => a.type !== 'clarify' && a.type !== 'none') ?? [];
266
293
  const sure = intent && real.length === intent.actions.length && real.length > 0 && (intent.confidence ?? 1) >= (deps.minAutoConfidence ?? MIN_AUTO);
267
294
  if (intent && sure) {
@@ -269,7 +296,7 @@ export function createConverseBrain(deps: ConverseBrainDeps): ConverseBrain {
269
296
  actions: intent.actions, clientActionId: `converse-${now}-${Math.abs(hash(utterance))}`.slice(0, 64), seam: deps.seam, log: deps.log,
270
297
  ownerSub: deps.ownerSub, now: () => now, timeZone,
271
298
  }));
272
- return { text: outcome.text, did: outcome.results.map((r) => r.spoken).filter(Boolean), intent: 'command' as const };
299
+ return { text: outcome.text, did: outcome.results.map((r) => r.spoken).filter(Boolean), intent: 'command' as const, pending: null };
273
300
  }
274
301
 
275
302
  if (!ADDRESSES_RELAY.test(utterance)) {
@@ -282,8 +309,9 @@ export function createConverseBrain(deps: ConverseBrainDeps): ConverseBrain {
282
309
  const full = speakable(answered.answer ?? '', 400) || (answered.answer ?? '').trim();
283
310
  if (!full || GIVE_UP.test(full)) return { text: CANNOT_SEE, intent: 'question' as const };
284
311
  const short = spokenSummary(full);
285
- const listed: PlayedItem[] = (answered.sources ?? []).filter((x) => x.id.startsWith('item:')).map((x) => ({ id: x.id.replace(/^item:/, ''), title: x.title }));
286
- return { text: full, intent: 'question' as const, ...(short ? { spoken: short } : {}), ...(answered.sources?.length ? { sources: answered.sources } : {}), ...(listed.length ? { context: { items: listed } } : {}) };
312
+ const sources = answered.sources ?? (answered.citations ? askSources(answered) : undefined);
313
+ const listed: PlayedItem[] = (sources ?? []).filter((x) => x.id.startsWith('item:')).map((x) => ({ id: x.id.replace(/^item:/, ''), title: x.title }));
314
+ return { text: full, intent: 'question' as const, ...(short ? { spoken: short } : {}), ...(sources?.length ? { sources } : {}), ...(listed.length ? { context: { items: listed } } : {}) };
287
315
  }
288
316
 
289
317
  return async (input) => {