@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
@@ -0,0 +1,105 @@
1
+ import { useEffect, useState } from 'react';
2
+ import { View } from 'react-native';
3
+ import { Header, SegmentedControl, Text, useTheme } from '@startsimpli/ui-native';
4
+ import { PLAN_TABS, TAB_COPY, type PlanTabKey } from '../../corpus/nav-copy';
5
+ import type { FoundryTab, TabContext } from '../components/FoundryTabsShell';
6
+ import type { NativeCorpusApi } from '../corpus/api';
7
+ import { PlanningDetailScreen, PlanningListScreen, usePlanningController } from '../screens/planning/PlanningScreens';
8
+ import { createTrackerController, type TrackerController } from '../tracker/controller';
9
+ import { TrackerBody, type TrackerTabOptions } from '../tracker/tab';
10
+ import { NewProjectRow } from './NewProjectRow';
11
+ import { ProjectTodos } from './ProjectTodos';
12
+ import { TimelineScreen } from './TimelineScreen';
13
+ import { createTimelineController, type TimelineController } from './timeline';
14
+
15
+ export const PLAN_TAB = 'plan';
16
+ const TODO = 'todo/';
17
+ const PROJECT = 'project/';
18
+ const SUBS = new Set<string>(PLAN_TABS.map((t) => t.key));
19
+
20
+ export interface PlanTabOptions {
21
+ api: TrackerTabOptions['api'] & Pick<NativeCorpusApi, 'lists' | 'standings'>;
22
+ key?: string;
23
+ label?: string;
24
+ /** Voice notes tab: a to-do from a note offers "Open note". */
25
+ notesKey?: string;
26
+ /** The Library tab: a project's filed notes open there. */
27
+ documentTab?: string;
28
+ memberConnections?: TrackerTabOptions['memberConnections'];
29
+ openUrl?: TrackerTabOptions['openUrl'];
30
+ /** Something else edited items (a spoken reply): the to-do list re-reads. */
31
+ itemsChanged?: TrackerTabOptions['itemsChanged'];
32
+ timeZone?: string;
33
+ now?: () => number;
34
+ }
35
+
36
+ /** The route ids the Plan tab understands: `todo/<id>`, `project/<id>`, and (launch args) a bare sub-tab name. */
37
+ export const planRoute = {
38
+ todo: (id: string) => `${TODO}${id}`,
39
+ project: (id: string) => `${PROJECT}${id}`,
40
+ };
41
+
42
+ function PlanBody({ opts, tracker, timeline, ctx }: { opts: PlanTabOptions; tracker: TrackerController; timeline: TimelineController; ctx: TabContext }) {
43
+ const theme = useTheme();
44
+ const { api, notesKey, documentTab, memberConnections, openUrl } = opts;
45
+ const planning = usePlanningController(api);
46
+ const routeId = ctx.route?.id ?? null;
47
+ const [sub, setSub] = useState<PlanTabKey>(() => (routeId && SUBS.has(routeId) ? (routeId as PlanTabKey) : 'todos'));
48
+ useEffect(() => { if (routeId && SUBS.has(routeId)) setSub(routeId as PlanTabKey); }, [routeId]);
49
+ const current = PLAN_TABS.find((t) => t.key === sub) ?? PLAN_TABS[0];
50
+ const todoId = routeId?.startsWith(TODO) ? routeId.slice(TODO.length) : null;
51
+ const projectId = routeId?.startsWith(PROJECT) ? routeId.slice(PROJECT.length) : null;
52
+ const openTodo = (id: string) => ctx.push(planRoute.todo(id));
53
+
54
+ if (todoId) {
55
+ return <TrackerBody api={api} controller={tracker} todoId={todoId} onOpen={openTodo} onBack={ctx.back} notesKey={notesKey} openTab={ctx.openTab} memberConnections={memberConnections} openUrl={openUrl} />;
56
+ }
57
+ if (projectId) {
58
+ return (
59
+ <PlanningDetailScreen
60
+ api={api} focusId={projectId} onBack={ctx.back}
61
+ onOpenDocument={documentTab ? (id) => ctx.openTab(documentTab, id) : undefined}
62
+ renderTodos={() => <ProjectTodos api={api} focusId={projectId} onOpen={openTodo} openTab={ctx.openTab} notesKey={notesKey} memberConnections={memberConnections} openUrl={openUrl} />}
63
+ />
64
+ );
65
+ }
66
+
67
+ return (
68
+ <View style={{ flex: 1 }} testID="plan-screen">
69
+ <Header large testID="plan-header" title={TAB_COPY.plan.label} subtitle={TAB_COPY.plan.subtitle} />
70
+ <View style={{ paddingHorizontal: theme.layout.gutter, gap: theme.spacing.xs, paddingBottom: theme.spacing.sm }}>
71
+ <SegmentedControl<PlanTabKey> testID="plan-subtabs" value={sub} onChange={setSub} options={PLAN_TABS.map((t) => ({ value: t.key, label: t.label }))} />
72
+ <Text variant="footnote" testID="plan-subtitle">{current.subtitle}</Text>
73
+ </View>
74
+ {sub === 'todos' ? (
75
+ <TrackerBody api={api} controller={tracker} todoId={null} onOpen={openTodo} onBack={ctx.back} notesKey={notesKey} openTab={ctx.openTab} memberConnections={memberConnections} openUrl={openUrl} embedded />
76
+ ) : null}
77
+ {sub === 'timeline' ? <TimelineScreen controller={timeline} /> : null}
78
+ {sub === 'projects' ? (
79
+ <View style={{ flex: 1 }}>
80
+ {api.corpus.createFocus ? (
81
+ <NewProjectRow onCreate={async (title) => { await api.corpus.createFocus!({ title, status: 'active' }); await planning.refresh(); }} />
82
+ ) : null}
83
+ <PlanningListScreen controller={planning} onOpen={(f) => ctx.push(planRoute.project(f.id))} embedded />
84
+ </View>
85
+ ) : null}
86
+ </View>
87
+ );
88
+ }
89
+
90
+ /**
91
+ * The Plan tab: ONE tab for everything owed and everything aimed at, with three sub-tabs. To-dos is the one list;
92
+ * Timeline is the created / done / overdue chart and its day table; Projects is projects and goals as one list with
93
+ * progress, and opening one shows its to-dos as the same list filtered. Tracker, Planning and Goals are not tabs.
94
+ */
95
+ export function planTab(opts: PlanTabOptions): FoundryTab {
96
+ const { api, key = PLAN_TAB, label = TAB_COPY.plan.label, itemsChanged, timeZone, now } = opts;
97
+ // One controller each for the tab's lifetime: switching sub-tabs or opening a to-do and coming back does not re-read.
98
+ const tracker = createTrackerController({ api });
99
+ const timeline = createTimelineController({ timeline: (api.corpus as { timeline?: TrackerBodyTimeline }).timeline?.bind(api.corpus), timeZone, now });
100
+ itemsChanged?.subscribe(() => { void tracker.refresh(); });
101
+ return { key, label, resetOnLeave: true, render: (ctx) => <PlanBody opts={opts} tracker={tracker} timeline={timeline} ctx={ctx} /> };
102
+ }
103
+
104
+ type TrackerBodyTimeline = NonNullable<import('../../corpus/types').CommitmentTrackerApi['timeline']>;
105
+
@@ -0,0 +1,24 @@
1
+ import { useEffect, useMemo } from 'react';
2
+ import { createTrackerController } from '../tracker/controller';
3
+ import { TrackerBody, type TrackerTabOptions } from '../tracker/tab';
4
+
5
+ /** One project's to-dos: the SHARED to-do list with its controller filtered to the project. Never a list of its own. */
6
+ export function ProjectTodos({ api, focusId, onOpen, openTab, notesKey, memberConnections, openUrl }: {
7
+ api: TrackerTabOptions['api'];
8
+ focusId: string;
9
+ onOpen: (todoId: string) => void;
10
+ openTab: (tab: string, id?: string) => void;
11
+ notesKey?: string;
12
+ memberConnections?: TrackerTabOptions['memberConnections'];
13
+ openUrl?: TrackerTabOptions['openUrl'];
14
+ }) {
15
+ const controller = useMemo(() => createTrackerController({ api }), [api]);
16
+ useEffect(() => { void controller.setFocus(focusId); }, [controller, focusId]);
17
+ return (
18
+ <TrackerBody
19
+ api={api} controller={controller} todoId={null} onOpen={onOpen} onBack={() => undefined}
20
+ notesKey={notesKey} openTab={openTab} memberConnections={memberConnections} openUrl={openUrl}
21
+ embedded projectLocked
22
+ />
23
+ );
24
+ }
@@ -0,0 +1,68 @@
1
+ import { useEffect, useState } from 'react';
2
+ import { FlatList, View } from 'react-native';
3
+ import { Alert, EmptyState, ListRow, SegmentedControl, Spinner, Text, TrendChart, useTheme } from '@startsimpli/ui-native';
4
+ import { useControllerState } from '../components/useControllerState';
5
+ import { TIMELINE_RANGES, lastDays, type TimelineController } from './timeline';
6
+
7
+ const SERIES_COLOR: Record<string, string> = { created: '#3B82F6', done: '#16A34A', overdue: '#DC2626' };
8
+
9
+ /** "Mon, Nov 9" from a YYYY-MM-DD day. */
10
+ const dayLabel = (iso: string) => new Date(`${iso}T00:00:00Z`).toLocaleDateString(undefined, { weekday: 'short', month: 'short', day: 'numeric', timeZone: 'UTC' });
11
+
12
+ /**
13
+ * Plan > Timeline: what was created, finished and overdue over time. One chart per series over the chosen range, then the
14
+ * days that had activity with the to-dos behind them (the web strip's chart and event table, in a phone's shape).
15
+ */
16
+ export function TimelineScreen({ controller }: { controller: TimelineController }) {
17
+ const s = useControllerState(controller);
18
+ const theme = useTheme();
19
+ const [range, setRange] = useState<string>('30');
20
+ useEffect(() => { void controller.load(); }, [controller]);
21
+ const days = TIMELINE_RANGES.find((r) => r.value === range)?.days ?? 30;
22
+ const rows = s.built ? s.built.points.filter((p) => s.built!.series[0].points.slice(-days).some((q) => q.date === p.date)).reverse() : [];
23
+
24
+ const header = (
25
+ <View style={{ gap: theme.spacing.md, paddingBottom: theme.spacing.md }}>
26
+ <SegmentedControl<string> testID="timeline-range" value={range} onChange={setRange} options={TIMELINE_RANGES.map((r) => ({ value: r.value, label: r.label }))} />
27
+ {s.built ? s.built.series.map((series) => {
28
+ const values = lastDays(series.points, days);
29
+ const total = values.reduce((a, b) => a + b, 0);
30
+ return (
31
+ <View key={series.id} testID={`timeline-series-${series.id}`} style={{ gap: theme.spacing.xs }}>
32
+ <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
33
+ <Text variant="headline">{series.name}</Text>
34
+ <Text variant="headline" style={{ color: SERIES_COLOR[series.id] }}>{String(total)}</Text>
35
+ </View>
36
+ <TrendChart data={values.length > 1 ? values : [0, ...values]} height={96} color={SERIES_COLOR[series.id]} gridLines={1} />
37
+ </View>
38
+ );
39
+ }) : null}
40
+ {s.built && s.built.estimatedDone > 0 ? <Text variant="footnote">{`${s.built.estimatedDone} done to-do${s.built.estimatedDone === 1 ? '' : 's'} sit on an estimated day.`}</Text> : null}
41
+ {s.built ? <Text variant="headline" testID="timeline-table-title">To-dos in this window</Text> : null}
42
+ </View>
43
+ );
44
+
45
+ if (!s.available) return <EmptyState icon="list" title="No timeline here" description="This workspace cannot serve the per-day counts the timeline needs." />;
46
+ return (
47
+ <View style={{ flex: 1 }} testID="timeline-screen">
48
+ {s.error ? <View style={{ padding: theme.spacing.lg }}><Alert variant="destructive">{s.error}</Alert></View> : null}
49
+ <FlatList
50
+ testID="timeline-table"
51
+ data={rows}
52
+ keyExtractor={(p) => p.date}
53
+ contentContainerStyle={{ paddingHorizontal: theme.layout.gutter, paddingBottom: theme.spacing.xl, flexGrow: 1 }}
54
+ ListHeaderComponent={header}
55
+ ListEmptyComponent={s.loading ? <Spinner /> : s.built ? <EmptyState icon="list" title="Nothing in this window" description="Created, finished and overdue to-dos show up here by day." /> : null}
56
+ renderItem={({ item }) => (
57
+ <ListRow
58
+ testID={`timeline-day-${item.date}`}
59
+ title={dayLabel(item.date)}
60
+ subtitle={(item.events ?? []).slice(0, 3).map((e) => `${e.status}: ${e.label}`).join('\n')}
61
+ meta={`${item.value} to-do${item.value === 1 ? '' : 's'}`}
62
+ chevron={false}
63
+ />
64
+ )}
65
+ />
66
+ </View>
67
+ );
68
+ }
@@ -0,0 +1,76 @@
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 { PLAN_TABS, TAB_COPY } from '../../../corpus/nav-copy';
6
+ import type { TabContext } from '../../components/FoundryTabsShell';
7
+ import { createFakeNativeCorpusApi } from '../../corpus/fake';
8
+ import { planRoute, planTab } from '../PlanTab';
9
+ import { createTimelineController } from '../timeline';
10
+
11
+ const tick = () => act(async () => { await new Promise((res) => setTimeout(res, 40)); });
12
+ const ctx = (over: Partial<TabContext> = {}): TabContext => ({ tab: 'plan', active: true, route: null, push: vi.fn(), back: vi.fn(), openTab: vi.fn(), ...over });
13
+ const has = (r: ReturnType<typeof render>, id: string) => r.root.findAllByProps({ testID: id }).length > 0;
14
+ const mount = (c: TabContext) => render(<>{planTab({ api: createFakeNativeCorpusApi() }).render(c)}</>);
15
+
16
+ describe('Plan tab', () => {
17
+ it('is one tab with the three sub-tabs and says what Plan and each sub-tab are for', async () => {
18
+ const r = mount(ctx());
19
+ await tick();
20
+ const text = allText(r);
21
+ expect(text).toContain(TAB_COPY.plan.subtitle);
22
+ for (const t of PLAN_TABS) expect(text).toContain(t.label);
23
+ expect(allText(r)).toContain(PLAN_TABS[0].subtitle);
24
+ for (const t of PLAN_TABS) expect(has(r, `plan-subtabs-${t.key}`)).toBe(true);
25
+ });
26
+
27
+ it('To-dos is the one list: rows, and a tap pushes the to-do', async () => {
28
+ const c = ctx();
29
+ const r = mount(c);
30
+ await tick();
31
+ expect(has(r, 'tracker-list')).toBe(true);
32
+ const row = r.root.findByProps({ testID: 'todo-c2' }).findAll((n) => typeof n.props.onPress === 'function' && !n.props.testID?.includes('action'))[0];
33
+ press(row);
34
+ // The to-do detail opens inside Plan under the `todo/` route, never in a tab of its own.
35
+ expect(c.push).toHaveBeenCalledWith('todo/c2');
36
+ });
37
+
38
+ it('a launch route names the sub-tab: Timeline shows its chart range and table, Projects its list and a New project button', async () => {
39
+ const t = mount(ctx({ route: { id: 'timeline' } }));
40
+ await tick();
41
+ expect(allText(t)).toContain(PLAN_TABS[1].subtitle);
42
+ expect(has(t, 'timeline-screen')).toBe(true);
43
+ expect(has(t, 'timeline-range-30')).toBe(true);
44
+ const p = mount(ctx({ route: { id: 'projects' } }));
45
+ await tick();
46
+ expect(allText(p)).toContain(PLAN_TABS[2].subtitle);
47
+ expect(has(p, 'planning-list')).toBe(true);
48
+ expect(has(p, 'project-new')).toBe(true);
49
+ });
50
+
51
+ it('opening a project shows its to-dos as the shared list, filtered, with no Open/Closed item lists of its own', async () => {
52
+ const c = ctx({ route: { id: planRoute.project('f287') } });
53
+ const r = mount(c);
54
+ await tick(); await tick();
55
+ expect(has(r, 'planning-detail')).toBe(true);
56
+ expect(has(r, 'tracker-list')).toBe(true);
57
+ expect(maybeById(r, 'planning-items')).toHaveLength(0);
58
+ expect(allText(r)).toContain('To-dos');
59
+ expect(allText(r)).toContain('Notes');
60
+ });
61
+ });
62
+
63
+ describe('timeline controller', () => {
64
+ it('builds the three series from the same server reads the web strip uses', async () => {
65
+ const api = createFakeNativeCorpusApi();
66
+ const controller = createTimelineController({ timeline: (api.corpus as any).timeline?.bind(api.corpus), now: () => Date.parse('2026-11-16T12:00:00Z') });
67
+ await controller.load();
68
+ const s = controller.getState();
69
+ expect(s.error).toBeNull();
70
+ expect(s.built?.series.map((x) => x.id)).toEqual(['created', 'done', 'overdue']);
71
+ });
72
+
73
+ it('says so when the workspace cannot serve a timeline', () => {
74
+ expect(createTimelineController({ timeline: undefined }).getState().available).toBe(false);
75
+ });
76
+ });
@@ -0,0 +1,5 @@
1
+ export { planTab, planRoute, PLAN_TAB } from './PlanTab';
2
+ export type { PlanTabOptions } from './PlanTab';
3
+ export { createTimelineController } from './timeline';
4
+ export type { TimelineController, TimelineState } from './timeline';
5
+ export { TimelineScreen } from './TimelineScreen';
@@ -0,0 +1,56 @@
1
+ /**
2
+ * The Plan > Timeline data as a framework-free controller: the same server reads and the same `buildTimeline` the web
3
+ * strip uses (created / done / overdue per day, and the to-dos behind the days), over the native corpus api.
4
+ */
5
+ import { buildTimeline, type BuiltTimeline } from '../../corpus/tracker-timeline';
6
+ import type { CommitmentTrackerApi } from '../../corpus/types';
7
+ import { createStore, errorMessage } from '../screens/store';
8
+
9
+ export interface TimelineState {
10
+ loading: boolean;
11
+ error: string | null;
12
+ /** Null until the first read lands, and when this workspace cannot serve a timeline. */
13
+ built: BuiltTimeline | null;
14
+ available: boolean;
15
+ anchor: string;
16
+ }
17
+
18
+ export interface TimelineController {
19
+ getState(): TimelineState;
20
+ subscribe(listener: () => void): () => void;
21
+ load(): Promise<void>;
22
+ }
23
+
24
+ export function createTimelineController({ timeline, now = Date.now, timeZone }: {
25
+ timeline: CommitmentTrackerApi['timeline'] | undefined;
26
+ now?: () => number;
27
+ timeZone?: string;
28
+ }): TimelineController {
29
+ const store = createStore<TimelineState>({ loading: Boolean(timeline), error: null, built: null, available: Boolean(timeline), anchor: '' });
30
+ return {
31
+ getState: store.getState,
32
+ subscribe: store.subscribe,
33
+ async load() {
34
+ if (!timeline) return;
35
+ store.set({ loading: true, error: null });
36
+ try {
37
+ const clock = now();
38
+ const read = await timeline({}, { now: clock, timeZone });
39
+ store.set({ loading: false, built: buildTimeline(read, clock, timeZone), anchor: read.anchor });
40
+ } catch (e) {
41
+ store.set({ loading: false, error: errorMessage(e, 'Could not load the timeline.') });
42
+ }
43
+ },
44
+ };
45
+ }
46
+
47
+ /** The last `days` values of a series, oldest first, for one chart. */
48
+ export function lastDays(points: Array<{ value: number }>, days: number): number[] {
49
+ return points.slice(-days).map((p) => p.value);
50
+ }
51
+
52
+ export const TIMELINE_RANGES = [
53
+ { value: '7', label: '7 days', days: 7 },
54
+ { value: '30', label: '30 days', days: 30 },
55
+ { value: '90', label: '90 days', days: 90 },
56
+ ] as const;
@@ -1,7 +1,7 @@
1
1
  import { describe, expect, it, vi, type Mock } from 'vitest';
