@startsimpli/integrations 0.2.53 → 0.2.54

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.
@@ -0,0 +1,144 @@
1
+ /**
2
+ * THE OPEN RECORD in the Library — provenance, parties, 'Filed under', summary,
3
+ * full text and any withheld-field notice. Lifted out of LibraryPage.tsx
4
+ * (CLAUDE.md: no source file over ~1,000 lines); behaviour is unchanged.
5
+ */
6
+ import * as React from 'react';
7
+
8
+ import { Markdown } from './Markdown';
9
+ import { FiledUnder } from './FiledUnder';
10
+ import { formatDate, fullTextOf, summaryOf } from './documentText';
11
+ import type { CorpusApi, CorpusScope, SourceDocument } from '../corpus/types';
12
+
13
+ type DetailSlots = Record<'card' | 'heading' | 'badge' | 'button' | 'input' | 'muted' | 'error' | 'warning', string>;
14
+
15
+ export function DocumentDetail({
16
+ document, scope, api, classNames: cn, onClose, onFilterByParty,
17
+ }: {
18
+ document: SourceDocument;
19
+ scope: CorpusScope;
20
+ api: CorpusApi;
21
+ classNames: DetailSlots;
22
+ onClose: () => void;
23
+ onFilterByParty: (partyId: string) => void;
24
+ }) {
25
+ // Defense in depth. The API scopes reads and Postgres RLS scopes them again,
26
+ // but a record that reached this component from the wrong workspace must not
27
+ // render — a leak is worst at the moment it is displayed as fact.
28
+ if (document.scope?.orgId && document.scope.orgId !== scope.orgId) {
29
+ return (
30
+ <section className={cn.card} aria-label="Record">
31
+ <p className={cn.error} role="alert">This record belongs to another workspace and was not shown.</p>
32
+ </section>
33
+ );
34
+ }
35
+
36
+ return (
37
+ <section className={cn.card} aria-label="Record detail">
38
+ <div className="flex items-start justify-between gap-4">
39
+ <div>
40
+ <div className="flex flex-wrap items-center gap-2">
41
+ <span className={cn.badge}>{document.sourceLabel || document.source}</span>
42
+ <h3 className={cn.heading}>{document.title}</h3>
43
+ </div>
44
+ <p className={cn.muted}>
45
+ {formatDate(document.occurredAt)}
46
+ {document.sourceRef ? ` · ${document.sourceRef}` : ''}
47
+ </p>
48
+ </div>
49
+ <button type="button" className={cn.button} onClick={onClose}>Close</button>
50
+ </div>
51
+
52
+ {document.url ? (
53
+ <p className="mt-2">
54
+ {/* Open it where it LIVES. A corpus that cannot point back at the
55
+ original is a copy nobody can check. */}
56
+ <a className="text-sm text-blue-700 underline" href={document.url} target="_blank" rel="noreferrer">
57
+ Open in {document.sourceLabel || document.source}
58
+ </a>
59
+ </p>
60
+ ) : null}
61
+
62
+ <FiledUnder api={api} documentId={document.id} classNames={cn} />
63
+
64
+ {document.participants.length ? (
65
+ <div className="mt-3">
66
+ <p className="text-sm font-medium text-gray-900">Parties</p>
67
+ <div className="mt-1 flex flex-wrap gap-2">
68
+ {document.participants.map((party) => (
69
+ <button
70
+ key={party.id}
71
+ type="button"
72
+ className={cn.badge}
73
+ onClick={() => onFilterByParty(party.id)}
74
+ title={`Show everything involving ${party.name}`}
75
+ >
76
+ {party.name}{party.kind ? ` · ${party.kind}` : ''}
77
+ </button>
78
+ ))}
79
+ </div>
80
+ </div>
81
+ ) : null}
82
+
83
+ {/* THE SUMMARY, UNDER THE WORD SUMMARY. This used to render `document.body`
84
+ here — which was the summary only for as long as nothing had ever
85
+ delivered a full text. The moment `ingest_transcripts` lands, `body` is
86
+ forty minutes of verbatim speech, and it would have appeared on this
87
+ screen labelled "Summary" while the actual summary appeared nowhere. */}
88
+ {summaryOf(document) ? (
89
+ <div className="mt-3">
90
+ <p className="text-sm font-medium text-gray-900">Summary</p>
91
+ {/* Sources write Markdown — a literal "## Decisions" on the screen
92
+ reads as a broken product, not as the source's punctuation. */}
93
+ <Markdown text={summaryOf(document)} className="mt-1 text-sm text-gray-700" />
94
+ </div>
95
+ ) : null}
96
+
97
+ {/* The FULL text, collapsed, next to the source's other long-form. Behind
98
+ a disclosure and not open by default, for the same reason a transcript
99
+ is opt-in at all: verbatim speech is a different data class from a
100
+ summary, and a screen that puts it in front of whoever opened the
101
+ record has quietly decided that on the reader's behalf. */}
102
+ {fullTextOf(document) ? (
103
+ <details className="mt-3">
104
+ <summary className="cursor-pointer text-sm font-medium text-gray-900">
105
+ Full text
106
+ </summary>
107
+ <pre className="mt-2 max-h-96 overflow-auto whitespace-pre-wrap rounded bg-gray-50 p-2 text-xs text-gray-700">
108
+ {fullTextOf(document)}
109
+ </pre>
110
+ </details>
111
+ ) : null}
112
+
113
+ {/* WITHHELD IS NOT EMPTY (bd startsim-768w.38.33). The tenant's per-field
114
+ read gate strips a restricted attribute and names it in
115
+ `redacted_fields`; without this line the reader sees a meeting with no
116
+ transcript and concludes there wasn't one. Named rather than counted,
117
+ because "the transcript" and "the salary" are different absences. */}
118
+ {document.withheldFields?.length ? (
119
+ <p className={`mt-3 ${cn.warning}`} role="status">
120
+ Part of this record is not shared with you:{' '}
121
+ {document.withheldFields.join(', ')}. Ask an admin if you need it.
122
+ </p>
123
+ ) : null}
124
+
125
+ {/* Long-form under the SOURCE's own name for it — "Transcript" for a
126
+ meeting, "Extracted text" for a PDF. This component does not know
127
+ which is which, and must not. */}
128
+ {document.sections.map((section) => (
129
+ <details key={section.key} className="mt-3">
130
+ <summary className="cursor-pointer text-sm font-medium text-gray-900">{section.label}</summary>
131
+ <pre className="mt-2 max-h-96 overflow-auto whitespace-pre-wrap rounded bg-gray-50 p-2 text-xs text-gray-700">
132
+ {section.text}
133
+ </pre>
134
+ </details>
135
+ ))}
136
+
137
+ {!document.body && document.sections.length === 0 ? (
138
+ <p className={`mt-3 ${cn.muted}`}>
139
+ This record arrived with no text. Its source may have deleted the content upstream.
140
+ </p>
141
+ ) : null}
142
+ </section>
143
+ );
144
+ }
@@ -0,0 +1,95 @@
1
+ /**
2
+ * 'FILED UNDER' for any `source_document` (bd startsim-vkymg) — the project chip
3
+ * and the control that moves the document to another one.
4
+ *
5
+ * Generic on purpose: nothing here knows what a voice note is, so a Fathom
6
+ * meeting or a PDF is filable the same way. It renders only what the injected
7
+ * api can do — no `getDocumentFiling` means nothing at all, no `fileDocument`
8
+ * means the chip without the control (a read-only fork).
9
+ */
10
+ import * as React from 'react';
11
+
12
+ import type { CorpusApi } from '../corpus/types';
13
+
14
+ type Slots = Record<'badge' | 'input' | 'muted' | 'error', string>;
15
+
16
+ export function FiledUnder({
17
+ api, documentId, classNames: cn,
18
+ }: {
19
+ api: Pick<CorpusApi, 'getDocumentFiling' | 'fileDocument' | 'listFocusChoices'>;
20
+ documentId: string;
21
+ classNames: Slots;
22
+ }) {
23
+ const apiRef = React.useRef(api);
24
+ apiRef.current = api;
25
+
26
+ const [filing, setFiling] = React.useState<{ id: string; title: string } | null | undefined>(undefined);
27
+ const [choices, setChoices] = React.useState<Array<{ id: string; title: string }>>([]);
28
+ const [busy, setBusy] = React.useState(false);
29
+ const [error, setError] = React.useState('');
30
+
31
+ const canRead = Boolean(api.getDocumentFiling);
32
+ const canFile = Boolean(api.fileDocument && api.listFocusChoices);
33
+
34
+ React.useEffect(() => {
35
+ if (!canRead) return undefined;
36
+ let live = true;
37
+ setFiling(undefined);
38
+ setError('');
39
+ apiRef.current.getDocumentFiling!(documentId)
40
+ .then((result) => { if (live) setFiling(result); })
41
+ .catch(() => { if (live) { setFiling(undefined); setError('Where this is filed could not be read.'); } });
42
+ return () => { live = false; };
43
+ }, [canRead, documentId]);
44
+
45
+ React.useEffect(() => {
46
+ if (!canFile) return undefined;
47
+ let live = true;
48
+ apiRef.current.listFocusChoices!()
49
+ .then((rows) => { if (live) setChoices(rows); })
50
+ .catch(() => { /* the chip still shows; only the control is lost */ });
51
+ return () => { live = false; };
52
+ }, [canFile]);
53
+
54
+ if (!canRead) return null;
55
+
56
+ async function move(focusId: string | null) {
57
+ setBusy(true);
58
+ setError('');
59
+ try {
60
+ await apiRef.current.fileDocument!(documentId, focusId);
61
+ const chosen = choices.find((choice) => choice.id === focusId);
62
+ setFiling(chosen ? { id: chosen.id, title: chosen.title } : null);
63
+ } catch (err) {
64
+ setError((err as { message?: string })?.message || 'That could not be filed.');
65
+ } finally {
66
+ setBusy(false);
67
+ }
68
+ }
69
+
70
+ return (
71
+ <div className="mt-3 flex flex-wrap items-center gap-2">
72
+ <p className="text-sm font-medium text-gray-900">Filed under</p>
73
+ {filing === undefined && !error ? <span className={cn.muted}>…</span> : null}
74
+ {filing ? <span className={cn.badge}>{filing.title}</span> : null}
75
+ {filing === null ? <span className={cn.muted}>Not filed under a project</span> : null}
76
+ {canFile && filing !== undefined ? (
77
+ <label>
78
+ <span className="sr-only">Change project</span>
79
+ <select
80
+ className={cn.input}
81
+ disabled={busy}
82
+ value={filing?.id ?? ''}
83
+ onChange={(event) => { void move(event.target.value || null); }}
84
+ >
85
+ <option value="">Not filed</option>
86
+ {choices.map((choice) => (
87
+ <option key={choice.id} value={choice.id}>{choice.title}</option>
88
+ ))}
89
+ </select>
90
+ </label>
91
+ ) : null}
92
+ {error ? <p className={cn.error} role="alert">{error}</p> : null}
93
+ </div>
94
+ );
95
+ }
@@ -0,0 +1,97 @@
1
+ /**
2
+ * THE DOCUMENTS FILED UNDER ONE FOCUS (bd startsim-vkymg) — a project's notes
3
+ * and meetings, beside its items on the Planning screen.
4
+ *
5
+ * Server-paginated (CLAUDE.md rule 8): every page turn is a round trip with
6
+ * `focus`, `page` and `pageSize`, and every row the server returns is rendered —
7
+ * nothing is filtered or sliced here. These rows are `source_document`s reached
8
+ * over `about_focus`; they never touch the item list or 'N of M done', which
9
+ * count `in_focus` commitments only.
10
+ */
11
+ import * as React from 'react';
12
+
13
+ import type { CorpusPage, DocumentQuery, SourceDocument } from '../corpus/types';
14
+
15
+ export const FOCUS_DOCUMENTS_PAGE_SIZE = 10;
16
+
17
+ type Slots = Record<'section' | 'heading' | 'badge' | 'secondaryButton' | 'muted' | 'error' | 'row', string>;
18
+
19
+ export interface FocusDocumentsProps {
20
+ listDocuments: (query: DocumentQuery) => Promise<CorpusPage<SourceDocument>>;
21
+ focusId: string;
22
+ focusTitle: string;
23
+ /** Changes when the screen should re-read, e.g. after a write elsewhere. */
24
+ epoch?: number;
25
+ onOpenDocument?: (documentId: string) => void;
26
+ classNames: Slots;
27
+ }
28
+
29
+ function when(value: string | null | undefined): string {
30
+ if (!value) return '';
31
+ const date = new Date(value);
32
+ return Number.isNaN(date.getTime()) ? '' : date.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' });
33
+ }
34
+
35
+ export function FocusDocuments({
36
+ listDocuments, focusId, focusTitle, epoch = 0, onOpenDocument, classNames: cn,
37
+ }: FocusDocumentsProps) {
38
+ // Held in a ref: the api is a capability, and its identity must not drive a refetch.
39
+ const listRef = React.useRef(listDocuments);
40
+ listRef.current = listDocuments;
41
+
42
+ const [page, setPage] = React.useState(1);
43
+ const [data, setData] = React.useState<CorpusPage<SourceDocument> | null>(null);
44
+ const [error, setError] = React.useState('');
45
+
46
+ React.useEffect(() => { setPage(1); }, [focusId]);
47
+
48
+ React.useEffect(() => {
49
+ let live = true;
50
+ setError('');
51
+ void listRef.current({ focus: focusId, page, pageSize: FOCUS_DOCUMENTS_PAGE_SIZE, order: 'recent' })
52
+ .then((result) => { if (live) setData(result); })
53
+ .catch((err) => {
54
+ if (!live) return;
55
+ setData(null);
56
+ setError((err as { message?: string })?.message || 'The documents could not be loaded.');
57
+ });
58
+ return () => { live = false; };
59
+ }, [focusId, page, epoch]);
60
+
61
+ const total = data?.count ?? 0;
62
+ const lastPage = Math.max(1, Math.ceil(total / FOCUS_DOCUMENTS_PAGE_SIZE));
63
+
64
+ return (
65
+ <section className={cn.section} aria-label="Documents">
66
+ <h2 className={cn.heading}>
67
+ {data ? `${total} note${total === 1 ? '' : 's'} and document${total === 1 ? '' : 's'} in ${focusTitle}` : 'Loading…'}
68
+ </h2>
69
+ {error ? <p className={cn.error} role="alert">{error}</p> : null}
70
+ {data && data.results.length === 0 ? (
71
+ <p className={cn.muted}>No notes or documents filed under this yet.</p>
72
+ ) : null}
73
+ {data?.results.map((document) => (
74
+ <div key={document.id} className={cn.row}>
75
+ <div className="flex flex-wrap items-center gap-2">
76
+ <span className={cn.badge}>{document.sourceLabel || document.source}</span>
77
+ {onOpenDocument ? (
78
+ <button type="button" className="text-left text-sm font-medium text-gray-900 underline" onClick={() => onOpenDocument(document.id)}>
79
+ {document.title}
80
+ </button>
81
+ ) : (
82
+ <span className="text-sm font-medium text-gray-900">{document.title}</span>
83
+ )}
84
+ <span className={cn.muted}>{when(document.occurredAt)}</span>
85
+ </div>
86
+ </div>
87
+ ))}
88
+ {total > FOCUS_DOCUMENTS_PAGE_SIZE ? (
89
+ <div className="flex items-center gap-2">
90
+ <button type="button" className={cn.secondaryButton} disabled={page <= 1} onClick={() => setPage((n) => n - 1)}>Previous</button>
91
+ <span className={cn.muted}>Page {page} of {lastPage}</span>
92
+ <button type="button" className={cn.secondaryButton} disabled={page >= lastPage} onClick={() => setPage((n) => n + 1)}>Next</button>
93
+ </div>
94
+ ) : null}
95
+ </section>
96
+ );
97
+ }
@@ -0,0 +1,31 @@
1
+ /** Small text helpers shared by the Library list and the record detail. */
2
+ import type { SourceDocument } from '../corpus/types';
3
+
4
+ export function formatDate(value: string | null | undefined): string {
5
+ if (!value) return 'No date';
6
+ const at = Date.parse(value);
7
+ if (Number.isNaN(at)) return 'No date';
8
+ return new Date(at).toLocaleDateString(undefined, {
9
+ year: 'numeric',
10
+ month: 'short',
11
+ day: 'numeric',
12
+ });
13
+ }
14
+
15
+ /**
16
+ * The short form, when the source wrote one.
17
+ *
18
+ * `body` falls back to the summary on a corpus that has never delivered a full
19
+ * text, so on today's tenant these are the same string and this returns it. When
20
+ * both exist they are different, and only this one belongs under the heading
21
+ * "Summary".
22
+ */
23
+ export function summaryOf(document: SourceDocument): string {
24
+ return document.summary || (document.body ?? '');
25
+ }
26
+
27
+ /** The verbatim text, when it is genuinely different from the summary. */
28
+ export function fullTextOf(document: SourceDocument): string {
29
+ const body = document.body ?? '';
30
+ return body && body !== summaryOf(document) ? body : '';
31
+ }
@@ -49,6 +49,13 @@ export interface AskPageProps {
49
49
  /** Prefill, e.g. from a `?q=` param. */
50
50
  initialQuestion?: string;
51
51
  initialMode?: AskMode;
52
+ /**
53
+ * The projects a question can be scoped to (bd startsim-vkymg). Supplying it
54
+ * renders a project picker; the choice goes out as `filters.focus`, so
55
+ * retrieval is narrowed by the SERVER to documents filed under that project.
56
+ * Left out, there is no picker and Ask covers everything, as before.
57
+ */
58
+ listProjects?: () => Promise<Array<{ id: string; title: string }>>;
52
59
  classNames?: Partial<Record<AskSlot, string>>;
53
60
  }
