@startsimpli/integrations 0.2.102 → 0.2.104

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 (50) hide show
  1. package/package.json +4 -4
  2. package/src/__tests__/focus-standings.test.tsx +119 -0
  3. package/src/components/pages/PlanningPage.tsx +16 -4
  4. package/src/corpus/client.ts +5 -0
  5. package/src/corpus/entity-query.ts +67 -4
  6. package/src/corpus/index.ts +4 -2
  7. package/src/corpus/standings.ts +75 -0
  8. package/src/corpus/types.ts +6 -0
  9. package/src/native/__tests__/design-screens.test.tsx +97 -0
  10. package/src/native/__tests__/ux-polish.test.tsx +4 -2
  11. package/src/native/app/FoundryApp.tsx +2 -2
  12. package/src/native/app/__tests__/launch.test.ts +4 -1
  13. package/src/native/app/entity/EntityTab.tsx +13 -18
  14. package/src/native/app/icon.tsx +6 -1
  15. package/src/native/app/launch.ts +4 -0
  16. package/src/native/app/screens/RecordScreen.tsx +37 -30
  17. package/src/native/app/screens/SignInScreen.tsx +4 -3
  18. package/src/native/components/FoundryTabsShell.tsx +8 -5
  19. package/src/native/components/MoreTabList.tsx +20 -25
  20. package/src/native/components/NoteDetailScreen.tsx +49 -57
  21. package/src/native/components/NotesListScreen.tsx +13 -19
  22. package/src/native/components/__tests__/notes-screens.test.tsx +7 -7
  23. package/src/native/corpus/__tests__/counts.test.ts +82 -0
  24. package/src/native/corpus/__tests__/display.test.ts +37 -0
  25. package/src/native/corpus/api.ts +35 -2
  26. package/src/native/corpus/counts.ts +16 -0
  27. package/src/native/corpus/display.ts +62 -0
  28. package/src/native/corpus/fake-counts.ts +59 -0
  29. package/src/native/corpus/fake-tenant.ts +31 -3
  30. package/src/native/home/HomeScreen.tsx +15 -12
  31. package/src/native/home/__tests__/controller.test.ts +24 -11
  32. package/src/native/home/controller.ts +23 -17
  33. package/src/native/index.ts +3 -1
  34. package/src/native/screens/ask/AskScreen.tsx +20 -22
  35. package/src/native/screens/connect-claude/ConnectClaudeScreen.tsx +68 -61
  36. package/src/native/screens/connections/ConnectionsScreens.tsx +46 -42
  37. package/src/native/screens/library/LibraryDetailScreen.tsx +35 -49
  38. package/src/native/screens/library/LibraryListScreen.tsx +13 -21
  39. package/src/native/screens/planning/PlanningScreens.tsx +49 -26
  40. package/src/native/screens/planning/__tests__/controller.test.ts +17 -23
  41. package/src/native/screens/planning/controller.ts +18 -26
  42. package/src/native/tracker/TodoGlyph.tsx +11 -0
  43. package/src/native/tracker/TrackerDetailScreen.tsx +34 -39
  44. package/src/native/tracker/TrackerListScreen.tsx +28 -19
  45. package/src/native/tracker/__tests__/detail.test.ts +17 -0
  46. package/src/native/tracker/__tests__/format.test.ts +3 -3
  47. package/src/native/tracker/detail.ts +32 -19
  48. package/src/native/tracker/format.ts +8 -7
  49. package/src/native/voice/format.ts +0 -3
  50. package/src/native/screens/shared/PressableCard.tsx +0 -14
@@ -1,31 +1,31 @@
1
1
  import { useEffect, useMemo, useState } from 'react';
2
2
  import { View } from 'react-native';
3
- import { DataList, Header, Progress, SegmentedControl, StatusChip, Text, useTheme } from '@startsimpli/ui-native';
3
+ import { Card, DataList, DetailHero, Header, IconTile, ListRow, Progress, SegmentedControl, StatusChip, Text, useTheme } from '@startsimpli/ui-native';
4
4
  import { standingLabel } from '../../../corpus/planning';
5
5
  import type { Commitment, Focus, FocusStanding, SourceDocument } from '../../../corpus/types';
6
- import { PressableCard } from '../shared/PressableCard';
6
+ import { TodoGlyph } from '../../tracker/TodoGlyph';
7
7
  import { useControllerState } from '../../components/useControllerState';
8
8
  import {
9
9
  createFocusDetailController, createPlanningController,
10
10
  type FocusDetailController, type PlanningScreenApi, type PlanningController,
11
11
  } from './controller';
12
+ import { isOverdue } from '../../../corpus/work-item-logic';
12
13
  import { documentLine, focusChipStatus, focusMeta, focusStatusLabel, itemLine, progressPercent, targetLine } from './format';
13
14
 
