@startsimpli/integrations 0.2.216 → 0.2.218
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 +5 -5
- package/src/__tests__/briefing-timezone-memory.test.ts +56 -0
- package/src/__tests__/corpus-storage.test.ts +6 -0
- package/src/__tests__/corpus-tracker.test.tsx +37 -0
- package/src/__tests__/engine-near-date.test.ts +136 -0
- package/src/__tests__/fleet-page.test.tsx +24 -0
- package/src/__tests__/near-date-ui.test.tsx +74 -0
- package/src/__tests__/relay-cli.test.ts +1 -1
- package/src/__tests__/share-default-row.test.tsx +44 -0
- package/src/__tests__/shared-with.test.tsx +87 -0
- package/src/__tests__/sync-health.test.ts +70 -0
- package/src/__tests__/task-detail.test.tsx +1 -1
- package/src/api/_fetch.ts +1 -1
- package/src/api/connections.ts +14 -0
- package/src/components/DocumentDetail.tsx +3 -0
- package/src/components/SharedWith.tsx +140 -0
- package/src/components/index.ts +1 -0
- package/src/components/pages/FleetPage.tsx +16 -4
- package/src/components/pages/SyncHealthCard.tsx +42 -0
- package/src/components/pages/TaskDetailPage.tsx +4 -2
- package/src/components/pages/TrackerPage.tsx +27 -7
- package/src/components/pages/connections/ConnectionCard.tsx +5 -0
- package/src/components/pages/connections/ShareDefaultRow.tsx +91 -0
- package/src/components/pages/connections/bound-api.ts +4 -1
- package/src/components/pages/tracker/PossiblyDone.tsx +28 -2
- package/src/components/pages/tracker/Suggestion.tsx +15 -11
- package/src/components/pages/types.ts +11 -0
- package/src/components/table/todo-model.ts +3 -0
- package/src/corpus/briefing/generate-weekly.ts +2 -1
- package/src/corpus/briefing/generate.ts +2 -1
- package/src/corpus/briefing/zone.ts +24 -0
- package/src/corpus/client.ts +6 -0
- package/src/corpus/commitments.ts +48 -3
- package/src/corpus/converse/fleet-view.ts +1 -1
- package/src/corpus/converse/fleet.ts +1 -1
- package/src/corpus/converse/index.ts +2 -0
- package/src/corpus/converse/respond.ts +2 -1
- package/src/corpus/converse/sync-health.ts +96 -0
- package/src/corpus/engine/apply.ts +10 -3
- package/src/corpus/engine/decide.ts +3 -2
- package/src/corpus/engine/near-match.ts +71 -0
- package/src/corpus/engine/proposed-due.ts +44 -0
- package/src/corpus/engine/suggestion.ts +5 -0
- package/src/corpus/engine/types.ts +2 -0
- package/src/corpus/entities.ts +13 -0
- package/src/corpus/extract.ts +10 -4
- package/src/corpus/index.ts +2 -0
- package/src/corpus/sharing.ts +135 -0
- package/src/corpus/types.ts +21 -1
package/src/api/connections.ts
CHANGED
|
@@ -45,6 +45,7 @@ import type {
|
|
|
45
45
|
ConnectorCatalogEntry,
|
|
46
46
|
MemberConnectionsApi,
|
|
47
47
|
OAuthStart,
|
|
48
|
+
ShareDefault,
|
|
48
49
|
} from '../components/pages/types';
|
|
49
50
|
import { createRequester, request, type ClientDeps, type Requester } from './_fetch';
|
|
50
51
|
|
|
@@ -217,6 +218,19 @@ function build(request: Requester): MemberConnectionsApi {
|
|
|
217
218
|
});
|
|
218
219
|
},
|
|
219
220
|
|
|
221
|
+
/** Who this account's records are shared with; `null` is private again (Todo ENG-158). */
|
|
222
|
+
updateConnectionSharing(id: string, share: ShareDefault | null): Promise<Connection> {
|
|
223
|
+
return request<Connection>(`${BASE}/${id}/sharing/`, {
|
|
224
|
+
method: 'PUT', body: { share_default: share },
|
|
225
|
+
});
|
|
226
|
+
},
|
|
227
|
+
|
|
228
|
+
/** The teams a default can name: those of the caller's own organisation. */
|
|
229
|
+
async shareTeams(): Promise<Array<{ slug: string; name: string }>> {
|
|
230
|
+
const body = await request<{ results?: Array<{ slug: string; name: string }> }>(`${BASE}/share-teams/`);
|
|
231
|
+
return body.results ?? [];
|
|
232
|
+
},
|
|
233
|
+
|
|
220
234
|
/**
|
|
221
235
|
* DISCONNECT, not delete. One transaction stops the scheduled fetches, revokes
|
|
222
236
|
* every token issued for the account and deletes the stored credential; the
|
|
@@ -7,6 +7,7 @@ import * as React from 'react';
|
|
|
7
7
|
|
|
8
8
|
import { Markdown } from './Markdown';
|
|
9
9
|
import { FiledUnder } from './FiledUnder';
|
|
10
|
+
import { SharedWith } from './SharedWith';
|
|
10
11
|
import { formatDate, fullTextOf, summaryOf, todosInPlanText, withoutNextSteps } from './documentText';
|
|
11
12
|
import type { CorpusApi, CorpusScope, SourceDocument } from '../corpus/types';
|
|
12
13
|
|
|
@@ -66,6 +67,8 @@ export function DocumentDetail({
|
|
|
66
67
|
|
|
67
68
|
<FiledUnder api={api} documentId={document.id} classNames={cn} />
|
|
68
69
|
|
|
70
|
+
<SharedWith api={api} documentId={document.id} classNames={cn} />
|
|
71
|
+
|
|
69
72
|
{document.participants.length ? (
|
|
70
73
|
<div className="mt-3">
|
|
71
74
|
<p className="text-sm font-medium text-gray-900">Parties</p>
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WHO CAN SEE THIS RECORD, on the open record in the Library (Todo ENG-158).
|
|
3
|
+
*
|
|
4
|
+
* A record is private to whoever it belongs to until they share it. This is the
|
|
5
|
+
* one place that says so and changes it: a line of who it is shared with, and one
|
|
6
|
+
* menu to add a person, a team, or the whole organisation. It hides itself when
|
|
7
|
+
* the host's client cannot read shares, and shows the line without the menu when
|
|
8
|
+
* the caller may read the record but not change who else can.
|
|
9
|
+
*/
|
|
10
|
+
import * as React from 'react';
|
|
11
|
+
|
|
12
|
+
import type { CorpusApi } from '../corpus/types';
|
|
13
|
+
import type { RecordShare, RecordShares, ShareChoices, ShareKind, ShareLevel } from '../corpus/sharing';
|
|
14
|
+
|
|
15
|
+
type Slots = Record<'badge' | 'input' | 'muted' | 'error', string>;
|
|
16
|
+
|
|
17
|
+
type SharingApi = Pick<CorpusApi, 'listRecordShares' | 'listShareChoices' | 'addRecordShare' | 'removeRecordShare'>;
|
|
18
|
+
|
|
19
|
+
const ORG_OPTION = 'org:';
|
|
20
|
+
|
|
21
|
+
export function labelFor(share: RecordShare, choices: ShareChoices): string {
|
|
22
|
+
if (share.kind === 'org') return choices.org?.label ?? 'Everyone in my organisation';
|
|
23
|
+
const pool = share.kind === 'group' ? choices.teams : choices.people;
|
|
24
|
+
return pool.find((c) => c.id === share.subjectId)?.label ?? (share.kind === 'group' ? 'A team' : 'A colleague');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function SharedWith({
|
|
28
|
+
api, documentId, classNames: cn,
|
|
29
|
+
}: {
|
|
30
|
+
api: SharingApi;
|
|
31
|
+
documentId: string;
|
|
32
|
+
classNames: Slots;
|
|
33
|
+
}) {
|
|
34
|
+
const apiRef = React.useRef(api);
|
|
35
|
+
apiRef.current = api;
|
|
36
|
+
const [state, setState] = React.useState<RecordShares | undefined>(undefined);
|
|
37
|
+
const [choices, setChoices] = React.useState<ShareChoices>({ people: [], teams: [] });
|
|
38
|
+
const [level, setLevel] = React.useState<ShareLevel>('viewer');
|
|
39
|
+
const [busy, setBusy] = React.useState(false);
|
|
40
|
+
const [error, setError] = React.useState('');
|
|
41
|
+
const canRead = Boolean(api.listRecordShares);
|
|
42
|
+
|
|
43
|
+
const load = React.useCallback(async () => {
|
|
44
|
+
try {
|
|
45
|
+
setState(await apiRef.current.listRecordShares!(documentId));
|
|
46
|
+
} catch {
|
|
47
|
+
setState(undefined);
|
|
48
|
+
setError('Who this is shared with could not be read.');
|
|
49
|
+
}
|
|
50
|
+
}, [documentId]);
|
|
51
|
+
|
|
52
|
+
React.useEffect(() => {
|
|
53
|
+
if (!canRead) return;
|
|
54
|
+
setState(undefined);
|
|
55
|
+
setError('');
|
|
56
|
+
void load();
|
|
57
|
+
}, [canRead, load]);
|
|
58
|
+
|
|
59
|
+
const canEdit = Boolean(state?.canShare && api.addRecordShare && api.removeRecordShare && api.listShareChoices);
|
|
60
|
+
React.useEffect(() => {
|
|
61
|
+
if (!canEdit) return undefined;
|
|
62
|
+
let live = true;
|
|
63
|
+
apiRef.current.listShareChoices!()
|
|
64
|
+
.then((result) => { if (live) setChoices(result); })
|
|
65
|
+
.catch(() => { /* the line still shows; only the menu is lost */ });
|
|
66
|
+
return () => { live = false; };
|
|
67
|
+
}, [canEdit]);
|
|
68
|
+
|
|
69
|
+
if (!canRead) return null;
|
|
70
|
+
|
|
71
|
+
async function act(work: () => Promise<void>) {
|
|
72
|
+
setBusy(true);
|
|
73
|
+
setError('');
|
|
74
|
+
try {
|
|
75
|
+
await work();
|
|
76
|
+
await load();
|
|
77
|
+
} catch (err) {
|
|
78
|
+
setError((err as { message?: string })?.message || 'Sharing could not be changed.');
|
|
79
|
+
} finally {
|
|
80
|
+
setBusy(false);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function add(value: string) {
|
|
85
|
+
if (!value) return;
|
|
86
|
+
const [kind, ...rest] = value.split(':');
|
|
87
|
+
const subjectId = rest.join(':');
|
|
88
|
+
void act(() => apiRef.current.addRecordShare!(documentId, { kind: kind as ShareKind, subjectId, level }));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const taken = new Set((state?.shares ?? []).map((s) => `${s.kind}:${s.subjectId}`));
|
|
92
|
+
const orgTaken = (state?.shares ?? []).some((s) => s.kind === 'org');
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<div className="mt-3 flex flex-wrap items-center gap-2" data-testid="shared-with">
|
|
96
|
+
<p className="text-sm font-medium text-gray-900">Shared with</p>
|
|
97
|
+
{state === undefined && !error ? <span className={cn.muted}>…</span> : null}
|
|
98
|
+
{state && state.shares.length === 0 ? <span className={cn.muted}>Only you</span> : null}
|
|
99
|
+
{state?.shares.map((share) => (
|
|
100
|
+
<span key={share.id} className={cn.badge}>
|
|
101
|
+
{labelFor(share, choices)}{share.level === 'editor' ? ' · can edit' : ''}
|
|
102
|
+
{canEdit ? (
|
|
103
|
+
<button
|
|
104
|
+
type="button"
|
|
105
|
+
className="ml-1"
|
|
106
|
+
aria-label={`Stop sharing with ${labelFor(share, choices)}`}
|
|
107
|
+
disabled={busy}
|
|
108
|
+
onClick={() => { void act(() => apiRef.current.removeRecordShare!(share.id)); }}
|
|
109
|
+
>×</button>
|
|
110
|
+
) : null}
|
|
111
|
+
</span>
|
|
112
|
+
))}
|
|
113
|
+
{canEdit ? (
|
|
114
|
+
<>
|
|
115
|
+
<label>
|
|
116
|
+
<span className="sr-only">Share with</span>
|
|
117
|
+
<select className={cn.input} disabled={busy} value="" onChange={(e) => add(e.target.value)}>
|
|
118
|
+
<option value="">Share with…</option>
|
|
119
|
+
{choices.org && !orgTaken ? <option value={`${ORG_OPTION}${choices.org.id}`}>{choices.org.label}</option> : null}
|
|
120
|
+
{choices.teams.filter((t) => !taken.has(`group:${t.id}`)).map((t) => (
|
|
121
|
+
<option key={`g${t.id}`} value={`group:${t.id}`}>{t.label} (team)</option>
|
|
122
|
+
))}
|
|
123
|
+
{choices.people.filter((p) => !taken.has(`user:${p.id}`)).map((p) => (
|
|
124
|
+
<option key={`u${p.id}`} value={`user:${p.id}`}>{p.label}</option>
|
|
125
|
+
))}
|
|
126
|
+
</select>
|
|
127
|
+
</label>
|
|
128
|
+
<label>
|
|
129
|
+
<span className="sr-only">Access</span>
|
|
130
|
+
<select className={cn.input} disabled={busy} value={level} onChange={(e) => setLevel(e.target.value as ShareLevel)}>
|
|
131
|
+
<option value="viewer">Can view</option>
|
|
132
|
+
<option value="editor">Can edit</option>
|
|
133
|
+
</select>
|
|
134
|
+
</label>
|
|
135
|
+
</>
|
|
136
|
+
) : null}
|
|
137
|
+
{error ? <p className={cn.error} role="alert">{error}</p> : null}
|
|
138
|
+
</div>
|
|
139
|
+
);
|
|
140
|
+
}
|
package/src/components/index.ts
CHANGED
|
@@ -79,6 +79,7 @@ export { DecisionsPage } from './pages/DecisionsPage';
|
|
|
79
79
|
export type { DecisionsPageProps, DecisionsClassNames } from './pages/DecisionsPage';
|
|
80
80
|
export { FleetPage } from './pages/FleetPage';
|
|
81
81
|
export type { FleetPageProps, FleetPayload } from './pages/FleetPage';
|
|
82
|
+
export { SyncHealthCard } from './pages/SyncHealthCard';
|
|
82
83
|
export type { VoiceRecordButtonProps, VoiceRecordClassNames } from './pages/VoiceRecordButton';
|
|
83
84
|
export * from './pages/home';
|
|
84
85
|
export * from './pages/questions';
|
|
@@ -9,10 +9,17 @@ import * as React from 'react';
|
|
|
9
9
|
|
|
10
10
|
import { ageWords, FLEET_FRESH_MS } from '../../corpus/converse/fleet';
|
|
11
11
|
import type { FleetSession, FleetView } from '../../corpus/converse/fleet-view';
|
|
12
|
+
import { buildSyncHealth, type SyncConnectionInput, type TodoSyncRecord } from '../../corpus/converse/sync-health';
|
|
13
|
+
import { SyncHealthCard } from './SyncHealthCard';
|
|
12
14
|
import { LoadError } from '../LoadError';
|
|
13
15
|
|
|
14
|
-
export interface FleetPayload { snapshot: { text: string; updatedAt: string; view: FleetView | null } | null }
|
|
15
|
-
export interface FleetPageProps {
|
|
16
|
+
export interface FleetPayload { snapshot: { text: string; updatedAt: string; view: FleetView | null; todoSync?: TodoSyncRecord | null } | null }
|
|
17
|
+
export interface FleetPageProps {
|
|
18
|
+
load: () => Promise<FleetPayload>;
|
|
19
|
+
/** The member's own connections (`connectionsMe.connections`); when given, the page shows one Sync health row per leg. */
|
|
20
|
+
loadConnections?: () => Promise<{ results: SyncConnectionInput[] }>;
|
|
21
|
+
refreshMs?: number;
|
|
22
|
+
}
|
|
16
23
|
|
|
17
24
|
function SessionRow({ s, testId }: { s: FleetSession; testId?: string }) {
|
|
18
25
|
return (
|
|
@@ -91,16 +98,21 @@ function FleetBody({ view }: { view: FleetView }) {
|
|
|
91
98
|
);
|
|
92
99
|
}
|
|
93
100
|
|
|
94
|
-
export function FleetPage({ load, refreshMs = 30000 }: FleetPageProps) {
|
|
101
|
+
export function FleetPage({ load, loadConnections, refreshMs = 30000 }: FleetPageProps) {
|
|
95
102
|
const [data, setData] = React.useState<FleetPayload | undefined>();
|
|
103
|
+
const [conns, setConns] = React.useState<SyncConnectionInput[] | undefined>();
|
|
104
|
+
const [connsError, setConnsError] = React.useState<string | null>(null);
|
|
96
105
|
const [error, setError] = React.useState<string | null>(null);
|
|
97
106
|
const [, tick] = React.useState(0);
|
|
98
|
-
const run = React.useCallback(() => { load().then((d) => { setData(d); setError(null); }).catch((e) => setError(e instanceof Error ? e.message : 'Could not load.'));
|
|
107
|
+
const run = React.useCallback(() => { load().then((d) => { setData(d); setError(null); }).catch((e) => setError(e instanceof Error ? e.message : 'Could not load.'));
|
|
108
|
+
loadConnections?.().then((c) => { setConns(c.results); setConnsError(null); }).catch((e) => setConnsError(e instanceof Error ? e.message : 'Could not load.')); }, [load, loadConnections]);
|
|
99
109
|
React.useEffect(() => { run(); const t = setInterval(() => { run(); tick((n) => n + 1); }, refreshMs); return () => clearInterval(t); }, [run, refreshMs]);
|
|
100
110
|
const snap = data?.snapshot;
|
|
101
111
|
const stale = snap ? Date.now() - Date.parse(snap.updatedAt) > FLEET_FRESH_MS : false;
|
|
112
|
+
const legs = React.useMemo(() => (conns ? buildSyncHealth(conns, snap?.todoSync ?? null, Date.now()) : null), [conns, snap, data]);
|
|
102
113
|
return (
|
|
103
114
|
<div className="space-y-4">
|
|
115
|
+
{loadConnections ? <SyncHealthCard legs={legs} error={connsError} /> : null}
|
|
104
116
|
{error ? <LoadError what="the fleet" message={error} onRetry={run} /> : null}
|
|
105
117
|
{data && !snap ? <div className="rounded-xl border border-gray-200 bg-white p-6 text-center" data-testid="fleet-empty"><p className="font-medium text-gray-900">The relay has not posted a fleet snapshot yet.</p></div> : null}
|
|
106
118
|
{snap ? (
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
/** Sync health (Fleet page): one row per sync leg, worst first. Draws `buildSyncHealth`; owns no logic. */
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
|
|
6
|
+
import type { LegState, SyncLeg } from '../../corpus/converse/sync-health';
|
|
7
|
+
|
|
8
|
+
const DOT: Record<LegState, string> = { ok: 'bg-green-500', behind: 'bg-amber-500', stale: 'bg-amber-500', failing: 'bg-red-500', reauth: 'bg-red-500', waiting: 'bg-gray-300', passive: 'bg-gray-300' };
|
|
9
|
+
const WORD: Record<LegState, string> = { ok: 'OK', behind: 'Behind', stale: 'Overdue', failing: 'Failing', reauth: 'Reconnect', waiting: 'Not run yet', passive: 'Receive-only' };
|
|
10
|
+
|
|
11
|
+
export function lagWords(ms: number | null): string {
|
|
12
|
+
if (ms === null) return 'never';
|
|
13
|
+
const m = Math.round(ms / 60000);
|
|
14
|
+
if (m < 1) return 'just now';
|
|
15
|
+
if (m < 60) return `${m} min ago`;
|
|
16
|
+
const h = Math.round(m / 60);
|
|
17
|
+
return h < 36 ? `${h} h ago` : `${Math.round(h / 24)} d ago`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function SyncHealthCard({ legs, error }: { legs: SyncLeg[] | null; error?: string | null }) {
|
|
21
|
+
const bad = legs?.filter((l) => l.state === 'failing' || l.state === 'reauth' || l.state === 'stale' || l.state === 'behind').length ?? 0;
|
|
22
|
+
return (
|
|
23
|
+
<section className={`rounded-xl border p-4 ${bad ? 'border-amber-300 bg-amber-50' : 'border-gray-200 bg-white'}`} data-testid="fleet-sync-health">
|
|
24
|
+
<h2 className="mb-1 text-sm font-semibold uppercase tracking-wide text-gray-500">Sync health{legs ? ` (${bad ? `${bad} need a look` : 'all fine'})` : ''}</h2>
|
|
25
|
+
{error ? <p className="text-sm text-red-700" data-testid="sync-health-error">Could not read the connections: {error}</p> : null}
|
|
26
|
+
{!legs && !error ? <p className="text-sm text-gray-500">Loading…</p> : null}
|
|
27
|
+
{legs ? (
|
|
28
|
+
<ul className="divide-y divide-gray-100 text-sm">
|
|
29
|
+
{legs.map((l) => (
|
|
30
|
+
<li key={l.key} className="flex flex-wrap items-baseline gap-x-2 py-1.5" data-testid={`sync-leg-${l.key}`} data-state={l.state}>
|
|
31
|
+
<span className={`h-2 w-2 shrink-0 self-center rounded-full ${DOT[l.state]}`} />
|
|
32
|
+
<span className="font-medium text-gray-900">{l.label}</span>
|
|
33
|
+
<span className="text-gray-700">{WORD[l.state]}</span>
|
|
34
|
+
<span className="text-xs text-gray-500">last ok {lagWords(l.lagMs)}{l.behind ? ` · ${l.behind} waiting to send` : ''}{l.retryAt ? ` · retries ${new Date(l.retryAt).toLocaleTimeString()}` : ''}</span>
|
|
35
|
+
{l.lastError ? <span className="w-full pl-4 text-xs text-red-700">{l.lastError}</span> : l.note && l.state !== 'ok' ? <span className="w-full pl-4 text-xs text-gray-500">{l.note}</span> : null}
|
|
36
|
+
</li>
|
|
37
|
+
))}
|
|
38
|
+
</ul>
|
|
39
|
+
) : null}
|
|
40
|
+
</section>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
@@ -23,7 +23,7 @@ import type { RosterMember } from '../../corpus/owner-link';
|
|
|
23
23
|
import { ExternalLinkChip } from './task-tracker/ExternalLinkChip';
|
|
24
24
|
import { failureMessage } from './work-items';
|
|
25
25
|
import { ProjectGuess } from './task-tracker/ProjectGuess';
|
|
26
|
-
import { PossiblyDoneNote, markDonePatch, notDonePatch } from './tracker/PossiblyDone';
|
|
26
|
+
import { PossiblyDoneNote, keepDuePatch, markDonePatch, notDonePatch, setDuePatch } from './tracker/PossiblyDone';
|
|
27
27
|
import { EngineReason, SuggestionNote, acceptPatch, rejectPatch } from './tracker/Suggestion';
|
|
28
28
|
import { SUGGESTED_STATUS } from '../../corpus/item-status';
|
|
29
29
|
import type { MemberConnectionsApi } from './types';
|
|
@@ -219,7 +219,7 @@ export function TaskDetailPage({
|
|
|
219
219
|
};
|
|
220
220
|
|
|
221
221
|
const back = onBack ? (
|
|
222
|
-
<button type="button" className="text-sm text-blue-700 underline" onClick={onBack}>← Back to
|
|
222
|
+
<button type="button" className="text-sm text-blue-700 underline" onClick={onBack}>← Back to to-dos</button>
|
|
223
223
|
) : null;
|
|
224
224
|
|
|
225
225
|
if (loading) return <div className={cn.root}>{back}<p className={cn.muted}>Loading…</p></div>;
|
|
@@ -311,6 +311,8 @@ export function TaskDetailPage({
|
|
|
311
311
|
item={item} disabled={busy}
|
|
312
312
|
onMarkDone={(it, c) => void patchItem(markDonePatch(c))}
|
|
313
313
|
onNotDone={(it, c) => void patchItem(notDonePatch(it, c))}
|
|
314
|
+
onSetDue={(it, p) => void patchItem(setDuePatch(it, p))}
|
|
315
|
+
onKeepDue={(it, p) => void patchItem(keepDuePatch(it, p))}
|
|
314
316
|
/>
|
|
315
317
|
) : null}
|
|
316
318
|
{item.statusReason ? (
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* `LibraryPage` and `AskPage`. The app owns className slots and a wrapper; extraction happens behind
|
|
6
6
|
* `api.extract`, server-side, where the provider key is. Nothing in this file imports a provider.
|
|
7
7
|
*
|
|
8
|
-
* ONE TOOLBAR, ONE TABLE (Quinn, 2026-11-20): a search box, Status and
|
|
8
|
+
* ONE TOOLBAR, ONE TABLE (Quinn, 2026-11-20): a search box, Status, Project and Owner dropdowns and a single
|
|
9
9
|
* filled "+ Add to-do"; then `TodoTable` with sortable headers and the shared pagination footer. No
|
|
10
10
|
* pill rows, no second status, no groups or boards or folds: Status "Done" is how finished work is read.
|
|
11
11
|
*
|
|
@@ -25,7 +25,7 @@ import { isStalled } from '../../corpus/runs';
|
|
|
25
25
|
import { useTrackerName } from '../../task-tracker/useTrackerName';
|
|
26
26
|
import type { MemberConnectionsApi } from './types';
|
|
27
27
|
import { failureMessage, unfilteredMessage } from './work-items';
|
|
28
|
-
import { PossiblyDoneNote, markDonePatch, notDonePatch } from './tracker/PossiblyDone';
|
|
28
|
+
import { PossiblyDoneNote, keepDuePatch, markDonePatch, notDonePatch, setDuePatch } from './tracker/PossiblyDone';
|
|
29
29
|
import { SuggestionNote, acceptPatch, rejectPatch } from './tracker/Suggestion';
|
|
30
30
|
import { SUGGESTED_STATUS } from '../../corpus/item-status';
|
|
31
31
|
import { SweepPanel } from './tracker/SweepPanel';
|
|
@@ -42,7 +42,8 @@ import type {
|
|
|
42
42
|
} from '../../corpus/types';
|
|
43
43
|
|
|
44
44
|
export interface TrackerPageProps {
|
|
45
|
-
|
|
45
|
+
/** `listMembers` (the viewer's own workspace roster) turns on the Owner dropdown. */
|
|
46
|
+
api: CommitmentTrackerApi & { listMembers?: () => Promise<Array<{ sub: string; email: string; name?: string }>> };
|
|
46
47
|
scope: CorpusScope;
|
|
47
48
|
/** Click-through from a mention to the record, normally the Library route. */
|
|
48
49
|
onOpenDocument?: (documentId: string) => void;
|
|
@@ -190,10 +191,20 @@ export function TrackerPage({
|
|
|
190
191
|
const [search, setSearch] = React.useState(initialSearch ?? '');
|
|
191
192
|
const [status, setStatus] = React.useState('open');
|
|
192
193
|
const [project, setProject] = React.useState('');
|
|
194
|
+
const [owner, setOwner] = React.useState('');
|
|
195
|
+
/** The viewer's own workspace roster (the server only returns the viewer's company); absent = no Owner filter. */
|
|
196
|
+
const [members, setMembers] = React.useState<Array<{ sub: string; email: string; name?: string }>>([]);
|
|
193
197
|
const [sort, setSort] = React.useState<TableSort | null>(null);
|
|
194
198
|
const [page, setPage] = React.useState(1);
|
|
195
199
|
const [pageSize, setPageSizeState] = React.useState<PageSize>(() => readPageSize('todos'));
|
|
196
200
|
|
|
201
|
+
React.useEffect(() => {
|
|
202
|
+
let live = true;
|
|
203
|
+
if (!api.listMembers) return undefined;
|
|
204
|
+
void apiRef.current.listMembers?.().then((roster) => { if (live) setMembers(roster); }).catch(() => undefined);
|
|
205
|
+
return () => { live = false; };
|
|
206
|
+
}, [api.listMembers, scope.orgId]);
|
|
207
|
+
|
|
197
208
|
// The typed text becomes a server query only after a pause, and starts again from page one.
|
|
198
209
|
React.useEffect(() => {
|
|
199
210
|
if (searchText === search) return undefined;
|
|
@@ -202,8 +213,8 @@ export function TrackerPage({
|
|
|
202
213
|
}, [searchText, search]);
|
|
203
214
|
|
|
204
215
|
const query = React.useMemo(
|
|
205
|
-
() => todoQuery({ search, status, project, sort, page, pageSize }, focusId),
|
|
206
|
-
[search, status, project, sort, page, pageSize, focusId],
|
|
216
|
+
() => todoQuery({ search, status, project, owner, sort, page, pageSize }, focusId),
|
|
217
|
+
[search, status, project, owner, sort, page, pageSize, focusId],
|
|
207
218
|
);
|
|
208
219
|
|
|
209
220
|
const load = React.useCallback(async () => {
|
|
@@ -347,9 +358,11 @@ export function TrackerPage({
|
|
|
347
358
|
setSaving(true);
|
|
348
359
|
setError('');
|
|
349
360
|
try {
|
|
350
|
-
await apiRef.current.createCommitment!({ title, ...(focusId ? { focusId } : {}) });
|
|
361
|
+
const created = await apiRef.current.createCommitment!({ title, ...(focusId ? { focusId } : {}) });
|
|
351
362
|
setDraftTitle('');
|
|
352
363
|
setAdding(false);
|
|
364
|
+
// A new to-do opens on its detail page at once; the list re-reads only where there is no detail to open.
|
|
365
|
+
if (onOpenItem && created) { onOpenItem(created); return; }
|
|
353
366
|
await loadRef.current();
|
|
354
367
|
} catch (err) {
|
|
355
368
|
setError(failureMessage(err));
|
|
@@ -368,12 +381,16 @@ export function TrackerPage({
|
|
|
368
381
|
const sweepBusy = Boolean(sweep && (sweep.status === 'queued' || sweep.status === 'running'));
|
|
369
382
|
// A run whose lease has lapsed is not running, whatever its status field says.
|
|
370
383
|
const sweepStalled = Boolean(sweep && isStalled(sweep, clock));
|
|
371
|
-
const filtering = search.trim().length > 0 || status !== 'open' || Boolean(project);
|
|
384
|
+
const filtering = search.trim().length > 0 || status !== 'open' || Boolean(project) || Boolean(owner);
|
|
372
385
|
|
|
373
386
|
const projectOptions = [
|
|
374
387
|
{ value: '', label: 'All projects' },
|
|
375
388
|
...Object.entries(projectNames).map(([value, label]) => ({ value, label })),
|
|
376
389
|
];
|
|
390
|
+
const ownerOptions = [
|
|
391
|
+
{ value: '', label: 'All owners' },
|
|
392
|
+
...members.map((m) => ({ value: m.sub, label: m.name || m.email })),
|
|
393
|
+
];
|
|
377
394
|
const resetPage = <T,>(set: (v: T) => void) => (v: T) => { set(v); setPage(1); };
|
|
378
395
|
|
|
379
396
|
const pullButton = !manualPull ? null : canQueue ? (
|
|
@@ -436,6 +453,7 @@ export function TrackerPage({
|
|
|
436
453
|
>
|
|
437
454
|
<FilterSelect label="Status" value={status} options={[...TODO_STATUS_FILTERS]} onChange={resetPage(setStatus)} />
|
|
438
455
|
{focusId ? null : <FilterSelect label="Project" value={project} options={projectOptions} onChange={resetPage(setProject)} />}
|
|
456
|
+
{members.length ? <FilterSelect label="Owner" value={owner} options={ownerOptions} onChange={resetPage(setOwner)} /> : null}
|
|
439
457
|
{pullButton}
|
|
440
458
|
</TableToolbar>
|
|
441
459
|
|
|
@@ -460,6 +478,8 @@ export function TrackerPage({
|
|
|
460
478
|
item={item}
|
|
461
479
|
onMarkDone={(it, c) => void act(it, markDonePatch(c))}
|
|
462
480
|
onNotDone={(it, c) => void act(it, notDonePatch(it, c))}
|
|
481
|
+
onSetDue={(it, p) => void act(it, setDuePatch(it, p))}
|
|
482
|
+
onKeepDue={(it, p) => void act(it, keepDuePatch(it, p))}
|
|
463
483
|
/>
|
|
464
484
|
</>
|
|
465
485
|
) : undefined}
|
|
@@ -9,6 +9,7 @@ import { TaskTrackerSettings } from '../task-tracker/TaskTrackerSettings';
|
|
|
9
9
|
import type { Connection, ConnectionChoice, ConnectionRun, ConnectionTarget, ConnectorAction, ConnectorCatalogEntry } from '../types';
|
|
10
10
|
import { CapabilityPicker, orderCapabilities } from './CapabilityPicker';
|
|
11
11
|
import { ConnectionSettingsForm, ReplaceKeyForm } from './ConnectionForms';
|
|
12
|
+
import { ShareDefaultRow } from './ShareDefaultRow';
|
|
12
13
|
import type { BoundApi } from './bound-api';
|
|
13
14
|
import { DEFAULTS, RUN_KIND_COPY } from './copy';
|
|
14
15
|
|
|
@@ -251,6 +252,10 @@ export function ConnectionCard({
|
|
|
251
252
|
</div>
|
|
252
253
|
</div>
|
|
253
254
|
|
|
255
|
+
{personal && api.updateConnectionSharing ? (
|
|
256
|
+
<ShareDefaultRow api={api} connection={connection} classNames={cn} onChanged={onChanged} />
|
|
257
|
+
) : null}
|
|
258
|
+
|
|
254
259
|
{activityOpen ? (
|
|
255
260
|
<div className="mt-3 space-y-2 border-t pt-3" role="group"
|
|
256
261
|
aria-label="Recent activity">
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WHO THE RECORDS FROM THIS ACCOUNT ARE SHARED WITH (Todo ENG-158).
|
|
3
|
+
*
|
|
4
|
+
* One row on a person's own connection card, not a panel: "Only me", "Everyone in
|
|
5
|
+
* my organisation", or one of the organisation's teams. Changing it applies to
|
|
6
|
+
* what the account already brought in and to everything it brings later; turning
|
|
7
|
+
* it off takes back exactly what it shared, and never a share made by hand.
|
|
8
|
+
*/
|
|
9
|
+
import * as React from 'react';
|
|
10
|
+
|
|
11
|
+
import type { Connection, MemberConnectionsApi, ShareDefault } from '../types';
|
|
12
|
+
|
|
13
|
+
type Slots = Record<'muted' | 'error', string>;
|
|
14
|
+
const SELECT = 'rounded-md border border-gray-300 bg-white px-2 py-1 text-sm text-gray-900';
|
|
15
|
+
|
|
16
|
+
const ONLY_ME = 'none';
|
|
17
|
+
const ORG = 'org';
|
|
18
|
+
|
|
19
|
+
export function valueOf(share: ShareDefault | null | undefined): string {
|
|
20
|
+
if (!share) return ONLY_ME;
|
|
21
|
+
return share.kind === 'org' ? ORG : `group:${share.id}`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function parse(value: string): ShareDefault | null {
|
|
25
|
+
if (value === ONLY_ME) return null;
|
|
26
|
+
if (value === ORG) return { kind: 'org' };
|
|
27
|
+
return { kind: 'group', id: value.slice('group:'.length) };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function ShareDefaultRow({
|
|
31
|
+
api, connection, classNames: cn, onChanged,
|
|
32
|
+
}: {
|
|
33
|
+
api: Pick<MemberConnectionsApi, 'updateConnectionSharing' | 'shareTeams'>;
|
|
34
|
+
connection: Connection;
|
|
35
|
+
classNames: Slots;
|
|
36
|
+
onChanged: () => void;
|
|
37
|
+
}) {
|
|
38
|
+
const [teams, setTeams] = React.useState<Array<{ slug: string; name: string }>>([]);
|
|
39
|
+
const [busy, setBusy] = React.useState(false);
|
|
40
|
+
const [error, setError] = React.useState('');
|
|
41
|
+
const apiRef = React.useRef(api);
|
|
42
|
+
apiRef.current = api;
|
|
43
|
+
|
|
44
|
+
React.useEffect(() => {
|
|
45
|
+
let live = true;
|
|
46
|
+
apiRef.current.shareTeams?.()
|
|
47
|
+
.then((rows) => { if (live) setTeams(rows); })
|
|
48
|
+
.catch(() => { /* only the team options are lost */ });
|
|
49
|
+
return () => { live = false; };
|
|
50
|
+
}, []);
|
|
51
|
+
|
|
52
|
+
if (!api.updateConnectionSharing) return null;
|
|
53
|
+
const current = valueOf(connection.share_default);
|
|
54
|
+
const known = connection.share_default?.kind === 'group'
|
|
55
|
+
&& !teams.some((t) => t.slug === (connection.share_default as { id: string }).id);
|
|
56
|
+
|
|
57
|
+
async function change(value: string) {
|
|
58
|
+
setBusy(true);
|
|
59
|
+
setError('');
|
|
60
|
+
try {
|
|
61
|
+
await api.updateConnectionSharing!(connection.id, parse(value));
|
|
62
|
+
onChanged();
|
|
63
|
+
} catch (err) {
|
|
64
|
+
setError((err as { message?: string })?.message || 'Sharing could not be changed.');
|
|
65
|
+
} finally {
|
|
66
|
+
setBusy(false);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<div className="mt-2 flex flex-wrap items-center gap-2" data-testid="share-default">
|
|
72
|
+
<label className="text-sm font-medium text-gray-900" htmlFor={`share-${connection.id}`}>
|
|
73
|
+
Records are shared with
|
|
74
|
+
</label>
|
|
75
|
+
<select
|
|
76
|
+
id={`share-${connection.id}`}
|
|
77
|
+
className={SELECT}
|
|
78
|
+
disabled={busy}
|
|
79
|
+
value={current}
|
|
80
|
+
onChange={(e) => { void change(e.target.value); }}
|
|
81
|
+
>
|
|
82
|
+
<option value={ONLY_ME}>Only me</option>
|
|
83
|
+
<option value={ORG}>Everyone in my organisation</option>
|
|
84
|
+
{teams.map((t) => <option key={t.slug} value={`group:${t.slug}`}>{t.name} (team)</option>)}
|
|
85
|
+
{known ? <option value={current}>A team</option> : null}
|
|
86
|
+
</select>
|
|
87
|
+
{busy ? <span className={cn.muted}>Updating what it already brought in…</span> : null}
|
|
88
|
+
{error ? <p className={cn.error} role="alert">{error}</p> : null}
|
|
89
|
+
</div>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The injected api as the connection components use it (slugless), and the page props. Split out of ConnectionsPage (bd startsim-ovq7f) with no behaviour change.
|
|
3
3
|
*/
|
|
4
|
-
import type { Connection, ConnectionChoicePage, ConnectionInvokeResult, ConnectionPermissions, ConnectionRun, ConnectionTarget, ConnectionsApi, ConnectorAction, ConnectorCatalogEntry, MemberConnectionRow, MemberConnectionsApi } from '../types';
|
|
4
|
+
import type { Connection, ConnectionChoicePage, ConnectionInvokeResult, ConnectionPermissions, ConnectionRun, ConnectionTarget, ConnectionsApi, ConnectorAction, ConnectorCatalogEntry, MemberConnectionRow, MemberConnectionsApi, ShareDefault } from '../types';
|
|
5
5
|
|
|
6
6
|
export type ClassNames = Partial<Record<
|
|
7
7
|
'root' | 'section' | 'heading' | 'card' | 'button' | 'muted' | 'error', string
|
|
@@ -71,6 +71,9 @@ export interface BoundApi {
|
|
|
71
71
|
updateConnectionConfig?(
|
|
72
72
|
id: string, config: Record<string, unknown>,
|
|
73
73
|
): Promise<Connection>;
|
|
74
|
+
/** Personal mode only: who this account's records are shared with (Todo ENG-158). */
|
|
75
|
+
updateConnectionSharing?(id: string, share: ShareDefault | null): Promise<Connection>;
|
|
76
|
+
shareTeams?(): Promise<Array<{ slug: string; name: string }>>;
|
|
74
77
|
connectionChoices?(id: string, params?: { kind?: string; cursor?: string }):
|
|
75
78
|
Promise<ConnectionChoicePage>;
|
|
76
79
|
/** Task-tracker connections: sync now (bd startsim-el0zf). */
|
|
@@ -7,6 +7,8 @@ import * as React from 'react';
|
|
|
7
7
|
|
|
8
8
|
import { stripMarkdown } from '../../Markdown';
|
|
9
9
|
import { dismissCandidate, pendingCandidates } from '../../../corpus/possibly-done';
|
|
10
|
+
import { dismissProposal, pendingProposals } from '../../../corpus/engine/proposed-due';
|
|
11
|
+
import type { ProposedDue } from '../../../corpus/engine/proposed-due';
|
|
10
12
|
import type { Commitment, PossiblyDone } from '../../../corpus/types';
|
|
11
13
|
|
|
12
14
|
const BTN = 'rounded border border-gray-300 px-2 py-0.5 text-xs text-gray-700 hover:border-gray-400';
|
|
@@ -23,17 +25,41 @@ export const notDonePatch = (item: Commitment, candidate: PossiblyDone) => ({
|
|
|
23
25
|
possiblyDone: dismissCandidate(item.possiblyDone, candidate.documentId),
|
|
24
26
|
});
|
|
25
27
|
|
|
26
|
-
|
|
28
|
+
/** A later source's date, taken. */
|
|
29
|
+
export const setDuePatch = (item: Commitment, proposal: ProposedDue) => ({
|
|
30
|
+
dueAt: proposal.dueAt,
|
|
31
|
+
proposedDue: dismissProposal(item.proposedDue, proposal.documentId),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
/** A later source's date, declined; it is remembered so the same source does not ask again. */
|
|
35
|
+
export const keepDuePatch = (item: Commitment, proposal: ProposedDue) => ({
|
|
36
|
+
proposedDue: dismissProposal(item.proposedDue, proposal.documentId),
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export function PossiblyDoneNote({ item, onMarkDone, onNotDone, onSetDue, onKeepDue, disabled }: {
|
|
27
40
|
item: Commitment;
|
|
28
41
|
onMarkDone: (item: Commitment, candidate: PossiblyDone) => void;
|
|
29
42
|
onNotDone: (item: Commitment, candidate: PossiblyDone) => void;
|
|
43
|
+
onSetDue?: (item: Commitment, proposal: ProposedDue) => void;
|
|
44
|
+
onKeepDue?: (item: Commitment, proposal: ProposedDue) => void;
|
|
30
45
|
disabled?: boolean;
|
|
31
46
|
}) {
|
|
32
47
|
if (item.status === 'done' || item.status === 'dropped') return null;
|
|
33
48
|
const pending = pendingCandidates(item.possiblyDone);
|
|
34
|
-
|
|
49
|
+
const dates = onSetDue && onKeepDue ? pendingProposals(item.proposedDue) : [];
|
|
50
|
+
if (!pending.length && !dates.length) return null;
|
|
35
51
|
return (
|
|
36
52
|
<div className="mt-1 space-y-1" data-testid="possibly-done">
|
|
53
|
+
{dates.map((p) => (
|
|
54
|
+
<div key={`due:${p.documentId}`} className="flex flex-wrap items-center gap-2 text-xs text-amber-900" data-testid="proposed-due">
|
|
55
|
+
<span className="min-w-0">
|
|
56
|
+
<span className="font-medium">New date:</span> a later note says {new Date(p.dueAt).toLocaleDateString()}
|
|
57
|
+
{p.quote ? <> “{stripMarkdown(p.quote)}”</> : null}
|
|
58
|
+
</span>
|
|
59
|
+
<button type="button" className={BTN} disabled={disabled} onClick={() => onSetDue!(item, p)}>Use it</button>
|
|
60
|
+
<button type="button" className={BTN} disabled={disabled} onClick={() => onKeepDue!(item, p)}>Keep mine</button>
|
|
61
|
+
</div>
|
|
62
|
+
))}
|
|
37
63
|
{pending.map((c) => (
|
|
38
64
|
<div key={c.documentId} className="flex flex-wrap items-center gap-2 text-xs text-amber-900">
|
|
39
65
|
<span className="min-w-0">
|
|
@@ -18,17 +18,20 @@ const reviewed = (item: Commitment, outcome: NonNullable<Suggestion['outcome']>)
|
|
|
18
18
|
({ ...item.suggestion!, outcome, reviewedAt: new Date().toISOString() });
|
|
19
19
|
|
|
20
20
|
/** Accepting puts it on the list. If the owner changed it first, the review says so. */
|
|
21
|
-
export const acceptPatch = (item: Commitment, edited = false) =>
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
21
|
+
export const acceptPatch = (item: Commitment, edited = false) => item.suggestion?.rule === 'L-NEAR' && !edited
|
|
22
|
+
// "Same as that one": this row is the duplicate. Its quotes join the other item on the next pass.
|
|
23
|
+
? { status: 'dropped' as const, statusReason: 'Merged into the item it was the same as', suggestion: reviewed(item, 'accepted') }
|
|
24
|
+
: { status: 'open' as const, suggestion: reviewed(item, edited ? 'edited' : 'accepted') };
|
|
25
25
|
|
|
26
26
|
/** Rejecting drops it, and the rejection is what teaches the rule. */
|
|
27
|
-
export const rejectPatch = (item: Commitment) =>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
export const rejectPatch = (item: Commitment) => item.suggestion?.rule === 'L-NEAR'
|
|
28
|
+
// "Not the same": the owner wants it as an item of its own.
|
|
29
|
+
? { status: 'open' as const, suggestion: reviewed(item, 'rejected') }
|
|
30
|
+
: {
|
|
31
|
+
status: 'dropped' as const,
|
|
32
|
+
statusReason: 'Suggestion rejected',
|
|
33
|
+
suggestion: reviewed(item, 'rejected'),
|
|
34
|
+
};
|
|
32
35
|
|
|
33
36
|
export function SuggestionNote({ item, onAccept, onReject, disabled }: {
|
|
34
37
|
item: Commitment;
|
|
@@ -38,14 +41,15 @@ export function SuggestionNote({ item, onAccept, onReject, disabled }: {
|
|
|
38
41
|
}) {
|
|
39
42
|
if (item.status !== SUGGESTED_STATUS || !item.suggestion) return null;
|
|
40
43
|
const { reason, quote } = item.suggestion;
|
|
44
|
+
const same = item.suggestion.rule === 'L-NEAR';
|
|
41
45
|
return (
|
|
42
46
|
<div className="mt-1 flex flex-wrap items-center gap-2 text-xs text-sky-900 dark:text-sky-200" data-testid="suggestion">
|
|
43
47
|
<span className="min-w-0">
|
|
44
48
|
<span className="font-medium">Suggested:</span> {reason}
|
|
45
49
|
{quote ? <> “{stripMarkdown(quote)}”</> : null}
|
|
46
50
|
</span>
|
|
47
|
-
<button type="button" className={BTN} disabled={disabled} onClick={() => onAccept(item)}>Accept</button>
|
|
48
|
-
<button type="button" className={BTN} disabled={disabled} onClick={() => onReject(item)}>Reject</button>
|
|
51
|
+
<button type="button" className={BTN} disabled={disabled} onClick={() => onAccept(item)}>{same ? 'Same item' : 'Accept'}</button>
|
|
52
|
+
<button type="button" className={BTN} disabled={disabled} onClick={() => onReject(item)}>{same ? 'Keep separate' : 'Reject'}</button>
|
|
49
53
|
</div>
|
|
50
54
|
);
|
|
51
55
|
}
|