54
61
 
@@ -100,6 +107,7 @@ export function AskPage({
100
107
  onOpenDocument,
101
108
  initialQuestion = '',
102
109
  initialMode = 'ask',
110
+ listProjects,
103
111
  classNames = {},
104
112
  }: AskPageProps) {
105
113
  const cn = { ...DEFAULTS, ...classNames };
@@ -111,6 +119,20 @@ export function AskPage({
111
119
  const [busy, setBusy] = React.useState(false);
112
120
  const [error, setError] = React.useState('');
113
121
  const [saveState, setSaveState] = React.useState<'idle' | 'saving' | 'saved'>('idle');
122
+ const [projects, setProjects] = React.useState<Array<{ id: string; title: string }>>([]);
123
+ const [projectId, setProjectId] = React.useState('');
124
+
125
+ const hasProjects = Boolean(listProjects);
126
+ const listProjectsRef = React.useRef(listProjects);
127
+ listProjectsRef.current = listProjects;
128
+ React.useEffect(() => {
129
+ if (!hasProjects) return undefined;
130
+ let live = true;
131
+ void listProjectsRef.current!()
132
+ .then((rows) => { if (live) setProjects(rows); })
133
+ .catch(() => { /* Ask still works across everything without the picker's choices */ });
134
+ return () => { live = false; };
135
+ }, [hasProjects, scope.orgId]);
114
136
 
115
137
  const submit = React.useCallback(async () => {
116
138
  const trimmed = question.trim();
@@ -123,6 +145,7 @@ export function AskPage({
123
145
  question: trimmed,
124
146
  mode,
125
147
  scope,
148
+ ...(projectId ? { filters: { focus: projectId } } : {}),
126
149
  ...(mode === 'generate' && instructions.trim() ? { instructions: instructions.trim() } : {}),
127
150
  };
128
151
  setResult(await api.ask(request));
@@ -132,7 +155,7 @@ export function AskPage({
132
155
  } finally {
133
156
  setBusy(false);
134
157
  }
135
- }, [api, instructions, mode, question, scope]);
158
+ }, [api, instructions, mode, projectId, question, scope]);
136
159
 
137
160
  const canSave = Boolean(api.saveDraft) && mode === 'generate' && result?.status === 'answered';
138
161
 
@@ -169,6 +192,22 @@ export function AskPage({
169
192
  />
170
193
  </label>
171
194
 
195
+ {hasProjects ? (
196
+ <label className="block space-y-1">
197
+ <span className="text-sm font-medium text-gray-900">Project</span>
198
+ <select
199
+ className={cn.input}
200
+ value={projectId}
201
+ onChange={(event) => setProjectId(event.target.value)}
202
+ >
203
+ <option value="">All projects</option>
204
+ {projects.map((project) => (
205
+ <option key={project.id} value={project.id}>{project.title}</option>
206
+ ))}
207
+ </select>
208
+ </label>
209
+ ) : null}
210
+
172
211
  {mode === 'generate' ? (
173
212
  <label className="block space-y-1">
174
213
  <span className="text-sm font-medium text-gray-900">Tone or format (optional)</span>
@@ -27,10 +27,12 @@
27
27
  */
28
28
  import * as React from 'react';
29
29
 
30
+ import { DocumentDetail } from '../DocumentDetail';
31
+ import { formatDate, summaryOf } from '../documentText';
30
32
  import { FolderTree, folderTrail } from '../FolderTree';
31
33
  import { folderName } from '../../corpus/entities';
32
34
  import type { FolderTreeSlot } from '../FolderTree';
33
- import { Markdown, stripMarkdown } from '../Markdown';
35
+ import { stripMarkdown } from '../Markdown';
34
36
  import { enforceScope } from '../../corpus/retrieval';
35
37
  import type {
36
38
  CorpusApi,
@@ -137,17 +139,6 @@ function openFailureMessage(err: unknown, id: string): string {
137
139
  return (err as { message?: string })?.message || `That record could not be opened (${id}).`;
138
140
  }
139
141
 
140
- function formatDate(value: string | null | undefined): string {
141
- if (!value) return 'No date';
142
- const at = Date.parse(value);
143
- if (Number.isNaN(at)) return 'No date';
144
- return new Date(at).toLocaleDateString(undefined, {
145
- year: 'numeric',
146
- month: 'short',
147
- day: 'numeric',
148
- });
149
- }
150
-
151
142
  function relative(value: string | null | undefined, now: number): string {
152
143
  if (!value) return 'never';
153
144
  const at = Date.parse(value);
@@ -173,24 +164,6 @@ function preview(document: SourceDocument, length = 180): string {
173
164
  return text.length > length ? `${text.slice(0, length).trim()}…` : text;
174
165
  }
175
166
 
176
- /**
177
- * The short form, when the source wrote one.
178
- *
179
- * `body` falls back to the summary on a corpus that has never delivered a full
180
- * text, so on today's tenant these are the same string and this returns it. When
181
- * both exist they are different, and only this one belongs under the heading
182
- * "Summary".
183
- */
184
- function summaryOf(document: SourceDocument): string {
185
- return document.summary || (document.body ?? '');
186
- }
187
-
188
- /** The verbatim text, when it is genuinely different from the summary. */
189
- function fullTextOf(document: SourceDocument): string {
190
- const body = document.body ?? '';
191
- return body && body !== summaryOf(document) ? body : '';
192
- }
193
-
194
167
  // ---------------------------------------------------------------------------
195
168
 
196
169
  export function LibraryPage({
@@ -721,6 +694,7 @@ export function LibraryPage({
721
694
  <DocumentDetail
722
695
  document={selected}
723
696
  scope={scope}
697
+ api={api}
724
698
  classNames={cn}
725
699
  onClose={() => select(null)}
726
700
  onFilterByParty={(partyId) => update({ partyId })}
@@ -906,135 +880,3 @@ function EmptyState({
906
880
  }
907
881
  return <p className={cn.muted}>Your sources are connected but have not delivered any records yet.</p>;
908
882
  }
909
-
910
- // ---------------------------------------------------------------------------
911
- // detail
912
- // ---------------------------------------------------------------------------
913
-
914
- function DocumentDetail({
915
- document, scope, classNames: cn, onClose, onFilterByParty,
916
- }: {
917
- document: SourceDocument;
918
- scope: CorpusScope;
919
- classNames: Record<LibrarySlot, string>;
920
- onClose: () => void;
921
- onFilterByParty: (partyId: string) => void;
922
- }) {
923
- // Defense in depth. The API scopes reads and Postgres RLS scopes them again,
924
- // but a record that reached this component from the wrong workspace must not
925
- // render — a leak is worst at the moment it is displayed as fact.
926
- if (document.scope?.orgId && document.scope.orgId !== scope.orgId) {
927
- return (
928
- <section className={cn.card} aria-label="Record">
929
- <p className={cn.error} role="alert">This record belongs to another workspace and was not shown.</p>
930
- </section>
931
- );
932
- }
933
-
934
- return (
935
- <section className={cn.card} aria-label="Record detail">
936
- <div className="flex items-start justify-between gap-4">
937
- <div>
938
- <div className="flex flex-wrap items-center gap-2">
939
- <span className={cn.badge}>{document.sourceLabel || document.source}</span>
940
- <h3 className={cn.heading}>{document.title}</h3>
941
- </div>
942
- <p className={cn.muted}>
943
- {formatDate(document.occurredAt)}
944
- {document.sourceRef ? ` · ${document.sourceRef}` : ''}
945
- </p>
946
- </div>
947
- <button type="button" className={cn.button} onClick={onClose}>Close</button>
948
- </div>
949
-
950
- {document.url ? (
951
- <p className="mt-2">
952
- {/* Open it where it LIVES. A corpus that cannot point back at the
953
- original is a copy nobody can check. */}
954
- <a className="text-sm text-blue-700 underline" href={document.url} target="_blank" rel="noreferrer">
955
- Open in {document.sourceLabel || document.source}
956
- </a>
957
- </p>
958
- ) : null}
959
-
960
- {document.participants.length ? (
961
- <div className="mt-3">
962
- <p className="text-sm font-medium text-gray-900">Parties</p>
963
- <div className="mt-1 flex flex-wrap gap-2">
964
- {document.participants.map((party) => (
965
- <button
966
- key={party.id}
967
- type="button"
968
- className={cn.badge}
969
- onClick={() => onFilterByParty(party.id)}
970
- title={`Show everything involving ${party.name}`}
971
- >
972
- {party.name}{party.kind ? ` · ${party.kind}` : ''}
973
- </button>
974
- ))}
975
- </div>
976
- </div>
977
- ) : null}
978
-
979
- {/* THE SUMMARY, UNDER THE WORD SUMMARY. This used to render `document.body`
980
- here — which was the summary only for as long as nothing had ever
981
- delivered a full text. The moment `ingest_transcripts` lands, `body` is
982
- forty minutes of verbatim speech, and it would have appeared on this
983
- screen labelled "Summary" while the actual summary appeared nowhere. */}
984
- {summaryOf(document) ? (
985
- <div className="mt-3">
986
- <p className="text-sm font-medium text-gray-900">Summary</p>
987
- {/* Sources write Markdown — a literal "## Decisions" on the screen
988
- reads as a broken product, not as the source's punctuation. */}
989
- <Markdown text={summaryOf(document)} className="mt-1 text-sm text-gray-700" />
990
- </div>
991
- ) : null}
992
-
993
- {/* The FULL text, collapsed, next to the source's other long-form. Behind
994
- a disclosure and not open by default, for the same reason a transcript
995
- is opt-in at all: verbatim speech is a different data class from a
996
- summary, and a screen that puts it in front of whoever opened the
997
- record has quietly decided that on the reader's behalf. */}
998
- {fullTextOf(document) ? (
999
- <details className="mt-3">
1000
- <summary className="cursor-pointer text-sm font-medium text-gray-900">
1001
- Full text
1002
- </summary>
1003
- <pre className="mt-2 max-h-96 overflow-auto whitespace-pre-wrap rounded bg-gray-50 p-2 text-xs text-gray-700">
1004
- {fullTextOf(document)}
1005
- </pre>
1006
- </details>
1007
- ) : null}
1008
-
1009
- {/* WITHHELD IS NOT EMPTY (bd startsim-768w.38.33). The tenant's per-field
1010
- read gate strips a restricted attribute and names it in
1011
- `redacted_fields`; without this line the reader sees a meeting with no
1012
- transcript and concludes there wasn't one. Named rather than counted,
1013
- because "the transcript" and "the salary" are different absences. */}
1014
- {document.withheldFields?.length ? (
1015
- <p className={`mt-3 ${cn.warning}`} role="status">
1016
- Part of this record is not shared with you:{' '}
1017
- {document.withheldFields.join(', ')}. Ask an admin if you need it.
1018
- </p>
1019
- ) : null}
1020
-
1021
- {/* Long-form under the SOURCE's own name for it — "Transcript" for a
1022
- meeting, "Extracted text" for a PDF. This component does not know
1023
- which is which, and must not. */}
1024
- {document.sections.map((section) => (
1025
- <details key={section.key} className="mt-3">
1026
- <summary className="cursor-pointer text-sm font-medium text-gray-900">{section.label}</summary>
1027
- <pre className="mt-2 max-h-96 overflow-auto whitespace-pre-wrap rounded bg-gray-50 p-2 text-xs text-gray-700">
1028
- {section.text}
1029
- </pre>
1030
- </details>
1031
- ))}
1032
-
1033
- {!document.body && document.sections.length === 0 ? (
1034
- <p className={`mt-3 ${cn.muted}`}>
1035
- This record arrived with no text. Its source may have deleted the content upstream.
1036
- </p>
1037
- ) : null}
1038
- </section>
1039
- );
1040
- }
@@ -32,6 +32,7 @@
32
32
  import * as React from 'react';
33
33
 
34
34
  import { displayProgress } from '../../corpus/planning';
35
+ import { FocusDocuments } from '../FocusDocuments';
35
36
  import {
36
37
  UnfilteredNotice,
37
38
  WorkItemRow,
@@ -384,6 +385,17 @@ export function PlanningPage({
384
385
  />
385
386
  ))}
386
387
  </section>
388
+
389
+ {selectedFocus && api.listDocuments ? (
390
+ <FocusDocuments
391
+ listDocuments={(query) => apiRef.current.listDocuments!(query)}
392
+ focusId={selectedFocus.id}
393
+ focusTitle={selectedFocus.title}
394
+ epoch={epoch}
395
+ onOpenDocument={onOpenDocument}
396
+ classNames={cn}
397
+ />
398
+ ) : null}
387
399
  </div>
388
400
  );
389
401
  }