14
- /** The standing, progress bar and facts for one focus. Shared by the list row and the detail header. */
15
+ /** The standing, progress bar and facts for one focus (a project card on the list). */
15
16
  function FocusSummary({ focus, standing }: { focus: Focus; standing: FocusStanding | null }) {
16
17
  const theme = useTheme();
17
18
  const percent = progressPercent(focus, standing);
18
19
  const meta = focusMeta(focus);
19
- const target = targetLine(focus);
20
20
  return (
21
- <View style={{ gap: theme.spacing.xs }}>
22
- <View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: theme.spacing.sm }}>
23
- <Text variant="heading" style={{ flex: 1, fontSize: theme.fontSizes.base }} numberOfLines={2}>{focus.title}</Text>
21
+ <View style={{ gap: theme.spacing.sm }}>
22
+ <View style={{ flexDirection: 'row', alignItems: 'flex-start', justifyContent: 'space-between', gap: theme.spacing.sm }}>
23
+ <Text variant="headline" style={{ flex: 1 }} numberOfLines={2}>{focus.title}</Text>
24
24
  <StatusChip status={focusChipStatus(focus.status)} label={focusStatusLabel(focus.status)} />
25
25
  </View>
26
- {meta ? <Text variant="caption">{meta}</Text> : null}
26
+ {meta ? <Text variant="footnote">{meta}</Text> : null}
27
27
  {percent !== null ? <Progress value={percent} /> : null}
28
- <Text variant="muted">{[standingLabel(standing), target].filter(Boolean).join(' · ')}</Text>
28
+ <Text variant="subhead" style={{ color: theme.colors.mutedForeground }}>{[standingLabel(standing), targetLine(focus)].filter(Boolean).join(' · ')}</Text>
29
29
  </View>
30
30
  );
31
31
  }
