@startsimpli/integrations 0.2.179 → 0.2.180

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 (68) hide show
  1. package/package.json +3 -3
  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__/home-brief.test.tsx +12 -24
  6. package/src/__tests__/home-needs-your-call.test.tsx +13 -16
  7. package/src/__tests__/plan-shell.test.tsx +160 -0
  8. package/src/components/DocumentDetail.tsx +15 -4
  9. package/src/components/documentText.ts +24 -0
  10. package/src/components/index.ts +1 -0
  11. package/src/components/pages/LibraryPage.tsx +4 -0
  12. package/src/components/pages/PlanningPage.tsx +20 -10
  13. package/src/components/pages/TrackerPage.tsx +16 -3
  14. package/src/components/pages/home/DueSoonLine.tsx +28 -0
  15. package/src/components/pages/home/HomeBriefPage.tsx +19 -52
  16. package/src/components/pages/home/index.ts +1 -3
  17. package/src/components/pages/plan/ProjectsPage.tsx +54 -0
  18. package/src/components/pages/plan/TalkPage.tsx +48 -0
  19. package/src/components/pages/plan/TimelinePage.tsx +33 -0
  20. package/src/components/pages/plan/index.ts +6 -0
  21. package/src/corpus/converse/handle.ts +10 -3
  22. package/src/corpus/converse/handled-asks.ts +29 -0
  23. package/src/corpus/converse/handoff.ts +52 -0
  24. package/src/corpus/converse/index.ts +4 -2
  25. package/src/corpus/converse/meeting.ts +23 -7
  26. package/src/corpus/converse/relay.ts +8 -4
  27. package/src/corpus/converse/store.ts +2 -0
  28. package/src/corpus/converse/transcript.ts +9 -0
  29. package/src/corpus/converse/types.ts +14 -0
  30. package/src/corpus/index.ts +2 -0
  31. package/src/corpus/nav-copy.ts +31 -0
  32. package/src/corpus/view-text.ts +3 -2
  33. package/src/native/__tests__/design-screens.test.tsx +3 -2
  34. package/src/native/app/FoundryApp.tsx +1 -1
  35. package/src/native/app/__tests__/plan-talk-registry.test.tsx +74 -0
  36. package/src/native/app/briefingServices.ts +1 -0
  37. package/src/native/app/config/defaults.ts +8 -2
  38. package/src/native/app/config/types.ts +1 -1
  39. package/src/native/app/converseServices.ts +1 -0
  40. package/src/native/app/registry.tsx +26 -6
  41. package/src/native/app/services.ts +3 -2
  42. package/src/native/components/NoteDetailScreen.tsx +16 -4
  43. package/src/native/components/__tests__/notes-screens.test.tsx +8 -8
  44. package/src/native/converse/ConverseScreen.tsx +24 -5
  45. package/src/native/converse/__tests__/liveScreen.test.tsx +15 -2
  46. package/src/native/home/HomeScreen.tsx +20 -7
  47. package/src/native/home/controller.ts +15 -5
  48. package/src/native/home/tab.tsx +31 -6
  49. package/src/native/plan/NewProjectRow.tsx +30 -0
  50. package/src/native/plan/PlanTab.tsx +105 -0
  51. package/src/native/plan/ProjectTodos.tsx +24 -0
  52. package/src/native/plan/TimelineScreen.tsx +68 -0
  53. package/src/native/plan/__tests__/plan-tab.test.tsx +76 -0
  54. package/src/native/plan/index.ts +5 -0
  55. package/src/native/plan/timeline.ts +56 -0
  56. package/src/native/recording/__tests__/recorderAudio.test.ts +10 -2
  57. package/src/native/recording/recorderAudio.ts +6 -2
  58. package/src/native/screens/__tests__/tabs.test.tsx +13 -0
  59. package/src/native/screens/ask/AskScreen.tsx +4 -2
  60. package/src/native/screens/library/LibraryDetailScreen.tsx +11 -4
  61. package/src/native/screens/planning/PlanningScreens.tsx +30 -13
  62. package/src/native/screens/tabs.tsx +5 -4
  63. package/src/native/talk/TalkTab.tsx +62 -0
  64. package/src/native/talk/__tests__/talk-tab.test.tsx +57 -0
  65. package/src/native/tracker/TrackerListScreen.tsx +7 -3
  66. package/src/native/tracker/tab.tsx +33 -8
  67. package/src/components/pages/home/DueAcrossProjects.tsx +0 -76
  68. package/src/components/pages/home/RecentNotes.tsx +0 -69
@@ -4,13 +4,15 @@ import type { RecorderAudio, StoppedRecording } from './recorder';
4
4
 
5
5
  /** 'simple' = mono, 44.1 kHz AAC m4a, default mode: the retry profile. */
6
6
  export type RecordProfile = 'normal' | 'simple';
7
+ /** A 'note' is a voice note: recovery files a leftover one. 'transient' (a Converse utterance, a spoken reply) is never a note: a leftover one is discarded. */
8
+ export type RecordingKind = 'note' | 'transient';
7
9
 
8
10
  /** The slice of expo-audio the recorder needs (real binding: expoDriver.ts). */
