@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.
- package/package.json +4 -4
- package/src/__tests__/focus-standings.test.tsx +119 -0
- package/src/components/pages/PlanningPage.tsx +16 -4
- package/src/corpus/client.ts +5 -0
- package/src/corpus/entity-query.ts +67 -4
- package/src/corpus/index.ts +4 -2
- package/src/corpus/standings.ts +75 -0
- package/src/corpus/types.ts +6 -0
- package/src/native/__tests__/design-screens.test.tsx +97 -0
- package/src/native/__tests__/ux-polish.test.tsx +4 -2
- package/src/native/app/FoundryApp.tsx +2 -2
- package/src/native/app/__tests__/launch.test.ts +4 -1
- package/src/native/app/entity/EntityTab.tsx +13 -18
- package/src/native/app/icon.tsx +6 -1
- package/src/native/app/launch.ts +4 -0
- package/src/native/app/screens/RecordScreen.tsx +37 -30
- package/src/native/app/screens/SignInScreen.tsx +4 -3
- package/src/native/components/FoundryTabsShell.tsx +8 -5
- package/src/native/components/MoreTabList.tsx +20 -25
- package/src/native/components/NoteDetailScreen.tsx +49 -57
- package/src/native/components/NotesListScreen.tsx +13 -19
- package/src/native/components/__tests__/notes-screens.test.tsx +7 -7
- package/src/native/corpus/__tests__/counts.test.ts +82 -0
- package/src/native/corpus/__tests__/display.test.ts +37 -0
- package/src/native/corpus/api.ts +35 -2
- package/src/native/corpus/counts.ts +16 -0
- package/src/native/corpus/display.ts +62 -0
- package/src/native/corpus/fake-counts.ts +59 -0
- package/src/native/corpus/fake-tenant.ts +31 -3
- package/src/native/home/HomeScreen.tsx +15 -12
- package/src/native/home/__tests__/controller.test.ts +24 -11
- package/src/native/home/controller.ts +23 -17
- package/src/native/index.ts +3 -1
- package/src/native/screens/ask/AskScreen.tsx +20 -22
- package/src/native/screens/connect-claude/ConnectClaudeScreen.tsx +68 -61
- package/src/native/screens/connections/ConnectionsScreens.tsx +46 -42
- package/src/native/screens/library/LibraryDetailScreen.tsx +35 -49
- package/src/native/screens/library/LibraryListScreen.tsx +13 -21
- package/src/native/screens/planning/PlanningScreens.tsx +49 -26
- package/src/native/screens/planning/__tests__/controller.test.ts +17 -23
- package/src/native/screens/planning/controller.ts +18 -26
- package/src/native/tracker/TodoGlyph.tsx +11 -0
- package/src/native/tracker/TrackerDetailScreen.tsx +34 -39
- package/src/native/tracker/TrackerListScreen.tsx +28 -19
- package/src/native/tracker/__tests__/detail.test.ts +17 -0
- package/src/native/tracker/__tests__/format.test.ts +3 -3
- package/src/native/tracker/detail.ts +32 -19
- package/src/native/tracker/format.ts +8 -7
- package/src/native/voice/format.ts +0 -3
- 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 {
|
|
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
|
|
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.
|
|
22
|
-
<View style={{ flexDirection: 'row', alignItems: '
|
|
23
|
-
<Text variant="
|
|
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="
|
|
26
|
+
{meta ? <Text variant="footnote">{meta}</Text> : null}
|
|
27
27
|
{percent !== null ? <Progress value={percent} /> : null}
|
|
28
|
-
<Text variant="
|
|
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
|
-
<
|
|
62
|
+
<Card testID={`focus-${item.id}`} onPress={() => onOpen(item)}>
|
|
63
63
|
<FocusSummary focus={item} standing={state.standings[item.id] ?? null} />
|
|
64
|
-
</
|
|
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.
|
|
104
|
-
{
|
|
105
|
-
|
|
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=
|
|
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
|
-
<
|
|
142
|
-
|
|
143
|
-
<
|
|
144
|
-
|
|
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
|
-
<
|
|
163
|
-
|
|
164
|
-
{
|
|
165
|
-
|
|
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('
|
|
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.
|
|
37
|
-
expect(counts
|
|
38
|
-
expect(
|
|
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('
|
|
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 <
|
|
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 ===
|
|
57
|
-
expect(Object.keys(c.getState().standings)).toHaveLength(
|
|
58
|
-
expect(
|
|
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('
|
|
64
|
+
it('standings that fail leave the cards uncounted instead of failing the list', async () => {
|
|
71
65
|
const api = fakeApi();
|
|
72
|
-
|
|
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(() =>
|
|
68
|
+
await settle(() => !c.getState().focuses.loading);
|
|
69
|
+
await tick();
|
|
76
70
|
expect(c.getState().focuses.error).toBeNull();
|
|
77
|
-
expect(c.getState().standings
|
|
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
|
|
7
|
-
* (
|
|
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
|
-
/**
|
|
50
|
-
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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;
|
|
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, (
|
|
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.
|
|
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 {
|
|
3
|
-
import { Alert, Button,
|
|
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
|
-
<
|
|
33
|
-
|
|
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
|
|
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
|
-
<
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
{
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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="
|
|
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
|
-
</
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
</
|
|
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,
|
|
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 {
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
<
|
|
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,
|
|
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(
|
|
44
|
-
expect(
|
|
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 (
|
|
3
|
-
*
|
|
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' | '
|
|
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
|
-
|
|
60
|
-
|
|
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
|
|
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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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) });
|