@startsimpli/integrations 0.2.203 → 0.2.205

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.
@@ -1,49 +1,37 @@
1
1
  /**
2
- * The Library — the corpus surface, as ONE composer (bd startsim-768w.38.6).
2
+ * The Library — everything pulled in, as ONE table (bd startsim-768w.38.6; table redesign startsim-x3pd3).
3
3
  *
4
- * `<LibraryPage api={corpus} scope={scope} />` is the whole integration. An app
5
- * owns theme classNames and a wrapper of ten lines, the same shape as
6
- * `ConnectionsPage` and for the same reason: shipping primitives and letting
7
- * each app assemble the page just relocates the duplication one level up
8
- * (feedback_share_page_composers_not_just_primitives).
4
+ * `<LibraryPage api={corpus} scope={scope} />` is the whole integration. The screen is a left tree
5
+ * (All documents, then each source with its count and, only where it has folders, its folders), one
6
+ * compact toolbar (search, Type, Date) and the shared DataTable with the shared pagination footer.
7
+ * Connector health lives in the Sources table, not here; no title, no subtitle, no pills.
9
8
  *
10
- * WHAT IT RENDERS, in the order the question is actually asked:
9
+ * EVERY filter, the sort and the page are SERVER parameters (CLAUDE.md rule 8); nothing is filtered
10
+ * in the browser. A filter the server did not apply is said out loud, and a row from another
11
+ * workspace is never drawn (`enforceScope`), whatever the API returned.
11
12
  *
12
- * 1. FRESHNESS per source — when did each one last pull, and did it work. This
13
- * is on the screen, not in a settings page, because a corpus silently four
14
- * days stale is what makes an AI answer confidently wrong.
15
- * 2. FILTERS — search, source, party, date window. Every one of them is a
16
- * SERVER parameter (CLAUDE.md rule 8); nothing is filtered in the browser.
17
- * 3. The LIST, every row wearing its source as a visible badge.
18
- * 4. The DETAIL, with participants as Party links and whatever long-form the
19
- * source attached, under the source's own name for it.
13
+ * LOAD ORDER (the queue order on a server that answers one request at a time): the ROWS first (one
14
+ * documents read, no people), then the people on each row, then the source counts that fill the
15
+ * tree, then the folders of each source one source at a time. Its test is
16
+ * `library-call-shape.test.tsx`.
20
17
  *
21
- * NOTHING HERE NAMES A VENDOR. The standing test for every element below is
22
- * "would this row, badge, filter or empty state still make sense if the only
23
- * connected source were Dropbox?" — so the source list comes from the freshness
24
- * data, the badge renders whatever label the catalog gave it, and long-form text
25
- * is a labelled `section` rather than a transcript. A screen that only works for
26
- * meeting notes is a failed design even though it would demo fine.
18
+ * NOTHING HERE NAMES A VENDOR: sources, types and labels all come from the corpus catalog.
27
19
  */
28
20
  import * as React from 'react';
29
21
 
30
22
  import { LoadError } from '../LoadError';
31
-
32
23
  import { DocumentDetail } from '../DocumentDetail';
33
- import { formatDate, summaryOf } from '../documentText';
34
- import { FolderTree, folderTrail } from '../FolderTree';
35
- import { folderName } from '../../corpus/entities';
24
+ import { folderTrail } from '../FolderTree';
36
25
  import type { FolderTreeSlot } from '../FolderTree';
37
- import { documentPreview as preview, openFailureMessage, readFailureMessage } from '../../corpus/view-text';
26
+ import { DEFAULT_PAGE_SIZE, FilterSelect, TableToolbar, readPageSize, writePageSize } from '../table';
27
+ import type { PageSize, TableSort } from '../table';
38
28
  import { enforceScope } from '../../corpus/retrieval';
39
- import type {
40
- CorpusApi,
41
- CorpusScope,
42
- DocumentQuery,
43
- Party,
44
- SourceDocument,
45
- SourceFreshness,
46
- } from '../../corpus/types';
29
+ import { openFailureMessage, readFailureMessage } from '../../corpus/view-text';
30
+ import type { CorpusApi, CorpusScope, DocumentQuery, SourceDocument, SourceFreshness } from '../../corpus/types';
31
+ import { LibraryTable } from './library/LibraryTable';
32
+ import { LibraryTree } from './library/LibraryTree';
33
+ import type { LibrarySelection } from './library/LibraryTree';
34
+ import { DATE_FILTERS, dateAfter, emptyColumns, orderOf, typeOptions } from './library/library-model';
47
35
 