@@ -40,7 +40,7 @@ export function PlanningListScreen({ controller, onOpen }: PlanningListScreenPro
40
40
  const f = state.focuses;
41
41
  return (
42
42
  <View style={{ flex: 1 }}>
43
- <Header title="Planning" subtitle={f.count !== null ? `${f.count} project${f.count === 1 ? '' : 's'}` : undefined} />
43
+ <Header large title="Planning" subtitle={f.count !== null ? `${f.count} project${f.count === 1 ? '' : 's'}` : undefined} />
44
44
  <DataList
45
45
  testID="planning-list"
46
46
  data={f.items}
@@ -59,9 +59,9 @@ export function PlanningListScreen({ controller, onOpen }: PlanningListScreenPro
59
59
  noResultsTitle="No matching projects"
60
60
  ItemSeparatorComponent={() => <View style={{ height: theme.spacing.sm }} />}
61
61
  renderItem={({ item }: { item: Focus }) => (
62
- <PressableCard testID={`focus-${item.id}`} onPress={() => onOpen(item)}>
62
+ <Card testID={`focus-${item.id}`} onPress={() => onOpen(item)}>
63
63
  <FocusSummary focus={item} standing={state.standings[item.id] ?? null} />
64
- </PressableCard>
64
+ </Card>
65
65
  )}
66
66
  />
67
67
  </View>
@@ -99,10 +99,27 @@ export function DetailBody({ controller, onBack, onOpenDocument, now = Date.now
99
99
  if (next !== 'notes') void controller.setShowClosed(next === 'closed');
100
100
  };
101
101
  const clock = now();
102
+ const focus = state.focus;
103
+ const percent = focus ? progressPercent(focus, state.standing) : null;
102
104
  const header = (
103
- <View style={{ gap: theme.spacing.sm, paddingBottom: theme.spacing.sm }}>
104
- {state.focus ? <FocusSummary focus={state.focus} standing={state.standing} /> : null}
105
- {state.focus?.detail ? <Text variant="muted">{state.focus.detail}</Text> : null}
105
+ <View style={{ gap: theme.spacing.md, paddingBottom: theme.spacing.md }}>
106
+ {focus ? (
107
+ <>
108
+ <DetailHero
109
+ eyebrow="Project"
110
+ title={focus.title}
111
+ subtitle={focusMeta(focus) || undefined}
112
+ tags={<StatusChip status={focusChipStatus(focus.status)} label={focusStatusLabel(focus.status)} />}
113
+ />
114
+ <Card>
115
+ <View style={{ gap: theme.spacing.sm }}>
116
+ {percent !== null ? <Progress value={percent} /> : null}
117
+ <Text variant="callout">{[standingLabel(state.standing), targetLine(focus)].filter(Boolean).join(' · ')}</Text>
118
+ </View>
119
+ </Card>
120
+ {focus.detail ? <Text variant="body" style={{ color: theme.colors.mutedForeground }}>{focus.detail}</Text> : null}
121
+ </>
122
+ ) : null}
106
123
  <SegmentedControl<Mode>
107
124
  testID="planning-mode"
108
125
  value={mode}
@@ -114,11 +131,10 @@ export function DetailBody({ controller, onBack, onOpenDocument, now = Date.now
114
131
  const common = {
115
132
  onRefresh: () => { void controller.refresh(); },
116
133
  ListHeaderComponent: header,
117
- ItemSeparatorComponent: () => <View style={{ height: theme.spacing.sm }} />,
118
134
  };
119
135
  return (
120
- <View style={{ flex: 1 }} testID="planning-detail">
121
- <Header testID="planning-header" title={state.focus?.title ?? 'Project'} onBack={onBack} />
136
+ <View style={{ flex: 1, backgroundColor: theme.surface.grouped }} testID="planning-detail">
137
+ <Header testID="planning-header" title="Project" onBack={onBack} background={theme.surface.grouped} />
122
138
  {state.error ? (
123
139
  <View style={{ padding: theme.spacing.lg, gap: theme.spacing.sm }}>
124
140
  <Text variant="muted">{state.error}</Text>
@@ -138,10 +154,13 @@ export function DetailBody({ controller, onBack, onOpenDocument, now = Date.now
138
154
  emptyTitle="No notes yet"
139
155
  emptyDescription="Notes and documents filed under this project appear here."
140
156
  renderItem={({ item }: { item: SourceDocument }) => (
141
- <PressableCard testID={`doc-${item.id}`} onPress={onOpenDocument ? () => onOpenDocument(item.id) : undefined}>
142
- <Text variant="heading" style={{ fontSize: theme.fontSizes.base }}>{item.title}</Text>
143
- <Text variant="caption">{documentLine(item, clock)}</Text>
144
- </PressableCard>
157
+ <ListRow
158
+ testID={`doc-${item.id}`}
159
+ leading={<IconTile icon="note" tone="info" />}
160
+ title={item.title}
161
+ meta={documentLine(item, clock)}
162
+ onPress={onOpenDocument ? () => onOpenDocument(item.id) : undefined}
163
+ />
145
164
  )}
146
165
  />
147
166
  ) : (
@@ -159,10 +178,14 @@ export function DetailBody({ controller, onBack, onOpenDocument, now = Date.now
159
178
  emptyTitle={mode === 'closed' ? 'Nothing closed yet' : 'Nothing open'}
160
179
  emptyDescription={mode === 'closed' ? 'Finished items filed under this project appear here.' : 'Nothing is filed under this project yet.'}
161
180
  renderItem={({ item }: { item: Commitment }) => (
162
- <PressableCard testID={`item-${item.id}`}>
163
- <Text variant="heading" style={{ fontSize: theme.fontSizes.base }}>{item.title}</Text>
164
- {itemLine(item, clock) ? <Text variant="caption">{itemLine(item, clock)}</Text> : null}
165
- </PressableCard>
181
+ <ListRow
182
+ testID={`item-${item.id}`}
183
+ leading={<TodoGlyph status={item.status} overdue={isOverdue(item, clock)} />}
184
+ title={item.title}
185
+ meta={itemLine(item, clock) || undefined}
186
+ metaTone={isOverdue(item, clock) ? 'danger' : undefined}
187
+ chevron={false}
188
+ />
166
189
  )}
167
190
  />
168
191
  )}
@@ -25,7 +25,7 @@ describe('planning list: focuses with counts from the server', () => {
25
25
  c.stop();
26
26
  });
27
27
 
28
- it('walks the in_focus edges for open/done/overdue counts, as the web card does', async () => {
28
+ it('counts open/done/overdue for the whole page in two grouped reads, not three per card', async () => {
29
29
  const api = fakeApi();
30
30
  const c = createPlanningController({ api, now: () => NOW });
31
31
  await settle(() => Object.keys(c.getState().standings).length === 3);
@@ -33,29 +33,23 @@ describe('planning list: focuses with counts from the server', () => {
33
33
  expect(st.f287).toMatchObject({ total: 3, done: 0, overdue: 1 });
34
34
  expect(st.fma).toMatchObject({ total: 2, done: 1, overdue: 0 });
35
35
  expect(st.fdbg).toMatchObject({ total: 0, done: 0 });
36
- const counts = api.tenant.requests.filter((r) => r.params?.related_via === 'in_focus');
37
- expect(counts.length).toBeGreaterThanOrEqual(9);
38
- expect(counts.every((r) => r.params?.page_size === 1)).toBe(true);
36
+ const counts = api.tenant.requests.filter((r) => r.path.endsWith('entities/counts'));
37
+ expect(counts).toHaveLength(2);
38
+ expect(api.tenant.requests.filter((r) => r.params?.related_via === 'in_focus')).toHaveLength(0);
39
39
  c.stop();
40
40
  });
41
41
 
42
- it('fetches at most four standings at once', async () => {
43
- const api = fakeApi();
44
- let running = 0; let peak = 0;
45
- const real = api.corpus.focusStanding!.bind(api.corpus);
46
- api.corpus.focusStanding = async (id, now) => {
47
- running += 1; peak = Math.max(peak, running);
48
- await tick();
49
- try { return await real(id, now); } finally { running -= 1; }
50
- };
42
+ it('a long page of projects still costs two count reads, plus one more per further page', async () => {
51
43
  const entities = sampleTenantEntities();
52
- for (let i = 0; i < 10; i += 1) entities.push({ id: `x${i}`, entity_type: 'focus', external_id: `focus:x${i}`, name: `X${i}`, created_at: '2026-09-10T00:00:00Z', org_id: 'tandem', data: { title: `X${i}`, status: 'active' } } as never);
44
+ for (let i = 0; i < 30; i += 1) entities.push({ id: `x${i}`, entity_type: 'focus', external_id: `focus:x${i}`, name: `X${i}`, created_at: '2026-09-10T00:00:00Z', org_id: 'tandem', data: { title: `X${i}`, status: 'active' } } as never);
53
45
  const many = createFakeNativeCorpusApi({ entities, relationships: sampleTenantRelationships() });
54
- many.corpus.focusStanding = api.corpus.focusStanding;
55
46
  const c = createPlanningController({ api: many, now: () => NOW });
56
- await settle(() => Object.keys(c.getState().standings).length === 13);
57
- expect(Object.keys(c.getState().standings)).toHaveLength(13);
58
- expect(peak).toBeLessThanOrEqual(4);
47
+ await settle(() => Object.keys(c.getState().standings).length === 25);
48
+ expect(Object.keys(c.getState().standings)).toHaveLength(25);
49
+ expect(many.tenant.requests.filter((r) => r.path.endsWith('entities/counts'))).toHaveLength(2);
50
+ await c.loadMore();
51
+ await settle(() => Object.keys(c.getState().standings).length === 33);
52
+ expect(many.tenant.requests.filter((r) => r.path.endsWith('entities/counts'))).toHaveLength(4);
59
53
  c.stop();
60
54
  });
61
55
 
@@ -67,14 +61,14 @@ describe('planning list: focuses with counts from the server', () => {
67
61
  c.stop();
68
62
  });
69
63
 
70
- it('a standing that fails leaves that card uncounted instead of failing the list', async () => {
64
+ it('standings that fail leave the cards uncounted instead of failing the list', async () => {
71
65
  const api = fakeApi();
72
- const real = api.corpus.focusStanding!.bind(api.corpus);
73
- api.corpus.focusStanding = async (id, now) => { if (id === 'fma') throw new Error('boom'); return real(id, now); };
66
+ api.standings = async () => { throw new Error('boom'); };
74
67
  const c = createPlanningController({ api, now: () => NOW });
75
- await settle(() => Object.keys(c.getState().standings).length === 2);
68
+ await settle(() => !c.getState().focuses.loading);
69
+ await tick();
76
70
  expect(c.getState().focuses.error).toBeNull();
77
- expect(c.getState().standings.fma).toBeUndefined();
71
+ expect(c.getState().standings).toEqual({});
78
72
  c.stop();
79
73
  });
80
74
 
@@ -3,8 +3,8 @@
3
3
  * native corpus api - the same adapters the web `PlanningPage` uses.
4
4
  *
5
5
  * Server-side only: the focus list is one server page at a time (worst-off first,
6
- * the order the stored `progress` buys), each card's counts are `focusStanding`
7
- * (three count-only reads walking the `in_focus` edge, exactly the web card's),
6
+ * the order the stored `progress` buys), each page's card counts are `api.standings`
7
+ * (two grouped `entities/counts` reads for the WHOLE page, not three per card),
8
8
  * and a project's items and documents are server-paged queries filtered by the
9
9
  * focus edge. Nothing loads a list to narrow, sort or page it on the phone.
10
10
  */
@@ -14,10 +14,8 @@ import type { NativeCorpusApi } from '../../corpus/api';
14
14
  import type { PagedList, PagedListState } from '../../corpus/paged';
15
15
  import { createStore, errorMessage } from '../store';
16
16
 
17
- export type PlanningScreenApi = Pick<NativeCorpusApi, 'lists' | 'corpus' | 'entities' | 'scope'>;
17
+ export type PlanningScreenApi = Pick<NativeCorpusApi, 'lists' | 'corpus' | 'entities' | 'scope' | 'standings'>;
18
18
 
19
- /** How many standings are fetched at once - each is three reads, and the tenant pays for every one. */
20
- export const STANDING_CONCURRENCY = 4;
21
19
  export const FOCUS_PAGE_SIZE = 25;
22
20
  export const DOCUMENT_PAGE_SIZE = 10;
23
21
  export const ITEM_PAGE_SIZE = 25;
@@ -46,32 +44,26 @@ export interface PlanningDeps {
46
44
  now?: () => number;
47
45
  }
48
46
 
49
- /** Worker pool that runs standing reads `STANDING_CONCURRENCY` at a time. */
50
- function createStandingFetcher(api: PlanningScreenApi, now: () => number, onResult: (s: FocusStanding) => void) {
47
+ /**
48
+ * Standings for each page of projects as it arrives: ONE batched call per page
49
+ * (two grouped reads, however many cards), never one request set per card.
50
+ */
51
+ function createStandingFetcher(api: PlanningScreenApi, now: () => number, onResult: (s: Record<string, FocusStanding>) => void) {
51
52
  const requested = new Set<string>();
52
- const queue: string[] = [];
53
- let running = 0;
54
53
  let stopped = false;
55
54
 
56
- function pump() {
57
- while (!stopped && running < STANDING_CONCURRENCY && queue.length) {
58
- const id = queue.shift() as string;
59
- running += 1;
60
- Promise.resolve()
61
- .then(() => api.corpus.focusStanding!(id, now()))
62
- .then((s) => { if (!stopped) onResult(s); }, () => { /* uncounted, not a failed list */ })
63
- .finally(() => { running -= 1; pump(); });
64
- }
65
- }
66
-
67
55
  return {
68
56
  request(ids: string[]) {
69
- if (!api.corpus.focusStanding) return;
70
- for (const id of ids) if (!requested.has(id)) { requested.add(id); queue.push(id); }
71
- pump();
57
+ const fresh = ids.filter((id) => !requested.has(id));
58
+ if (!fresh.length) return;
59
+ fresh.forEach((id) => requested.add(id));
60
+ api.standings(fresh, now()).then(
61
+ (found) => { if (!stopped) onResult(found); },
62
+ () => { fresh.forEach((id) => requested.delete(id)); /* uncounted, not a failed list */ },
63
+ );
72
64
  },
73
65
  forget() { requested.clear(); },
74
- stop() { stopped = true; queue.length = 0; },
66
+ stop() { stopped = true; },
75
67
  };
76
68
  }
77
69
 
@@ -80,7 +72,7 @@ export function createPlanningController({ api, now = Date.now }: PlanningDeps):
80
72
  const store = createStore<{ standings: Record<string, FocusStanding>; search: string }>({ standings: {}, search: '' });
81
73
  const listeners = new Set<() => void>();
82
74
  const notify = () => listeners.forEach((l) => l());
83
- const counts = createStandingFetcher(api, now, (s) => store.set({ standings: { ...store.getState().standings, [s.focusId]: s } }));
75
+ const counts = createStandingFetcher(api, now, (found) => store.set({ standings: { ...store.getState().standings, ...found } }));
84
76
 
85
77
  // One cached snapshot, rebuilt only when a part changes: `useSyncExternalStore` loops on a getState that returns a new object each call.
86
78
  let snapshot: PlanningState = { focuses: list.getState(), standings: store.getState().standings, search: store.getState().search };
@@ -147,7 +139,7 @@ export function createFocusDetailController(
147
139
  if (!stopped) store.set({ focus: null, error: errorMessage(e, 'This project could not be loaded.') });
148
140
  }
149
141
  try {
150
- const standing = await api.corpus.focusStanding?.(focusId, now());
142
+ const standing = (await api.standings([focusId], now()))[focusId];
151
143
  if (!stopped && standing) store.set({ standing });
152
144
  } catch { /* the header shows no count rather than a wrong one */ }
153
145
  }
@@ -0,0 +1,11 @@
1
+ import { Icon, useTheme } from '@startsimpli/ui-native';
2
+ import type { CommitmentStatus } from '../../corpus/types';
3
+
4
+ /** The leading mark of a to-do: an open ring, a green check when done, red ring when overdue, amber when blocked. */
5
+ export function TodoGlyph({ status, overdue = false, size = 22 }: { status: CommitmentStatus; overdue?: boolean; size?: number }) {
6
+ const { tones, colors } = useTheme();
7
+ if (status === 'done') return <Icon name="check" size={size} color={tones.success.fg} />;
8
+ if (status === 'dropped') return <Icon name="close" size={size} color={colors.mutedForeground} />;
9
+ if (status === 'blocked') return <Icon name="alert" size={size} color={tones.warning.fg} />;
10
+ return <Icon name="circle" size={size} color={overdue ? tones.danger.fg : colors.mutedForeground} />;
11
+ }
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useMemo } from 'react';
2
- import { ScrollView, View } from 'react-native';
3
- import { Alert, Button, Card, CardContent, Header, Spinner, StatusChip, Text, useTheme } from '@startsimpli/ui-native';
2
+ import { View } from 'react-native';
3
+ import { Alert, Button, DetailScreen, Section, StatusChip, Text, useTheme } from '@startsimpli/ui-native';
4
4
  import type { NativeCorpusApi } from '../corpus/api';
5
5
  import { usePullRefresh } from '../components/usePullRefresh';
6
6
  import { useControllerState } from '../components/useControllerState';
@@ -26,59 +26,54 @@ export function TrackerDetailScreen({ api, id, onBack, onOpenNote, onChanged, no
26
26
  const s = useControllerState(controller);
27
27
  const item = s.item;
28
28
  const refreshControl = usePullRefresh(() => controller.load());
29
+ const frame = { title: 'To-do', onBack, headerTestID: 'todo-header', testID: 'todo-detail', refreshControl } as const;
29
30
 
30
31
  if (!item) {
31
- return (
32
- <View style={{ flex: 1 }}>
33
- <Header title="To-do" onBack={onBack} testID="todo-header" />
34
- <ScrollView testID="todo-detail" refreshControl={refreshControl} contentContainerStyle={{ padding: theme.spacing.lg }}>
35
- {s.loading ? <Spinner /> : <Alert variant="destructive">{s.error ?? 'This to-do is no longer available.'}</Alert>}
36
- </ScrollView>
37
- </View>
38
- );
32
+ return s.loading
33
+ ? <DetailScreen {...frame} loading />
34
+ : <DetailScreen {...frame} unavailable={{ title: s.error ?? 'This to-do is no longer available' }} />;
39
35
  }
40
36
 
41
37
  const closed = item.status === 'done' || item.status === 'dropped';
42
38
  const due = formatDue(item.dueAt, now());
43
- const meta = [
44
- due ? `${isOverdueAt(item, now()) ? 'Overdue · ' : 'Due '}${due}` : null,
45
- item.ownerName ? `Owner ${item.ownerName}` : null,
46
- s.projectTitle ? `Project ${s.projectTitle}` : null,
47
- priorityText(item.priority),
48
- ].filter(Boolean) as string[];
39
+ const overdue = isOverdueAt(item, now());
49
40
 
50
41
  return (
51
- <View style={{ flex: 1 }}>
52
- <Header title="To-do" onBack={onBack} testID="todo-header" />
53
- <ScrollView testID="todo-detail" refreshControl={refreshControl} contentContainerStyle={{ padding: theme.spacing.lg, gap: theme.spacing.md }}>
54
- <Text variant="heading">{item.title}</Text>
55
- <View style={{ flexDirection: 'row', alignItems: 'center', gap: theme.spacing.sm }}>
56
- <StatusChip status={item.status} />
57
- </View>
58
- {meta.map((line) => <Text key={line} variant="muted">{line}</Text>)}
59
- {item.statusReason ? <Text variant="caption">{item.statusReason}</Text> : null}
60
- {item.detail ? <Text>{item.detail}</Text> : null}
61
- {s.error ? <Alert variant="destructive">{s.error}</Alert> : null}
42
+ <DetailScreen
43
+ {...frame}
44
+ hero={{ eyebrow: 'To-do', title: item.title, tags: <StatusChip status={item.status} />, subtitle: item.statusReason || undefined }}
45
+ meta={[
46
+ { label: 'Due', value: due ? `${overdue ? 'Overdue · ' : ''}${due}` : '', tone: overdue ? 'danger' : undefined },
47
+ { label: 'Owner', value: item.ownerName ?? '' },
48
+ { label: 'Project', value: s.projectTitle ?? '' },
49
+ { label: 'Priority', value: priorityText(item.priority) ?? '' },
50
+ ]}
51
+ banner={s.error ? <Alert variant="destructive">{s.error}</Alert> : undefined}
52
+ actions={(
62
53
  <Button
63
54
  testID="todo-toggle"
64
55
  title={closed ? 'Reopen' : 'Mark done'}
65
56
  variant={closed ? 'outline' : 'primary'}
57
+ size="lg"
66
58
  disabled={s.busy}
67
59
  onPress={() => { void controller.setStatus(closed ? 'open' : 'done'); }}
68
60
  />
69
- {s.sources.length ? <Text variant="caption" style={{ fontWeight: '600' }}>WHERE IT CAME FROM</Text> : null}
70
- {s.sources.map((src) => (
71
- <Card key={`${src.documentId}-${src.quote.slice(0, 24)}`}>
72
- <CardContent>
73
- <Text style={{ fontWeight: '600' }}>{src.title}{src.section ? ` · ${src.section}` : ''}</Text>
74
- {src.quote ? <Text variant="muted" style={{ fontStyle: 'italic' }}>{`“${src.quote}”`}</Text> : null}
61
+ )}
62
+ >
63
+ {item.detail ? <Section title="Details"><View style={{ paddingVertical: theme.spacing.md }}><Text variant="body">{item.detail}</Text></View></Section> : null}
64
+ {s.sources.length ? (
65
+ <Section title="Where it came from">
66
+ {s.sources.map((src) => (
67
+ <View key={`${src.documentId}-${src.quote.slice(0, 24)}`} style={{ paddingVertical: theme.spacing.md, gap: theme.spacing.xs }}>
68
+ <Text variant="headline">{src.title}{src.section ? ` · ${src.section}` : ''}</Text>
69
+ {src.quote ? <Text variant="callout" style={{ fontStyle: 'italic', color: theme.colors.mutedForeground }}>{`“${src.quote}”`}</Text> : null}
75
70
  {src.isVoiceNote && onOpenNote ? (
76
- <Button testID={`todo-open-note-${src.documentId}`} title="Open note" variant="ghost" size="sm" style={{ alignSelf: 'flex-start' }} onPress={() => onOpenNote(src.documentId)} />
71
+ <Button testID={`todo-open-note-${src.documentId}`} title="Open note" variant="outline" size="sm" style={{ alignSelf: 'flex-start', marginTop: theme.spacing.xs }} onPress={() => onOpenNote(src.documentId)} />
77
72
  ) : null}
78
- </CardContent>
79
- </Card>
80
- ))}
81
- </ScrollView>
82
- </View>
73
+ </View>
74
+ ))}
75
+ </Section>
76
+ ) : null}
77
+ </DetailScreen>
83
78
  );
84
79
  }
@@ -1,11 +1,12 @@
1
1
  import { useEffect, useState } from 'react';
2
2
  import { View } from 'react-native';
3
- import { DataList, Header, ListRow, StatusChip, SwipeRow, Text, useTheme, type FilterGroup } from '@startsimpli/ui-native';
3
+ import { Alert, DataList, Header, ListRow, StatusChip, SwipeRow, useTheme, type FilterGroup } from '@startsimpli/ui-native';
4
4
  import { UNFILED_PROJECT } from '../../corpus/filing';
5
5
  import type { Commitment } from '../../corpus/types';
6
6
  import { useControllerState } from '../components/useControllerState';
7
7
  import type { TrackerController, TrackerRow } from './controller';
8
- import { TRACKER_VIEWS, rowSubtitle, type TrackerView } from './format';
8
+ import { TodoGlyph } from './TodoGlyph';
9
+ import { TRACKER_VIEWS, rowParts, type TrackerView } from './format';
9
10
 
10
11
  export interface TrackerListScreenProps {
11
12
  controller: TrackerController;
@@ -41,27 +42,35 @@ export function TrackerListScreen({ controller, onOpen, now = Date.now }: Tracke
41
42
  ];
42
43
  const isFiltered = state.filters.focusId !== null || state.filters.search.trim() !== '';
43
44
 
44
- const renderRow = ({ item: row }: { item: TrackerRow }) => (
45
- <SwipeRow
46
- testID={`todo-${row.item.id}`}
47
- actions={closed
48
- ? [{ key: 'reopen', label: 'Reopen', tone: 'neutral', onPress: () => { void controller.setStatus(row.item, 'open'); } }]
49
- : [{ key: 'done', label: 'Done', tone: 'success', onPress: () => { void controller.setStatus(row.item, 'done'); } }]}
50
- >
51
- <ListRow
52
- title={row.item.title}
53
- subtitle={rowSubtitle(row.item, titleOf(row.focusId), now()) || undefined}
54
- trailing={<StatusChip status={row.item.status} />}
55
- onPress={() => onOpen(row.item)}
56
- />
57
- </SwipeRow>
58
- );
45
+ const renderRow = ({ item: row }: { item: TrackerRow }) => {
46
+ const parts = rowParts(row.item, titleOf(row.focusId), now());
47
+ const status = row.item.status;
48
+ return (
49
+ <SwipeRow
50
+ testID={`todo-${row.item.id}`}
51
+ actions={closed
52
+ ? [{ key: 'reopen', label: 'Reopen', tone: 'neutral', onPress: () => { void controller.setStatus(row.item, 'open'); } }]
53
+ : [{ key: 'done', label: 'Done', tone: 'success', onPress: () => { void controller.setStatus(row.item, 'done'); } }]}
54
+ >
55
+ <ListRow
56
+ leading={<TodoGlyph status={status} overdue={parts.overdue} />}
57
+ title={row.item.title}
58
+ subtitle={parts.who || undefined}
59
+ meta={parts.due ?? undefined}
60
+ metaTone={parts.overdue ? 'danger' : undefined}
61
+ // Open is the default and needs no badge; blocked and dropped do.
62
+ trailing={status === 'blocked' || status === 'dropped' ? <StatusChip status={status} /> : undefined}
63
+ onPress={() => onOpen(row.item)}
64
+ />
65
+ </SwipeRow>
66
+ );
67
+ };
59
68
 
60
69
  const subtitle = state.count !== null ? `${state.count} ${closed ? 'closed' : 'to go'}${isFiltered ? ' (filtered)' : ''}` : undefined;
61
70
 
62
71
  return (
63
72
  <View style={{ flex: 1 }} testID="todos-screen">
64
- <Header testID="todos-header" title="To-dos" subtitle={subtitle} />
73
+ <Header large testID="todos-header" title="To-dos" subtitle={subtitle} />
65
74
  <DataList<TrackerRow>
66
75
  testID="tracker-list"
67
76
  data={state.rows}
@@ -88,7 +97,7 @@ export function TrackerListScreen({ controller, onOpen, now = Date.now }: Tracke
88
97
  noResultsTitle="No to-dos match"
89
98
  ListHeaderComponent={state.ignoredFilters.length ? (
90
99
  <View style={{ paddingBottom: theme.spacing.sm }}>
91
- <Text variant="caption" style={{ color: theme.colors.destructive }}>This workspace did not apply: {state.ignoredFilters.join(', ')}. The list is not filtered by it.</Text>
100
+ <Alert variant="notice">{`This workspace did not apply: ${state.ignoredFilters.join(', ')}. The list is not filtered by it.`}</Alert>
92
101
  </View>
93
102
  ) : undefined}
94
103
  />
@@ -23,6 +23,23 @@ describe('tracker detail controller', () => {
23
23
  expect(api.tenant.requests.filter((r) => r.params?.type === 'commitment')).toHaveLength(0);
24
24
  });
25
25
 
26
+ it('reads a to-do in two rounds of requests, the source documents in ONE batched read', async () => {
27
+ const { api } = await open('c3');
28
+ const reads = api.tenant.requests.filter((r) => r.method === 'GET');
29
+ // round 1: the to-do + its project edge; round 2: the project + all source documents.
30
+ expect(reads).toHaveLength(4);
31
+ const docs = reads.filter((r) => r.params?.id__in !== undefined);
32
+ expect(docs).toHaveLength(1);
33
+ expect(docs[0].params).toMatchObject({ type: 'source_document', id__in: 'd2' });
34
+ // no per-document GET of /entities/<id> and no participants walk
35
+ expect(reads.filter((r) => /entities\/d2$/.test(r.path))).toHaveLength(0);
36
+ });
37
+
38
+ it('a to-do with no mentions does not ask for documents at all', async () => {
39
+ const { api } = await open('c4');
40
+ expect(api.tenant.requests.filter((r) => r.params?.id__in !== undefined)).toHaveLength(0);
41
+ });
42
+
26
43
  it('titles a non-voice source from its document and does not offer the Notes link', async () => {
27
44
  const { c } = await open('c3');
28
45
  const [src] = c.getState().sources;
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from 'vitest';
2
2
  import { UNFILED_PROJECT } from '../../../corpus/filing';
3
- import { DEFAULT_TRACKER_FILTERS, formatDue, isOverdueAt, leavesView, rowSubtitle, trackerQuery } from '../format';
3
+ import { DEFAULT_TRACKER_FILTERS, formatDue, isOverdueAt, leavesView, rowParts, trackerQuery } from '../format';
4
4
 
5
5
  const NOW = Date.parse('2026-11-05T00:00:00Z');
6
6
 
@@ -40,7 +40,7 @@ describe('row text', () => {
40
40
  });
41
41
  it('subtitle joins due, owner and project', () => {
42
42
  const item = { dueAt: '2026-11-01T00:00:00Z', status: 'open', ownerName: 'Quinn' } as never;
43
- expect(rowSubtitle(item, '287A', NOW)).toBe('Overdue · Nov 1 · Quinn · 287A');
44
- expect(rowSubtitle({ status: 'open' } as never, undefined, NOW)).toBe('');
43
+ expect(rowParts(item, '287A', NOW)).toEqual({ due: 'Overdue · Nov 1', overdue: true, who: 'Quinn · 287A' });
44
+ expect(rowParts({ status: 'open' } as never, undefined, NOW)).toEqual({ due: null, overdue: false, who: '' });
45
45
  });
46
46
  });
@@ -1,10 +1,11 @@
1
1
  /**
2
- * One to-do, read directly (one entity read, its project edge, and the source
3
- * documents its mentions point at) - never by scanning the list. Mark done /
2
+ * One to-do, read directly (the entity and its project edge together, then the
3
+ * project and ALL source documents together) - never by scanning the list and
4
+ * never one read per mention. Mark done /
4
5
  * reopen is optimistic and rolls back with the server's reason.
5
6
  */
6
- import type { Commitment, CommitmentStatus } from '../../corpus/types';
7
- import { toCommitment } from '../../corpus/entities';
7
+ import type { Commitment, CommitmentStatus, SourceDocument } from '../../corpus/types';
8
+ import { DEFAULT_TYPE_KEYS, toCommitment, toSourceDocument } from '../../corpus/entities';
8
9
  import type { NativeCorpusApi } from '../corpus/api';
9
10
  import { statusText } from './format';
10
11
 
@@ -37,7 +38,7 @@ export interface TrackerDetailController {
37
38
  }
38
39
 
39
40
  export interface TrackerDetailOptions {
40
- api: Pick<NativeCorpusApi, 'entities' | 'corpus' | 'relationships' | 'commitments' | 'scope'>;
41
+ api: Pick<NativeCorpusApi, 'entities' | 'relationships' | 'commitments' | 'scope'>;
41
42
  id: string;
42
43
  /** Called after a status write succeeds, so the list can refresh. */
43
44
  onChanged?: () => void;
@@ -56,23 +57,35 @@ export function createTrackerDetailController({ api, id, onChanged }: TrackerDet
56
57
  async load() {
57
58
  set({ loading: true, error: null });
58
59
  try {
59
- const item = toCommitment(await api.entities.get(id), api.scope);
60
- const edge = await api.relationships.list({ relType: 'in_focus', source: id, pageSize: 1 }).catch(() => null);
60
+ // Round 1: the to-do and its project edge are independent. Round 2: the
61
+ // project's name and ALL source documents (one `id__in` read, not one
62
+ // read per mention).
63
+ const [entity, edge] = await Promise.all([
64
+ api.entities.get(id),
65
+ api.relationships.list({ relType: 'in_focus', source: id, pageSize: 1 }).catch(() => null),
66
+ ]);
67
+ const item = toCommitment(entity, api.scope);
61
68
  const focusId = edge?.items[0]?.target;
62
- const [project, sources] = await Promise.all([
69
+ const documentIds = [...new Set(item.mentions.map((m) => m.documentId))];
70
+ const [project, documents] = await Promise.all([
63
71
  focusId ? api.entities.get(String(focusId)).then((f) => f.name || null).catch(() => null) : Promise.resolve(null),
64
- Promise.all(item.mentions.map(async (m): Promise<TrackerSource> => {
65
- const doc = await api.corpus.getDocument?.(m.documentId).catch(() => null);
66
- return {
67
- documentId: m.documentId,
68
- title: doc?.title || item.sourceLabel || 'Source',
69
- quote: m.quote,
70
- occurredAt: m.occurredAt ?? doc?.occurredAt ?? null,
71
- ...(m.section ? { section: m.section } : {}),
72
- isVoiceNote: (doc?.source ?? item.source) === 'voice',
73
- };
74
- })),
72
+ documentIds.length
73
+ ? api.entities.list({ type: DEFAULT_TYPE_KEYS.document, filters: { idIn: documentIds }, pageSize: documentIds.length })
74
+ .then((page) => new Map(page.items.map((e) => [String(e.id), toSourceDocument(e, api.scope)])))
75
+ .catch(() => new Map<string, SourceDocument>())
76
+ : Promise.resolve(new Map<string, SourceDocument>()),
75
77
  ]);
78
+ const sources = item.mentions.map((m): TrackerSource => {
79
+ const doc = documents.get(m.documentId);
80
+ return {
81
+ documentId: m.documentId,
82
+ title: doc?.title || item.sourceLabel || 'Source',
83
+ quote: m.quote,
84
+ occurredAt: m.occurredAt ?? doc?.occurredAt ?? null,
85
+ ...(m.section ? { section: m.section } : {}),
86
+ isVoiceNote: (doc?.source ?? item.source) === 'voice',
87
+ };
88
+ });
76
89
  set({ loading: false, item, projectTitle: project, sources });
77
90
  } catch (e) {
78
91
  set({ loading: false, item: null, error: (e as { status?: number })?.status === 404 ? 'This to-do is no longer available.' : msg(e) });