@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startsimpli/integrations",
3
- "version": "0.2.102",
3
+ "version": "0.2.104",
4
4
  "description": "Provider-agnostic types, API clients, hooks, and UI primitives for email + calendar integrations across StartSimpli apps, plus foundry customer email (subpath ./comms).",
5
5
  "license": "MIT",
6
6
  "homepage": "https://startsimpli.com",
@@ -48,11 +48,11 @@
48
48
  "@tanstack/react-query": ">=5.0.0",
49
49
  "@startsimpli/llm": ">=0.4.0",
50
50
  "react-native": ">=0.74.0",
51
- "@startsimpli/ui-native": ">=0.1.0",
51
+ "@startsimpli/ui-native": ">=0.1.10",
52
52
  "react-native-safe-area-context": ">=4.0.0",
53
- "@startsimpli/ui": "^0.4.170",
54
53
  "@startsimpli/auth": "^0.4.49",
55
- "@startsimpli/utils": "^0.4.17"
54
+ "@startsimpli/utils": "^0.4.17",
55
+ "@startsimpli/ui": "^0.4.170"
56
56
  },
57
57
  "peerDependenciesMeta": {
58
58
  "react": {
@@ -0,0 +1,119 @@
1
+ import { render, screen, waitFor } from '@testing-library/react';
2
+ import { describe, expect, it, vi } from 'vitest';
3
+ import { PlanningPage } from '../components/pages/PlanningPage';
4
+ import { createPlanningApi } from '../corpus/client';
5
+ import { readStandings, standingsFrom } from '../corpus/standings';
6
+ import type { FocusStanding, PlanningApi } from '../corpus/types';
7
+ import { FIXTURE_DOCUMENTS } from '../corpus/fixtures';
8
+ import type { TenantEntity, TenantRelationship } from '../corpus/entities';
9
+ import { createFakeTenantHttp } from '../native/corpus/fake-tenant';
10
+
11
+ const SCOPE = FIXTURE_DOCUMENTS[0].scope;
12
+ const NOW = Date.parse('2026-11-05T00:00:00Z');
13
+
14
+ function countsHttp() {
15
+ const gets: Array<{ path: string; params: Record<string, unknown> }> = [];
16
+ return {
17
+ gets,
18
+ http: {
19
+ async get<T>(path: string, init?: { params?: Record<string, unknown> }): Promise<T> {
20
+ const params = init?.params ?? {};
21
+ gets.push({ path, params });
22
+ if (params.group_by === 'edge:in_focus,attr.status') {
23
+ return { results: [
24
+ { values: ['a', 'open'], count: 2 },
25
+ { values: ['a', 'done'], count: 1 },
26
+ { values: ['b', 'open'], count: 1 },
27
+ ] } as T;
28
+ }
29
+ return { results: [{ values: ['a'], count: 1 }] } as T;
30
+ },
31
+ },
32
+ };
33
+ }
34
+
35
+ describe('readStandings: never a false zero from a truncated page', () => {
36
+ it('reads EVERY page of the grouped answer: 100 projects x 3 statuses is 300 rows', async () => {
37
+ const focuses = Array.from({ length: 100 }, (_, i) => ({ id: `p${String(i).padStart(3, '0')}`, entity_type: 'focus', name: `P${i}`, created_at: '2026-09-01T00:00:00Z', data: {} }));
38
+ const todos: TenantEntity[] = [];
39
+ const edges: TenantRelationship[] = [];
40
+ focuses.forEach((f, i) => (['open', 'done', 'blocked'] as const).forEach((status, k) => {
41
+ const id = `t${i}-${k}`;
42
+ todos.push({ id, entity_type: 'commitment', name: id, created_at: '2026-09-02T00:00:00Z', data: { status } });
43
+ edges.push({ id: `e${id}`, rel_type: 'in_focus', source: id, target: f.id });
44
+ }));
45
+ const tenant = createFakeTenantHttp({ entities: [...(focuses as TenantEntity[]), ...todos], relationships: edges });
46
+ const out = await readStandings(tenant.http as never, focuses.map((f) => f.id), NOW);
47
+ expect(Object.values(out).every((s) => s.total === 3 && s.done === 1)).toBe(true);
48
+ expect(out.p099).toMatchObject({ total: 3, done: 1 });
49
+ // 300 rows at 200 per page: two pages for the status read, one for overdue.
50
+ expect(tenant.requests.filter((r) => r.path.endsWith('counts'))).toHaveLength(3);
51
+ });
52
+ });
53
+
54
+ describe('readStandings: a page of projects in two grouped reads', () => {
55
+ it('computes total, done and overdue and includes every id asked for', async () => {
56
+ const { http, gets } = countsHttp();
57
+ const out = await readStandings(http, ['a', 'b', 'c'], NOW);
58
+ expect(out).toEqual({
59
+ a: { focusId: 'a', total: 3, done: 1, overdue: 1 },
60
+ b: { focusId: 'b', total: 1, done: 0, overdue: 0 },
61
+ c: { focusId: 'c', total: 0, done: 0, overdue: 0 },
62
+ });
63
+ expect(gets).toHaveLength(2);
64
+ expect(gets[0]).toMatchObject({ path: 'api/v1/entities/counts', params: { type: 'commitment', edge_targets: 'a,b,c', group_by: 'edge:in_focus,attr.status' } });
65
+ expect(gets[1].params).toMatchObject({ 'attr.status': 'open', 'attr.due_at__lte': '2026-11-05T00:00:00.000Z', group_by: 'edge:in_focus' });
66
+ });
67
+
68
+ it('more than 200 projects go out in chunks of 200', async () => {
69
+ const { http, gets } = countsHttp();
70
+ const ids = Array.from({ length: 250 }, (_, i) => `f${i}`);
71
+ const out = await readStandings(http, ids, NOW);
72
+ expect(Object.keys(out)).toHaveLength(250);
73
+ expect(gets).toHaveLength(4);
74
+ });
75
+
76
+ it('no projects, no requests; duplicates are asked once', async () => {
77
+ const { http, gets } = countsHttp();
78
+ expect(await readStandings(http, [], NOW)).toEqual({});
79
+ await readStandings(http, ['a', 'a'], NOW);
80
+ expect(gets[0].params.edge_targets).toBe('a');
81
+ });
82
+
83
+ it('createPlanningApi exposes it as focusStandings with its own type key and path', async () => {
84
+ const { http, gets } = countsHttp();
85
+ const api = createPlanningApi({ http: http as never, scope: SCOPE, typeKeys: { commitment: 'todo' }, paths: { entities: 'v1/e' } });
86
+ await api.focusStandings!(['a'], NOW);
87
+ expect(gets[0]).toMatchObject({ path: 'v1/e/counts', params: { type: 'todo' } });
88
+ });
89
+
90
+ it('standingsFrom ignores a group for a project not on the page', () => {
91
+ expect(standingsFrom(['a'], [{ group: { 'edge:in_focus': 'zzz', 'attr.status': 'open' }, count: 5 }], [])).toEqual({ a: { focusId: 'a', total: 0, done: 0, overdue: 0 } });
92
+ });
93
+ });
94
+
95
+ const page = <T,>(results: T[]) => ({ count: results.length, next: null, previous: null, results, appliedFilters: ['status'] });
96
+ const FOCUS = { id: 'f1', title: 'Crochets', status: 'active', scope: SCOPE } as never;
97
+
98
+ function planning(extra: Partial<PlanningApi>): PlanningApi {
99
+ return { listCommitments: async () => page([]), listFocuses: async () => page([FOCUS]), ...extra } as PlanningApi;
100
+ }
101
+
102
+ describe('PlanningPage standings', () => {
103
+ it('uses ONE batched read for every card and never the per-card path', async () => {
104
+ const focusStanding = vi.fn();
105
+ const focusStandings = vi.fn(async (): Promise<Record<string, FocusStanding>> => ({ f1: { focusId: 'f1', total: 40, done: 12, overdue: 3 } }));
106
+ render(<PlanningPage api={planning({ focusStanding, focusStandings })} scope={SCOPE} now={NOW} />);
107
+ await waitFor(() => expect(screen.getByText(/12 of 40 done/)).toBeInTheDocument());
108
+ expect(focusStandings).toHaveBeenCalledTimes(1);
109
+ expect(focusStanding).not.toHaveBeenCalled();
110
+ });
111
+
112
+ it('falls back to a standing per card on a tenant that predates the endpoint', async () => {
113
+ const focusStandings = vi.fn(async () => { throw new Error('400'); });
114
+ const focusStanding = vi.fn(async (focusId: string): Promise<FocusStanding> => ({ focusId, total: 10, done: 5, overdue: 0 }));
115
+ render(<PlanningPage api={planning({ focusStanding, focusStandings })} scope={SCOPE} now={NOW} />);
116
+ await waitFor(() => expect(screen.getByText(/5 of 10 done/)).toBeInTheDocument());
117
+ expect(focusStanding).toHaveBeenCalledTimes(1);
118
+ });
119
+ });
@@ -171,10 +171,22 @@ export function PlanningPage({
171
171
  let live = true;
172
172
  void (async () => {
173
173
  const loaded = await loadFocuses();
174
- if (!live || !apiRef.current.focusStanding) return;
175
- // Bounded fan-out, and the clock is passed IN so "overdue" is computed
176
- // against the frozen mount time rather than a fresh Date.now() per call.
177
- const standing = apiRef.current.focusStanding.bind(apiRef.current);
174
+ if (!live) return;
175
+ const api = apiRef.current;
176
+ // The clock is passed IN so "overdue" is computed against the frozen mount
177
+ // time rather than a fresh Date.now() per call.
178
+ if (api.focusStandings) {
179
+ // The whole page in two grouped reads. A tenant that predates the
180
+ // endpoint refuses it, and the per-card path below still works.
181
+ try {
182
+ const found = await api.focusStandings(loaded.map((f) => f.id), clock);
183
+ if (!live) return;
184
+ setStandings((prev) => ({ ...prev, ...found }));
185
+ return;
186
+ } catch { /* fall through to one standing per card */ }
187
+ }
188
+ if (!api.focusStanding) return;
189
+ const standing = api.focusStanding.bind(api);
178
190
  for (let i = 0; i < loaded.length && live; i += STANDING_CONCURRENCY) {
179
191
  const slice = loaded.slice(i, i + STANDING_CONCURRENCY);
180
192
  const results = await Promise.all(
@@ -30,6 +30,7 @@
30
30
  * second copy of the graph that will drift; the edge is the declared contract,
31
31
  * so the edge is what is read. The join is cached, bounded and fails soft.
32
32
  */
33
+ import { readStandings } from './standings';
33
34
  import {
34
35
  DEFAULT_PARTICIPANT_EDGES,
35
36
  FOLDER_ROOT,
@@ -1449,6 +1450,10 @@ export function createPlanningApi(options: CreateCorpusApiOptions): PlanningApi
1449
1450
  return { focusId, total, done, overdue };
1450
1451
  },
1451
1452
 
1453
+ focusStandings: (focusIds, now) => readStandings(http, focusIds, now ?? Date.now(), {
1454
+ commitmentType: types.commitment, entitiesPath: entities,
1455
+ }),
1456
+
1452
1457
  /**
1453
1458
  * The tenant's real members, for the owner picker — what closes the
1454
1459
  * free-text-owner gap (bd startsim-768w.38.29).
@@ -9,8 +9,8 @@
9
9
  *
10
10
  * Server contract: start-simpli-api `tenant-starter/apps/api/filters.py`.
11
11
  * page, page_size (max 200), search, order=recent|oldest|relevance|[-]attr.<name>,
12
- * type, id, id__in (comma list), external_id, external_id__in (REPEATED param),
13
- * source, party, scope, occurred_after/before, created_after/before,
12
+ * type, type__in (comma list), id, id__in (comma list), external_id, external_id__in (REPEATED param),
13
+ * source, party, scope, occurred_after/before, created_after/before, updated_after,
14
14
  * related_to + related_via/related_direction/related_depth,
15
15
  * unrelated_via + unrelated_direction (rows with NO such edge),
16
16
  * attr.<name>[__op] (op: in gt gte lt lte icontains isnull isblank startswith
@@ -31,6 +31,8 @@ export type EntityOrder =
31
31
  export type AttrValue = string | number | boolean | null | undefined;
32
32
 
33
33
  export interface EntityFilters {
34
+ /** Several types in one read (`type__in`): the newest rows across a Home's types. Use instead of `EntityQuery.type`. */
35
+ typeIn?: string[];
34
36
  id?: string;
35
37
  idIn?: string[];
36
38
  externalId?: string;
@@ -43,6 +45,12 @@ export interface EntityFilters {
43
45
  occurredBefore?: string;
44
46
  createdAfter?: string;
45
47
  createdBefore?: string;
48
+ /**
49
+ * Only rows touched strictly AFTER this instant (`updated_after`): pass back the
50
+ * newest `updated_at` held for a cheap refresh. Deletions are not reported; a
51
+ * client reconciles those with a full read.
52
+ */
53
+ updatedAfter?: string;
46
54
  relatedTo?: string;
47
55
  relatedVia?: string | string[];
48
56
  relatedDirection?: 'out' | 'in' | 'any';
@@ -57,7 +65,8 @@ export interface EntityFilters {
57
65
  }
58
66
 
59
67
  export interface EntityQuery {
60
- type: string;
68
+ /** Omit only with `filters.typeIn`. */
69
+ type?: string;
61
70
  search?: string;
62
71
  order?: EntityOrder;
63
72
  filters?: EntityFilters;
@@ -90,6 +99,7 @@ function put(out: Record<string, unknown>, key: string, value: unknown): void {
90
99
  /** Filters that are common to the list and to facets. */
91
100
  export function entityFilterParams(filters: EntityFilters = {}): Record<string, unknown> {
92
101
  const out: Record<string, unknown> = {};
102
+ if (filters.typeIn?.length) out.type__in = filters.typeIn.join(',');
93
103
  put(out, 'id', filters.id);
94
104
  if (filters.idIn?.length) out.id__in = idList('id__in', filters.idIn);
95
105
  put(out, 'external_id', filters.externalId);
@@ -106,6 +116,7 @@ export function entityFilterParams(filters: EntityFilters = {}): Record<string,
106
116
  put(out, 'occurred_before', filters.occurredBefore);
107
117
  put(out, 'created_after', filters.createdAfter);
108
118
  put(out, 'created_before', filters.createdBefore);
119
+ put(out, 'updated_after', filters.updatedAfter);
109
120
  if (filters.relatedTo) {
110
121
  out.related_to = filters.relatedTo;
111
122
  // Companions only ride along with a target: alone the server ignores them.
@@ -138,7 +149,9 @@ export function attrParams(attr: EntityQuery['attr'] = {}): Record<string, unkno
138
149
 
139
150
  /** `EntityQuery` -> the query string parameters of `GET api/v1/entities/`. */
140
151
  export function entityParams(query: EntityQuery): Record<string, unknown> {
141
- const out: Record<string, unknown> = { type: query.type, page: query.page ?? 1 };
152
+ const out: Record<string, unknown> = {};
153
+ put(out, 'type', query.type);
154
+ out.page = query.page ?? 1;
142
155
  if (query.pageSize) out.page_size = Math.min(Math.max(1, query.pageSize), MAX_PAGE_SIZE);
143
156
  const search = query.search?.trim();
144
157
  if (search) out.search = search.slice(0, TEXT_FILTER_MAX);
@@ -164,6 +177,56 @@ export function facetParams(query: FacetQuery): Record<string, unknown> {
164
177
  return out;
165
178
  }
166
179
 
180
+ /**
181
+ * `GET api/v1/entities/counts/`: how many rows, grouped by up to two keys - ONE
182
+ * request for a Home tile row, a filter badge row or a page of project cards.
183
+ * Every list filter narrows it exactly as it narrows the list.
184
+ *
185
+ * Group keys: `type`, `attr.<name>`, `edge:<rel_type>[:out|in]` (the id at the
186
+ * other end of the row's edge; the row is the source for `out`, the default).
187
+ * `edgeTargets` bounds an edge key to one page of far-end ids.
188
+ */
189
+ export type CountGroup = 'type' | `attr.${string}` | `edge:${string}`;
190
+
191
+ export interface CountQuery extends Omit<EntityQuery, 'order'> {
192
+ groupBy: CountGroup[];
193
+ edgeTargets?: string[];
194
+ }
195
+
196
+ /** A group value: an id, a status, a type key; `null` is "none" (unfiled, no status). */
197
+ export type CountValue = string | number | boolean | null;
198
+
199
+ export interface CountRow {
200
+ /** Keyed by the group token the query asked for, e.g. `{ 'edge:in_focus': 'f1', 'attr.status': 'open' }`. */
201
+ group: Record<string, CountValue>;
202
+ count: number;
203
+ }
204
+
205
+ /**
206
+ * What the server sends: values by POSITION (`group_by` order), never keyed by
207
+ * token. A group token is data, and the apps' API client camelCases response
208
+ * KEYS (`edge:in_focus` -> `edge:inFocus`), which would make every lookup miss.
209
+ */
210
+ export interface WireCountRow { values: CountValue[]; count: number }
211
+
212
+ /** Wire rows -> rows keyed by the tokens the CALLER asked for, in that order. */
213
+ export function toCountRows(groupBy: CountGroup[], rows: WireCountRow[] | undefined): CountRow[] {
214
+ return (rows ?? []).map((row) => ({
215
+ group: Object.fromEntries(groupBy.map((token, i) => [token, row.values?.[i] ?? null])),
216
+ count: row.count,
217
+ }));
218
+ }
219
+
220
+ export function countParams(query: CountQuery): Record<string, unknown> {
221
+ if (query.groupBy.length < 1 || query.groupBy.length > 2) {
222
+ throw new Error('groupBy: name one or two keys.');
223
+ }
224
+ const out = entityParams({ ...query, order: undefined });
225
+ out.group_by = query.groupBy.join(',');
226
+ if (query.edgeTargets?.length) out.edge_targets = idList('edge_targets', query.edgeTargets);
227
+ return out;
228
+ }
229
+
167
230
  export interface RelationshipListQuery {
168
231
  source?: string;
169
232
  target?: string;
@@ -262,11 +262,13 @@ export type {
262
262
  VoiceTranscriber,
263
263
  } from './voice';
264
264
 
265
+ export { readStandings, standingsFrom } from './standings';
266
+ export type { StandingsOptions } from './standings';
265
267
  export {
266
- attrParams, entityFilterParams, entityParams, facetParams, reconcileFilters, relationshipParams,
268
+ attrParams, countParams, entityFilterParams, entityParams, facetParams, reconcileFilters, relationshipParams,
267
269
  sentFilterNames, toEntityPage,
268
270
  } from './entity-query';
269
271
  export type {
270
- AttrValue, EntityFilters, EntityOrder, EntityPage, EntityQuery, FacetQuery, FilterReport,
272
+ AttrValue, CountGroup, CountQuery, CountRow, EntityFilters, EntityOrder, EntityPage, EntityQuery, FacetQuery, FilterReport,
271
273
  FilterVerdict, RelationshipListQuery,
272
274
  } from './entity-query';
@@ -0,0 +1,75 @@
1
+ /**
2
+ * "12 of 40 done, 3 overdue" for a PAGE of projects, from two grouped reads of
3
+ * `GET api/v1/entities/counts/` (bd startsim-09zue) - however many projects the
4
+ * page holds. It replaces `focusStanding`'s three count-only reads PER project
5
+ * (a 100-project web page was 300 requests). The web and native Planning screens
6
+ * share this one reader.
7
+ *
8
+ * `all` to-dos per project x status -> total, done
9
+ * `overdue` open to-dos past due, per project -> overdue
10
+ *
11
+ * Every id asked for is in the result, zeros when the project holds nothing, so a
12
+ * card never waits on a count that will not come.
13
+ */
14
+ import { MAX_PAGE_SIZE, countParams, toCountRows, type CountQuery, type CountRow, type WireCountRow } from './entity-query';
15
+ import type { CorpusHttp } from './client';
16
+ import type { FocusStanding } from './types';
17
+ import { MAX_ID_LIST } from './entities';
18
+
19
+ const IN_FOCUS_KEY = 'edge:in_focus';
20
+ const STATUS_KEY = 'attr.status';
21
+
22
+ export interface StandingsOptions {
23
+ /** The tenant's commitment type key (default `commitment`). */
24
+ commitmentType?: string;
25
+ entitiesPath?: string;
26
+ }
27
+
28
+ export function standingsFrom(focusIds: string[], all: CountRow[], overdue: CountRow[]): Record<string, FocusStanding> {
29
+ const out: Record<string, FocusStanding> = {};
30
+ for (const focusId of focusIds) out[focusId] = { focusId, total: 0, done: 0, overdue: 0 };
31
+ for (const row of all) {
32
+ const target = out[String(row.group[IN_FOCUS_KEY])];
33
+ if (!target) continue;
34
+ target.total += row.count;
35
+ if (row.group[STATUS_KEY] === 'done') target.done += row.count;
36
+ }
37
+ for (const row of overdue) {
38
+ const target = out[String(row.group[IN_FOCUS_KEY])];
39
+ if (target) target.overdue += row.count;
40
+ }
41
+ return out;
42
+ }
43
+
44
+ export async function readStandings(
45
+ http: Pick<CorpusHttp, 'get'>,
46
+ focusIds: string[],
47
+ now: number,
48
+ options: StandingsOptions = {},
49
+ ): Promise<Record<string, FocusStanding>> {
50
+ const ids = [...new Set(focusIds)];
51
+ if (!ids.length) return {};
52
+ const path = `${options.entitiesPath ?? 'api/v1/entities'}/counts`;
53
+ const type = options.commitmentType ?? 'commitment';
54
+ const asOf = new Date(now).toISOString();
55
+ // EVERY page of a grouped read: a chunk of ids x their statuses can exceed one
56
+ // page, and a row that is not read becomes a false zero on a project card.
57
+ const rows = async (query: CountQuery): Promise<CountRow[]> => {
58
+ const out: CountRow[] = [];
59
+ for (let page = 1; ; page += 1) {
60
+ const body = await http.get<{ results?: WireCountRow[]; next?: string | null }>(path, { params: countParams({ ...query, page }) });
61
+ out.push(...toCountRows(query.groupBy, body.results));
62
+ if (!body.next) return out;
63
+ }
64
+ };
65
+ const chunks: string[][] = [];
66
+ for (let i = 0; i < ids.length; i += MAX_ID_LIST) chunks.push(ids.slice(i, i + MAX_ID_LIST));
67
+ const parts = await Promise.all(chunks.map(async (edgeTargets) => {
68
+ const [all, overdue] = await Promise.all([
69
+ rows({ type, groupBy: [IN_FOCUS_KEY, STATUS_KEY], edgeTargets, pageSize: MAX_PAGE_SIZE }),
70
+ rows({ type, groupBy: [IN_FOCUS_KEY], edgeTargets, pageSize: MAX_PAGE_SIZE, attr: { status: 'open', due_at__lte: asOf } }),
71
+ ]);
72
+ return standingsFrom(edgeTargets, all, overdue);
73
+ }));
74
+ return Object.assign({}, ...parts);
75
+ }
@@ -1373,6 +1373,12 @@ export interface PlanningApi extends CommitmentApi {
1373
1373
  listChildFocuses?(focusId: string): Promise<CorpusPage<Focus>>;
1374
1374
  /** Counts for one focus, from `count` alone — no row bodies cross the wire. */
1375
1375
  focusStanding?(focusId: string, now?: number): Promise<FocusStanding>;
1376
+ /**
1377
+ * Counts for a whole PAGE of projects in two grouped reads (`entities/counts`),
1378
+ * keyed by focus id. Prefer it over calling `focusStanding` per card; a tenant
1379
+ * that predates the endpoint rejects it and the caller falls back.
1380
+ */
1381
+ focusStandings?(focusIds: string[], now?: number): Promise<Record<string, FocusStanding>>;
1376
1382
  /** The tenant's real members, for the owner picker. Absent when the fork is
1377
1383
  * not wired to central, in which case owners stay free text. */
1378
1384
  listMembers?(): Promise<Array<{ sub: string; email: string; name?: string }>>;
@@ -0,0 +1,97 @@
1
+ /** startsim-o1xg5: the screens speak the shared design language (row primitives, detail scaffold, tinted status, sections). */
2
+ import { describe, expect, it, vi } from 'vitest';
3
+ import { act, allText, flat, hostById, maybeById, render, darkTheme } from '../../../../ui-native/test/render';
4
+ import { NoteDetailScreen } from '../components/NoteDetailScreen';
5
+ import { NotesListScreen } from '../components/NotesListScreen';
6
+ import { MoreTabList } from '../components/MoreTabList';
7
+ import { createFakeNativeCorpusApi } from '../corpus/fake';
8
+ import { createTrackerController } from '../tracker/controller';
9
+ import { TrackerDetailScreen } from '../tracker/TrackerDetailScreen';
10
+ import { TrackerListScreen } from '../tracker/TrackerListScreen';
11
+ import { rowParts } from '../tracker/format';
12
+ import { createVoiceNotesController } from '../voice/controller';
13
+ import { createFakeVoiceApi } from '../voice/fake';
14
+
15
+ const settle = () => act(async () => { await new Promise((res) => setTimeout(res, 0)); });
16
+ const NOW = Date.parse('2026-11-05T00:00:00Z');
17
+ const hasChevron = (n: any) => n.findAll((x: any) => x.type === 'Svg').length > 0;
18
+
19
+ describe('Notes list rows', () => {
20
+ async function mount() {
21
+ const controller = createVoiceNotesController({ api: createFakeVoiceApi(), pollMs: 60_000 });
22
+ const r = render(<NotesListScreen controller={controller} onOpen={vi.fn()} />);
23
+ await act(async () => { await controller.start?.(); });
24
+ await settle();
25
+ return r;
26
+ }
27
+ it('a ready note has no status badge; a failed or transcribing one does', async () => {
28
+ const r = await mount();
29
+ expect(allText(r)).toContain('Failed');
30
+ expect(allText(r)).toContain('Transcribing...');
31
+ expect(allText(r)).not.toContain('Ready');
32
+ });
33
+ it('rows are pressable with a disclosure chevron and a microphone tile', async () => {
34
+ const r = await mount();
35
+ const row = hostById(r, 'note-row-n1');
36
+ expect(row.props.accessibilityRole).toBe('button');
37
+ expect(hasChevron(row)).toBe(true);
38
+ });
39
+ it('the title is a large title', async () => {
40
+ const r = await mount();
41
+ const title = hostById(r, 'notes-header').findAll((n: any) => n.type === 'Text')[0];
42
+ expect(flat(title.props.style).fontSize).toBeGreaterThanOrEqual(28);
43
+ });
44
+ });
45
+
46
+ describe('To-dos', () => {
47
+ it('rowParts splits the due line from who / project and flags overdue', () => {
48
+ const item: any = { id: 'x', title: 't', status: 'open', dueAt: '2026-11-04T00:00:00Z', ownerName: 'Quinn' };
49
+ expect(rowParts(item, '287A', NOW)).toEqual({ due: 'Overdue · Nov 4', overdue: true, who: 'Quinn · 287A' });
50
+ expect(rowParts({ ...item, dueAt: null }, undefined, NOW)).toEqual({ due: null, overdue: false, who: 'Quinn' });
51
+ });
52
+ it('an open to-do shows no "Open" badge, an overdue one reads in the danger tone', async () => {
53
+ const api = createFakeNativeCorpusApi({});
54
+ const controller = createTrackerController({ api, now: () => NOW });
55
+ const r = render(<TrackerListScreen controller={controller} onOpen={vi.fn()} now={() => NOW} />, darkTheme);
56
+ await act(async () => { await controller.start(); });
57
+ await settle();
58
+ expect(allText(r)).not.toMatch(/(^|[^a-z])Open($|[^a-z])/);
59
+ const overdue = r.root.findAll((n: any) => n.type === 'Text' && String(n.props.children).startsWith('Overdue ·'));
60
+ expect(flat(overdue[0].props.style).color).toBe(darkTheme.tones.danger.fg);
61
+ });
62
+ it('the detail is hero, facts, then the action, and reopens in the same scaffold', async () => {
63
+ const api = createFakeNativeCorpusApi({});
64
+ const r = render(<TrackerDetailScreen api={api} id="c1" onBack={vi.fn()} now={() => NOW} />);
65
+ await settle(); await settle();
66
+ const text = allText(r);
67
+ expect(text.indexOf('Finish exhibit list')).toBeLessThan(text.indexOf('Owner'));
68
+ expect(text.indexOf('Owner')).toBeLessThan(text.indexOf('Mark done'));
69
+ expect(maybeById(r, 'todo-toggle')).toHaveLength(1);
70
+ });
71
+ });
72
+
73
+ describe('Note detail', () => {
74
+ it('uses the scaffold: hero with the project tag, to-dos as rows, project section, delete in the footer', async () => {
75
+ const controller = createVoiceNotesController({ api: createFakeVoiceApi(), pollMs: 60_000 });
76
+ const r = render(<NoteDetailScreen controller={controller} noteId="n1" onBack={vi.fn()} />);
77
+ await settle(); await settle();
78
+ const text = allText(r);
79
+ expect(text.indexOf('Voice note')).toBeLessThan(text.indexOf('Finish exhibit list'));
80
+ expect(text).toContain('Project');
81
+ expect(text.indexOf('Project')).toBeLessThan(text.indexOf('Delete note'));
82
+ expect(maybeById(r, 'note-delete')).toHaveLength(1);
83
+ });
84
+ });
85
+
86
+ describe('More list', () => {
87
+ it('one grouped row per overflow tab, each with an icon tile and a chevron', () => {
88
+ const tabs: any[] = [{ key: 'library', label: 'Library', description: 'Documents' }, { key: 'weird-key', label: 'Weird' }];
89
+ const open = vi.fn();
90
+ const r = render(<MoreTabList tabs={tabs} onOpen={open} />);
91
+ expect(allText(r)).toContain('Library');
92
+ expect(allText(r)).toContain('Documents');
93
+ for (const k of ['library', 'weird-key']) expect(hasChevron(hostById(r, `more-row-${k}`))).toBe(true);
94
+ act(() => { hostById(r, 'more-row-library').props.onPress(); });
95
+ expect(open).toHaveBeenCalledWith('library');
96
+ });
97
+ });
@@ -93,7 +93,9 @@ describe('detail screens (bd .13)', () => {
93
93
  await settle();
94
94
  const back = hostById(r, 'note-back');
95
95
  expect(back.props.accessibilityLabel).toBe('Back');
96
- expect(texts(back).join('')).toBe('‹');
96
+ // The chevron is a drawn icon (no text glyph) and there is no text label beside it.
97
+ expect(texts(back).join('')).toBe('');
98
+ expect(back.findAll((n: any) => n.type === 'Svg')).toHaveLength(1);
97
99
  press(back);
98
100
  expect(onBack).toHaveBeenCalled();
99
101
  });
@@ -102,7 +104,7 @@ describe('detail screens (bd .13)', () => {
102
104
  const controller = createVoiceNotesController({ api: createFakeVoiceApi(), pollMs: 60_000 });
103
105
  const r = render(<NoteDetailScreen controller={controller} noteId="nope" onBack={vi.fn()} />);
104
106
  await settle();
105
- expect(texts(hostById(r, 'note-back')).join('')).toBe('‹');
107
+ expect(texts(hostById(r, 'note-back')).join('')).toBe('');
106
108
  expect(allText(r)).toContain('no longer available');
107
109
  });
108
110
 
@@ -27,7 +27,7 @@ export interface FoundryAppProps {
27
27
  screens?: Record<string, ScreenFactory>;
28
28
  }
29
29
 
30
- function Themed({ mode, children }: { mode: FoundryAppConfig['theme']['mode']; children: ReactNode }) {
30
+ function Themed({ mode, children }: { mode: FoundryAppConfig['theme']['mode'] | 'light' | 'dark'; children: ReactNode }) {
31
31
  const scheme = useColorScheme();
32
32
  const dark = mode === 'dark' || (mode === 'system' && scheme !== 'light');
33
33
  return (
@@ -116,7 +116,7 @@ function Root({ config, device, registry }: { config: FoundryAppConfig; device:
116
116
  }, [nav, services, restoreStore, launch.fake]);
117
117
 
118
118
  return (
119
- <Themed mode={config.theme.mode}>
119
+ <Themed mode={launch.scheme ?? config.theme.mode}>
120
120
  {auth === 'unknown' || (auth === 'signedIn' && !nav) ? <Spinner /> : null}
121
121
  {auth === 'signedOut' ? <SignInScreen strings={strings} notice={expired ? strings.sessionExpired : null} onSignIn={(e, p) => services.session.signIn(e, p)} /> : null}
122
122
  {auth === 'signedIn' && nav && !showDiag ? (
@@ -7,7 +7,7 @@ const args = (o: Record<string, string>) => (k: string) => o[k];
7
7
 
8
8
  describe('readLaunch', () => {
9
9
  it('a plain launch is real mode with nothing to open', () => {
10
- expect(readLaunch(args({}), config)).toEqual({ fake: false, scenario: 'normal', target: null, autostop: null });
10
+ expect(readLaunch(args({}), config)).toEqual({ fake: false, scenario: 'normal', target: null, autostop: null, scheme: null });
11
11
  });
12
12
  it('-tgFakeTabs with -tgTab and -tgDetail', () => {
13
13
  expect(readLaunch(args({ tgFakeTabs: '1', tgTab: 'tracker', tgDetail: 'c1' }), config)).toMatchObject({ fake: true, target: { tab: 'tracker', id: 'c1' } });
@@ -20,6 +20,9 @@ describe('readLaunch', () => {
20
20
  it('-tgFakeState and -tgAutostop', () => {
21
21
  expect(readLaunch(args({ tgFakeTabs: '1', tgFakeState: 'empty', tgAutostop: '30' }), config)).toMatchObject({ scenario: 'empty', autostop: 30 });
22
22
  expect(readLaunch(args({ tgAutostop: 'x' }), config).autostop).toBeNull();
23
+ expect(readLaunch(args({ tgScheme: 'light' }), config).scheme).toBe('light');
24
+ expect(readLaunch(args({ tgScheme: 'dark' }), config).scheme).toBe('dark');
25
+ expect(readLaunch(args({ tgScheme: 'neon' }), config).scheme).toBeNull();
23
26
  });
24
27
  it('an app with no notes tab ignores the notes arguments', () => {
25
28
  const none = resolveFoundryApp({ app: { name: 'A' }, tenant: { url: 'http://x' }, features: { notes: false } });
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useMemo, useState } from 'react';
2
- import { ScrollView, View } from 'react-native';
3
- import { Alert, DataList, Header, ListRow, Spinner, StatusChip, Text, useTheme } from '@startsimpli/ui-native';
2
+ import { View } from 'react-native';
3
+ import { Alert, DataList, DetailScreen, Header, IconTile, ListRow, StatusChip } from '@startsimpli/ui-native';
4
4
  import type { TenantEntity } from '../../../corpus/entities';
5
5
  import type { FoundryTab, TabContext } from '../../components/FoundryTabsShell';
6
6
  import { useControllerState } from '../../components/useControllerState';
@@ -18,7 +18,7 @@ function EntityList({ api, type, spec, onOpen }: { api: Api; type: string; spec:
18
18
  const plural = spec.plural ?? `${spec.label}s`;
19
19
  return (
20
20
  <View style={{ flex: 1 }} testID={`entity-${type}-screen`}>
21
- <Header title={plural} subtitle={state.count !== null ? `${state.count}` : undefined} />
21
+ <Header large title={plural} subtitle={state.count !== null ? `${state.count}` : undefined} />
22
22
  <DataList<EntityRowView>
23
23
  testID={`entity-${type}-list`}
24
24
  data={rows}
@@ -26,6 +26,7 @@ function EntityList({ api, type, spec, onOpen }: { api: Api; type: string; spec:
26
26
  renderItem={({ item }) => (
27
27
  <View testID={`entity-${item.id}`}>
28
28
  <ListRow
29
+ leading={<IconTile icon="note" tone="info" />}
29
30
  title={item.title}
30
31
  subtitle={item.subtitle}
31
32
  trailing={item.status ? <StatusChip status={item.status} /> : undefined}
@@ -48,7 +49,6 @@ function EntityList({ api, type, spec, onOpen }: { api: Api; type: string; spec:
48
49
  }
49
50
 
50
51
  function EntityDetail({ api, spec, id, onBack }: { api: Api; spec: FoundryEntityType; id: string; onBack: () => void }) {
51
- const theme = useTheme();
52
52
  const [entity, setEntity] = useState<TenantEntity | null>(null);
53
53
  const [error, setError] = useState<string | null>(null);
54
54
  useEffect(() => {
@@ -60,20 +60,15 @@ function EntityDetail({ api, spec, id, onBack }: { api: Api; spec: FoundryEntity
60
60
  }, [api, id]);
61
61
  const row = entity ? entityRow(entity, spec) : null;
62
62
  return (
63
- <View style={{ flex: 1 }}>
64
- <Header testID="entity-detail" title={row?.title ?? spec.label} subtitle={row?.subtitle} onBack={onBack} />
65
- <ScrollView contentContainerStyle={{ padding: theme.spacing.lg, gap: theme.spacing.md }}>
66
- {error ? <Alert variant="destructive">{error}</Alert> : null}
67
- {!entity && !error ? <Spinner /> : null}
68
- {row?.status ? <StatusChip status={row.status} /> : null}
69
- {entity ? entityFields(entity).map((f) => (
70
- <View key={f.key} style={{ gap: 2 }}>
71
- <Text variant="caption">{f.label}</Text>
72
- <Text selectable>{f.value}</Text>
73
- </View>
74
- )) : null}
75
- </ScrollView>
76
- </View>
63
+ <DetailScreen
64
+ title={spec.label}
65
+ onBack={onBack}
66
+ headerTestID="entity-detail"
67
+ loading={!entity && !error}
68
+ unavailable={!entity && error ? { title: 'Could not load this record', description: error } : undefined}
69
+ hero={row ? { eyebrow: spec.label, title: row.title, subtitle: row.subtitle, tags: row.status ? <StatusChip status={row.status} /> : undefined } : undefined}
70
+ meta={entity ? entityFields(entity).map((f) => ({ label: f.label, value: f.value, wide: f.value.length > 24 })) : undefined}
71
+ />
77
72
  );
78
73
  }
79
74