9
11
  export interface AudioDriver {
10
12
  /** record-capable category, background recording, activated. */
11
13
  configureSession(): Promise<void>;
12
14
  /** Builds a NEW recorder. Must run after configureSession (iOS 16.2+ ordering). */
13
- create(profile: RecordProfile): void;
15
+ create(profile: RecordProfile, kind?: RecordingKind): void;
14
16
  prepare(): Promise<void>;
15
17
  record(): void;
16
18
  stop(): Promise<void>;
@@ -38,6 +40,8 @@ const POLL_MS = 100;
38
40
  const START_CHECK_MS = 250;
39
41
 
40
42
  export function createRecorderAudio(deps: {
43
+ /** What the recordings are for (default 'note'). */
44
+ kind?: RecordingKind;
41
45
  driver: AudioDriver;
42
46
  session: SessionInspector;
43
47
  fs: { size(uri: string): Promise<number> };
@@ -84,7 +88,7 @@ export function createRecorderAudio(deps: {
84
88
  async function attempt(profile: RecordProfile): Promise<void> {
85
89
  await guarded('configureSession', deps.driver.configureSession());
86
90
  step = 'create';
87
- deps.driver.create(profile);
91
+ deps.driver.create(profile, deps.kind);
88
92
  await guarded('prepare', deps.driver.prepare());
89
93
  step = 'record';
90
94
  deps.driver.record();
@@ -44,3 +44,16 @@ describe('Library and Ask tab config', () => {
44
44
  expect(c.openTab).toHaveBeenCalledWith('library', 'd4');
45
45
  });
46
46
  });
47
+
48
+ describe('Library detail has no to-do list of its own', () => {
49
+ it('shows the prose, no Next steps bullets, and a row that opens Plan', async () => {
50
+ const c = ctx({ route: { id: 'd4' } });
51
+ const r = render(<>{libraryTab(createFakeLibraryApi(), { planKey: 'plan' }).render(c)}</>);
52
+ await tick();
53
+ expect(allText(r)).toContain('$4,800 per month');
54
+ expect(allText(r)).not.toContain('Send the order form');
55
+ expect(allText(r)).toContain('2 to-dos from this note are in Plan.');
56
+ press(hostById(r, 'library-todos-in-plan'));
57
+ expect(c.openTab).toHaveBeenCalledWith('plan');
58
+ });
59
+ });
@@ -9,10 +9,12 @@ export interface AskScreenProps {
9
9
  controller: AskController;
10
10
  /** A citation was tapped: open that document (normally the Library tab). */
11
11
  onOpenDocument: (documentId: string) => void;
12
+ /** The Talk tab draws the title above this screen. */
13
+ embedded?: boolean;
12
14
  }
13
15
 
14
16
  /** Ask your documents: pick a project to scope, ask, read a Markdown answer, tap a citation to open the record. */
15
- export function AskScreen({ controller, onOpenDocument }: AskScreenProps) {
17
+ export function AskScreen({ controller, onOpenDocument, embedded }: AskScreenProps) {
16
18
  const s = useStore(controller);
17
19
  const theme = useTheme();
18
20
  const list = useRef<FlatList<AskMessage>>(null);
@@ -21,7 +23,7 @@ export function AskScreen({ controller, onOpenDocument }: AskScreenProps) {
21
23
 
22
24
  return (
23
25
  <View style={{ flex: 1 }}>
24
- <Header large testID="ask-header" title="Ask" subtitle={scope ? `Scoped to ${scope}` : 'All projects'} />
26
+ {embedded ? null : <Header large testID="ask-header" title="Ask" subtitle={scope ? `Scoped to ${scope}` : 'All projects'} />}
25
27
  {s.projects.length ? (
26
28
  <View style={{ paddingHorizontal: theme.spacing.lg, paddingBottom: theme.spacing.sm, flexDirection: 'row' }}>
27
29
  <Select
@@ -1,7 +1,7 @@
1
1
  import { useEffect } from 'react';
2
2
  import { View } from 'react-native';
3
- import { Alert, DetailScreen, Markdown, Section, Select, Tag, Text, useTheme } from '@startsimpli/ui-native';
4
- import { formatDate, fullTextOf, summaryOf } from '../../../components/documentText';
3
+ import { Alert, DetailScreen, ListRow, Markdown, Section, Select, Tag, Text, useTheme } from '@startsimpli/ui-native';
4
+ import { formatDate, fullTextOf, summaryOf, todosInPlanText, withoutNextSteps } from '../../../components/documentText';
5
5
  import { usePullRefresh } from '../../components/usePullRefresh';
6
6
  import { useControllerState as useStore } from '../../components/useControllerState';
7
7
  import type { LibraryController } from './controller';
@@ -10,10 +10,12 @@ export interface LibraryDetailScreenProps {
10
10
  controller: LibraryController;
11
11
  documentId: string;
12
12
  onBack: () => void;
13
+ /** Open Plan: a note's to-dos are listed there, never in the note. */
14
+ onOpenPlan?: () => void;
13
15
  }
14
16
 
15
17
  /** One document: its Markdown summary and text, where it came from, and the project it is filed under (changeable). */
16
- export function LibraryDetailScreen({ controller, documentId, onBack }: LibraryDetailScreenProps) {
18
+ export function LibraryDetailScreen({ controller, documentId, onBack, onOpenPlan }: LibraryDetailScreenProps) {
17
19
  const s = useStore(controller);
18
20
  const theme = useTheme();
19
21
  // Opened from a link or a citation the list may never have been shown: load what the screen needs itself.
@@ -28,7 +30,7 @@ export function LibraryDetailScreen({ controller, documentId, onBack }: LibraryD
28
30
  }
29
31
 
30
32
  const filings = s.filings[document.id] ?? [];
31
- const summary = summaryOf(document);
33
+ const { text: summary, todos } = withoutNextSteps(summaryOf(document));
32
34
  const fullText = fullTextOf(document);
33
35
  const people = document.participants.map((p) => p.name).join(', ');
34
36
  const pad = { paddingVertical: theme.spacing.md, paddingRight: theme.spacing.xs } as const;
@@ -72,6 +74,11 @@ export function LibraryDetailScreen({ controller, documentId, onBack }: LibraryD
72
74
  {summary ? <Markdown testID="library-detail-summary">{summary}</Markdown> : <Text variant="muted">No summary was captured for this document.</Text>}
73
75
  </View>
74
76
  </Section>
77
+ {todos > 0 ? (
78
+ <Section title="To-dos">
79
+ <ListRow testID="library-todos-in-plan" title={todosInPlanText(todos)} subtitle="They are in Plan, in the one list." onPress={onOpenPlan} chevron={Boolean(onOpenPlan)} />
80
+ </Section>
81
+ ) : null}
75
82
  {document.sections.map((section) => (
76
83
  <Section key={section.key} title={section.label}><View style={pad}><Markdown>{section.text}</Markdown></View></Section>
77
84
  ))}
@@ -1,4 +1,4 @@
1
- import { useEffect, useMemo, useState } from 'react';
1
+ import { useEffect, useMemo, useState, type ReactNode } from 'react';
2
2
  import { View } from 'react-native';
3
3
  import { Card, DataList, DetailHero, Header, IconTile, ListRow, Progress, SegmentedControl, StatusChip, Text, useTheme } from '@startsimpli/ui-native';
4
4
  import { standingLabel } from '../../../corpus/planning';
@@ -31,17 +31,17 @@ function FocusSummary({ focus, standing }: { focus: Focus; standing: FocusStandi
31
31
  );
32
32
  }
33
33
 
34
- export interface PlanningListScreenProps { controller: PlanningController; onOpen: (focus: Focus) => void }
34
+ export interface PlanningListScreenProps { controller: PlanningController; onOpen: (focus: Focus) => void; /** The caller draws the title (the Plan tab's header). */ embedded?: boolean }
35
35
 
36
36
  /** Projects (focuses), worst-off first from the server, each with its done/overdue counts. */
37
- export function PlanningListScreen({ controller, onOpen }: PlanningListScreenProps) {
37
+ export function PlanningListScreen({ controller, onOpen, embedded }: PlanningListScreenProps) {
38
38
  const state = useControllerState(controller);
39
39
  const theme = useTheme();
40
40
  const [text, setText] = useState(state.search);
41
41
  const f = state.focuses;
42
42
  return (
43
43
  <View style={{ flex: 1 }}>
44
- <Header large title="Planning" subtitle={f.count !== null ? `${f.count} project${f.count === 1 ? '' : 's'}` : undefined} />
44
+ {embedded ? null : <Header large title="Projects" subtitle={f.count !== null ? `${f.count} project${f.count === 1 ? '' : 's'}` : undefined} />}
45
45
  <DataList
46
46
  testID="planning-list"
47
47
  data={f.items}
@@ -56,7 +56,7 @@ export function PlanningListScreen({ controller, onOpen }: PlanningListScreenPro
56
56
  search={{ value: text, onChange: setText, onSearch: (q) => { void controller.setSearch(q); }, placeholder: 'Search projects' }}
57
57
  onClearFilters={() => { setText(''); void controller.setSearch(''); }}
58
58
  emptyTitle="No projects yet"
59
- emptyDescription="A project is something you are trying to achieve. Create one on the web and it shows up here."
59
+ emptyDescription="A project is something you are trying to achieve. Tap New project to add one."
60
60
  noResultsTitle="No matching projects"
61
61
  ItemSeparatorComponent={() => <View style={{ height: theme.spacing.sm }} />}
62
62
  renderItem={({ item }: { item: Focus }) => (
@@ -69,7 +69,7 @@ export function PlanningListScreen({ controller, onOpen }: PlanningListScreenPro
69
69
  );
70
70
  }
71
71
 
72
- type Mode = 'open' | 'closed' | 'notes';
72
+ type Mode = 'open' | 'closed' | 'notes' | 'todos';
73
73
 
74
74
  export interface PlanningDetailScreenProps {
75
75
  api: PlanningScreenApi;
@@ -77,27 +77,32 @@ export interface PlanningDetailScreenProps {
77
77
  onBack: () => void;
78
78
  /** Open a filed document (the Library tab). Without it, documents are not tappable. */
79
79
  onOpenDocument?: (documentId: string) => void;
80
+ /**
81
+ * The project's to-dos as the SHARED to-do list (the Plan tab passes it already filtered to this project). With it the
82
+ * Open/Closed item lists below are not drawn: a project never carries a to-do list of its own.
83
+ */
84
+ renderTodos?: () => ReactNode;
80
85
  now?: () => number;
81
86
  }
82
87
 
83
88
  /** One project: its standing, then the items filed under it (open / closed) or its notes and documents. */
84
- export function PlanningDetailScreen({ api, focusId, onBack, onOpenDocument, now = Date.now }: PlanningDetailScreenProps) {
89
+ export function PlanningDetailScreen({ api, focusId, onBack, onOpenDocument, renderTodos, now = Date.now }: PlanningDetailScreenProps) {
85
90
  const controller = useMemo(() => createFocusDetailController({ api, focusId, now }), [api, focusId, now]);
86
91
  useEffect(() => () => controller.stop(), [controller]);
87
- return <DetailBody controller={controller} onBack={onBack} onOpenDocument={onOpenDocument} now={now} />;
92
+ return <DetailBody controller={controller} onBack={onBack} onOpenDocument={onOpenDocument} renderTodos={renderTodos} now={now} />;
88
93
  }
89
94
 
90
- export function DetailBody({ controller, onBack, onOpenDocument, now = Date.now }: {
91
- controller: FocusDetailController; onBack: () => void; onOpenDocument?: (id: string) => void; now?: () => number;
95
+ export function DetailBody({ controller, onBack, onOpenDocument, renderTodos, now = Date.now }: {
96
+ controller: FocusDetailController; onBack: () => void; onOpenDocument?: (id: string) => void; renderTodos?: () => ReactNode; now?: () => number;
92
97
  }) {
93
98
  const state = useControllerState(controller);
94
99
  const items = useControllerState(controller.items);
95
100
  const docs = useControllerState(controller.documents);
96
101
  const theme = useTheme();
97
- const [mode, setMode] = useState<Mode>('open');
102
+ const [mode, setMode] = useState<Mode>(renderTodos ? 'todos' : 'open');
98
103
  const pick = (next: Mode) => {
99
104
  setMode(next);
100
- if (next !== 'notes') void controller.setShowClosed(next === 'closed');
105
+ if (next === 'open' || next === 'closed') void controller.setShowClosed(next === 'closed');
101
106
  };
102
107
  const clock = now();
103
108
  const focus = state.focus;
@@ -125,7 +130,9 @@ export function DetailBody({ controller, onBack, onOpenDocument, now = Date.now
125
130
  testID="planning-mode"
126
131
  value={mode}
127
132
  onChange={pick}
128
- options={[{ value: 'open', label: 'Open' }, { value: 'closed', label: 'Closed' }, { value: 'notes', label: 'Notes' }]}
133
+ options={renderTodos
134
+ ? [{ value: 'todos', label: 'To-dos' }, { value: 'notes', label: 'Notes' }]
135
+ : [{ value: 'open', label: 'Open' }, { value: 'closed', label: 'Closed' }, { value: 'notes', label: 'Notes' }]}
129
136
  />
130
137
  </View>
131
138
  );
@@ -140,6 +147,16 @@ export function DetailBody({ controller, onBack, onOpenDocument, now = Date.now
140
147
  <View style={{ padding: theme.spacing.lg, gap: theme.spacing.sm }}>
141
148
  <Text variant="muted">{state.error}</Text>
142
149
  </View>
150
+ ) : mode === 'todos' && renderTodos ? (
151
+ <View style={{ flex: 1 }}>
152
+ <View style={{ gap: theme.spacing.sm, paddingHorizontal: theme.layout.gutter, paddingBottom: theme.spacing.sm }}>
153
+ {focus ? <Text variant="headline" numberOfLines={2}>{focus.title}</Text> : null}
154
+ {percent !== null ? <Progress value={percent} /> : null}
155
+ {focus ? <Text variant="footnote">{[standingLabel(state.standing), targetLine(focus)].filter(Boolean).join(' · ')}</Text> : null}
156
+ <SegmentedControl<Mode> testID="planning-mode" value={mode} onChange={pick} options={[{ value: 'todos', label: 'To-dos' }, { value: 'notes', label: 'Notes' }]} />
157
+ </View>
158
+ {renderTodos()}
159
+ </View>
143
160
  ) : mode === 'notes' ? (
144
161
  <DataList
145
162
  {...common}
@@ -10,10 +10,10 @@ import { createLibraryController } from './library/controller';
10
10
  export const LIBRARY_TAB = 'library';
11
11
  export const ASK_TAB = 'ask';
12
12
 
13
- function LibraryTabBody({ api, ctx }: { api: NativeCorpusApi; ctx: TabContext }) {
13
+ function LibraryTabBody({ api, ctx, planKey }: { api: NativeCorpusApi; ctx: TabContext; planKey?: string }) {
14
14
  const controller = useMemo(() => createLibraryController(api), [api]);
15
15
  return ctx.route
16
- ? <LibraryDetailScreen controller={controller} documentId={ctx.route.id} onBack={ctx.back} />
16
+ ? <LibraryDetailScreen controller={controller} documentId={ctx.route.id} onBack={ctx.back} onOpenPlan={planKey ? () => ctx.openTab(planKey) : undefined} />
17
17
  : <LibraryListScreen controller={controller} onOpen={(id) => ctx.push(id)} displays={api.schema?.displays} />;
18
18
  }
19
19
 
@@ -28,8 +28,9 @@ function AskTabBody({ api, ctx }: { api: NativeCorpusApi; ctx: TabContext }) {
28
28
  }
29
29
 
30
30
  /** The Library tab: documents list -> one document. */
31
- export function libraryTab(api: NativeCorpusApi, over: Partial<Pick<FoundryTab, 'key' | 'label'>> = {}): FoundryTab {
32
- return { key: LIBRARY_TAB, label: 'Library', ...over, render: (ctx) => <LibraryTabBody api={api} ctx={ctx} /> };
31
+ export function libraryTab(api: NativeCorpusApi, over: Partial<Pick<FoundryTab, 'key' | 'label'>> & { planKey?: string } = {}): FoundryTab {
32
+ const { planKey, ...tab } = over;
33
+ return { key: LIBRARY_TAB, label: 'Library', ...tab, render: (ctx) => <LibraryTabBody api={api} ctx={ctx} planKey={planKey} /> };
33
34
  }
34
35
 
35
36
  /** The Ask tab: project-scoped questions over the documents. Citations jump to the Library tab. */
@@ -0,0 +1,62 @@
1
+ import { useMemo, useState } from 'react';
2
+ import { View } from 'react-native';
3
+ import { Header, SegmentedControl, Text, useTheme } from '@startsimpli/ui-native';
4
+ import { TAB_COPY, TALK_MODES, type TalkMode } from '../../corpus/nav-copy';
5
+ import type { MeetingController } from '../../corpus/converse/meeting';
6
+ import type { FoundryTab, TabContext } from '../components/FoundryTabsShell';
7
+ import type { NativeCorpusApi } from '../corpus/api';
8
+ import { ConverseScreen } from '../converse/ConverseScreen';
9
+ import type { SpeedStore } from '../converse/speed';
10
+ import { AskScreen } from '../screens/ask/AskScreen';
11
+ import { createAskController } from '../screens/ask/controller';
12
+
13
+ export const TALK_TAB = 'talk';
14
+
15
+ export interface TalkTabOptions {
16
+ api: Pick<NativeCorpusApi, 'corpus' | 'ask' | 'scope'>;
17
+ /** Absent when `features.converse` is off: Talk is then Ask alone. */
18
+ converse?: MeetingController | null;
19
+ speed?: SpeedStore | null;
20
+ key?: string;
21
+ label?: string;
22
+ /** The Library tab, where a cited source opens. */
23
+ libraryKey?: string;
24
+ }
25
+
26
+ function TalkBody({ opts, ctx }: { opts: TalkTabOptions; ctx: TabContext }) {
27
+ const theme = useTheme();
28
+ const { api, converse, speed, libraryKey = 'library' } = opts;
29
+ const modes = TALK_MODES.filter((m) => m.key === 'ask' || converse);
30
+ // `-tgTab talk -tgDetail ask` (and a link) land on Ask.
31
+ const [mode, setMode] = useState<TalkMode>(ctx.route?.id === 'ask' || !converse ? 'ask' : 'talk');
32
+ const ask = useMemo(() => createAskController({ api: api.ask, scope: api.scope, listProjects: async () => (await api.corpus.listFocusChoices?.()) ?? [] }), [api]);
33
+ const current = modes.find((m) => m.key === mode) ?? modes[0];
34
+ return (
35
+ <View style={{ flex: 1 }} testID="talk-screen">
36
+ <Header large testID="talk-header" title={TAB_COPY.talk.label} subtitle={TAB_COPY.talk.subtitle} />
37
+ <View style={{ paddingHorizontal: theme.layout.gutter, gap: theme.spacing.xs, paddingBottom: theme.spacing.sm }}>
38
+ {modes.length > 1 ? (
39
+ <SegmentedControl<TalkMode> testID="talk-mode" value={current.key} onChange={setMode} options={modes.map((m) => ({ value: m.key, label: m.label }))} />
40
+ ) : null}
41
+ <Text variant="footnote" testID="talk-mode-subtitle">{current.subtitle}</Text>
42
+ </View>
43
+ {/* Both stay mounted: switching modes must not end a meeting in progress. */}
44
+ {converse ? (
45
+ <View style={{ flex: 1, display: current.key === 'talk' ? 'flex' : 'none' }}>
46
+ <ConverseScreen controller={converse} speed={speed ?? undefined} embedded />
47
+ </View>
48
+ ) : null}
49
+ <View style={{ flex: 1, display: current.key === 'ask' ? 'flex' : 'none' }}>
50
+ <AskScreen controller={ask} onOpenDocument={(id) => ctx.openTab(libraryKey, id)} embedded />
51
+ </View>
52
+ </View>
53
+ );
54
+ }
55
+
56
+ /**
57
+ * The Talk tab: ONE place to speak to Tandem. Start talking, a type box, and an Ask mode (a question answered with cited
58
+ * sources); Ask is a mode here, not a tab. Leaving the tab does not end a meeting.
59
+ */
60
+ export function talkTab(opts: TalkTabOptions): FoundryTab {
61
+ return { key: opts.key ?? TALK_TAB, label: opts.label ?? TAB_COPY.talk.label, render: (ctx) => <TalkBody opts={opts} ctx={ctx} /> };
62
+ }
@@ -0,0 +1,57 @@
1
+ import { describe, expect, it, vi } from 'vitest';
2
+
3
+ vi.mock('react-native', async () => ({ ...(await import('../../../../../ui-native/test/rn-stub')) }));
4
+ import { act, allText, hostById, maybeById, press, render } from '../../../../../ui-native/test/render';
5
+ import { TALK_MODES, TAB_COPY } from '../../../corpus/nav-copy';
6
+ import type { TabContext } from '../../components/FoundryTabsShell';
7
+ import { createFakeNativeCorpusApi } from '../../corpus/fake';
8
+ import type { MeetingController } from '../../../corpus/converse/meeting';
9
+ import { talkTab } from '../TalkTab';
10
+
11
+ const tick = () => act(async () => { await new Promise((res) => setTimeout(res, 40)); });
12
+ const IDLE = { phase: 'idle', retryable: false, lines: [], error: null, noAudio: null, conversationId: null, saved: null, relayNotice: null };
13
+ const idleMeeting = () => {
14
+ const typed: string[] = [];
15
+ const controller = {
16
+ start() {}, end: async () => null, replay: async () => {}, sendText: async (t: string) => { typed.push(t); }, dismissNotice() {},
17
+ getState: () => IDLE, state: () => IDLE, subscribe: () => () => undefined,
18
+ } as unknown as MeetingController;
19
+ return { controller, typed };
20
+ };
21
+ const has = (r: ReturnType<typeof render>, id: string) => r.root.findAllByProps({ testID: id }).length > 0;
22
+ const ctx = (over: Partial<TabContext> = {}): TabContext => ({ tab: 'talk', active: true, route: null, push: vi.fn(), back: vi.fn(), openTab: vi.fn(), ...over });
23
+
24
+ describe('Talk tab', () => {
25
+ it('has start-talking, a type box and an Ask mode, with the one-line copy', async () => {
26
+ const { controller } = idleMeeting();
27
+ const r = render(<>{talkTab({ api: createFakeNativeCorpusApi(), converse: controller }).render(ctx())}</>);
28
+ await tick();
29
+ expect(allText(r)).toContain(TAB_COPY.talk.subtitle);
30
+ expect(has(r, 'converse-talk')).toBe(true);
31
+ expect(has(r, 'converse-input')).toBe(true);
32
+ expect(has(r, 'talk-mode-ask')).toBe(true);
33
+ expect(allText(r)).toContain(TALK_MODES[1].label);
34
+ });
35
+
36
+ it('Ask is a mode, not a tab: a question gets a cited answer and a source opens the Library', async () => {
37
+ const { controller } = idleMeeting();
38
+ const c = ctx({ route: { id: 'ask' } });
39
+ const r = render(<>{talkTab({ api: createFakeNativeCorpusApi(), converse: controller }).render(c)}</>);
40
+ await tick();
41
+ expect(allText(r)).toContain(TALK_MODES[1].subtitle);
42
+ act(() => { hostById(r, 'ask-composer-input').props.onChangeText('Debug launch checklist'); });
43
+ press(hostById(r, 'ask-composer-send'));
44
+ await tick(); await tick();
45
+ const cite = r.root.findAll((n) => typeof n.props.testID === 'string' && n.props.testID.startsWith('ask-citation-') && typeof n.props.onPress === 'function')[0];
46
+ expect(cite).toBeTruthy();
47
+ press(cite);
48
+ expect(c.openTab).toHaveBeenCalledWith('library', expect.any(String));
49
+ });
50
+
51
+ it('without a meeting controller Talk is Ask alone', async () => {
52
+ const r = render(<>{talkTab({ api: createFakeNativeCorpusApi(), converse: null }).render(ctx())}</>);
53
+ await tick();
54
+ expect(has(r, 'talk-mode-ask')).toBe(false);
55
+ expect(has(r, 'ask-composer-input')).toBe(true);
56
+ });
57
+ });
@@ -21,6 +21,10 @@ export interface TrackerListScreenProps {
21
21
  trackerName?: string;
22
22
  /** Open a tracker item's url (the app's opener: tracker app first, https fallback). */
23
23
  onOpenLink?: (url: string) => void;
24
+ /** The caller draws the title above the list (the Plan tab's header, a project's header): leave out the large "To-dos" one. */
25
+ embedded?: boolean;
26
+ /** The list belongs to one project (its controller is already filtered): no project picker. */
27
+ projectLocked?: boolean;
24
28
  }
25
29
 
26
30
  /** What an empty list says per view. Reached only when no project or search narrows it (those read "No to-dos match"). */
@@ -36,7 +40,7 @@ const EMPTY: Record<TrackerView, { title: string; description: string }> = {
36
40
  * Closed), project and search are all query parameters; swipe a row to mark it
37
41
  * done (or reopen it from Closed); pull to refresh; the list pages on scroll.
38
42
  */
39
- export function TrackerListScreen({ controller, onOpen, displays, now = Date.now, trackerName, onOpenLink }: TrackerListScreenProps) {
43
+ export function TrackerListScreen({ controller, onOpen, displays, now = Date.now, trackerName, onOpenLink, embedded, projectLocked }: TrackerListScreenProps) {
40
44
  const state = useControllerState(controller);
41
45
  const display = useTypeDisplay(displays, 'commitment');
42
46
  const theme = useTheme();
@@ -47,7 +51,7 @@ export function TrackerListScreen({ controller, onOpen, displays, now = Date.now
47
51
  const closed = state.filters.view === 'closed';
48
52
  const filters: FilterGroup[] = [
49
53
  { key: 'view', label: 'Show', view: true, options: TRACKER_VIEWS, value: state.filters.view },
50
- { key: 'project', label: 'Project', display: 'select', options: [{ value: UNFILED_PROJECT, label: 'Unfiled' }, ...state.projects.map((p) => ({ value: p.id, label: p.title }))], value: state.filters.focusId },
54
+ ...(projectLocked ? [] : [{ key: 'project', label: 'Project', display: 'select' as const, options: [{ value: UNFILED_PROJECT, label: 'Unfiled' }, ...state.projects.map((p) => ({ value: p.id, label: p.title }))], value: state.filters.focusId }]),
51
55
  ];
52
56
  const isFiltered = state.filters.focusId !== null || state.filters.search.trim() !== '';
53
57
 
@@ -81,7 +85,7 @@ export function TrackerListScreen({ controller, onOpen, displays, now = Date.now
81
85
 
82
86
  return (
83
87
  <View style={{ flex: 1 }} testID="todos-screen">
84
- <Header large testID="todos-header" title="To-dos" subtitle={subtitle} />
88
+ {embedded ? null : <Header large testID="todos-header" title="To-dos" subtitle={subtitle} />}
85
89
  <DataList<TrackerRow>
86
90
  testID="tracker-list"
87
91
  data={state.rows}
@@ -22,15 +22,40 @@ export interface TrackerTabOptions {
22
22
  itemsChanged?: { subscribe(listener: () => void): () => void };
23
23
  }
24
24
 
25
+ /** What the to-do list and its detail need from the shell. The Plan tab and the standalone tab both supply it. */
26
+ export interface TrackerBodyProps {
27
+ api: TrackerTabOptions['api'];
28
+ controller: TrackerController;
29
+ /** The open to-do's id, or null for the list. */
30
+ todoId: string | null;
31
+ onOpen: (id: string) => void;
32
+ onBack: () => void;
33
+ notesKey?: string;
34
+ openTab: (tab: string, id?: string) => void;
35
+ memberConnections?: TrackerTabOptions['memberConnections'];
36
+ openUrl?: TrackerTabOptions['openUrl'];
37
+ /** The caller draws the title (the Plan tab's header): the list leaves out its own. */
38
+ embedded?: boolean;
39
+ /** The list belongs to one project: no project picker. */
40
+ projectLocked?: boolean;
41
+ }
42
+
43
+ /** The to-do list, or one to-do's detail with the source note link. The ONE to-do list: every screen that shows to-dos mounts this. */
44
+ export function TrackerBody({ api, controller, todoId, onOpen, onBack, notesKey, openTab, memberConnections, openUrl, embedded, projectLocked }: TrackerBodyProps) {
45
+ const trackerName = useTrackerName(memberConnections);
46
+ const onOpenLink = openUrl ? (url: string) => { void openTrackerLink(url, openUrl).catch(() => undefined); } : undefined;
47
+ return todoId
48
+ ? <TrackerDetailScreen api={api} id={todoId} onBack={onBack} onChanged={() => { void controller.refresh(); }} onOpenNote={notesKey ? (docId) => openTab(notesKey, docId) : undefined} trackerName={trackerName} onOpenLink={onOpenLink} />
49
+ : <TrackerListScreen controller={controller} displays={api.schema?.displays} onOpen={(c) => onOpen(c.id)} trackerName={trackerName} onOpenLink={onOpenLink} embedded={embedded} projectLocked={projectLocked} />;
50
+ }
51
+
25
52
  /** The to-do tab as one `FoundryTabsShell` entry: list -> detail (with the source note link). */
26
53
  export function trackerTab({ api, key = 'tracker', label = 'To-dos', notesKey = 'notes', controller = createTrackerController({ api }), memberConnections, openUrl, itemsChanged }: TrackerTabOptions): FoundryTab {
27
54
  itemsChanged?.subscribe(() => { void controller.refresh(); });
28
- const onOpenLink = openUrl ? (url: string) => { void openTrackerLink(url, openUrl).catch(() => undefined); } : undefined;
29
- function Screen({ route, push, back, openTab }: { route: { id: string } | null; push: (id: string) => void; back: () => void; openTab: (tab: string, id?: string) => void }) {
30
- const trackerName = useTrackerName(memberConnections);
31
- return route
32
- ? <TrackerDetailScreen api={api} id={route.id} onBack={back} onChanged={() => { void controller.refresh(); }} onOpenNote={notesKey ? (docId) => openTab(notesKey, docId) : undefined} trackerName={trackerName} onOpenLink={onOpenLink} />
33
- : <TrackerListScreen controller={controller} displays={api.schema?.displays} onOpen={(c) => push(c.id)} trackerName={trackerName} onOpenLink={onOpenLink} />;
34
- }
35
- return { key, label, resetOnLeave: true, render: (props) => <Screen {...props} /> };
55
+ return {
56
+ key, label, resetOnLeave: true,
57
+ render: ({ route, push, back, openTab }) => (
58
+ <TrackerBody api={api} controller={controller} todoId={route?.id ?? null} onOpen={push} onBack={back} notesKey={notesKey} openTab={openTab} memberConnections={memberConnections} openUrl={openUrl} />
59
+ ),
60
+ };
36
61
  }
@@ -1,76 +0,0 @@
1
- /**
2
- * DUE ACROSS PROJECTS — Overdue / Today / This week / Later, one row each, with
3
- * the project as a chip (bd startsim-cpzoz). Takes the already-grouped result of
4
- * `groupDue` so the rule lives in one tested place. Later is folded; so are the
5
- * rows past `perGroup`, with the count on the button.
6
- */
7
- import * as React from 'react';
8
-
9
- import type { DueGroups } from '../../../corpus/due-groups';
10
- import type { Commitment } from '../../../corpus/types';
11
- import { CompactItemRow } from './CompactItemRow';
12
-
13
- const TONE: Record<string, string> = { overdue: 'text-red-700', today: 'text-gray-900', week: 'text-gray-900', later: 'text-gray-500' };
14
-
15
- export function DueAcrossProjects({
16
- due, projectNames = {}, perGroup = 6, trackerName, onOpen, onSeeAll, guessed,
17
- }: {
18
- due: DueGroups;
19
- projectNames?: Record<string, string>;
20
- perGroup?: number;
21
- trackerName?: string;
22
- onOpen?: (item: Commitment) => void;
23
- /** "Open the Tracker" — shown when there is more than the home lists. */
24
- onSeeAll?: () => void;
25
- /** Items whose date is still Tandem's guess: shown quietly. */
26
- guessed?: ReadonlySet<string>;
27
- }) {
28
- const [open, setOpen] = React.useState<Record<string, boolean>>({});
29
- if (due.total === 0) {
30
- return <p className="text-sm text-gray-500">Nothing is due. {due.undated ? `${due.undated} open item${due.undated === 1 ? ' has' : 's have'} no date.` : ''}</p>;
31
- }
32
- return (
33
- <div className="space-y-4">
34
- {due.groups.map((group) => {
35
- const folded = group.bucket === 'later' && !open.later;
36
- const shown = open[group.bucket] ? group.entries : group.entries.slice(0, perGroup);
37
- return (
38
- <section key={group.bucket} aria-label={group.label}>
39
- <h3 className={`mb-1 flex items-baseline gap-2 text-sm font-semibold ${TONE[group.bucket]}`}>
40
- {group.label}
41
- <span className="text-xs font-normal text-gray-500">{group.entries.length}</span>
42
- {group.bucket === 'later' ? (
43
- <button type="button" className="text-xs font-normal text-blue-700 underline" onClick={() => setOpen({ ...open, later: !open.later })}>
44
- {open.later ? 'hide' : 'show'}
45
- </button>
46
- ) : null}
47
- </h3>
48
- {folded ? null : (
49
- <ul>
50
- {shown.map((entry) => (
51
- <CompactItemRow
52
- key={entry.item.externalId}
53
- item={entry.item} days={entry.days} due={entry.due}
54
- project={entry.item.focusId ? projectNames[entry.item.focusId] : undefined}
55
- trackerName={trackerName} onOpen={onOpen} guessedDue={guessed?.has(entry.item.id)}
56
- />
57
- ))}
58
- </ul>
59
- )}
60
- {!folded && group.entries.length > shown.length ? (
61
- <button type="button" className="mt-1 text-xs text-blue-700 underline" onClick={() => setOpen({ ...open, [group.bucket]: true })}>
62
- Show {group.entries.length - shown.length} more
63
- </button>
64
- ) : null}
65
- </section>
66
- );
67
- })}
68
- {due.undated || onSeeAll ? (
69
- <p className="text-xs text-gray-500">
70
- {due.undated ? `${due.undated} open item${due.undated === 1 ? ' has' : 's have'} no date. ` : ''}
71
- {onSeeAll ? <button type="button" className="text-blue-700 underline" onClick={onSeeAll}>Open the Tracker</button> : null}
72
- </p>
73
- ) : null}
74
- </div>
75
- );
76
- }
@@ -1,69 +0,0 @@
1
- /**
2
- * RECENT NOTES, each with the actions that came out of it (bd startsim-cpzoz).
3
- * A row is the note's title, when, and "N to-dos · M open"; opening it shows the
4
- * summary and the to-dos themselves, each linking back to the full note. The
5
- * join (`actionsByNote`) is done by the caller; this only draws it.
6
- */
7
- import * as React from 'react';
8
-
9
- import { stripMarkdown } from '../../Markdown';
10
- import type { NoteActions } from '../../../corpus/note-actions';
11
- import type { Commitment, SourceDocument } from '../../../corpus/types';
12
- import { CompactItemRow } from './CompactItemRow';
13
- import { dueDay, localDate } from '../../../corpus/today';
14
- import { daysBetween } from '../../../corpus/due-groups';
15
-
16
- export interface RecentNote { doc: SourceDocument; actions: NoteActions }
17
-
18
- export function RecentNotes({
19
- notes, projectNames = {}, now, timeZone, onOpenNote, onOpenItem,
20
- }: {
21
- notes: RecentNote[];
22
- projectNames?: Record<string, string>;
23
- now: number;
24
- timeZone?: string;
25
- onOpenNote?: (documentId: string) => void;
26
- onOpenItem?: (item: Commitment) => void;
27
- }) {
28
- if (!notes.length) return <p className="text-sm text-gray-500">No notes yet. Record one, or connect a meeting source.</p>;
29
- const today = localDate(now, timeZone);
30
- return (
31
- <ul className="divide-y divide-gray-100 rounded-lg border border-gray-200 bg-white">
32
- {notes.map(({ doc, actions }) => (
33
- <li key={doc.id}>
34
- <details className="group">
35
- <summary className="flex cursor-pointer list-none items-center gap-3 px-4 py-3">
36
- <span className="min-w-0 flex-1 truncate text-sm font-medium text-gray-900">{doc.title || 'Untitled note'}</span>
37
- <span className="shrink-0 text-xs text-gray-500">
38
- {actions.tasks.length === 0 ? 'no to-dos' : `${actions.tasks.length} to-do${actions.tasks.length === 1 ? '' : 's'} · ${actions.open} open`}
39
- </span>
40
- <span className="w-20 shrink-0 text-right text-xs text-gray-500">
41
- {doc.occurredAt ? new Date(doc.occurredAt).toLocaleDateString(undefined, { month: 'short', day: 'numeric' }) : ''}
42
- </span>
43
- </summary>
44
- <div className="space-y-3 px-4 pb-4">
45
- {doc.summary ? <p className="whitespace-pre-line text-sm text-gray-700">{stripMarkdown(doc.summary)}</p> : null}
46
- {actions.tasks.length ? (
47
- <ul>
48
- {actions.tasks.map((item) => {
49
- const due = dueDay(item.dueAt, timeZone);
50
- return (
51
- <CompactItemRow
52
- key={item.externalId} item={item} due={due} days={due ? daysBetween(today, due) : null}
53
- project={item.focusId ? projectNames[item.focusId] : undefined} onOpen={onOpenItem}
54
- />
55
- );
56
- })}
57
- </ul>
58
- ) : null}
59
- {actions.statements ? <p className="text-xs text-gray-500">{actions.statements} decision{actions.statements === 1 ? '' : 's'} or question{actions.statements === 1 ? '' : 's'} noted</p> : null}
60
- {onOpenNote ? (
61
- <button type="button" className="text-sm text-blue-700 underline" onClick={() => onOpenNote(doc.id)}>Open the full note</button>
62
- ) : null}
63
- </div>
64
- </details>
65
- </li>
66
- ))}
67
- </ul>
68
- );
69
- }