@startsimpli/integrations 0.2.179 → 0.2.181

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 (73) hide show
  1. package/package.json +1 -1
  2. package/src/__tests__/converse-handoff.test.ts +129 -0
  3. package/src/__tests__/converse-meeting.test.ts +41 -0
  4. package/src/__tests__/converse-relay.test.ts +19 -3
  5. package/src/__tests__/corpus-ask-projects.test.ts +74 -0
  6. package/src/__tests__/home-brief.test.tsx +12 -24
  7. package/src/__tests__/home-needs-your-call.test.tsx +13 -16
  8. package/src/__tests__/library-asks-line.test.ts +27 -0
  9. package/src/__tests__/plan-shell.test.tsx +160 -0
  10. package/src/components/DocumentDetail.tsx +15 -4
  11. package/src/components/documentText.ts +33 -0
  12. package/src/components/index.ts +1 -0
  13. package/src/components/pages/AskPage.tsx +9 -1
  14. package/src/components/pages/LibraryPage.tsx +4 -0
  15. package/src/components/pages/PlanningPage.tsx +20 -10
  16. package/src/components/pages/TrackerPage.tsx +16 -3
  17. package/src/components/pages/home/DueSoonLine.tsx +28 -0
  18. package/src/components/pages/home/HomeBriefPage.tsx +19 -52
  19. package/src/components/pages/home/index.ts +1 -3
  20. package/src/components/pages/plan/ProjectsPage.tsx +54 -0
  21. package/src/components/pages/plan/TalkPage.tsx +48 -0
  22. package/src/components/pages/plan/TimelinePage.tsx +33 -0
  23. package/src/components/pages/plan/index.ts +6 -0
  24. package/src/corpus/ask-projects.ts +94 -0
  25. package/src/corpus/ask.ts +21 -2
  26. package/src/corpus/converse/handle.ts +10 -3
  27. package/src/corpus/converse/handled-asks.ts +29 -0
  28. package/src/corpus/converse/handoff.ts +52 -0
  29. package/src/corpus/converse/index.ts +4 -2
  30. package/src/corpus/converse/meeting.ts +23 -7
  31. package/src/corpus/converse/relay.ts +8 -4
  32. package/src/corpus/converse/store.ts +2 -0
  33. package/src/corpus/converse/transcript.ts +9 -0
  34. package/src/corpus/converse/types.ts +14 -0
  35. package/src/corpus/index.ts +5 -0
  36. package/src/corpus/nav-copy.ts +31 -0
  37. package/src/corpus/view-text.ts +3 -2
  38. package/src/native/__tests__/design-screens.test.tsx +3 -2
  39. package/src/native/app/FoundryApp.tsx +1 -1
  40. package/src/native/app/__tests__/plan-talk-registry.test.tsx +74 -0
  41. package/src/native/app/briefingServices.ts +1 -0
  42. package/src/native/app/config/defaults.ts +8 -2
  43. package/src/native/app/config/types.ts +1 -1
  44. package/src/native/app/converseServices.ts +1 -0
  45. package/src/native/app/registry.tsx +26 -6
  46. package/src/native/app/services.ts +3 -2
  47. package/src/native/components/NoteDetailScreen.tsx +16 -4
  48. package/src/native/components/__tests__/notes-screens.test.tsx +8 -8
  49. package/src/native/converse/ConverseScreen.tsx +24 -5
  50. package/src/native/converse/__tests__/liveScreen.test.tsx +15 -2
  51. package/src/native/home/HomeScreen.tsx +20 -7
  52. package/src/native/home/controller.ts +15 -5
  53. package/src/native/home/tab.tsx +31 -6
  54. package/src/native/plan/NewProjectRow.tsx +30 -0
  55. package/src/native/plan/PlanTab.tsx +105 -0
  56. package/src/native/plan/ProjectTodos.tsx +24 -0
  57. package/src/native/plan/TimelineScreen.tsx +68 -0
  58. package/src/native/plan/__tests__/plan-tab.test.tsx +76 -0
  59. package/src/native/plan/index.ts +5 -0
  60. package/src/native/plan/timeline.ts +56 -0
  61. package/src/native/recording/__tests__/recorderAudio.test.ts +10 -2
  62. package/src/native/recording/recorderAudio.ts +6 -2
  63. package/src/native/screens/__tests__/tabs.test.tsx +13 -0
  64. package/src/native/screens/ask/AskScreen.tsx +4 -2
  65. package/src/native/screens/library/LibraryDetailScreen.tsx +11 -4
  66. package/src/native/screens/planning/PlanningScreens.tsx +30 -13
  67. package/src/native/screens/tabs.tsx +5 -4
  68. package/src/native/talk/TalkTab.tsx +65 -0
  69. package/src/native/talk/__tests__/talk-tab.test.tsx +57 -0
  70. package/src/native/tracker/TrackerListScreen.tsx +7 -3
  71. package/src/native/tracker/tab.tsx +33 -8
  72. package/src/components/pages/home/DueAcrossProjects.tsx +0 -76
  73. package/src/components/pages/home/RecentNotes.tsx +0 -69