2
2
  import { createRecorderAudio, type AudioDriver, type SessionInspector } from '../recorderAudio';
3
3
 
4
- function setup(sizes: number[] = [0, 4000, 8000, 8000], sessionOver: Record<string, unknown> = {}) {
4
+ function setup(sizes: number[] = [0, 4000, 8000, 8000], sessionOver: Record<string, unknown> = {}, kind?: 'note' | 'transient') {
5
5
  const order: string[] = [];
6
6
  let status = { url: 'file:///docs/x.m4a', durationMillis: 2500, metering: -30 as number | undefined, isRecording: true };
7
7
  const driver: AudioDriver = {
@@ -24,11 +24,19 @@ function setup(sizes: number[] = [0, 4000, 8000, 8000], sessionOver: Record<stri
24
24
  const poll = vi.fn((fn: () => void) => { tick = fn; return () => { tick = undefined; }; });
25
25
  const diag = { log: vi.fn() };
26
26
  const onInterrupted = vi.fn();
27
- const audio = createRecorderAudio({ driver, session, fs, poll, sleep: async () => undefined, diag, onInterrupted, stepTimeoutMs: 30 });
27
+ const audio = createRecorderAudio({ driver, session, fs, poll, sleep: async () => undefined, diag, onInterrupted, stepTimeoutMs: 30, ...(kind ? { kind } : {}) });
28
28
  return { audio, driver, order, fs, diag, listeners, onInterrupted, tick: () => tick?.(), setStatus: (s: Partial<typeof status>) => { status = { ...status, ...s }; } };
29
29
  }
30
30
 
31
31
  describe('recorder audio adapter', () => {
32
+ it('tells the driver what the recording is for (a Converse utterance is transient, a note is the default)', async () => {
33
+ const t = setup(undefined, {}, 'transient');
34
+ await t.audio.start({ onLevel: vi.fn() });
35
+ expect((t.driver.create as Mock).mock.calls[0]).toEqual(['normal', 'transient']);
36
+ const n = setup();
37
+ await n.audio.start({ onLevel: vi.fn() });
38
+ expect((n.driver.create as Mock).mock.calls[0]).toEqual(['normal', undefined]);
39
+ });
32
40
  it('pins the order: session configured+active -> recorder CREATED -> prepared -> record (the DevHQ failure)', async () => {
33
41
  const s = setup();
34
42
  await s.audio.start({ onLevel: vi.fn() });
@@ -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. */