48
36
  export interface LibraryPageProps {
49
37
  api: CorpusApi;
@@ -59,47 +47,17 @@ export interface LibraryPageProps {
59
47
  initialFolder?: string;
60
48
  /** Told whenever the open folder changes, so an app can put it in the URL. */
61
49
  onSelectFolder?: (folder: string | null) => void;
62
- /**
63
- * PULL THE TEXT OF ONE RECORD. Supply it and the control on a text-less row is
64
- * live; leave it out and the same control is there and DISABLED.
65
- *
66
- * IT IS A CONTROL EITHER WAY, and that is the whole point of the seam
67
- * (Quinn, 2026-08-27, on the sentence this replaced: "don't say stupid shit
68
- * like 'no text blah blah'. either have a button to pull the text, or have it
69
- * grayed out if we can't do the action. simple ui."). A sentence in the place
70
- * a control belongs tells a reader what happened; a greyed-out control tells
71
- * them what they may do, which is the question they were actually asking.
72
- *
73
- * NOTHING SUPPLIES IT TODAY, and that is correct rather than a stub. Content
74
- * is OPT-IN and never the default (bd startsim-h6xnu): the index owes what
75
- * exists, where it lives and findability, and pulling the bytes of every file
76
- * is the expensive, privacy-loaded half nobody asked for. The route that would
77
- * fill this in is bd startsim-99g8.2 and it is deliberately unshipped, so on
78
- * today's tenant the control is disabled — which is the honest answer to "can
79
- * I read this .ttf".
80
- */
81
- onRequestText?: (document: SourceDocument) => void | Promise<void>;
50
+ /** Rows per page when the reader has not chosen one (the footer remembers their choice). */
82
51
  pageSize?: number;
83
52
  classNames?: Partial<Record<LibrarySlot, string>>;
84
- /** Theme slots for the folder tree, passed straight through. */
53
+ /** Theme slots for the folder rows, passed straight through. */
85
54
  folderClassNames?: Partial<Record<FolderTreeSlot, string>>;
86
55
  }
87
56
 
88
- type LibrarySlot =
89
- | 'root'
90
- | 'section'
91
- | 'heading'
92
- | 'card'
93
- | 'row'
94
- | 'badge'
95
- | 'button'
96
- | 'input'
97
- | 'muted'
98
- | 'error'
99
- | 'warning';
57
+ type LibrarySlot = 'root' | 'section' | 'heading' | 'card' | 'row' | 'badge' | 'button' | 'input' | 'muted' | 'error' | 'warning';
100
58
 
101
59
  const DEFAULTS: Record<LibrarySlot, string> = {
102
- root: 'space-y-6',
60
+ root: 'space-y-4',
103
61
  section: 'space-y-3',
104
62
  heading: 'text-lg font-semibold text-gray-900',
105
63
  card: 'rounded-lg border border-gray-200 p-4',
@@ -112,152 +70,97 @@ const DEFAULTS: Record<LibrarySlot, string> = {
112
70
  warning: 'rounded-md border border-amber-300 bg-amber-50 p-2 text-sm text-amber-800',
113
71
  };
114
72
 
115
- function relative(value: string | null | undefined, now: number): string {
116
- if (!value) return 'never';
117
- const at = Date.parse(value);
118
- if (Number.isNaN(at)) return 'never';
119
- const minutes = Math.round((now - at) / 60000);
120
- if (minutes < 1) return 'just now';
121
- if (minutes < 60) return `${minutes} min ago`;
122
- const hours = Math.round(minutes / 60);
123
- if (hours < 48) return `${hours}h ago`;
124
- return `${Math.round(hours / 24)}d ago`;
125
- }
126
-
127
- // ---------------------------------------------------------------------------
73
+ const SEARCH_DEBOUNCE_MS = 300;
128
74
 
129
75
  export function LibraryPage({
130
- api,
131
- onOpenPlan,
132
- scope,
133
- initialDocumentId,
134
- onSelectDocument,
135
- initialFolder,
136
- onSelectFolder,
137
- onRequestText,
138
- pageSize = 20,
139
- classNames = {},
140
- folderClassNames = {},
76
+ api, onOpenPlan, scope, initialDocumentId, onSelectDocument, initialFolder, onSelectFolder, pageSize, classNames = {},
141
77
  }: LibraryPageProps) {
142
78
  const cn = { ...DEFAULTS, ...classNames };
143
79
 
144
- const [filters, setFilters] = React.useState<DocumentQuery>({ page: 1, pageSize });
145
- /**
146
- * THE OPEN FOLDER, or `null` for the whole corpus.
147
- *
148
- * `null` IS NOT A BUCKET AND MUST NOT BECOME ONE. The facet read enumerates
149
- * values of `path` and skips records that have none, so a meeting note and an
150
- * email are in NO folder — which on today's tandem is most of the corpus. The
151
- * top of the tree therefore clears the path filter rather than narrowing to
152
- * some invented "unfiled", and every record stays one click from the top the
153
- * way it is in any file browser.
154
- */
155
- const [folder, setFolder] = React.useState<string | null>(initialFolder ?? null);
156
- /** Set once the corpus proves it cannot enumerate folders; see `FolderTree`. */
157
- const [noTree, setNoTree] = React.useState(false);
158
- /**
159
- * Whether an open folder means IT AND EVERYTHING BELOW IT. Default yes, and
160
- * the default is the whole point.
161
- *
162
- * THE NUMBER THE READER JUST CLICKED HAS TO BE THE LIST THEY GET. A folder's
163
- * count is DESCENDANTS — the tenant says so outright, because that is the
164
- * number a person reading a collapsed folder wants — so a list bounded to the
165
- * exact shelf disagrees with it the moment a folder is a container. On the
166
- * live tandem corpus that is the two biggest folders: `/ERA22 Shared` (142)
167
- * and `/Demo Day Presentations` (37) both hold their documents in subfolders.
168
- * Bounded exactly, clicking either showed "0 records" beside a sidebar reading
169
- * 142, under the sentence "Nothing matches those filters. Clear them to see
170
- * everything." — filters the reader never set, in the place a control belongs.
171
- * That is the same fault as the row sentence this screen just removed.
172
- *
173
- * IT IS A CONTROL, so the other reading stays available: uncheck it and the
174
- * list is the shelf. What it is not is a hidden mode — the bound used to
175
- * depend on whether the search box had a term in it, which meant the same
176
- * click answered two different questions depending on state the reader was not
177
- * looking at.
178
- */
179
- const [includeSubfolders, setIncludeSubfolders] = React.useState(true);
80
+ // THE VIEW — everything the server query is made of. One object, so a change to any of it is one query.
180
81
  const [draftSearch, setDraftSearch] = React.useState('');
82
+ const [search, setSearch] = React.useState('');
83
+ const [subtype, setSubtype] = React.useState('');
84
+ const [date, setDate] = React.useState<{ key: string; after?: string }>({ key: '' });
85
+ const [sort, setSort] = React.useState<TableSort | null>(null);
86
+ const [selection, setSelection] = React.useState<LibrarySelection>({ source: null, folder: initialFolder ?? null });
87
+ const [partyFilter, setPartyFilter] = React.useState<{ id: string; name: string } | null>(null);
88
+ const [page, setPage] = React.useState(1);
89
+ const [size, setSize] = React.useState<PageSize>(() => (pageSize ? (pageSize as PageSize) : readPageSize('library')));
90
+
181
91
  const [documents, setDocuments] = React.useState<SourceDocument[]>([]);
182
92
  const [count, setCount] = React.useState(0);
183
93
  const [applied, setApplied] = React.useState<string[] | undefined>(undefined);
184
94
  const [sources, setSources] = React.useState<SourceFreshness[]>([]);
185
- /** Per-source totals, held apart from the cards so a late count patches a card, never replaces it. */
186
95
  const [sourceCounts, setSourceCounts] = React.useState<Map<string, number | null>>(new Map());
187
- /** True once the first list read has settled; the reads that are not the rows wait for it. */
96
+ const [seenTypes, setSeenTypes] = React.useState<string[]>([]);
97
+ /** True once the first list read has settled; every read that is not the rows waits for it. */
188
98
  const [firstPaint, setFirstPaint] = React.useState(false);
189
- const defer = typeof api.participantsFor === 'function';
190
- const shownSources = React.useMemo(
191
- () => (sourceCounts.size === 0
192
- ? sources
193
- : sources.map((source) => (sourceCounts.has(source.source)
194
- ? { ...source, documentCount: sourceCounts.get(source.source) ?? null }
195
- : source))),
196
- [sources, sourceCounts],
197
- );
198
- const [parties, setParties] = React.useState<Party[]>([]);
99
+ /** The people on the rows arrive after the rows; until they have, `Who` is not judged empty. */
100
+ const [peopleSettled, setPeopleSettled] = React.useState(false);
101
+ const [sourcesLoaded, setSourcesLoaded] = React.useState(false);
102
+ const [noTree, setNoTree] = React.useState(false);
199
103
  const [selectedId, setSelectedId] = React.useState<string | null>(initialDocumentId ?? null);
200
104
  const [selected, setSelected] = React.useState<SourceDocument | null>(null);
201
- /**
202
- * Why the open record is not open. Held separately from `loadError`, which is
203
- * about the LIST: a Library that loaded fine and a citation that no longer
204
- * resolves are different facts, and blanking the list for the second one would
205
- * be a worse answer than the silence this replaces.
206
- */
207
105
  const [selectError, setSelectError] = React.useState('');
208
106
  const [loading, setLoading] = React.useState(true);
209
107
  const [loadError, setLoadError] = React.useState('');
210
108
  const [attempt, setAttempt] = React.useState(0);
211
- /**
212
- * LATCHED, not per-page. "The data API returned another workspace's rows" is a
213
- * fact about the API, and paging forward past the offending page must not make
214
- * the warning disappear as though it were fixed.
215
- */
109
+ /** LATCHED: "the API returned another workspace's rows" is a fact about the API, and paging past it does not fix it. */
216
110
  const [droppedOutOfScope, setDroppedOutOfScope] = React.useState(0);
111
+ const defer = typeof api.participantsFor === 'function';
217
112
 
218
- /**
219
- * The list query: the filter bar PLUS the open folder, bounded the way the
220
- * reader asked for it — see `includeSubfolders` for why the default is the
221
- * subtree and not the shelf.
222
- */
223
- const query = React.useMemo<DocumentQuery>(() => {
224
- if (!folder) return filters;
225
- // ONE OF THE TWO, NEVER BOTH: the list endpoint ANDs its filters, so sending
226
- // both would intersect a folder with its own subtree and quietly answer with
227
- // the shelf.
228
- return includeSubfolders ? { ...filters, underFolder: folder } : { ...filters, folder };
229
- }, [filters, folder, includeSubfolders]);
113
+ // Debounced search: typing is not a query until the reader pauses.
114
+ React.useEffect(() => {
115
+ if (draftSearch === search) return undefined;
116
+ const handle = setTimeout(() => { setSearch(draftSearch); setPage(1); }, SEARCH_DEBOUNCE_MS);
117
+ return () => clearTimeout(handle);
118
+ }, [draftSearch, search]);
119
+
120
+ const query = React.useMemo<DocumentQuery>(() => ({
121
+ page,
122
+ pageSize: size,
123
+ ...(search ? { search } : {}),
124
+ ...(selection.source ? { source: selection.source } : {}),
125
+ ...(subtype ? { subtype } : {}),
126
+ ...(date.after ? { occurredAfter: date.after } : {}),
127
+ ...(partyFilter ? { partyId: partyFilter.id } : {}),
128
+ // A folder means it AND everything below it. The list endpoint ANDs its filters, so exactly one of folder / underFolder.
129
+ ...(selection.folder ? { underFolder: selection.folder } : {}),
130
+ ...(orderOf(sort) ? { order: orderOf(sort) } : {}),
131
+ }), [page, size, search, selection, subtype, date.after, partyFilter, sort]);
132
+ const queryKey = JSON.stringify(query);
230
133
 
231
134
  React.useEffect(() => {
232
135
  let live = true;
233
136
  setLoading(true);
137
+ setPeopleSettled(false);
234
138
  void (async () => {
235
139
  try {
236
- // ROWS FIRST. With an adapter that can fetch participants separately the
237
- // list waits for ONE read — the documents page — and the people on each
238
- // row are patched in below. Behind a slow or single-file backend the
239
- // edge read and the six-page roster walk were the page (2026-11-20).
240
- const page = await api.listDocuments(query, defer ? { participants: false } : undefined);
140
+ // ROWS FIRST: with an adapter that can fetch people separately the list waits for ONE read.
141
+ const result = await api.listDocuments(query, defer ? { participants: false } : undefined);
241
142
  if (!live) return;
242
- // THE GUARD RUNS ON THE LIST, not only on the detail panel. A row from
243
- // another workspace is a leak the moment it is drawn — its title and its
244
- // preview text are already on the screen, and nobody has to click. The
245
- // API scopes reads and RLS scopes them again; this is the third check,
246
- // and a non-zero drop is stated rather than absorbed.
247
- const { kept, dropped } = enforceScope(page.results ?? [], scope);
143
+ const { kept, dropped } = enforceScope(result.results ?? [], scope);
248
144
  setDocuments(kept);
249
145
  setDroppedOutOfScope((seen) => seen + dropped.length);
250
- setCount(Math.max(0, (page.count ?? 0) - dropped.length));
251
- setApplied(page.appliedFilters);
146
+ setCount(Math.max(0, (result.count ?? 0) - dropped.length));
147
+ setApplied(result.appliedFilters);
252
148
  setLoadError('');
149
+ setSeenTypes((prev) => {
150
+ const next = new Set(prev);
151
+ kept.forEach((d) => { if (d.subtype) next.add(d.subtype); });
152
+ return next.size === prev.length ? prev : Array.from(next);
153
+ });
253
154
  if (defer && api.participantsFor && kept.length) {
254
- void api.participantsFor(kept.map((document) => document.id)).then((people) => {
155
+ void api.participantsFor(kept.map((d) => d.id)).then((people) => {
255
156
  if (!live) return;
256
- setDocuments((current) => current.map((document) => {
257
- const found = people.get(String(document.id));
258
- return found ? { ...document, participants: found } : document;
157
+ setDocuments((current) => current.map((d) => {
158
+ const found = people.get(String(d.id));
159
+ return found ? { ...d, participants: found } : d;
259
160
  }));
260
- }).catch(() => { /* the rows stand without their people, as before */ });
161
+ }).catch(() => { /* the rows stand without their people */ }).finally(() => { if (live) setPeopleSettled(true); });
162
+ } else {
163
+ setPeopleSettled(true);
261
164
  }
262
165
  } catch (err) {
263
166
  if (live) setLoadError(readFailureMessage(err));
@@ -266,55 +169,40 @@ export function LibraryPage({
266
169
  }
267
170
  })();
268
171
  return () => { live = false; };
269
- }, [api, query, scope, attempt]);
172
+ // `queryKey` stands for `query`: a re-render with an equal query must not ask again.
173
+ // eslint-disable-next-line react-hooks/exhaustive-deps
174
+ }, [api, queryKey, scope, attempt]);
270
175
 
271
- // The reference-only surfaces (which sources exist, which parties exist) load
272
- // once. They are what makes the filter controls DATA rather than a hardcoded
273
- // vendor list — add a connector and its option appears with no code change.
274
- //
275
- // IN QUEUE ORDER, because the queue is the bottleneck: the documents effect
276
- // above asked first, the source CARDS ask next (they are above the fold), and
277
- // everything that is not on the first screen — the per-source counts, the
278
- // party filter, the people on each row — waits its turn behind the rows.
176
+ // The sources (and their counts) fill the tree. They come after the rows, which asked first.
279
177
  React.useEffect(() => {
178
+ if (!firstPaint) return undefined;
280
179
  let live = true;
281
180
  void (async () => {
282
181
  const freshness = await api
283
182
  .listSources({ onCounts: (counts) => { if (live) setSourceCounts(counts); } })
284
183
  .catch(() => [] as SourceFreshness[]);
285
- if (live) setSources(freshness);
286
- })();
287
- return () => { live = false; };
288
- }, [api]);
289
-
290
- React.useEffect(() => {
291
- if (!firstPaint) return undefined;
292
- let live = true;
293
- void (async () => {
294
- const partyPage = await api.listParties({ page: 1, pageSize: 100 }).catch(() => ({
295
- count: 0, next: null, previous: null, results: [] as Party[],
296
- }));
297
- if (live) setParties(partyPage.results ?? []);
184
+ if (live) { setSources(freshness); setSourcesLoaded(true); }
298
185
  })();
299
186
  return () => { live = false; };
300
187
  }, [api, firstPaint]);
301
188
 
189
+ const shownSources = React.useMemo(
190
+ () => (sourceCounts.size === 0
191
+ ? sources
192
+ : sources.map((s) => (sourceCounts.has(s.source) ? { ...s, documentCount: sourceCounts.get(s.source) ?? null } : s))),
193
+ [sources, sourceCounts],
194
+ );
195
+
302
196
  React.useEffect(() => {
303
- if (!selectedId) { setSelected(null); setSelectError(''); return; }
197
+ if (!selectedId) { setSelected(null); setSelectError(''); return undefined; }
304
198
  let live = true;
305
199
  void (async () => {
306
- // Prefer the row already on screen; fall back to a fetch so a citation
307
- // deep-link opens a record that is not on the current page.
308
- const onPage = documents.find((document) => document.id === selectedId);
200
+ const onPage = documents.find((d) => d.id === selectedId);
309
201
  if (onPage) { setSelected(onPage); setSelectError(''); return; }
310
202
  try {
311
203
  const fetched = await api.getDocument(selectedId);
312
204
  if (live) { setSelected(fetched); setSelectError(''); }
313
205
  } catch (err) {
314
- // THE REPORTED BUG (bd startsim-4s4um). This was `setSelected(null)` and
315
- // nothing else, so `?doc=<id>` in the address bar produced a Library
316
- // with no record and no explanation — the one outcome a reader cannot
317
- // act on, and indistinguishable from a page that simply ignored them.
318
206
  if (live) { setSelected(null); setSelectError(openFailureMessage(err, selectedId)); }
319
207
  }
320
208
  })();
@@ -327,377 +215,110 @@ export function LibraryPage({
327
215
  onSelectDocument?.(id);
328
216
  }, [onSelectDocument]);
329
217
 
330
- const update = React.useCallback((patch: Partial<DocumentQuery>) => {
331
- // Any filter change resets to page 1 — page 3 of the old result set is not
332
- // page 3 of the new one, and silently keeping it shows an empty list.
333
- setFilters((prev) => ({ ...prev, ...patch, page: patch.page ?? 1 }));
334
- }, []);
335
-
336
- /**
337
- * Move to a folder. Same page-1 reset as any other narrowing, and for the
338
- * same reason: page 3 of `/Contracts` is not page 3 of the corpus.
339
- */
340
- const openFolder = React.useCallback((next: string | null) => {
341
- setFolder(next);
342
- setFilters((prev) => ({ ...prev, page: 1 }));
343
- // AND THE BOUND RESETS WITH IT. "Only this shelf" is a thing the reader
344
- // wanted to know about THAT folder, not a mode they signed up to carry
345
- // around: left sticky, unchecking it on a container like `/Decks` and then
346
- // clicking `/Contracts` — which does have files of its own — lists 2 of its
347
- // 7 under a sidebar reading 7, which is the disagreement this screen just
348
- // spent a commit removing, reachable in two clicks. Same reasoning as the
349
- // page reset above: the answer to the old question is not the answer to the
350
- // new one, and the control is one click away for anyone who wants it back.
351
- setIncludeSubfolders(true);
352
- onSelectFolder?.(next);
218
+ const choose = React.useCallback((next: LibrarySelection) => {
219
+ setSelection(next);
220
+ setPage(1);
221
+ onSelectFolder?.(next.folder);
353
222
  }, [onSelectFolder]);
354
223
 
355
- const page = filters.page ?? 1;
356
- const size = filters.pageSize ?? pageSize;
357
- const lastPage = Math.max(1, Math.ceil(count / size));
358
- const now = Date.now();
359
-
360
- /**
361
- * A filter the SERVER did not apply. Rendering the unfiltered list under a
362
- * filled-in search box is a lie the user cannot catch, so it is stated.
363
- */
224
+ /** A filter the SERVER did not apply: rendering the unfiltered list under a filled-in box is a lie. */
364
225
  const ignored = React.useMemo(() => {
365
- if (!applied) return [] as string[];
366
- const requested: Array<[string, unknown]> = [
367
- ['search', filters.search],
368
- ['source', filters.source],
369
- ['party', filters.partyId],
370
- ['date', filters.occurredAfter || filters.occurredBefore],
371
- // THE ONE THAT MATTERS MOST HERE. A tree the server cannot narrow by is
372
- // worse than no tree: the reader clicks `/Contracts`, the list does not
373
- // change, and nothing on the screen says why. Same rule as the search box.
374
- ['folder', query.folder || query.underFolder],
226
+ // `applied` describes the PREVIOUS answer while a new one is on its way; judging the new query by it flashes a false warning.
227
+ if (!applied || loading) return [] as string[];
228
+ const requested: Array<[string, unknown, string[]]> = [
229
+ ['search', query.search, ['search']],
230
+ ['source', query.source, ['source']],
231
+ ['type', query.subtype, ['subtype']],
232
+ ['person', query.partyId, ['partyId']],
233
+ ['date', query.occurredAfter, ['occurredAfter', 'occurredBefore']],
234
+ ['folder', query.folder || query.underFolder, ['folder', 'underFolder']],
235
+ ['sort', query.order, ['order']],
375
236
  ];
376
- const keyFor: Record<string, string[]> = {
377
- search: ['search'], source: ['source'], party: ['partyId'],
378
- date: ['occurredAfter', 'occurredBefore'],
379
- folder: ['folder', 'underFolder'],
380
- };
381
- return requested
382
- .filter(([name, value]) => value && !keyFor[name].some((key) => applied.includes(key)))
383
- .map(([name]) => name);
384
- }, [applied, filters, query]);
237
+ return requested.filter(([, value, keys]) => value && !keys.some((key) => applied.includes(key))).map(([name]) => name);
238
+ }, [applied, query, loading]);
385
239
 
386
- const hasFilters = Boolean(filters.source || filters.partyId || filters.occurredAfter || filters.occurredBefore);
240
+ const hasFilters = Boolean(search || selection.source || selection.folder || subtype || date.after || partyFilter);
387
241
 
388
242
  if (loadError) {
389
243
  return <LoadError what="the library" message={loadError} onRetry={() => { setLoadError(''); setAttempt((n) => n + 1); }} />;
390
244
  }
391
245
 
246
+ const emptyMessage = hasFilters
247
+ ? 'Nothing matches.'
248
+ : sourcesLoaded && sources.length === 0
249
+ ? 'Nothing has been pulled in yet. Connect a source and its records appear here.'
250
+ : 'Nothing has arrived yet.';
251
+
392
252
  return (
393
253
  <div className={cn.root}>
394
- <FreshnessStrip sources={shownSources} classNames={cn} now={now} />
395
-
396
- <section className={cn.section}>
397
- <form
398
- className="flex flex-wrap items-end gap-2"
399
- onSubmit={(event) => { event.preventDefault(); update({ search: draftSearch || undefined }); }}
400
- >
401
- <label className="flex min-w-0 flex-1 flex-col gap-1">
402
- <span className="text-xs font-medium text-gray-700">Search</span>
403
- <input
404
- className={`${cn.input} w-full`}
405
- type="search"
406
- value={draftSearch}
407
- placeholder="Search everything pulled in"
408
- onChange={(event) => setDraftSearch(event.target.value)}
254
+ <div className={noTree ? '' : 'grid gap-4 md:grid-cols-[minmax(0,13rem)_minmax(0,1fr)]'}>
255
+ <aside className="h-max min-w-0 rounded-lg border border-gray-200 bg-white p-2 dark:border-gray-700 dark:bg-gray-900">
256
+ <LibraryTree
257
+ api={api}
258
+ sources={shownSources}
259
+ sourcesLoaded={sourcesLoaded}
260
+ selection={selection}
261
+ onSelect={choose}
262
+ hold={!firstPaint || noTree}
263
+ onUnavailable={() => setNoTree(true)}
264
+ />
265
+ </aside>
266
+
267
+ <section className="min-w-0 space-y-3">
268
+ <TableToolbar search={draftSearch} onSearch={setDraftSearch} searchLabel="Search the library" searchPlaceholder="Search everything pulled in">
269
+ {seenTypes.length > 0 || subtype ? (
270
+ <FilterSelect label="Type" value={subtype} options={typeOptions(seenTypes, subtype)} onChange={(value) => { setSubtype(value); setPage(1); }} />
271
+ ) : null}
272
+ <FilterSelect
273
+ label="Date"
274
+ value={date.key}
275
+ options={DATE_FILTERS}
276
+ onChange={(key) => { setDate({ key, after: dateAfter(key, Date.now()) }); setPage(1); }}
409
277
  />
410
- </label>
411
-
412
- <button type="submit" className={cn.button}>Search</button>
413
-
414
- {/* The rest of the filters fold away: a phone should see the search box first, not a form a third of the screen tall. */}
415
- <details className="w-full rounded-lg border border-gray-200 bg-white px-3 py-2" open={hasFilters}>
416
- <summary className="cursor-pointer text-sm font-medium text-gray-700">Filters{hasFilters ? ' (on)' : ''}</summary>
417
- <div className="mt-3 flex flex-wrap items-end gap-2">
418
- <label className="flex flex-col gap-1">
419
- <span className="text-xs font-medium text-gray-700">Source</span>
420
- <select
421
- className={cn.input}
422
- value={filters.source ?? ''}
423
- onChange={(event) => update({ source: event.target.value || undefined })}
424
- >
425
- <option value="">All sources</option>
426
- {/* Options are DATA. A fourth connector appears here by existing. */}
427
- {shownSources.map((source) => (
428
- <option key={source.source} value={source.source}>{source.label}</option>
429
- ))}
430
- </select>
431
- </label>
432
-
433
- <label className="flex flex-col gap-1">
434
- <span className="text-xs font-medium text-gray-700">Party</span>
435
- <select
436
- className={cn.input}
437
- value={filters.partyId ?? ''}
438
- onChange={(event) => update({ partyId: event.target.value || undefined })}
439
- >
440
- <option value="">Anyone</option>
441
- {parties.map((party) => (
442
- <option key={party.id} value={party.id}>{party.name}</option>
443
- ))}
444
- </select>
445
- </label>
446
-
447
- <label className="flex flex-col gap-1">
448
- <span className="text-xs font-medium text-gray-700">From</span>
449
- <input
450
- className={cn.input}
451
- type="date"
452
- value={(filters.occurredAfter ?? '').slice(0, 10)}
453
- onChange={(event) => update({
454
- occurredAfter: event.target.value ? `${event.target.value}T00:00:00Z` : undefined,
455
- })}
456
- />
457
- </label>
458
-
459
- <label className="flex flex-col gap-1">
460
- <span className="text-xs font-medium text-gray-700">To</span>
461
- <input
462
- className={cn.input}
463
- type="date"
464
- value={(filters.occurredBefore ?? '').slice(0, 10)}
465
- onChange={(event) => update({
466
- occurredBefore: event.target.value ? `${event.target.value}T23:59:59Z` : undefined,
467
- })}
468
- />
469
- </label>
470
-
471
- <button
472
- type="button"
473
- className={cn.button}
474
- onClick={() => {
475
- setDraftSearch('');
476
- setFilters({ page: 1, pageSize: size });
477
- setIncludeSubfolders(true);
478
- // "Clear" resets the VIEW, and the open folder is part of the view
479
- // a reader is looking at. Leaving them inside a folder with an
480
- // emptied filter bar is the same half-answer as leaving the search
481
- // term in the box.
482
- openFolder(null);
483
- }}
484
- >
485
- Clear
486
- </button>
487
- </div>
488
- </details>
489
- </form>
490
-
491
- {ignored.length ? (
492
- <p className={cn.warning} role="status">
493
- This workspace’s data API does not filter by {ignored.join(', ')} yet, so the list below
494
- is not narrowed by {ignored.length > 1 ? 'those' : 'that'}.
495
- </p>
496
- ) : null}
497
-
498
- {droppedOutOfScope > 0 ? (
499
- // Good news about the guard, bad news about the API. Both are worth
500
- // seeing: a data plane returning other workspaces' rows is a bug that
501
- // silence would let run for months.
502
- <p className={cn.error} role="alert">
503
- This workspace’s data API returned {droppedOutOfScope} record
504
- {droppedOutOfScope === 1 ? '' : 's'} belonging to another workspace. They were hidden,
505
- and the record counts below exclude them.
506
- </p>
507
- ) : null}
508
- </section>
509
-
510
- {/* ONE LIST, CATEGORISED BY FOLDER STRUCTURE (bd startsim-nbhno). The tree
511
- is not a second surface and not a second taxonomy — it is the shelf the
512
- one list is standing on, which is the arrangement every computer user
513
- already knows. When the corpus cannot enumerate folders the aside
514
- simply is not there and this is the single-column list it has always
515
- been; a half-drawn tree would be worse than none. */}
516
- <div className={noTree ? '' : 'grid gap-6 md:grid-cols-[minmax(0,16rem)_minmax(0,1fr)]'}>
517
- {noTree ? null : (
518
- <aside className={`${cn.card} h-max`}>
519
- <h2 className="mb-2 text-xs font-semibold uppercase tracking-wide text-gray-500">
520
- Folders
521
- </h2>
522
- <FolderTree
523
- api={api}
524
- selected={folder}
525
- onSelect={openFolder}
526
- classNames={folderClassNames}
527
- onUnavailable={() => setNoTree(true)}
528
- hold={!firstPaint}
529
- />
530
- </aside>
531
- )}
532
-
533
- <section className={cn.section}>
534
- <div className="flex items-baseline justify-between gap-4">
535
- <h2 className={cn.heading}>{folder ? folderName(folder) : 'All documents'}</h2>
536
- <p className={cn.muted}>
537
- {count} record{count === 1 ? '' : 's'}
538
- {count > 0 ? ` · page ${page} of ${lastPage}` : ''}
539
- </p>
540
- </div>
541
-
542
- {/* WHERE YOU ARE. Derived from the open path, which the server returned;
543
- every crumb re-asks the server for that container rather than
544
- reusing anything already on screen. */}
545
- {folder ? (
546
- <nav aria-label="Folder path" className="flex flex-wrap items-center gap-1 text-sm">
547
- <button
548
- type="button"
549
- className="text-gray-500 underline underline-offset-2 hover:text-gray-900"
550
- onClick={() => openFolder(null)}
551
- >
552
- All documents
553
- </button>
554
- {folderTrail(folder).map((crumb, index, all) => (
555
- <React.Fragment key={crumb.path}>
556
- <span aria-hidden="true" className="text-gray-300">/</span>
557
- {index === all.length - 1 ? (
558
- <span className="font-medium text-gray-900" aria-current="page">{crumb.name}</span>
559
- ) : (
560
- <button
561
- type="button"
562
- className="text-gray-500 underline underline-offset-2 hover:text-gray-900"
563
- onClick={() => openFolder(crumb.path)}
564
- >
565
- {crumb.name}
566
- </button>
567
- )}
568
- </React.Fragment>
569
- ))}
570
- {/* THE CONTROL THAT MAKES THE BOUND VISIBLE, rather than a mode the
571
- reader has to infer. Checked, the count beside the folder in the
572
- tree is the count above the list; unchecked, the list is the
573
- shelf and the difference is on screen as a thing they did. */}
574
- <label className="ml-3 flex items-center gap-1.5 text-xs text-gray-600">
575
- <input
576
- type="checkbox"
577
- checked={includeSubfolders}
578
- onChange={(event) => {
579
- setIncludeSubfolders(event.target.checked);
580
- // A narrowing is a filter change: page 3 of the subtree is not
581
- // page 3 of the shelf.
582
- setFilters((prev) => ({ ...prev, page: 1 }));
583
- }}
584
- />
585
- Include subfolders
586
- </label>
587
- </nav>
588
- ) : null}
278
+ </TableToolbar>
589
279
 
590
- {loading && documents.length === 0 ? <p className={cn.muted}>Loading…</p> : null}
591
-
592
- {!loading && documents.length === 0 ? (
593
- // A FOLDER THAT HOLDS ITS DOCUMENTS ONE LEVEL DOWN, with the reader
594
- // having narrowed to the shelf. Zero is the true answer to what they
595
- // asked, but "Nothing matches those filters. Clear them to see
596
- // everything." is the wrong advice — there is no filter to clear, and
597
- // the remedy is one specific thing. So the remedy IS what stands here:
598
- // the control, in the place the sentence was. Same rule as the row's
599
- // Get text button, and the same reason.
600
- folder && !includeSubfolders ? (
601
- <button
602
- type="button"
603
- className={cn.button}
604
- onClick={() => {
605
- setIncludeSubfolders(true);
606
- setFilters((prev) => ({ ...prev, page: 1 }));
607
- }}
608
- >
609
- Include subfolders
610
- </button>
611
- ) : (
612
- <EmptyState
613
- hasFilters={Boolean(
614
- filters.search || filters.source || filters.partyId
615
- || filters.occurredAfter || filters.occurredBefore || folder,
616
- )}
617
- sources={shownSources}
618
- classNames={cn}
619
- />
620
- )
621
- ) : null}
280
+ {selection.folder ? (
281
+ <p className="text-xs text-gray-500" aria-label="Folder path">
282
+ {folderTrail(selection.folder).map((crumb) => crumb.name).join(' / ')}
283
+ </p>
284
+ ) : null}
622
285
 
623
- <div className="space-y-2">
624
- {documents.map((document) => (
625
- // A DIV WRAPPING TWO BUTTONS, not one button wrapping everything.
626
- // The row now carries an action of its own, and a button inside a
627
- // button is invalid HTML that browsers resolve by dropping one of
628
- // them — usually the one you wanted.
629
- <div key={document.id} className={`${cn.row} flex items-start gap-3`}>
630
- <button
631
- type="button"
632
- className="min-w-0 flex-1 text-left"
633
- aria-expanded={selectedId === document.id}
634
- onClick={() => select(selectedId === document.id ? null : document.id)}
635
- >
636
- <div className="flex flex-wrap items-center gap-2">
637
- {/* The source is a BADGE on every row, never a hidden column:
638
- "the AI learned this from a meeting" and "…from a contract
639
- in Drive" are different claims to whoever reads a draft
640
- later. */}
641
- <span className={cn.badge}>{document.sourceLabel || document.source}</span>
642
- <span className="font-medium text-gray-900">{document.title}</span>
643
- </div>
644
- <p className={cn.muted}>
645
- {formatDate(document.occurredAt)}
646
- {document.participants.length
647
- ? ` · ${document.participants.map((party) => party.name).join(', ')}`
648
- : ''}
649
- {document.sections.length
650
- ? ` · ${document.sections.map((section) => section.label).join(', ')}`
651
- : ''}
652
- </p>
653
- {preview(document) ? (
654
- <p className="mt-1 text-sm text-gray-600">{preview(document)}</p>
655
- ) : null}
656
- </button>
286
+ {partyFilter ? (
287
+ <p className="text-xs text-gray-600">
288
+ With {partyFilter.name}{' '}
289
+ <button type="button" className="underline" onClick={() => { setPartyFilter(null); setPage(1); }}>Show everyone</button>
290
+ </p>
291
+ ) : null}
657
292
 
658
- {/* WHERE THE SENTENCE USED TO BE. A row with no captured text said
659
- "No text was captured for this record." — an explanation
660
- standing in the place a control belongs, which tells a reader
661
- what happened and not what they may do. It is a BUTTON now,
662
- and it is disabled when the action genuinely cannot be
663
- performed. Quinn, 2026-08-27: "either have a button to pull the
664
- text, or have it grayed out if we can't do the action. simple
665
- ui." */}
666
- {preview(document) ? null : (
667
- <GetTextButton
668
- document={document}
669
- className={cn.button}
670
- onRequestText={onRequestText}
671
- />
672
- )}
673
- </div>
674
- ))}
675
- </div>
293
+ {ignored.length ? (
294
+ <p className={cn.warning} role="status">
295
+ This workspace’s data API does not filter by {ignored.join(', ')} yet, so the list below
296
+ is not narrowed by {ignored.length > 1 ? 'those' : 'that'}.
297
+ </p>
298
+ ) : null}
676
299
 
677
- {count > size ? (
678
- <div className="flex items-center gap-2">
679
- <button
680
- type="button"
681
- className={cn.button}
682
- disabled={page <= 1 || loading}
683
- onClick={() => setFilters((prev) => ({ ...prev, page: Math.max(1, page - 1) }))}
684
- >
685
- Previous
686
- </button>
687
- <button
688
- type="button"
689
- className={cn.button}
690
- disabled={page >= lastPage || loading}
691
- onClick={() => setFilters((prev) => ({ ...prev, page: page + 1 }))}
692
- >
693
- Next
694
- </button>
695
- {/* Paging is a SERVER round trip (CLAUDE.md rule 8) — the browser
696
- never holds the corpus, so this keeps working at any size. */}
697
- <span className={cn.muted}>Page {page} of {lastPage}</span>
698
- </div>
699
- ) : null}
700
- </section>
300
+ {droppedOutOfScope > 0 ? (
301
+ <p className={cn.error} role="alert">
302
+ This workspace’s data API returned {droppedOutOfScope} record{droppedOutOfScope === 1 ? '' : 's'} belonging to
303
+ another workspace. They were hidden, and the record counts below exclude them.
304
+ </p>
305
+ ) : null}
306
+
307
+ <LibraryTable
308
+ rows={documents}
309
+ hidden={emptyColumns(documents, peopleSettled)}
310
+ onOpen={(id) => select(selectedId === id ? null : id)}
311
+ sort={sort}
312
+ onSort={(next) => { setSort(next); setPage(1); }}
313
+ page={page}
314
+ pageSize={size}
315
+ total={count}
316
+ onPage={setPage}
317
+ onPageSize={(next) => { setSize(next); writePageSize('library', next); setPage(1); }}
318
+ loading={loading}
319
+ emptyMessage={loading && documents.length === 0 ? 'Loading…' : emptyMessage}
320
+ />
321
+ </section>
701
322
  </div>
702
323
 
703
324
  {selected ? (
@@ -707,12 +328,16 @@ export function LibraryPage({
707
328
  api={api}
708
329
  classNames={cn}
709
330
  onClose={() => select(null)}
710
- onFilterByParty={(partyId) => update({ partyId })}
331
+ onFilterByParty={(partyId) => {
332
+ const person = selected.participants.find((p) => String(p.id) === String(partyId));
333
+ setPartyFilter({ id: partyId, name: person?.name ?? 'this person' });
334
+ setPage(1);
335
+ select(null);
336
+ }}
711
337
  onOpenPlan={onOpenPlan}
712
338
  />
713
339
  ) : null}
714
340
 
715
- {/* Asked for, and not shown — said out loud rather than left blank. */}
716
341
  {!selected && selectError ? (
717
342
  <section className={cn.card} aria-label="Record">
718
343
  <div className="flex items-start justify-between gap-4">
@@ -724,170 +349,3 @@ export function LibraryPage({
724
349
  </div>
725
350
  );
726
351
  }
727
-
728
- // ---------------------------------------------------------------------------
729
- // the row's own action
730
- // ---------------------------------------------------------------------------
731
-
732
- /**
733
- * "Get text" on a record that has none — ENABLED when the corpus can fetch it,
734
- * GREYED OUT when it cannot (bd startsim-ei8gm.5).
735
- *
736
- * THIS REPLACED A SENTENCE, and the swap is the point. The row used to read
737
- * "No text was captured for this record." in exactly this slot. That is an
738
- * explanation where a control belongs: it answers "what happened" when the
739
- * reader was asking "what can I do", and it is the thing Quinn objected to in
740
- * those words — "don't say stupid shit like 'no text blah blah'. either have a
741
- * button to pull the text, or have it grayed out if we can't do the action.
742
- * simple ui." A disabled control answers the real question in the standard
743
- * vocabulary of every desktop application ever written.
744
- *
745
- * DISABLED IS THE HONEST STATE TODAY, not a placeholder. Content is opt-in and
746
- * never the default (bd startsim-h6xnu) — the corpus owes what exists, where it
747
- * lives and findability, and pulling every file's bytes is the expensive,
748
- * privacy-loaded half that was deliberately not built. The route that would make
749
- * this live is bd startsim-99g8.2. When it lands, an app passes `onRequestText`
750
- * and the same control wakes up; nothing here changes.
751
- *
752
- * `title` CARRIES THE WHY, and a tooltip on a control is not the sentence that
753
- * was removed: it is attached to the thing it is about, costs no row space, and
754
- * a reader who does not care never reads it. `aria-disabled` is not used in its
755
- * place — a genuinely inert control should not be focusable-and-lying.
756
- */
757
- function GetTextButton({
758
- document, className, onRequestText,
759
- }: {
760
- document: SourceDocument;
761
- className: string;
762
- onRequestText?: (document: SourceDocument) => void | Promise<void>;
763
- }) {
764
- const [busy, setBusy] = React.useState(false);
765
- const [failed, setFailed] = React.useState('');
766
- const can = Boolean(onRequestText);
767
-
768
- return (
769
- <button
770
- type="button"
771
- className={`${className} shrink-0 self-start`}
772
- disabled={!can || busy}
773
- title={
774
- can
775
- ? `Fetch the text of ${document.title}`
776
- : 'This workspace does not pull file contents. Nothing has been extracted from this record.'
777
- }
778
- onClick={() => {
779
- if (!onRequestText) return;
780
- setBusy(true);
781
- setFailed('');
782
- void Promise.resolve(onRequestText(document))
783
- .catch((err: unknown) => setFailed(
784
- (err as { message?: string })?.message || 'Could not fetch the text.',
785
- ))
786
- .finally(() => setBusy(false));
787
- }}
788
- >
789
- {busy ? 'Getting…' : failed ? 'Retry' : 'Get text'}
790
- </button>
791
- );
792
- }
793
-
794
- // ---------------------------------------------------------------------------
795
- // freshness
796
- // ---------------------------------------------------------------------------
797
-
798
- const FRESHNESS_WORDS: Record<SourceFreshness['status'], string> = {
799
- ok: 'Up to date',
800
- stale: 'Stale',
801
- error: 'Failing',
802
- never: 'Nothing yet',
803
- };
804
-
805
- /**
806
- * The count clause of a source card, or nothing at all (bd startsim-jevtu).
807
- *
808
- * THREE STATES, NOT TWO. `null` is "this workspace's API could not narrow the
809
- * corpus by source, so the only number available describes every source at
810
- * once" — printing it would put the same total on every card, which is the
811
- * failure this replaced wearing a bigger number. Saying nothing is the honest
812
- * option, and it costs the reader the count rather than the card.
813
- *
814
- * `0` is spelled out in words rather than left as a bare digit because "0
815
- * records" is exactly what the broken version printed for years; a source that
816
- * has genuinely delivered nothing deserves a sentence that could not be
817
- * produced by not asking.
818
- *
819
- * NOTE THE SCOPE. This is the source's WHOLE contribution, unfiltered — the
820
- * strip describes sources, while the list beneath it answers the current query.
821
- * A card reading "208 records" above a list reading "3 records" under an active
822
- * search is the two questions being different, not a disagreement.
823
- */
824
- function countClause(count: SourceFreshness['documentCount']): string {
825
- if (count === null || count === undefined) return '';
826
- if (count === 0) return 'No records yet · ';
827
- return `${count} record${count === 1 ? '' : 's'} · `;
828
- }
829
-
830
- function FreshnessStrip({
831
- sources, classNames: cn, now,
832
- }: { sources: SourceFreshness[]; classNames: Record<LibrarySlot, string>; now: number }) {
833
- if (sources.length === 0) return null;
834
- return (
835
- <section className={cn.section} aria-label="Source freshness">
836
- <div className="flex flex-wrap gap-2">
837
- {sources.map((source) => (
838
- <div key={source.source} className={cn.card}>
839
- <div className="flex items-center gap-2">
840
- <span className={cn.badge}>{source.label}</span>
841
- <span
842
- className={source.status === 'ok' ? 'text-xs text-gray-500' : 'text-xs font-medium text-amber-700'}
843
- >
844
- {FRESHNESS_WORDS[source.status]}
845
- </span>
846
- </div>
847
- <p className={cn.muted}>
848
- {countClause(source.documentCount)}synced {relative(source.lastSyncedAt, now)}
849
- </p>
850
- {/* A source that is failing says so HERE, next to the corpus it is
851
- supposed to be filling — not on a settings page nobody opens. */}
852
- {source.detail ? <p className="text-xs text-amber-700">{source.detail}</p> : null}
853
- </div>
854
- ))}
855
- </div>
856
- </section>
857
- );
858
- }
859
-
860
- // ---------------------------------------------------------------------------
861
- // empty state
862
- // ---------------------------------------------------------------------------
863
-
864
- /**
865
- * Three different nothings, because they need three different actions: no
866
- * sources connected, sources connected but nothing arrived, and a filter that
867
- * matched nothing. One generic "No results" would send the user to the wrong
868
- * place in two of the three.
869
- */
870
- function EmptyState({
871
- hasFilters, sources, classNames: cn,
872
- }: { hasFilters: boolean; sources: SourceFreshness[]; classNames: Record<LibrarySlot, string> }) {
873
- if (hasFilters) {
874
- return <p className={cn.muted}>Nothing matches those filters. Clear them to see everything.</p>;
875
- }
876
- if (sources.length === 0) {
877
- return (
878
- <p className={cn.muted}>
879
- Nothing has been pulled in yet. Connect a source and its records appear here.
880
- </p>
881
- );
882
- }
883
- const failing = sources.filter((source) => source.status === 'error');
884
- if (failing.length) {
885
- return (
886
- <p className={cn.warning} role="status">
887
- Nothing has arrived yet, and {failing.map((source) => source.label).join(', ')}{' '}
888
- {failing.length === 1 ? 'is' : 'are'} failing to sync.
889
- </p>
890
- );
891
- }
892
- return <p className={cn.muted}>Your sources are connected but have not delivered any records yet.</p>;
893
- }