@@ -7,13 +7,13 @@ import * as React from 'react';
7
7
 
8
8
  import { Markdown } from './Markdown';
9
9
  import { FiledUnder } from './FiledUnder';
10
- import { formatDate, fullTextOf, summaryOf } from './documentText';
10
+ import { formatDate, fullTextOf, summaryOf, todosInPlanText, withoutNextSteps } from './documentText';
11
11
  import type { CorpusApi, CorpusScope, SourceDocument } from '../corpus/types';
12
12
 
13
13
  type DetailSlots = Record<'card' | 'heading' | 'badge' | 'button' | 'input' | 'muted' | 'error' | 'warning', string>;
14
14
 
15
15
  export function DocumentDetail({
16
- document, scope, api, classNames: cn, onClose, onFilterByParty,
16
+ document, scope, api, classNames: cn, onClose, onFilterByParty, onOpenPlan,
17
17
  }: {
18
18
  document: SourceDocument;
19
19
  scope: CorpusScope;
@@ -21,6 +21,8 @@ export function DocumentDetail({
21
21
  classNames: DetailSlots;
22
22
  onClose: () => void;
23
23
  onFilterByParty: (partyId: string) => void;
24
+ /** Open Plan, where this note's to-dos are listed. */
25
+ onOpenPlan?: () => void;
24
26
  }) {
25
27
  // Defense in depth. The API scopes reads and Postgres RLS scopes them again,
26
28
  // but a record that reached this component from the wrong workspace must not
@@ -33,6 +35,9 @@ export function DocumentDetail({
33
35
  );
34
36
  }
35
37
 
38
+ // The to-dos live only in Plan: the note shows its prose and a link, not its own list.
39
+ const summary = withoutNextSteps(summaryOf(document));
40
+
36
41
  return (
37
42
  <section className={cn.card} aria-label="Record detail">
38
43
  <div className="flex items-start justify-between gap-4">
@@ -85,15 +90,21 @@ export function DocumentDetail({
85
90
  delivered a full text. The moment `ingest_transcripts` lands, `body` is
86
91
  forty minutes of verbatim speech, and it would have appeared on this
87
92
  screen labelled "Summary" while the actual summary appeared nowhere. */}
88
- {summaryOf(document) ? (
93
+ {summary.text ? (
89
94
  <div className="mt-3">
90
95
  <p className="text-sm font-medium text-gray-900">Summary</p>
91
96
  {/* Sources write Markdown — a literal "## Decisions" on the screen
92
97
  reads as a broken product, not as the source's punctuation. */}
93
- <Markdown text={summaryOf(document)} className="mt-1 text-sm text-gray-700" />
98
+ <Markdown text={summary.text} className="mt-1 text-sm text-gray-700" />
94
99
  </div>
95
100
  ) : null}
96
101
 
102
+ {summary.todos > 0 ? (
103
+ <p className="mt-3 text-sm text-gray-700" data-testid="todos-in-plan">
104
+ {todosInPlanText(summary.todos)}{onOpenPlan ? <>{' '}<button type="button" className="text-blue-700 underline" onClick={onOpenPlan}>Open Plan</button></> : null}
105
+ </p>
106
+ ) : null}
107
+
97
108
  {/* The FULL text, collapsed, next to the source's other long-form. Behind
98
109
  a disclosure and not open by default, for the same reason a transcript
99
110
  is opt-in at all: verbatim speech is a different data class from a
@@ -29,3 +29,36 @@ export function fullTextOf(document: SourceDocument): string {
29
29
  const body = document.body ?? '';
30
30
  return body && body !== summaryOf(document) ? body : '';
31
31
  }
32
+
33
+ /** Headings that introduce a note's list of to-dos: a Conversation's "Asks", a note's "Next steps", and their cousins. */
34
+ const TODO_HEADING = /^(?:next\s+steps?|asks?|action\s+items?|to-?dos?|follow-?\s?ups?)$/i;
35
+ const BULLET = /^\s*(?:[-*+]|\d+[.)])\s+\S/;
36
+
37
+ /**
38
+ * A record's markdown without its to-do list, and how many to-dos that list held. The to-dos live only in Plan
39
+ * (Quinn, 2026-11-16): a record shows its prose and a link, never a second to-do list. TEXT-BASED and applied when
40
+ * rendering, so a record filed before that change shows it too. A list is introduced by a markdown heading
41
+ * (`## Asks`), a bold line (`**Next steps**`) or a colon line (`Asks:`) and runs until the next heading.
42
+ */
43
+ export function withoutNextSteps(markdown: string): { text: string; todos: number } {
44
+ const lines = (markdown ?? '').split('\n');
45
+ const out: string[] = [];
46
+ let skipping = false;
47
+ let todos = 0;
48
+ for (const line of lines) {
49
+ const heading = line.match(/^\s*#{1,6}\s+(.+?)\s*$/);
50
+ const bold = line.match(/^\s*\*\*(.+?)\*\*:?\s*$/);
51
+ const colon = line.match(/^\s*([A-Za-z][A-Za-z -]{1,24}):\s*$/);
52
+ const title = (heading ?? bold ?? colon)?.[1]?.replace(/:$/, '').trim();
53
+ if (heading || ((bold || colon) && title && TODO_HEADING.test(title))) skipping = Boolean(title && TODO_HEADING.test(title));
54
+ if (skipping) {
55
+ if (BULLET.test(line)) todos += 1;
56
+ continue;
57
+ }
58
+ out.push(line);
59
+ }
60
+ return { text: out.join('\n').replace(/\n{3,}/g, '\n\n').trim(), todos };
61
+ }
62
+
63
+ /** `N to-dos from this note are in Plan.` */
64
+ export const todosInPlanText = (n: number): string => `${n} to-do${n === 1 ? '' : 's'} from this note ${n === 1 ? 'is' : 'are'} in Plan.`;
@@ -80,3 +80,4 @@ export type { VoiceRecordButtonProps, VoiceRecordClassNames } from './pages/Voic
80
80
  export * from './pages/home';
81
81
  export * from './pages/questions';
82
82
  export * from './pages/task-tracker/OwnerPicker';
83
+ export * from './pages/plan';
@@ -32,6 +32,7 @@
32
32
  import * as React from 'react';
33
33
 
34
34
  import { itemIdOf } from '../../corpus/ask-items';
35
+ import { projectIdOf } from '../../corpus/ask-projects';
35
36
  import { Markdown, stripMarkdown } from '../Markdown';
36
37
  import {
37
38
  UNCITED_NOTICE, askFailureMessage as failureMessage, droppedNotice, freshnessNotice,
@@ -53,6 +54,8 @@ export interface AskPageProps {
53
54
  onOpenDocument?: (documentId: string) => void;
54
55
  /** Click-through from a cited TRACKED ITEM (an `item:` record) to the item, by its external id. */
55
56
  onOpenItem?: (itemId: string) => void;
57
+ /** Click-through from a cited PROJECT (a `project:` record) to the project, by its id. */
58
+ onOpenProject?: (projectId: string) => void;
56
59
  /** Prefill, e.g. from a `?q=` param. */
57
60
  initialQuestion?: string;
58
61
  initialMode?: AskMode;
@@ -106,6 +109,7 @@ export function AskPage({
106
109
  scope,
107
110
  onOpenDocument,
108
111
  onOpenItem,
112
+ onOpenProject,
109
113
  initialQuestion = '',
110
114
  initialMode = 'ask',
111
115
  listProjects,
@@ -235,6 +239,7 @@ export function AskPage({
235
239
  classNames={cn}
236
240
  onOpenDocument={onOpenDocument}
237
241
  onOpenItem={onOpenItem}
242
+ onOpenProject={onOpenProject}
238
243
  canSave={canSave}
239
244
  saveState={saveState}
240
245
  onSave={async () => {
@@ -262,12 +267,13 @@ export function AskPage({
262
267
  // ---------------------------------------------------------------------------
263
268
 
264
269
  function AnswerPanel({
265
- result, classNames: cn, onOpenDocument, onOpenItem, canSave, saveState, onSave,
270
+ result, classNames: cn, onOpenDocument, onOpenItem, onOpenProject, canSave, saveState, onSave,
266
271
  }: {
267
272
  result: AskResult;
268
273
  classNames: Record<AskSlot, string>;
269
274
  onOpenDocument?: (documentId: string) => void;
270
275
  onOpenItem?: (itemId: string) => void;
276
+ onOpenProject?: (projectId: string) => void;
271
277
  canSave: boolean;
272
278
  saveState: 'idle' | 'saving' | 'saved';
273
279
  onSave: () => void;
@@ -335,7 +341,9 @@ function AnswerPanel({
335
341
  className="text-sm font-medium text-blue-700 underline"
336
342
  onClick={() => {
337
343
  const itemId = itemIdOf(citation.documentId);
344
+ const projectId = projectIdOf(citation.documentId);
338
345
  if (itemId) onOpenItem?.(itemId);
346
+ else if (projectId) onOpenProject?.(projectId);
339
347
  else onOpenDocument?.(citation.documentId);
340
348
  }}
341
349
  >
@@ -45,6 +45,8 @@ import type {
45
45
 
46
46
  export interface LibraryPageProps {
47
47
  api: CorpusApi;
48
+ /** Open Plan: a note's to-dos are listed there, never in the note. */
49
+ onOpenPlan?: () => void;
48
50
  /** The asking principal's tenant scope. Rows outside it are never rendered. */
49
51
  scope: CorpusScope;
50
52
  /** Open straight onto one record — how a citation from the Ask surface lands. */
@@ -124,6 +126,7 @@ function relative(value: string | null | undefined, now: number): string {
124
126
 
125
127
  export function LibraryPage({
126
128
  api,
129
+ onOpenPlan,
127
130
  scope,
128
131
  initialDocumentId,
129
132
  onSelectDocument,
@@ -654,6 +657,7 @@ export function LibraryPage({
654
657
  classNames={cn}
655
658
  onClose={() => select(null)}
656
659
  onFilterByParty={(partyId) => update({ partyId })}
660
+ onOpenPlan={onOpenPlan}
657
661
  />
658
662
  ) : null}
659
663
 
@@ -56,11 +56,11 @@ import type {
56
56
  PlanningApi,
57
57
  } from '../../corpus/types';
58
58
 
59
- type PlanningSlot =
59
+ export type PlanningSlot =
60
60
  | 'root' | 'section' | 'heading' | 'card' | 'badge' | 'button' | 'secondaryButton'
61
61
  | 'input' | 'muted' | 'error' | 'warning' | 'row' | 'due' | 'progressTrack' | 'progressBar';
62
62
 
63
- const DEFAULTS: Record<PlanningSlot, string> = {
63
+ export const PLANNING_DEFAULTS: Record<PlanningSlot, string> = {
64
64
  root: 'space-y-6',
65
65
  section: 'space-y-3',
66
66
  heading: 'text-lg font-semibold text-gray-900',
@@ -129,13 +129,18 @@ export interface PlanningPageProps {
129
129
  */
130
130
  focusId?: string | null;
131
131
  onFocusChange?: (focusId: string | null) => void;
132
+ /**
133
+ * Replaces the open project's own item list. Plan passes the shared to-do list filtered to
134
+ * this project, so a project never carries a second list of its own.
135
+ */
136
+ renderItems?: (focus: Focus) => React.ReactNode;
132
137
  classNames?: Partial<Record<PlanningSlot, string>>;
133
138
  }
134
139
 
135
140
  export function PlanningPage({
136
- api, scope, onOpenDocument, now, timeZone, focusId, onFocusChange, classNames = {},
141
+ api, scope, onOpenDocument, now, timeZone, focusId, onFocusChange, renderItems, classNames = {},
137
142
  }: PlanningPageProps) {
138
- const cn = { ...DEFAULTS, ...classNames };
143
+ const cn = { ...PLANNING_DEFAULTS, ...classNames };
139
144
 
140
145
  // Frozen once. See the note on the prop.
141
146
  const [mountedAt] = React.useState(() => Date.now());
@@ -372,7 +377,7 @@ export function PlanningPage({
372
377
  {showAll ? 'Show fewer' : `Show all ${overview.length}`}
373
378
  </button>
374
379
  ) : null}
375
- {unfiled ? <p className={cn.muted}>{unfiled} open item{unfiled === 1 ? ' is' : 's are'} not filed under a focus. Open the Tracker to see them.</p> : null}
380
+ {unfiled ? <p className={cn.muted}>{unfiled} open item{unfiled === 1 ? ' is' : 's are'} not filed under a focus. Open Plan to see them.</p> : null}
376
381
  </section>
377
382
  {drawer}
378
383
  </div>
@@ -384,7 +389,7 @@ export function PlanningPage({
384
389
  <section className={cn.section} aria-label="Focus">
385
390
  <div className="flex flex-wrap items-center gap-2">
386
391
  <button type="button" className={cn.secondaryButton} onClick={() => { setSelected(null); setShowDone(false); }}>
387
- ← All focuses
392
+ ← All projects
388
393
  </button>
389
394
  {warningChip}
390
395
  </div>
@@ -399,6 +404,9 @@ export function PlanningPage({
399
404
  {error ? <p className={cn.error} role="alert">{error}</p> : null}
400
405
  </section>
401
406
 
407
+ {renderItems ? (
408
+ <section className={cn.section} aria-label="To-dos">{renderItems(selectedFocus)}</section>
409
+ ) : (
402
410
  <section className={cn.section} aria-label="Items">
403
411
  <div className="flex flex-wrap items-center gap-2">
404
412
  <h2 className={cn.heading}>
@@ -467,6 +475,7 @@ export function PlanningPage({
467
475
  />
468
476
  ))}
469
477
  </section>
478
+ )}
470
479
 
471
480
  {api.listDocuments ? (
472
481
  <FocusDocuments
@@ -537,7 +546,8 @@ function FocusCard({
537
546
 
538
547
  // ---------------------------------------------------------------------------
539
548
 
540
- function NewFocusForm({
549
+ /** The create form, shared with the Projects sub-tab. */
550
+ export function NewFocusForm({
541
551
  classNames: cn, onCreate, onError,
542
552
  }: {
543
553
  classNames: Record<PlanningSlot, string>;
@@ -552,7 +562,7 @@ function NewFocusForm({
552
562
  if (!open) {
553
563
  return (
554
564
  <button type="button" className={`${cn.secondaryButton} ml-auto`} onClick={() => setOpen(true)}>
555
- New focus
565
+ New project
556
566
  </button>
557
567
  );
558
568
  }
@@ -576,7 +586,7 @@ function NewFocusForm({
576
586
  }}
577
587
  >
578
588
  <label>
579
- <span className="sr-only">Focus title</span>
589
+ <span className="sr-only">Project title</span>
580
590
  <input
581
591
  className={cn.input}
582
592
  value={title}
@@ -597,7 +607,7 @@ function NewFocusForm({
597
607
  </select>
598
608
  </label>
599
609
  <button type="submit" className={cn.button} disabled={busy || !title.trim()}>
600
- {busy ? 'Adding…' : 'Add focus'}
610
+ {busy ? 'Adding…' : 'Add project'}
601
611
  </button>
602
612
  <button type="button" className={cn.secondaryButton} onClick={() => setOpen(false)}>
603
613
  Cancel
@@ -100,6 +100,16 @@ export interface TrackerPageProps {
100
100
  projectNames?: Record<string, string>;
101
101
  /** The reader's IANA zone, for "today". Default UTC. */
102
102
  timeZone?: string;
103
+ /**
104
+ * Draw the created/done/overdue timeline strip under the filters. Default true. The Plan
105
+ * shell turns it off here and mounts `TrackerTimelinePage` as its own Timeline sub-tab.
106
+ */
107
+ showTimeline?: boolean;
108
+ /**
109
+ * Only the to-dos filed under this project (a SERVER filter: `CommitmentQuery.focus`). A to-do
110
+ * added from the box is filed under it too. This is how a project's to-dos are "the same list, filtered".
111
+ */
112
+ focusId?: string;
103
113
  classNames?: Partial<Record<TrackerSlot, string>>;
104
114
  }
105
115
 
@@ -140,6 +150,8 @@ export function TrackerPage({
140
150
  memberConnections,
141
151
  projectNames = {},
142
152
  timeZone,
153
+ showTimeline = true,
154
+ focusId,
143
155
  classNames = {},
144
156
  }: TrackerPageProps) {
145
157
  const foundTracker = useTrackerName(trackerNameProp ? undefined : memberConnections);
@@ -192,9 +204,10 @@ export function TrackerPage({
192
204
  // the first page.
193
205
  status: ['open', 'in_progress', 'blocked'] as CommitmentStatus[],
194
206
  withFocus: true,
207
+ ...(focusId ? { focus: focusId } : {}),
195
208
  pageSize: 200,
196
209
  }),
197
- [sort],
210
+ [sort, focusId],
198
211
  );
199
212
 
200
213
  const load = React.useCallback(async () => {
@@ -392,7 +405,7 @@ export function TrackerPage({
392
405
  setAdding(true);
393
406
  setError('');
394
407
  try {
395
- await apiRef.current.createCommitment!({ title });
408
+ await apiRef.current.createCommitment!({ title, ...(focusId ? { focusId } : {}) });
396
409
  setDraftTitle('');
397
410
  await loadRef.current();
398
411
  } catch (err) {
@@ -466,7 +479,7 @@ export function TrackerPage({
466
479
  ))}
467
480
  </div>
468
481
  ) : null}
469
- {api.timeline ? (
482
+ {showTimeline && api.timeline ? (
470
483
  <TrackerTimeline
471
484
  api={api} orgId={scope.orgId} now={clock} timeZone={timeZone}
472
485
  filter={filterFromChip(quick, { search: filterText })}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * The one line Today keeps about to-dos: how many are overdue, due today and due this
3
+ * week, and the way into Plan. It names no to-do: the list is Plan's alone.
4
+ */
5
+ import type { DueGroups } from '../../../corpus/due-groups';
6
+
7
+ const count = (due: DueGroups, bucket: string) => due.groups.find((g) => g.bucket === bucket)?.entries.length ?? 0;
8
+
9
+ export function dueSoonText(due: DueGroups): string {
10
+ const overdue = count(due, 'overdue');
11
+ const today = count(due, 'today');
12
+ const week = count(due, 'week');
13
+ const parts = [
14
+ overdue ? `${overdue} overdue` : '',
15
+ today ? `${today} due today` : '',
16
+ week ? `${week} due this week` : '',
17
+ ].filter(Boolean);
18
+ return parts.length ? parts.join(' · ') : 'Nothing is due soon.';
19
+ }
20
+
21
+ export function DueSoonLine({ due, onOpenPlan }: { due: DueGroups; onOpenPlan?: () => void }) {
22
+ return (
23
+ <p className="text-sm text-gray-700" data-testid="due-soon">
24
+ {dueSoonText(due)}
25
+ {onOpenPlan ? <>{' '}<button type="button" className="text-blue-700 underline" onClick={onOpenPlan}>Open Plan</button></> : null}
26
+ </p>
27
+ );
28
+ }
@@ -1,31 +1,27 @@
1
1
  /**
2
- * HOME — three things, fast to scan (bd startsim-cpzoz): today's brief (the text
3
- * the app speaks), what is due across projects, and the recent notes with the
4
- * actions that came out of them.
2
+ * TODAY — the morning brief (the text the app speaks), the questions waiting for
3
+ * you, and ONE short line on what is due soon with the way into Plan (bd
4
+ * startsim-cpzoz). The to-do list itself lives only in Plan: Today never draws
5
+ * its own copy of it.
5
6
  *
6
7
  * `<HomeBriefPage brief={...} corpus={...} />` is the whole integration; an app
7
8
  * adds a heading and navigation callbacks. Everything is read through the same
8
- * injected corpus clients as the other page composers, and every list is a
9
- * server-paginated read (one page each): open items with their project, the
10
- * last 30 days of changed items for the notes join, the newest documents, and
11
- * the project names.
9
+ * injected corpus clients as the other page composers: one server-paginated read
10
+ * of open items (for the due-soon counts and the question titles) and the project
11
+ * names.
12
12
  */
13
13
  import * as React from 'react';
14
14
 
15
15
  import { groupDue } from '../../../corpus/due-groups';
16
16
  import { isTask } from '../../../corpus/tracker-groups';
17
- import { actionsByNote } from '../../../corpus/note-actions';
18
17
  import { failureMessage } from '../../../corpus/work-item-logic';
19
18
  import type { Commitment, CommitmentApi, CorpusApi, Focus, PlanningApi } from '../../../corpus/types';
20
19
  import { applyAnswerToItem, type OpenQuestion, type QuestionAnswer } from '../../../corpus/questions';
21
20
  import { NeedsYourCall } from '../questions/NeedsYourCall';
22
21
  import type { NeedsYourCallApi } from '../questions/types';
23
22
  import { BriefCard, type BriefCardApi } from './BriefCard';
24
- import { DueAcrossProjects } from './DueAcrossProjects';
25
- import { RecentNotes, type RecentNote } from './RecentNotes';
23
+ import { DueSoonLine } from './DueSoonLine';
26
24
 
27
- const NOTE_SUBTYPES = new Set(['meeting', 'voice_note']);
28
- const DAY = 86_400_000;
29
25
 
30
26
  export interface HomeBriefPageProps {
31
27
  brief: BriefCardApi;
@@ -38,28 +34,17 @@ export interface HomeBriefPageProps {
38
34
  now?: number;
39
35
  trackerName?: string;
40
36
  onAsk?: () => void;
41
- onOpenTracker?: () => void;
42
- onOpenNote?: (documentId: string) => void;
37
+ /** The way into Plan (the to-do list). */
38
+ onOpenPlan?: () => void;
43
39
  onOpenItem?: (item: Commitment) => void;
44
- /** How many recent notes to list. Default 6. */
45
- noteCount?: number;
46
40
  /** Tandem's open questions ("Needs your call"). Absent = no such section. */
47
41
  questions?: NeedsYourCallApi;
48
42
  }
49
43
 
50
- interface Data { open: Commitment[]; recent: Commitment[]; notes: RecentNote[]; names: Record<string, string> }
51
-
52
- function Section({ title, children }: { title: string; children: React.ReactNode }) {
53
- return (
54
- <section className="space-y-3">
55
- <h2 className="text-lg font-semibold text-gray-900">{title}</h2>
56
- {children}
57
- </section>
58
- );
59
- }
44
+ interface Data { open: Commitment[]; names: Record<string, string> }
60
45
 
61
46
  export function HomeBriefPage({
62
- brief, weekly, corpus, listFocuses, timeZone, now, trackerName, onAsk, onOpenTracker, onOpenNote, onOpenItem, noteCount = 6, questions,
47
+ brief, weekly, corpus, listFocuses, timeZone, now, onAsk, onOpenPlan, onOpenItem, questions,
63
48
  }: HomeBriefPageProps) {
64
49
  // Frozen once: a clock that changes every render re-fires the load effect.
65
50
  const [mountedAt] = React.useState(() => Date.now());
@@ -76,19 +61,13 @@ export function HomeBriefPage({
76
61
  (async () => {
77
62
  const c = corpusRef.current;
78
63
  try {
79
- const [open, recent, docs, focuses] = await Promise.all([
64
+ const [open, focuses] = await Promise.all([
80
65
  c.listCommitments({ status: ['open', 'in_progress', 'blocked'], withFocus: true, pageSize: 200 }),
81
- c.listCommitments({ changedAfter: new Date(clock - 30 * DAY).toISOString(), pageSize: 200 }),
82
- c.listDocuments({ order: 'recent', occurredAfter: new Date(clock - 30 * DAY).toISOString(), pageSize: noteCount * 3 }),
83
66
  focusesRef.current ? focusesRef.current({ pageSize: 200 }).then((p) => p.results).catch((): Focus[] => []) : Promise.resolve([] as Focus[]),
84
67
  ]);
85
68
  if (!live) return;
86
- const noteDocs = docs.results.filter((d) => NOTE_SUBTYPES.has(d.subtype ?? '')).slice(0, noteCount);
87
- const joined = actionsByNote([...open.results, ...recent.results], noteDocs.map((d) => d.id));
88
69
  setData({
89
70
  open: open.results,
90
- recent: recent.results,
91
- notes: noteDocs.map((doc) => ({ doc, actions: joined.get(doc.id)! })),
92
71
  names: Object.fromEntries(focuses.map((f) => [f.id, f.title])),
93
72
  });
94
73
  } catch (err) {
@@ -96,21 +75,17 @@ export function HomeBriefPage({
96
75
  }
97
76
  })();
98
77
  return () => { live = false; };
99
- }, [clock, noteCount, corpus]);
78
+ }, [clock, corpus]);
100
79
 
101
80
  // An answer shows on its to-do the moment it is tapped; a failed save drops it again.
102
81
  const [applied, setApplied] = React.useState<Record<string, { q: OpenQuestion; answer: QuestionAnswer }>>({});
103
- const [guessed, setGuessed] = React.useState<ReadonlySet<string>>(new Set());
104
82
  const due = React.useMemo(() => {
105
83
  if (!data) return null;
106
84
  const answers = Object.values(applied);
107
85
  const open = answers.length ? data.open.map((item) => answers.reduce((cur, { q, answer }) => applyAnswerToItem(cur, q, answer), item)) : data.open;
108
86
  return groupDue(open.filter(isTask), { now: clock, timeZone });
109
87
  }, [data, applied, clock, timeZone]);
110
- const titles = React.useMemo(() => new Map((data ? [...data.open, ...data.recent] : []).map((i) => [i.id, i.title])), [data]);
111
- const onOpenQuestions = React.useCallback((open: OpenQuestion[]) => {
112
- setGuessed(new Set(open.filter((q) => q.kind === 'due_date' && q.assumed?.value).map((q) => q.itemId)));
113
- }, []);
88
+ const titles = React.useMemo(() => new Map((data ? data.open : []).map((i) => [i.id, i.title])), [data]);
114
89
 
115
90
  return (
116
91
  <div className="space-y-8">
@@ -120,22 +95,14 @@ export function HomeBriefPage({
120
95
  {questions ? (
121
96
  <NeedsYourCall
122
97
  api={questions} itemTitle={(id) => titles.get(id)} projectNames={data?.names} timeZone={timeZone} now={now}
123
- onOpenQuestions={onOpenQuestions}
124
98
  onApplied={(q, answer) => setApplied((a) => ({ ...a, [q.id]: { q, answer } }))}
125
99
  onReverted={(q) => setApplied(({ [q.id]: _gone, ...rest }) => rest)}
126
- onOpenItem={onOpenItem ? (id) => { const item = data?.open.find((i) => i.id === id) ?? data?.recent.find((i) => i.id === id); if (item) onOpenItem(item); } : undefined}
100
+ onOpenItem={onOpenItem ? (id) => { const item = data?.open.find((i) => i.id === id); if (item) onOpenItem(item); } : undefined}
127
101
  />
128
102
  ) : null}
129
- <Section title="Due across projects">
130
- {due && data ? (
131
- <DueAcrossProjects due={due} projectNames={data.names} guessed={guessed} trackerName={trackerName} onOpen={onOpenItem} onSeeAll={onOpenTracker} />
132
- ) : error ? null : <p className="text-sm text-gray-500">Loading…</p>}
133
- </Section>
134
- <Section title="Recent notes">
135
- {data ? (
136
- <RecentNotes notes={data.notes} projectNames={data.names} now={clock} timeZone={timeZone} onOpenNote={onOpenNote} onOpenItem={onOpenItem} />
137
- ) : error ? null : <p className="text-sm text-gray-500">Loading…</p>}
138
- </Section>
103
+ {due && data ? (
104
+ <DueSoonLine due={due} onOpenPlan={onOpenPlan} />
105
+ ) : error ? null : <p className="text-sm text-gray-500">Loading…</p>}
139
106
  </div>
140
107
  );
141
108
  }
@@ -2,9 +2,7 @@ export { BriefCard } from './BriefCard';
2
2
  export type { BriefCardApi } from './BriefCard';
3
3
  export { CompactItemRow, dueLabel } from './CompactItemRow';
4
4
  export type { CompactItemRowProps } from './CompactItemRow';
5
- export { DueAcrossProjects } from './DueAcrossProjects';
6
- export { RecentNotes } from './RecentNotes';
7
- export type { RecentNote } from './RecentNotes';
5
+ export { DueSoonLine, dueSoonText } from './DueSoonLine';
8
6
  export { HomeBriefPage } from './HomeBriefPage';
9
7
  export type { HomeBriefPageProps } from './HomeBriefPage';
10
8
  export { useProjectNames } from './useProjectNames';
@@ -0,0 +1,54 @@
1
+ 'use client';
2
+
3
+ /**
4
+ * PLAN > PROJECTS: projects and goals as ONE thing (a goal and a focus are the same
5
+ * row). The list is the goals table with progress, plus the create form; opening one
6
+ * shows the project header and progress history, and its to-dos are the SAME shared
7
+ * to-do list filtered to the project (`renderTodos`), never a second list.
8
+ */
9
+ import * as React from 'react';
10
+
11
+ import type { CorpusScope, Focus, PlanningApi } from '../../../corpus/types';
12
+ import { GoalsPage } from '../goals/GoalsPage';
13
+ import { NewFocusForm, PLANNING_DEFAULTS, PlanningPage } from '../PlanningPage';
14
+
15
+ export interface ProjectsPageProps {
16
+ api: PlanningApi;
17
+ scope: CorpusScope;
18
+ /** Controlled selection: the open project, or null for the list. */
19
+ focusId: string | null;
20
+ onFocusChange: (focusId: string | null) => void;
21
+ /** The to-do list for one project: the host mounts the shared list with `focusId` set. */
22
+ renderTodos: (focus: Focus) => React.ReactNode;
23
+ onOpenDocument?: (documentId: string) => void;
24
+ now?: number;
25
+ timeZone?: string;
26
+ }
27
+
28
+ export function ProjectsPage({ api, scope, focusId, onFocusChange, renderTodos, onOpenDocument, now, timeZone }: ProjectsPageProps) {
29
+ const [epoch, setEpoch] = React.useState(0);
30
+ const [error, setError] = React.useState('');
31
+ if (focusId) {
32
+ return (
33
+ <PlanningPage
34
+ api={api} scope={scope} focusId={focusId} onFocusChange={onFocusChange}
35
+ renderItems={renderTodos} onOpenDocument={onOpenDocument} now={now} timeZone={timeZone}
36
+ />
37
+ );
38
+ }
39
+ return (
40
+ <div className="space-y-4">
41
+ {api.createFocus ? (
42
+ <div className="flex items-center">
43
+ <NewFocusForm
44
+ classNames={PLANNING_DEFAULTS}
45
+ onCreate={async (draft) => { await api.createFocus!(draft); setEpoch((n) => n + 1); }}
46
+ onError={setError}
47
+ />
48
+ </div>
49
+ ) : null}
50
+ {error ? <p className="text-sm text-red-600" role="alert">{error}</p> : null}
51
+ <GoalsPage key={epoch} api={api} scope={scope} now={now} timeZone={timeZone} onOpenFocus={onFocusChange} />
52
+ </div>
53
+ );
54
+ }
@@ -0,0 +1,48 @@
1
+ 'use client';
2
+
3
+ /**
4
+ * TALK: one screen for speaking to Tandem. Two modes over the same assistant: Talk
5
+ * (start talking, or type: plans and notes, and the asks you make become to-dos) and
6
+ * Ask (a question, answered with the sources it came from). Each mode is the existing
7
+ * composer, mounted by the host; this file only owns the toggle and the one-line subtitle.
8
+ */
9
+ import * as React from 'react';
10
+
11
+ import { TALK_MODES, type TalkMode } from '../../../corpus/nav-copy';
12
+
13
+ export interface TalkPageProps {
14
+ mode: TalkMode;
15
+ onModeChange: (mode: TalkMode) => void;
16
+ /** The `ConversePage`. */
17
+ talk: React.ReactNode;
18
+ /** The `AskPage`. */
19
+ ask: React.ReactNode;
20
+ classNames?: Partial<Record<'root' | 'tabs' | 'tab' | 'tabActive' | 'subtitle', string>>;
21
+ }
22
+
23
+ const DEFAULTS = {
24
+ root: 'space-y-4',
25
+ tabs: 'inline-flex overflow-hidden rounded-md border border-gray-300',
26
+ tab: 'px-4 py-1.5 text-sm text-gray-700',
27
+ tabActive: 'bg-gray-900 px-4 py-1.5 text-sm text-white',
28
+ subtitle: 'text-sm text-gray-500',
29
+ };
30
+
31
+ export function TalkPage({ mode, onModeChange, talk, ask, classNames = {} }: TalkPageProps) {
32
+ const cn = { ...DEFAULTS, ...classNames };
33
+ const current = TALK_MODES.find((m) => m.key === mode) ?? TALK_MODES[0];
34
+ return (
35
+ <div className={cn.root}>
36
+ <div role="tablist" aria-label="Talk mode" className={cn.tabs}>
37
+ {TALK_MODES.map((m) => (
38
+ <button
39
+ key={m.key} type="button" role="tab" aria-selected={m.key === current.key}
40
+ className={m.key === current.key ? cn.tabActive : cn.tab} onClick={() => onModeChange(m.key)}
41
+ >{m.label}</button>
42
+ ))}
43
+ </div>
44
+ <p className={cn.subtitle} data-testid="talk-mode-subtitle">{current.subtitle}</p>
45
+ {current.key === 'ask' ? ask : talk}
46
+ </div>
47
+ );
48
+ }