@startsimpli/integrations 0.2.195 → 0.2.197

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@startsimpli/integrations",
3
- "version": "0.2.195",
3
+ "version": "0.2.197",
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",
@@ -50,9 +50,9 @@
50
50
  "react-native": ">=0.74.0",
51
51
  "@startsimpli/ui-native": ">=0.1.12",
52
52
  "react-native-safe-area-context": ">=4.0.0",
53
- "@startsimpli/auth": "^0.4.53",
54
- "@startsimpli/ui": "^0.4.189",
55
- "@startsimpli/utils": "^0.4.20"
53
+ "@startsimpli/utils": "^0.4.20",
54
+ "@startsimpli/ui": "^0.4.191",
55
+ "@startsimpli/auth": "^0.4.53"
56
56
  },
57
57
  "peerDependenciesMeta": {
58
58
  "react": {
@@ -99,7 +99,7 @@
99
99
  "react-native": "0.85.3",
100
100
  "react-native-safe-area-context": "~5.7.0",
101
101
  "@startsimpli/llm": "0.4.31",
102
- "@startsimpli/ui": "0.4.189",
102
+ "@startsimpli/ui": "0.4.191",
103
103
  "@startsimpli/ui-native": "0.1.15",
104
104
  "@startsimpli/auth": "0.4.53",
105
105
  "@startsimpli/utils": "0.4.20"
@@ -0,0 +1,52 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import { describe, expect, it } from 'vitest';
3
+
4
+ import { CompactItemRow } from '../components/pages/home/CompactItemRow';
5
+ import { renderExtractPrompt, extractSystemPrompt } from '../corpus/extract';
6
+ import { commitmentToEntity } from '../corpus/entities';
7
+ import type { Commitment } from '../corpus/types';
8
+
9
+ const base = {
10
+ id: 'c1', title: 'Send pricing sheet to Pat', detail: '', subtype: 'action', status: 'open', ownerName: 'Owner',
11
+ firstSeenAt: '2026-11-15T10:00:00Z', lastSeenAt: '2026-11-15T10:00:00Z', source: 'extracted',
12
+ } as unknown as Commitment;
13
+ const mention = (documentKind?: string) => ({
14
+ documentId: 'd1', originKey: 'model:send', occurredAt: '2026-11-15T10:00:00Z', quote: 'sending the pricing sheet tomorrow morning',
15
+ extractor: 'model' as const, ...(documentKind ? { documentKind } : {}),
16
+ ...(documentKind === 'email' ? { documentUrl: 'https://mail.example/#all/t1', documentTitle: 'Re: Atlas' } : {}),
17
+ });
18
+
19
+ describe('email evidence', () => {
20
+ it('says "an email" on the item when the mention came from mail, "a meeting" otherwise', () => {
21
+ const { rerender } = render(<ul><CompactItemRow item={{ ...base, mentions: [mention('email')] }} days={null} due={null} /></ul>);
22
+ expect(screen.getByTestId('item-evidence').textContent).toMatch(/^From an email/);
23
+ rerender(<ul><CompactItemRow item={{ ...base, mentions: [mention('meeting')] }} days={null} due={null} /></ul>);
24
+ expect(screen.getByTestId('item-evidence').textContent).toMatch(/^From a meeting/);
25
+ });
26
+
27
+ it('keeps the document kind through the tenant round trip', () => {
28
+ const entity = commitmentToEntity({ ...base, mentions: [mention('email')] });
29
+ const written = (entity.data.mentions as Array<Record<string, unknown>>)[0];
30
+ expect(written.document_kind).toBe('email');
31
+ expect(written.document_url).toBe('https://mail.example/#all/t1');
32
+ expect(written.document_title).toBe('Re: Atlas');
33
+ });
34
+
35
+ it('prompt tells the model a document is an email and how to read waiting-on', () => {
36
+ const prompt = renderExtractPrompt({ documents: [{ id: 'd1', title: 'Re: Atlas', source: 'Google', occurredAt: null, participants: ['Pat'], kind: 'email', text: 'From: Pat\nDirection: received\n\nhi', alreadyFound: [] }] });
37
+ expect(prompt).toContain('kind: email');
38
+ expect(extractSystemPrompt()).toMatch(/waiting on/i);
39
+ expect(extractSystemPrompt()).toMatch(/ENG-42/);
40
+ });
41
+ });
42
+
43
+ describe('email push switch', () => {
44
+ it('is stored only when off, and a save of other fields keeps it', async () => {
45
+ const { readTaskSync, withTaskSync } = await import('../task-tracker/sync-config');
46
+ const off = { config: { task_sync: { push_from_email: false, default_container_id: 't1' } } };
47
+ expect(readTaskSync(off).push_from_email).toBe(false);
48
+ expect(withTaskSync(off, { default_project_id: 'p1' }).push_from_email).toBe(false);
49
+ expect('push_from_email' in withTaskSync(off, { push_from_email: undefined })).toBe(false);
50
+ expect('push_from_email' in withTaskSync({ config: {} }, { default_container_id: 't1' })).toBe(false);
51
+ });
52
+ });
@@ -0,0 +1,46 @@
1
+ import { fireEvent, render, screen, waitFor } from '@testing-library/react';
2
+ import { describe, expect, it } from 'vitest';
3
+
4
+ import { LoadError } from '../components/LoadError';
5
+ import { OverviewPage } from '../components/pages/overview/OverviewPage';
6
+
7
+ describe('LoadError', () => {
8
+ it('says what failed in a sentence, keeps the server words, and Try again calls back', () => {
9
+ let tries = 0;
10
+ render(<LoadError what="the thing" message="simulated outage" onRetry={() => { tries += 1; }} />);
11
+ expect(screen.getByRole('alert').textContent).toContain('Could not load the thing.');
12
+ expect(screen.getByRole('alert').textContent).toContain('simulated outage');
13
+ fireEvent.click(screen.getByRole('button', { name: 'Try again' }));
14
+ expect(tries).toBe(1);
15
+ });
16
+ });
17
+
18
+ describe('OverviewPage failing then recovering', () => {
19
+ it('shows a retryable error, and Try again loads the page', async () => {
20
+ let calls = 0;
21
+ const page = <T,>(results: T[]) => ({ count: results.length, next: null, previous: null, results });
22
+ const api = {
23
+ listFocuses: async () => { calls += 1; if (calls === 1) throw new Error('simulated outage'); return page([{ id: 'f1', title: 'Alpha', status: 'active' }]); },
24
+ listCommitments: async () => page([{ id: '1', externalId: 'c1', title: 'task', status: 'open', ownerName: 'Sam', focusId: 'f1', mentions: [], dueAt: null, lastSeenAt: null }]),
25
+ } as never;
26
+ render(<OverviewPage api={api} scope={{} as never} onOpenProject={() => {}} />);
27
+ await waitFor(() => expect(screen.getByTestId('load-error')).toBeTruthy());
28
+ fireEvent.click(screen.getByRole('button', { name: 'Try again' }));
29
+ await waitFor(() => expect(screen.getAllByText('Alpha').length).toBeGreaterThan(0));
30
+ });
31
+ });
32
+
33
+ import { TrackerPage } from '../components/pages/TrackerPage';
34
+
35
+ describe('TrackerPage when the load fails', () => {
36
+ it('shows a retryable error and no 0-owed counts, then loads on Try again', async () => {
37
+ let calls = 0;
38
+ const page = { count: 0, next: null, previous: null, results: [] as never[] };
39
+ const api = { listCommitments: async () => { calls += 1; if (calls <= 1) throw new Error('simulated outage'); return page; } } as never;
40
+ render(<TrackerPage api={api} scope={{} as never} classNames={{} as never} />);
41
+ await waitFor(() => expect(screen.getByTestId('load-error')).toBeTruthy());
42
+ expect(screen.getByTestId('tracker-summary').textContent).toBe('');
43
+ fireEvent.click(screen.getByRole('button', { name: 'Try again' }));
44
+ await waitFor(() => expect(screen.queryByTestId('load-error')).toBeNull());
45
+ });
46
+ });
@@ -226,8 +226,8 @@ function build(request: Requester): MemberConnectionsApi {
226
226
  * A card that is not mine answers 404 rather than 403 — on this surface
227
227
  * existence is itself the payload.
228
228
  */
229
- disconnect(id: string): Promise<void> {
230
- return request<void>(`${BASE}/${id}/`, { method: 'DELETE' });
229
+ disconnect(id: string, options?: { removeData?: boolean }): Promise<void> {
230
+ return request<void>(`${BASE}/${id}/${options?.removeData ? '?remove_data=true' : ''}`, { method: 'DELETE' });
231
231
  },
232
232
 
233
233
  /** Recent activity on my card: a merge over the run tables it owns. */
@@ -0,0 +1,21 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+
5
+ /**
6
+ * A load failure that says what happened in a sentence and offers Try again. The server's own words stay visible
7
+ * underneath (they are the useful part for whoever has to fix it), but they are never the whole message.
8
+ */
9
+ export function LoadError({ message, onRetry, what = 'this' }: { message: string; onRetry?: () => void; what?: string }) {
10
+ return (
11
+ <div className="rounded-xl border border-red-200 bg-red-50 p-4 text-sm" role="alert" data-testid="load-error">
12
+ <p className="font-medium text-red-900">Could not load {what}.</p>
13
+ {message ? <p className="mt-1 text-red-800">{message}</p> : null}
14
+ {onRetry ? (
15
+ <button type="button" onClick={onRetry} className="mt-3 rounded-md border border-red-300 bg-white px-3 py-1.5 font-medium text-red-900 hover:bg-red-100">
16
+ Try again
17
+ </button>
18
+ ) : null}
19
+ </div>
20
+ );
21
+ }
@@ -82,3 +82,4 @@ export * from './pages/questions';
82
82
  export * from './pages/task-tracker/OwnerPicker';
83
83
  export * from './pages/plan';
84
84
  export * from './pages/overview';
85
+ export { LoadError } from './LoadError';
@@ -34,6 +34,8 @@
34
34
  */
35
35
  import * as React from 'react';
36
36
 
37
+ import { LoadError } from '../LoadError';
38
+
37
39
  import type { Connection, ConnectionPermissions, ConnectorCatalogEntry } from './types';
38
40
  import { MemberConnectionRoster } from './MemberConnectionRoster';
39
41
  import { connectableEntries } from './connectable-entries';
@@ -91,7 +93,7 @@ export function ConnectionsPage(props: ConnectionsPageProps) {
91
93
  React.useEffect(() => { void reload(); }, [reload]);
92
94
 
93
95
  if (loadError) {
94
- return <p className={cn.error} role="alert">{loadError}</p>;
96
+ return <LoadError what="your connections" message={loadError} onRetry={() => { setLoadError(''); void reload(); }} />;
95
97
  }
96
98
 
97
99
  return (
@@ -5,6 +5,8 @@
5
5
  */
6
6
  import * as React from 'react';
7
7
 
8
+ import { LoadError } from '../LoadError';
9
+
8
10
  import type { NotifyClient } from '../../corpus/notify/client';
9
11
  import type { DecisionIndexRow, DecisionRecord } from '../../corpus/notify/types';
10
12
 
@@ -61,7 +63,7 @@ export function DecisionsPage({ client, classNames, focus }: DecisionsPageProps)
61
63
  const ordered = (rows ?? []).slice().sort((a, b) => Number(b.id === focus) - Number(a.id === focus));
62
64
  return (
63
65
  <div className={cx('root')}>
64
- {error ? <div className={cx('error')} role="alert">{error}</div> : null}
66
+ {error ? <LoadError what="your decisions" message={error} onRetry={() => { setError(null); load(); }} /> : null}
65
67
  {rows && !rows.length ? (
66
68
  <div className="rounded-xl border border-gray-200 bg-white p-6 text-center" data-testid="decisions-empty">
67
69
  <p className="font-medium text-gray-900">Nothing is waiting on you.</p>
@@ -27,6 +27,8 @@
27
27
  */
28
28
  import * as React from 'react';
29
29
 
30
+ import { LoadError } from '../LoadError';
31
+
30
32
  import { DocumentDetail } from '../DocumentDetail';
31
33
  import { formatDate, summaryOf } from '../documentText';
32
34
  import { FolderTree, folderTrail } from '../FolderTree';
@@ -192,6 +194,7 @@ export function LibraryPage({
192
194
  const [selectError, setSelectError] = React.useState('');
193
195
  const [loading, setLoading] = React.useState(true);
194
196
  const [loadError, setLoadError] = React.useState('');
197
+ const [attempt, setAttempt] = React.useState(0);
195
198
  /**
196
199
  * LATCHED, not per-page. "The data API returned another workspace's rows" is a
197
200
  * fact about the API, and paging forward past the offending page must not make
@@ -256,7 +259,7 @@ export function LibraryPage({
256
259
  }
257
260
  })();
258
261
  return () => { live = false; };
259
- }, [api, query, scope]);
262
+ }, [api, query, scope, attempt]);
260
263
 
261
264
  React.useEffect(() => {
262
265
  if (!selectedId) { setSelected(null); setSelectError(''); return; }
@@ -345,7 +348,7 @@ export function LibraryPage({
345
348
  const hasFilters = Boolean(filters.source || filters.partyId || filters.occurredAfter || filters.occurredBefore);
346
349
 
347
350
  if (loadError) {
348
- return <p className={cn.error} role="alert">{loadError}</p>;
351
+ return <LoadError what="the library" message={loadError} onRetry={() => { setLoadError(''); setAttempt((n) => n + 1); }} />;
349
352
  }
350
353
 
351
354
  return (
@@ -314,7 +314,7 @@ export function TaskDetailPage({
314
314
  {item.mentions.map((m) => (
315
315
  <li key={`${m.documentId}:${m.originKey}`}>
316
316
  <button type="button" className="text-sm text-blue-700 underline" onClick={() => onOpenDocument?.(m.documentId)}>
317
- {m.occurredAt ? new Date(m.occurredAt).toLocaleDateString() : 'Undated meeting'}
317
+ {m.occurredAt ? new Date(m.occurredAt).toLocaleDateString() : m.documentKind === 'email' ? 'Undated email' : 'Undated meeting'}{m.documentKind === 'email' ? ' (email)' : ''}
318
318
  </button>
319
319
  {m.quote ? <span className={`ml-2 ${cn.muted}`}>“{m.quote}”</span> : null}
320
320
  </li>
@@ -26,6 +26,8 @@
26
26
  */
27
27
  import * as React from 'react';
28
28
 
29
+ import { LoadError } from '../LoadError';
30
+
29
31
  import { isStalled, runProgress } from '../../corpus/runs';
30
32
  import { isOverdue } from '../../corpus/work-item-logic';
31
33
  import { useTrackerName } from '../../task-tracker/useTrackerName';
@@ -181,6 +183,8 @@ export function TrackerPage({
181
183
  const [applied, setApplied] = React.useState<string[]>([]);
182
184
  const [loading, setLoading] = React.useState(true);
183
185
  const [error, setError] = React.useState('');
186
+ // a failed LOAD (offer Try again, hide the counts) is different from a failed action on one row (keep the plain message)
187
+ const [loadFailed, setLoadFailed] = React.useState(false);
184
188
  const [running, setRunning] = React.useState(false);
185
189
  /**
186
190
  * The SWEEP, when this deployment runs extraction as a job
@@ -214,6 +218,8 @@ export function TrackerPage({
214
218
  const load = React.useCallback(async () => {
215
219
  setLoading(true);
216
220
  setError('');
221
+ setLoadFailed(false);
222
+ setLoadFailed(false);
217
223
  try {
218
224
  const page = await apiRef.current.listCommitments(query);
219
225
  setRows(page.results);
@@ -232,6 +238,8 @@ export function TrackerPage({
232
238
  } catch (err) {
233
239
  setRows([]);
234
240
  setError(failureMessage(err));
241
+ setLoadFailed(true);
242
+ setLoadFailed(true);
235
243
  } finally {
236
244
  setLoading(false);
237
245
  }
@@ -499,7 +507,7 @@ export function TrackerPage({
499
507
  ) : null}
500
508
  <div className="flex flex-wrap items-center gap-3">
501
509
  <p className={cn.muted} data-testid="tracker-summary">
502
- {loading ? 'Loading…' : `${owed} owed · ${c.today} today · ${c.inProgress} in progress`}
510
+ {loading ? 'Loading…' : loadFailed ? '' : `${owed} owed · ${c.today} today · ${c.inProgress} in progress`}
503
511
  </p>
504
512
  <div className="ml-auto">
505
513
  {canQueue ? (
@@ -560,7 +568,7 @@ export function TrackerPage({
560
568
  <p className={`mt-2 ${cn.warning}`} role="status">{unfilteredMessage(['status'] as const, applied, query)}</p>
561
569
  </details>
562
570
  ) : null}
563
- {error ? <p className={cn.error} role="alert">{error}</p> : null}
571
+ {error ? (loadFailed ? <LoadError what="your to-dos" message={error} onRetry={() => void load()} /> : <p className={cn.error} role="alert">{error}</p>) : null}
564
572
  {sweep ? <SweepPanel sweep={sweep} now={clock} classNames={cn} /> : null}
565
573
 
566
574
  {!loading && owed === 0 && c.stale === 0 && !filtering ? (
@@ -40,6 +40,7 @@ export function ConnectionCard({
40
40
  const [replacing, setReplacing] = React.useState(false);
41
41
  const [settingsOpen, setSettingsOpen] = React.useState(false);
42
42
  const [confirmingDisconnect, setConfirmingDisconnect] = React.useState(false);
43
+ const [removeData, setRemoveData] = React.useState(false);
43
44
  const [activityOpen, setActivityOpen] = React.useState(false);
44
45
  /** `null` is NOT LOADED YET, which reads differently from a connection that
45
46
  has never run — the distinction the empty state below turns on. */
@@ -339,6 +340,15 @@ export function ConnectionCard({
339
340
  here, marked disabled, and you can connect it again later with a new
340
341
  key.
341
342
  </p>
343
+ {entry?.kind === 'mailbox' ? (
344
+ <label className="flex items-start gap-2 text-sm text-gray-800">
345
+ <input type="checkbox" checked={removeData} onChange={(e) => setRemoveData(e.target.checked)} />
346
+ <span>
347
+ Also delete the emails, events and people this account brought into Tandem. To-dos you made from them
348
+ stay, but their link back to the email stops working.
349
+ </span>
350
+ </label>
351
+ ) : null}
342
352
  {trackerApi ? (
343
353
  <p className={cn.muted}>
344
354
  {`Your to-dos stay in Tandem. Nothing is deleted in ${connection.connector_name}; they simply stop syncing.`}
@@ -350,8 +360,9 @@ export function ConnectionCard({
350
360
  className={cn.button}
351
361
  disabled={Boolean(busy)}
352
362
  onClick={() => void guard('disconnect', async () => {
353
- await api.disconnect(connection.id);
363
+ await (removeData ? api.disconnect(connection.id, { removeData: true }) : api.disconnect(connection.id));
354
364
  setConfirmingDisconnect(false);
365
+ setRemoveData(false);
355
366
  setNotice('Disconnected.');
356
367
  onChanged();
357
368
  })}
@@ -53,7 +53,7 @@ export interface BoundApi {
53
53
  }): Promise<Connection>;
54
54
  checkConnection(id: string): Promise<{ ok: boolean; account_label: string; detail: string; reason?: string; next_step?: string }>;
55
55
  rotateCredential(id: string, credentials: Record<string, unknown>): Promise<Connection>;
56
- disconnect(id: string): Promise<void>;
56
+ disconnect(id: string, options?: { removeData?: boolean }): Promise<void>;
57
57
  updateConnection?(id: string, input: {
58
58
  name?: string; capabilities_enabled?: string[]; config?: Record<string, unknown>;
59
59
  }): Promise<Connection>;
@@ -50,7 +50,7 @@ function MeetingEvidence({ item }: { item: Commitment }) {
50
50
  const more = item.mentions.length > 1 ? ` · +${item.mentions.length - 1} more` : '';
51
51
  return (
52
52
  <span className="block truncate text-xs text-gray-500" data-testid="item-evidence">
53
- From a meeting{when ? ` ${when}` : ''}: “{stripMarkdown(latest.quote)}”{more}
53
+ From {latest.documentKind === 'email' ? 'an email' : 'a meeting'}{when ? ` ${when}` : ''}: “{stripMarkdown(latest.quote)}”{more}
54
54
  </span>
55
55
  );
56
56
  }
@@ -7,6 +7,7 @@
7
7
  */
8
8
  import * as React from 'react';
9
9
 
10
+ import { LoadError } from '../../LoadError';
10
11
  import { buildOverview, NO_PROJECT, type OverviewRow } from '../../../corpus/overview';
11
12
  import type { Commitment, CorpusScope, Focus, PlanningApi } from '../../../corpus/types';
12
13
 
@@ -45,6 +46,7 @@ export function OverviewPage({ api, scope, meNames, onOpenProject, now }: Overvi
45
46
  const [error, setError] = React.useState('');
46
47
  const [who, setWho] = React.useState<string | null>(null);
47
48
  const [sort, setSort] = React.useState<{ key: SortKey; dir: 1 | -1 } | null>(null);
49
+ const [attempt, setAttempt] = React.useState(0);
48
50
 
49
51
  React.useEffect(() => {
50
52
  let live = true;
@@ -59,10 +61,10 @@ export function OverviewPage({ api, scope, meNames, onOpenProject, now }: Overvi
59
61
  return () => {
60
62
  live = false;
61
63
  };
62
- }, [api, scope]);
64
+ }, [api, scope, attempt]);
63
65
 
64
66
  const overview = React.useMemo(() => (data ? buildOverview(data.focuses, data.items, { meNames, now }) : null), [data, meNames, now]);
65
- if (error) return <p className="text-sm text-red-600" role="alert">{error}</p>;
67
+ if (error) return <LoadError what="the overview" message={error} onRetry={() => setAttempt((n) => n + 1)} />;
66
68
  if (!overview) return <p className="text-sm text-gray-500">Loading…</p>;
67
69
  if (!overview.rows.length) return <p className="text-sm text-gray-500">Nothing in flight yet. Projects and their open to-dos show up here as they are connected or planned.</p>;
68
70
 
@@ -70,6 +70,19 @@ export function TaskTrackerSettings({ api, connection, classNames: cn, onSaved }
70
70
  {picker('Your private space for personal to-dos', 'personal_container_id', 'team', 'Not set (personal to-dos stay in Tandem)')}
71
71
  {picker(`Also bring in ${tracker} issues assigned to`, 'assignee_id', 'user', 'Nobody in particular')}
72
72
 
73
+ <label className="flex items-start gap-2 text-sm text-gray-900">
74
+ <input
75
+ type="checkbox"
76
+ checked={s.value.push_from_email !== false}
77
+ disabled={s.loading}
78
+ onChange={(e) => controller.set({ push_from_email: e.target.checked ? undefined : false })}
79
+ />
80
+ <span>
81
+ {`Send to-dos that came from my email to ${tracker}`}
82
+ <span className="block text-xs text-gray-500">Each one gets a “Pushed from email” link to the message. Turn off to keep them in Tandem only; turning it back on sends them.</span>
83
+ </span>
84
+ </label>
85
+
73
86
  <div>
74
87
  <p className="text-sm font-medium text-gray-900">{`${tracker} states and Tandem status`}</p>
75
88
  {s.rows.length === 0 && !s.loading ? <p className={cn.muted}>No states found.</p> : null}
@@ -11,6 +11,8 @@
11
11
  * or render would be a second.
12
12
  */
13
13
  import * as React from 'react';
14
+
15
+ import { LoadError } from '../../LoadError';
14
16
  import { DEFAULT_RANGES, RangeEventTable, RangeSelector, RangeTimelineChart } from '@startsimpli/ui/insights';
15
17
 
16
18
  import { buildTimeline, anchorOf, type TimelineFilter } from '../../../corpus/tracker-timeline';
@@ -61,6 +63,7 @@ export function TrackerTimeline({
61
63
  owner: filter.owner ?? '', search: debouncedSearch,
62
64
  });
63
65
  const anchor = anchorOf(now, timeZone);
66
+ const [attempt, setAttempt] = React.useState(0);
64
67
 
65
68
  React.useEffect(() => {
66
69
  let live = true;
@@ -77,14 +80,14 @@ export function TrackerTimeline({
77
80
  return () => { live = false; };
78
81
  // `now` is the page's frozen clock; the anchor day stands in for it.
79
82
  // eslint-disable-next-line react-hooks/exhaustive-deps
80
- }, [orgId, filterKey, anchor, timeZone]);
83
+ }, [orgId, filterKey, anchor, timeZone, attempt]);
81
84
 
82
85
  const built = React.useMemo(() => (read ? buildTimeline(read, now, timeZone) : null), [read, now, timeZone]);
83
86
 
84
87
  return (
85
88
  <section className={className ?? 'space-y-4'} aria-label="Tracker timeline" data-testid="tracker-timeline">
86
89
  {heading ? <h2 className="text-lg font-semibold text-gray-900">Timeline</h2> : null}
87
- {error ? <p className="text-sm text-red-600" role="alert">{error}</p> : null}
90
+ {error ? <LoadError what="the timeline" message={error} onRetry={() => setAttempt((n) => n + 1)} /> : null}
88
91
  {loading && !built ? <p className="text-sm text-gray-500">Loading the timeline…</p> : null}
89
92
  {built ? (
90
93
  <>
@@ -447,7 +447,8 @@ export interface MemberConnectionsApi {
447
447
  /** What a task-tracker account reaches (teams, projects, states, users): `kind` picks the list. */
448
448
  connectionChoices?(id: string, params?: { kind?: string; cursor?: string }): Promise<ConnectionChoicePage>;
449
449
  rotateCredential(id: string, credentials: Record<string, unknown>): Promise<Connection>;
450
- disconnect(id: string): Promise<void>;
450
+ /** `removeData` also deletes what the account brought in (mailbox connectors). */
451
+ disconnect(id: string, options?: { removeData?: boolean }): Promise<void>;
451
452
  connectionRuns(id: string): Promise<{ results: ConnectionRun[] }>;
452
453
  /**
453
454
  * The OAuth half of the surface (bd startsim-768w.22.25.14/.21). Optional so
@@ -183,7 +183,7 @@ export function WorkItemRow({
183
183
  ) : (
184
184
  <details className="mt-2">
185
185
  <summary className="cursor-pointer text-sm text-gray-600">
186
- From {item.mentions.length} meeting{item.mentions.length === 1 ? '' : 's'}
186
+ From {item.mentions.length} {item.mentions.every((m) => m.documentKind === 'email') ? 'email' : item.mentions.some((m) => m.documentKind === 'email') ? 'source' : 'meeting'}{item.mentions.length === 1 ? '' : 's'}
187
187
  </summary>
188
188
  <div className="mt-2 space-y-2">
189
189
  {item.mentions.map((mention) => (
@@ -196,7 +196,7 @@ export function WorkItemRow({
196
196
  >
197
197
  {mention.occurredAt
198
198
  ? new Date(mention.occurredAt).toLocaleDateString()
199
- : 'Undated meeting'}
199
+ : mention.documentKind === 'email' ? 'Undated email' : 'Undated meeting'}
200
200
  </button>
201
201
  {/* Where the row came from. A model-derived item and one the
202
202
  summariser itself wrote down are different levels of
@@ -395,6 +395,8 @@ function toMention(draft: CommitmentDraft, document: SourceDocument): Commitment
395
395
  return {
396
396
  documentId: draft.documentId,
397
397
  originKey: draft.originKey,
398
+ ...(document.subtype ? { documentKind: document.subtype } : {}),
399
+ ...(document.subtype === 'email' && document.url ? { documentUrl: document.url, documentTitle: document.title } : {}),
398
400
  occurredAt: iso(document.occurredAt),
399
401
  quote: draft.quote ?? '',
400
402
  extractor: draft.extractor,
@@ -784,6 +784,8 @@ function toMention(value: unknown): CommitmentMention | null {
784
784
  return {
785
785
  documentId,
786
786
  originKey: asText(pick(data, 'origin_key', 'originKey')),
787
+ ...(asText(pick(data, 'document_kind', 'documentKind')) ? { documentKind: asText(pick(data, 'document_kind', 'documentKind')) } : {}),
788
+ ...(asText(pick(data, 'document_url', 'documentUrl')) ? { documentUrl: asText(pick(data, 'document_url', 'documentUrl')), documentTitle: asText(pick(data, 'document_title', 'documentTitle')) } : {}),
787
789
  occurredAt: asIso(pick(data, 'occurred_at', 'occurredAt')),
788
790
  quote: asText(pick(data, 'quote')),
789
791
  extractor: extractor === 'model' ? 'model' : 'rules',
@@ -832,6 +834,8 @@ export function commitmentToEntity(commitment: Commitment): {
832
834
  mentions: commitment.mentions.slice(-MAX_MENTIONS).map((mention) => ({
833
835
  document_id: mention.documentId,
834
836
  origin_key: mention.originKey,
837
+ ...(mention.documentKind ? { document_kind: mention.documentKind } : {}),
838
+ ...(mention.documentUrl ? { document_url: mention.documentUrl, document_title: (mention.documentTitle ?? '').slice(0, 200) } : {}),
835
839
  occurred_at: mention.occurredAt,
836
840
  quote: mention.quote.slice(0, 400),
837
841
  extractor: mention.extractor,
@@ -276,6 +276,9 @@ export function extractSystemPrompt(): string {
276
276
  'Set "subject" to what the item is ABOUT — a matter or case number, a property, a client, a system, a person. Copy an identifier verbatim when the text has one.',
277
277
  'Set "owner" only to a name the document actually names. Leave it out otherwise.',
278
278
  'Never estimate or invent a due date, and do not compute one: the system reads the date itself from your "quote". When the item has a stated date or day ("by 29th July", "tomorrow", "on Monday"), make sure those exact words are inside the quote; when the document states none, say nothing about a date.',
279
+ 'Some documents are EMAILS (kind: email). The text starts with From, To and Direction lines. Direction "sent" means the mailbox owner wrote it, so commitments in it ("I will send...", "I will update...") belong to the owner. Direction "received" means somebody wrote to the owner: what the sender promises is theirs, what they ask for is the owner\'s.',
280
+ 'In an email, "waiting on" matters as much as "to do": when the writer says they are blocked on, or waiting for, another person ("waiting on your reply", "I need the sheet before Friday"), report a "need" with status "blocked", owner set to the person being waited on, and the writer named in the detail. Quoted older messages (lines starting with >) are history, not new statements.',
281
+ 'An issue key such as ENG-42 in a document is a strong "subject": copy it verbatim, including when the email says the work is finished or moved.',
279
282
  'Also report RESOLUTIONS: statements that something previously outstanding is now done or abandoned. Give the subject, what happened, and a verbatim quote.',
280
283
  'Respond with JSON only: {"items":[{"documentId":string,"subtype":"action"|"decision"|"need"|"risk"|"question","title":string,"detail":string,"status":"open"|"done"|"blocked","owner":string,"subject":string,"quote":string}],"resolutions":[{"documentId":string,"subject":string,"statement":string,"quote":string,"outcome":"done"|"dropped"}]}',
281
284
  '"title" must be one short imperative line.',
@@ -286,7 +289,7 @@ export function extractSystemPrompt(): string {
286
289
  export function renderExtractPrompt(input: {
287
290
  documents: Array<{
288
291
  id: string; title: string; source: string; occurredAt: string | null;
289
- participants: string[]; text: string; alreadyFound: string[];
292
+ participants: string[]; kind?: string; text: string; alreadyFound: string[];
290
293
  }>;
291
294
  }): string {
292
295
  const blocks = input.documents.map((document) =>
@@ -294,6 +297,7 @@ export function renderExtractPrompt(input: {
294
297
  `<document id="${document.id}">`,
295
298
  `title: ${document.title}`,
296
299
  `source: ${document.source}`,
300
+ document.kind ? `kind: ${document.kind}` : '',
297
301
  `occurred_at: ${document.occurredAt ?? 'unknown'}`,
298
302
  document.participants.length ? `participants: ${document.participants.join(', ')}` : '',
299
303
  document.alreadyFound.length
@@ -505,6 +509,7 @@ export async function extractCommitments(
505
509
  source: document.sourceLabel || document.source,
506
510
  occurredAt: document.occurredAt,
507
511
  participants: document.participants.map((party) => party.name),
512
+ ...(document.subtype ? { kind: document.subtype } : {}),
508
513
  text: promptText.get(document.id) ?? '',
509
514
  alreadyFound: foundByDocument.get(document.id) ?? [],
510
515
  })),
@@ -639,6 +639,11 @@ export interface CommitmentMention {
639
639
  documentId: string;
640
640
  /** Stable within a document: the vendor's own bullet, or the model's item. */
641
641
  originKey: string;
642
+ /** What kind of document the mention came from (`email`, `meeting`, ...): the evidence line says "email", never "meeting", for mail. */
643
+ documentKind?: string;
644
+ /** Link back to the original (an email in its mailbox) and its title: what a pushed tracker item points at. */
645
+ documentUrl?: string;
646
+ documentTitle?: string;
642
647
  /** When the meeting happened — NOT when the row was written. */
643
648
  occurredAt: string | null;
644
649
  /** Verbatim span from that document, so the claim can be checked. */
@@ -1088,6 +1093,8 @@ export interface ExtractionRequest {
1088
1093
  source: string;
1089
1094
  occurredAt: string | null;
1090
1095
  participants: string[];
1096
+ /** `email`, `meeting`, ...: lets the prompt read a message as a message. */
1097
+ kind?: string;
1091
1098
  text: string;
1092
1099
  /**
1093
1100
  * What the deterministic pre-pass already found in this document. Sent so
@@ -22,6 +22,8 @@ export interface TaskSyncConfig {
22
22
  /** tracker workflow state id -> Tandem status. */
23
23
  state_overrides?: Record<string, TrackerStatus>;
24
24
  assignee_id?: string;
25
+ /** `false` pauses sending to-dos that exist only because of an email; absent means on. */
26
+ push_from_email?: boolean;
25
27
  }
26
28
 
27
29
  export const TASK_SYNC_KEY = 'task_sync';
@@ -50,6 +52,7 @@ export function readTaskSync(connection: Pick<Connection, 'config'>): TaskSyncCo
50
52
  const src = raw as Record<string, unknown>;
51
53
  const out: Record<string, unknown> = {};
52
54
  for (const k of STRINGS) if (typeof src[k] === 'string' && src[k]) out[k] = src[k];
55
+ if (src.push_from_email === false) out.push_from_email = false;
53
56
  for (const k of MAPS) {
54
57
  const m = src[k];
55
58
  if (m && typeof m === 'object' && Object.keys(m).length) out[k] = { ...(m as object) };
@@ -61,6 +64,7 @@ export function readTaskSync(connection: Pick<Connection, 'config'>): TaskSyncCo
61
64
  export function withTaskSync(connection: Pick<Connection, 'config'>, edit: Partial<TaskSyncConfig>): TaskSyncConfig {
62
65
  const merged: Record<string, unknown> = { ...readTaskSync(connection), ...edit };
63
66
  for (const k of STRINGS) if (!merged[k]) delete merged[k];
67
+ if (merged.push_from_email !== false) delete merged.push_from_email;
64
68
  for (const k of MAPS) {
65
69
  const m = merged[k] as Record<string, unknown> | undefined;
66
70
  if (!m || !Object.keys(m).length) delete merged[k];