@startsimpli/integrations 0.2.187 → 0.2.188
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 +6 -6
- package/src/__tests__/connection-reconnect.test.tsx +69 -0
- package/src/__tests__/converse-brain.test.ts +44 -0
- package/src/__tests__/converse-meeting.test.ts +118 -0
- package/src/__tests__/converse-page.test.tsx +150 -83
- package/src/__tests__/converse.test.ts +32 -0
- package/src/__tests__/corpus-tracker.test.tsx +37 -35
- package/src/__tests__/plan-shell.test.tsx +14 -11
- package/src/__tests__/possibly-done-extract.test.ts +90 -0
- package/src/__tests__/possibly-done-ui.test.tsx +80 -0
- package/src/components/pages/ConversePage.tsx +128 -83
- package/src/components/pages/TaskDetailPage.tsx +22 -0
- package/src/components/pages/TrackerPage.tsx +15 -141
- package/src/components/pages/connections/ConnectionCard.tsx +20 -0
- package/src/components/pages/connections/bound-api.ts +2 -0
- package/src/components/pages/converse/Thread.tsx +46 -0
- package/src/components/pages/converse/browserIO.ts +15 -5
- package/src/components/pages/home/CompactItemRow.tsx +4 -1
- package/src/components/pages/plan/TalkPage.tsx +8 -29
- package/src/components/pages/tracker/PossiblyDone.tsx +49 -0
- package/src/corpus/client.ts +2 -0
- package/src/corpus/commitments.ts +27 -6
- package/src/corpus/converse/brain.ts +24 -16
- package/src/corpus/converse/handle.ts +24 -2
- package/src/corpus/converse/index.ts +2 -1
- package/src/corpus/converse/meeting.ts +70 -21
- package/src/corpus/converse/route.ts +4 -3
- package/src/corpus/converse/sources.ts +17 -0
- package/src/corpus/converse/types.ts +19 -0
- package/src/corpus/entities.ts +4 -0
- package/src/corpus/nav-copy.ts +3 -3
- package/src/corpus/possibly-done.ts +59 -0
- package/src/corpus/types.ts +17 -1
- package/src/native/converse/io.ts +2 -1
|
@@ -1,32 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* THE CONVERSE PAGE:
|
|
2
|
+
* THE CONVERSE PAGE: one screen, one thread (Quinn). He talks or types to his assistant here: to-dos, wrapping them up,
|
|
3
|
+
* questions, thinking a project through, orders for the relay, and the morning voice note. Nothing is a mode.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* silent without saying why. The loop itself is `createMeetingController`, shared with the native app;
|
|
9
|
-
* silence length, utterance limits and interrupt-on-speech are `meeting` config with defaults.
|
|
5
|
+
* The thread is always readable (normal flow, nothing laid over it). Under it, a text box with a SMALL mic toggle and
|
|
6
|
+
* Send beside it: tap the mic to listen, tap it again to stop and send what was said; typing works with the mic off.
|
|
7
|
+
* "Done" saves the conversation; saying "parse that note" / "that's it" is handled by the assistant itself, and the
|
|
8
|
+
* thread then shows a quiet "Filed: N to-dos" line. The loop is `createMeetingController`, shared with the native app.
|
|
10
9
|
*/
|
|
11
10
|
import * as React from 'react';
|
|
12
11
|
|
|
13
12
|
import type { ConverseClient } from '../../corpus/converse/client';
|
|
14
|
-
import { createMeetingController, type MeetingController, type MeetingState } from '../../corpus/converse/meeting';
|
|
13
|
+
import { createMeetingController, type MeetingController, type MeetingLine, type MeetingState } from '../../corpus/converse/meeting';
|
|
15
14
|
import type { MeetingConfig } from '../../corpus/converse/meeting-config';
|
|
15
|
+
import { resolveMeetingConfig } from '../../corpus/converse/meeting-config';
|
|
16
16
|
import type { ConverseEndResult } from '../../corpus/converse/types';
|
|
17
17
|
import { createBrowserMeetingIO, type BrowserMeetingIO } from './converse/browserIO';
|
|
18
18
|
import { DEFAULT_SPEED, SPEEDS, loadSpeed, normalizeSpeed, saveSpeed } from './converse/speed';
|
|
19
|
+
import { Thread } from './converse/Thread';
|
|
19
20
|
|
|
20
|
-
export type ConverseSlot = 'root' | '
|
|
21
|
+
export type ConverseSlot = 'root' | 'secondary' | 'bubbleUser' | 'bubbleReply' | 'muted' | 'error' | 'input' | 'chip' | 'replay' | 'mic' | 'micOn';
|
|
21
22
|
export type ConverseClassNames = Partial<Record<ConverseSlot, string>>;
|
|
22
23
|
|
|
23
24
|
const FALLBACK: Record<ConverseSlot, string> = {
|
|
24
|
-
root: 'space-y-
|
|
25
|
-
secondary: 'rounded-md border px-3 py-2 text-sm', bubbleUser: 'rounded-lg border p-3 text-sm', bubbleReply: 'rounded-lg border p-3 text-sm',
|
|
25
|
+
root: 'space-y-3', secondary: 'rounded-md border px-3 py-2 text-sm', bubbleUser: 'rounded-lg border p-3 text-sm', bubbleReply: 'rounded-lg border p-3 text-sm',
|
|
26
26
|
muted: 'text-sm opacity-70', error: 'rounded-md border p-3 text-sm', input: 'rounded-md border px-3 py-2 text-base',
|
|
27
|
+
chip: 'rounded-full border px-2 py-0.5 text-xs opacity-80', replay: 'inline-flex rounded border p-1 opacity-70',
|
|
28
|
+
mic: 'inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-full border', micOn: 'inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-full border bg-red-600 text-white',
|
|
27
29
|
};
|
|
28
30
|
|
|
29
|
-
const EMPTY: MeetingState = { phase: 'idle', retryable: false, lines: [], error: null, noAudio: null, conversationId: null, saved: null, relayNotice: null };
|
|
31
|
+
const EMPTY: MeetingState = { phase: 'idle', retryable: false, lines: [], error: null, noAudio: null, conversationId: null, saved: null, relayNotice: null, micOn: false };
|
|
30
32
|
|
|
31
33
|
export interface ConversePageProps {
|
|
32
34
|
client: ConverseClient;
|
|
@@ -35,28 +37,38 @@ export interface ConversePageProps {
|
|
|
35
37
|
meeting?: Partial<MeetingConfig>;
|
|
36
38
|
/** Injectable for tests; defaults to the browser's microphone and audio element. */
|
|
37
39
|
createIO?: () => BrowserMeetingIO;
|
|
38
|
-
/** Where the saved conversation can be read; given the
|
|
40
|
+
/** Where the saved conversation can be read; given the Done result. */
|
|
39
41
|
savedLink?: (saved: ConverseEndResult) => React.ReactNode;
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
const STATUS: Record<string, string> = {
|
|
43
|
-
idle: '
|
|
44
|
-
listening: 'Listening…
|
|
45
|
+
idle: '',
|
|
46
|
+
listening: 'Listening… tap the mic again to send.',
|
|
45
47
|
thinking: 'Thinking…',
|
|
46
48
|
speaking: 'Speaking…',
|
|
47
49
|
ending: 'Saving…',
|
|
48
50
|
ended: '',
|
|
49
|
-
stopped: 'The
|
|
51
|
+
stopped: 'The conversation stopped.',
|
|
50
52
|
};
|
|
51
53
|
|
|
54
|
+
const MicIcon = () => (
|
|
55
|
+
<svg aria-hidden="true" viewBox="0 0 24 24" width="20" height="20" fill="currentColor"><path d="M12 14a3 3 0 0 0 3-3V5a3 3 0 0 0-6 0v6a3 3 0 0 0 3 3zm5-3a5 5 0 0 1-10 0H5a7 7 0 0 0 6 6.92V21h2v-3.08A7 7 0 0 0 19 11h-2z" /></svg>
|
|
56
|
+
);
|
|
57
|
+
|
|
52
58
|
export function ConversePage({ client, classNames, meeting, createIO, savedLink }: ConversePageProps) {
|
|
53
59
|
const cx = (slot: ConverseSlot) => classNames?.[slot] ?? FALLBACK[slot];
|
|
54
60
|
const [state, setState] = React.useState<MeetingState>(EMPTY);
|
|
55
|
-
|
|
61
|
+
/** Lines of conversations already saved with Done: the thread keeps them, the next message starts a new conversation. */
|
|
62
|
+
const [history, setHistory] = React.useState<MeetingLine[]>([]);
|
|
63
|
+
const [error, setError] = React.useState<string | null>(null);
|
|
56
64
|
const [draft, setDraft] = React.useState('');
|
|
57
65
|
const ctl = React.useRef<MeetingController | null>(null);
|
|
58
66
|
const io = React.useRef<BrowserMeetingIO | null>(null);
|
|
67
|
+
const micReady = React.useRef(false);
|
|
59
68
|
const endRef = React.useRef<HTMLDivElement | null>(null);
|
|
69
|
+
/** Reply text -> its audio url, so each assistant line can be played again (the controller only replays the newest). */
|
|
70
|
+
const audioOf = React.useRef(new Map<string, string>());
|
|
71
|
+
const replayAbort = React.useRef<AbortController | null>(null);
|
|
60
72
|
const [speed, setSpeedState] = React.useState<number>(DEFAULT_SPEED);
|
|
61
73
|
const speedRef = React.useRef(speed);
|
|
62
74
|
React.useEffect(() => { const v = loadSpeed(); speedRef.current = v; setSpeedState(v); }, []);
|
|
@@ -64,97 +76,130 @@ export function ConversePage({ client, classNames, meeting, createIO, savedLink
|
|
|
64
76
|
speedRef.current = v; setSpeedState(v); saveSpeed(v); io.current?.setSpeed?.(v);
|
|
65
77
|
}
|
|
66
78
|
|
|
67
|
-
React.
|
|
79
|
+
const lines = React.useMemo(() => [...history, ...state.lines], [history, state.lines]);
|
|
80
|
+
React.useEffect(() => { endRef.current?.scrollIntoView?.({ block: 'end' }); }, [lines, state.phase]);
|
|
68
81
|
React.useEffect(() => () => { void ctl.current?.end(); io.current?.close(); }, []);
|
|
69
82
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
ctl.current.start();
|
|
83
|
+
/** The same client, remembering which audio belongs to which reply (for the per-line speaker). */
|
|
84
|
+
const trackedClient = React.useMemo<ConverseClient>(() => ({
|
|
85
|
+
...client,
|
|
86
|
+
turn: async (input) => {
|
|
87
|
+
const out = await client.turn(input);
|
|
88
|
+
if (out.audio_url) audioOf.current.set(out.reply_text, out.audio_url);
|
|
89
|
+
return out;
|
|
90
|
+
},
|
|
91
|
+
}), [client]);
|
|
92
|
+
const trackedRef = React.useRef(trackedClient);
|
|
93
|
+
trackedRef.current = trackedClient;
|
|
94
|
+
|
|
95
|
+
function ensureIO(): BrowserMeetingIO {
|
|
96
|
+
if (!io.current) io.current = createIO ? createIO() : createBrowserMeetingIO({ resolveAudio: (u) => client.audioUrl(u), getSpeed: () => speedRef.current });
|
|
97
|
+
return io.current;
|
|
86
98
|
}
|
|
87
99
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
100
|
+
/** The current conversation's controller; a finished or stopped one is replaced, so the next message starts fresh. */
|
|
101
|
+
function ensureCtl(): MeetingController {
|
|
102
|
+
const cur = ctl.current;
|
|
103
|
+
if (cur && cur.getState().phase !== 'ended' && cur.getState().phase !== 'stopped') return cur;
|
|
104
|
+
ctl.current = createMeetingController({ client: trackedRef.current as never, io: ensureIO(), config: meeting, onChange: setState });
|
|
105
|
+
return ctl.current;
|
|
91
106
|
}
|
|
92
107
|
|
|
93
|
-
async function
|
|
108
|
+
async function onMic() {
|
|
109
|
+
setError(null);
|
|
110
|
+
if (state.micOn) { ctl.current?.mic(false); return; }
|
|
111
|
+
const browserIO = ensureIO();
|
|
112
|
+
if (!micReady.current) {
|
|
113
|
+
try {
|
|
114
|
+
await browserIO.open(); // inside the tap
|
|
115
|
+
micReady.current = true;
|
|
116
|
+
} catch (e) {
|
|
117
|
+
setError(e instanceof Error ? e.message : 'Could not open the microphone.');
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
ensureCtl().mic(true);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
async function onSend(event: React.FormEvent) {
|
|
94
125
|
event.preventDefault();
|
|
95
126
|
const text = draft.trim();
|
|
96
127
|
if (!text) return;
|
|
97
128
|
setDraft('');
|
|
98
|
-
|
|
99
|
-
|
|
129
|
+
setError(null);
|
|
130
|
+
ensureIO().unlockPlayback?.(); // inside the tap, so the spoken reply is allowed to play; does not touch the microphone
|
|
131
|
+
await ensureCtl().sendText(text);
|
|
100
132
|
}
|
|
101
133
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
134
|
+
async function onDone() {
|
|
135
|
+
const c = ctl.current;
|
|
136
|
+
if (!c) return;
|
|
137
|
+
const lines = c.getState().lines;
|
|
138
|
+
await c.end();
|
|
139
|
+
const saved = c.getState().saved;
|
|
140
|
+
micReady.current = false;
|
|
141
|
+
io.current?.close();
|
|
142
|
+
// Keep what was said on screen; the controller is replaced on the next message.
|
|
143
|
+
setHistory((h) => [...h, ...lines]);
|
|
144
|
+
setState({ ...EMPTY, saved, error: c.getState().error });
|
|
145
|
+
ctl.current = null;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async function onReplay(line: MeetingLine) {
|
|
149
|
+
const url = audioOf.current.get(line.text);
|
|
150
|
+
if (!url) return;
|
|
151
|
+
replayAbort.current?.abort();
|
|
152
|
+
const abort = new AbortController();
|
|
153
|
+
replayAbort.current = abort;
|
|
154
|
+
const cfg = resolveMeetingConfig(meeting);
|
|
155
|
+
ensureIO().unlockPlayback?.();
|
|
156
|
+
await ensureIO().speak({ conversationId: state.conversationId ?? '', turn: 0, replyText: line.text, audioUrl: url }, abort.signal, cfg);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const status = state.noAudio && state.lines.length && state.phase !== 'thinking'
|
|
160
|
+
? `No spoken reply: ${state.noAudio}. The text is above.`
|
|
161
|
+
: STATUS[state.phase] ?? '';
|
|
162
|
+
const busy = state.phase === 'thinking' || state.phase === 'ending';
|
|
108
163
|
|
|
109
164
|
return (
|
|
110
165
|
<div className={cx('root')}>
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
)}
|
|
124
|
-
{startError || state.error ? <div className={cx('error')} role="alert">{startError ?? state.error}</div> : null}
|
|
166
|
+
<Thread
|
|
167
|
+
lines={lines}
|
|
168
|
+
cx={cx}
|
|
169
|
+
canReplay={(l) => audioOf.current.has(l.text)}
|
|
170
|
+
onReplay={(l) => void onReplay(l)}
|
|
171
|
+
/>
|
|
172
|
+
{state.saved ? (
|
|
173
|
+
<p className={cx('muted')} role="status" data-testid="converse-saved">
|
|
174
|
+
Saved {state.saved.turns} turn{state.saved.turns === 1 ? '' : 's'}. {savedLink?.(state.saved)}
|
|
175
|
+
</p>
|
|
176
|
+
) : null}
|
|
177
|
+
<p className={cx('muted')} role="status" aria-live="polite" data-testid="converse-status">{status}</p>
|
|
178
|
+
{error || state.error ? <div className={cx('error')} role="alert">{error ?? state.error}</div> : null}
|
|
125
179
|
{state.relayNotice ? (
|
|
126
180
|
<div className={cx('muted')} role="status" data-testid="converse-relay-notice">
|
|
127
181
|
Relay: {state.relayNotice}{' '}
|
|
128
182
|
<button type="button" className={cx('secondary')} onClick={() => ctl.current?.dismissNotice()}>Dismiss</button>
|
|
129
183
|
</div>
|
|
130
184
|
) : null}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
</select>
|
|
137
|
-
<button type="button" className={cx('secondary')} onClick={() => void ctl.current?.replay()} disabled={!hasReply || !live || state.phase === 'thinking'}>Play reply</button>
|
|
138
|
-
</div>
|
|
139
|
-
<ol className="space-y-2" aria-label="Conversation">
|
|
140
|
-
{state.lines.map((line, i) => (
|
|
141
|
-
<li key={i} className={line.role === 'user' ? cx('bubbleUser') : cx('bubbleReply')} data-from={line.role}>
|
|
142
|
-
<span className={line.role === 'relay' ? 'mr-1 font-medium' : 'sr-only'}>{line.role === 'user' ? 'You: ' : line.role === 'relay' ? 'Relay:' : 'Tandem: '}</span>{line.text}
|
|
143
|
-
</li>
|
|
144
|
-
))}
|
|
145
|
-
</ol>
|
|
146
|
-
{state.saved ? (
|
|
147
|
-
<p className={cx('muted')} role="status" data-testid="converse-saved">
|
|
148
|
-
Saved {state.saved.turns} turn{state.saved.turns === 1 ? '' : 's'}. {savedLink?.(state.saved)}
|
|
149
|
-
</p>
|
|
150
|
-
) : null}
|
|
151
|
-
<form onSubmit={onSendText} className="flex gap-2">
|
|
185
|
+
<form onSubmit={onSend} className="flex items-center gap-2">
|
|
186
|
+
<button
|
|
187
|
+
type="button" onClick={() => void onMic()} className={state.micOn ? cx('micOn') : cx('mic')} data-testid="converse-mic"
|
|
188
|
+
aria-pressed={state.micOn} aria-label={state.micOn ? 'Stop the microphone and send' : 'Start the microphone'} title={state.micOn ? 'Tap to stop and send' : 'Tap to talk'}
|
|
189
|
+
><MicIcon /></button>
|
|
152
190
|
<input
|
|
153
|
-
className={`${cx('input')} flex-1`} value={draft} onChange={(e) => setDraft(e.target.value)}
|
|
154
|
-
placeholder="
|
|
191
|
+
className={`${cx('input')} min-w-0 flex-1`} value={draft} onChange={(e) => setDraft(e.target.value)}
|
|
192
|
+
placeholder="Type or tap the mic" aria-label="Type a message" enterKeyHint="send"
|
|
155
193
|
/>
|
|
156
194
|
<button type="submit" className={cx('secondary')} disabled={!draft.trim()}>Send</button>
|
|
157
195
|
</form>
|
|
196
|
+
<div className="flex flex-wrap items-center gap-3 text-xs">
|
|
197
|
+
<button type="button" className="underline opacity-70" onClick={() => void onDone()} disabled={busy || (!ctl.current)}>Done</button>
|
|
198
|
+
<label className={cx('muted')} htmlFor="converse-speed">Speed</label>
|
|
199
|
+
<select id="converse-speed" className="rounded border px-1 py-0.5 text-xs" value={speed} onChange={(e) => onSpeed(normalizeSpeed(e.target.value))} data-testid="converse-speed" aria-label="Speech speed">
|
|
200
|
+
{SPEEDS.map((v) => <option key={v} value={v}>{v}x</option>)}
|
|
201
|
+
</select>
|
|
202
|
+
</div>
|
|
158
203
|
<div ref={endRef} />
|
|
159
204
|
</div>
|
|
160
205
|
);
|
|
@@ -22,6 +22,7 @@ import { OwnerPicker } from './task-tracker/OwnerPicker';
|
|
|
22
22
|
import type { RosterMember } from '../../corpus/owner-link';
|
|
23
23
|
import { ExternalLinkChip } from './task-tracker/ExternalLinkChip';
|
|
24
24
|
import { failureMessage } from './work-items';
|
|
25
|
+
import { PossiblyDoneNote, markDonePatch, notDonePatch } from './tracker/PossiblyDone';
|
|
25
26
|
import type { MemberConnectionsApi } from './types';
|
|
26
27
|
|
|
27
28
|
export interface TaskDetailPageProps {
|
|
@@ -131,6 +132,20 @@ export function TaskDetailPage({
|
|
|
131
132
|
return () => { live = false; };
|
|
132
133
|
}, [itemId]);
|
|
133
134
|
|
|
135
|
+
const patchItem = async (patch: Parameters<NonNullable<CommitmentApi['updateCommitment']>>[1]) => {
|
|
136
|
+
if (!item || !apiRef.current.updateCommitment) return;
|
|
137
|
+
setBusy(true);
|
|
138
|
+
setError('');
|
|
139
|
+
try {
|
|
140
|
+
const updated = await apiRef.current.updateCommitment(item, patch);
|
|
141
|
+
setItem({ ...item, ...updated, ...patch, possiblyDone: patch.possiblyDone ?? updated.possiblyDone ?? item.possiblyDone } as Commitment);
|
|
142
|
+
} catch (err) {
|
|
143
|
+
setError(failureMessage(err));
|
|
144
|
+
} finally {
|
|
145
|
+
setBusy(false);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
|
|
134
149
|
const setStatus = async (status: CommitmentStatus) => {
|
|
135
150
|
if (!item || !apiRef.current.updateCommitment) return;
|
|
136
151
|
setBusy(true);
|
|
@@ -255,6 +270,13 @@ export function TaskDetailPage({
|
|
|
255
270
|
</dl>
|
|
256
271
|
|
|
257
272
|
{item.detail ? <p className="mt-3 whitespace-pre-wrap text-sm text-gray-700">{item.detail}</p> : null}
|
|
273
|
+
{canWrite ? (
|
|
274
|
+
<PossiblyDoneNote
|
|
275
|
+
item={item} disabled={busy}
|
|
276
|
+
onMarkDone={(it, c) => void patchItem(markDonePatch(c))}
|
|
277
|
+
onNotDone={(it, c) => void patchItem(notDonePatch(it, c))}
|
|
278
|
+
/>
|
|
279
|
+
) : null}
|
|
258
280
|
{item.statusReason ? (
|
|
259
281
|
<p className="mt-3 text-sm text-gray-600">{item.status === 'done' ? 'Closed by' : 'Blocked by'}: “{item.statusReason}”</p>
|
|
260
282
|
) : null}
|
|
@@ -26,13 +26,13 @@
|
|
|
26
26
|
*/
|
|
27
27
|
import * as React from 'react';
|
|
28
28
|
|
|
29
|
-
import { isStalled,
|
|
30
|
-
import { stripMarkdown } from '../Markdown';
|
|
29
|
+
import { isStalled, runProgress } from '../../corpus/runs';
|
|
31
30
|
import { isOverdue } from '../../corpus/work-item-logic';
|
|
32
31
|
import { useTrackerName } from '../../task-tracker/useTrackerName';
|
|
33
32
|
import type { MemberConnectionsApi } from './types';
|
|
34
33
|
import { failureMessage, unfilteredMessage } from './work-items';
|
|
35
34
|
import { CompactItemRow } from './home/CompactItemRow';
|
|
35
|
+
import { PossiblyDoneNote, markDonePatch, notDonePatch } from './tracker/PossiblyDone';
|
|
36
36
|
import { TrackerBoard } from './tracker/TrackerBoard';
|
|
37
37
|
import { TrackerTimeline } from './tracker/TrackerTimeline';
|
|
38
38
|
import { filterFromChip } from '../../corpus/tracker-timeline';
|
|
@@ -47,7 +47,6 @@ import type {
|
|
|
47
47
|
CommitmentStatus,
|
|
48
48
|
CommitmentTrackerApi,
|
|
49
49
|
CorpusScope,
|
|
50
|
-
ExtractionResult,
|
|
51
50
|
ExtractionRun,
|
|
52
51
|
} from '../../corpus/types';
|
|
53
52
|
|
|
@@ -179,7 +178,6 @@ export function TrackerPage({
|
|
|
179
178
|
const [applied, setApplied] = React.useState<string[]>([]);
|
|
180
179
|
const [loading, setLoading] = React.useState(true);
|
|
181
180
|
const [error, setError] = React.useState('');
|
|
182
|
-
const [run, setRun] = React.useState<ExtractionResult | null>(null);
|
|
183
181
|
const [running, setRunning] = React.useState(false);
|
|
184
182
|
/**
|
|
185
183
|
* The SWEEP, when this deployment runs extraction as a job
|
|
@@ -443,6 +441,13 @@ export function TrackerPage({
|
|
|
443
441
|
trackerName={trackerName}
|
|
444
442
|
onOpen={onOpenItem || entry.item.mentions.length ? open : undefined}
|
|
445
443
|
actions={extra?.actions}
|
|
444
|
+
below={canWrite ? (
|
|
445
|
+
<PossiblyDoneNote
|
|
446
|
+
item={entry.item}
|
|
447
|
+
onMarkDone={(it, c) => void act(it, markDonePatch(c))}
|
|
448
|
+
onNotDone={(it, c) => void act(it, notDonePatch(it, c))}
|
|
449
|
+
/>
|
|
450
|
+
) : undefined}
|
|
446
451
|
/>
|
|
447
452
|
);
|
|
448
453
|
const btn = 'rounded border border-gray-300 px-2 py-0.5 text-xs text-gray-700 hover:border-gray-400';
|
|
@@ -530,7 +535,7 @@ export function TrackerPage({
|
|
|
530
535
|
setRunning(true);
|
|
531
536
|
setError('');
|
|
532
537
|
try {
|
|
533
|
-
|
|
538
|
+
await apiRef.current.extract!({ scope });
|
|
534
539
|
await load();
|
|
535
540
|
} catch (err) {
|
|
536
541
|
setError(failureMessage(err));
|
|
@@ -553,8 +558,7 @@ export function TrackerPage({
|
|
|
553
558
|
</details>
|
|
554
559
|
) : null}
|
|
555
560
|
{error ? <p className={cn.error} role="alert">{error}</p> : null}
|
|
556
|
-
{sweep ? <SweepPanel sweep={sweep} now={clock} classNames={cn}
|
|
557
|
-
{run ? <RunSummary result={run} classNames={cn} onOpenDocument={onOpenDocument} /> : null}
|
|
561
|
+
{sweep ? <SweepPanel sweep={sweep} now={clock} classNames={cn} /> : null}
|
|
558
562
|
|
|
559
563
|
{!loading && owed === 0 && c.stale === 0 && !filtering ? (
|
|
560
564
|
<p className={cn.muted}>
|
|
@@ -675,20 +679,21 @@ export function TrackerPage({
|
|
|
675
679
|
* meetings got only the deterministic pass.
|
|
676
680
|
*/
|
|
677
681
|
function SweepPanel({
|
|
678
|
-
sweep, now, classNames: cn,
|
|
682
|
+
sweep, now, classNames: cn,
|
|
679
683
|
}: {
|
|
680
684
|
sweep: ExtractionRun;
|
|
681
685
|
now: number;
|
|
682
686
|
classNames: Record<TrackerSlot, string>;
|
|
683
|
-
onOpenDocument?: (documentId: string) => void;
|
|
684
687
|
}) {
|
|
685
688
|
const progress = runProgress(sweep);
|
|
686
|
-
const coverage = runCoverage(sweep);
|
|
687
689
|
const stalled = isStalled(sweep, now);
|
|
688
690
|
const busy = (sweep.status === 'queued' || sweep.status === 'running') && !stalled;
|
|
689
691
|
const totals = sweep.totals;
|
|
690
692
|
const failure = sweep.lastModelFailure;
|
|
691
693
|
|
|
694
|
+
// A finished run leaves nothing on the page: the list is the result.
|
|
695
|
+
if (sweep.status === 'succeeded') return null;
|
|
696
|
+
|
|
692
697
|
return (
|
|
693
698
|
<div className={cn.card} role="status" aria-live="polite">
|
|
694
699
|
{busy || stalled ? (
|
|
@@ -719,14 +724,6 @@ function SweepPanel({
|
|
|
719
724
|
</p>
|
|
720
725
|
) : null}
|
|
721
726
|
|
|
722
|
-
{sweep.status === 'succeeded' ? (
|
|
723
|
-
<p className="text-sm text-gray-800">
|
|
724
|
-
Read {totals.documentsProcessed} meeting{totals.documentsProcessed === 1 ? '' : 's'}:{' '}
|
|
725
|
-
{totals.created} new, {totals.merged} matched to something already tracked,{' '}
|
|
726
|
-
{totals.resolved} closed by a later meeting.
|
|
727
|
-
</p>
|
|
728
|
-
) : null}
|
|
729
|
-
|
|
730
727
|
{sweep.status === 'failed' ? (
|
|
731
728
|
<p className={cn.error}>
|
|
732
729
|
This run stopped: {sweep.error || 'the workspace could not be reached'}. It kept
|
|
@@ -735,18 +732,6 @@ function SweepPanel({
|
|
|
735
732
|
</p>
|
|
736
733
|
) : null}
|
|
737
734
|
|
|
738
|
-
{/* WHAT THE MODEL DID, AND WHETHER IT ANSWERED AT ALL. */}
|
|
739
|
-
{sweep.status !== 'queued' && totals.documentsProcessed > 0 ? (
|
|
740
|
-
<p className={cn.muted}>
|
|
741
|
-
{totals.fromRules} came from the meetings’ own next-step lists, {totals.fromModel} were
|
|
742
|
-
read out of the notes by{' '}
|
|
743
|
-
{sweep.provider.live
|
|
744
|
-
? `${sweep.provider.provider} · ${sweep.provider.model}`
|
|
745
|
-
: 'no live model'}
|
|
746
|
-
.
|
|
747
|
-
</p>
|
|
748
|
-
) : null}
|
|
749
|
-
|
|
750
735
|
{totals.modelFailures > 0 ? (
|
|
751
736
|
<p className={`mt-2 ${cn.warning}`} role="status">
|
|
752
737
|
{/* NOT `fromModel: 0` on its own. That reading — "nothing to add" —
|
|
@@ -761,38 +746,6 @@ function SweepPanel({
|
|
|
761
746
|
</p>
|
|
762
747
|
) : null}
|
|
763
748
|
|
|
764
|
-
{sweep.status === 'succeeded' && coverage.missed > 0 ? (
|
|
765
|
-
<p className={`mt-2 ${cn.warning}`}>
|
|
766
|
-
{/* A document that arrived mid-sweep shifts the offsets under it. Said
|
|
767
|
-
out loud rather than reported as a complete pass. */}
|
|
768
|
-
{coverage.missed} meeting{coverage.missed === 1 ? '' : 's'} arrived while this was
|
|
769
|
-
running and were not read. Run it again to pick them up.
|
|
770
|
-
</p>
|
|
771
|
-
) : null}
|
|
772
|
-
|
|
773
|
-
{sweep.needsReview.length ? (
|
|
774
|
-
<div className={`mt-2 ${cn.warning}`} role="status">
|
|
775
|
-
<p>
|
|
776
|
-
{sweep.needsReview.length} meeting statement
|
|
777
|
-
{sweep.needsReview.length === 1 ? '' : 's'} looked like they closed something, but not
|
|
778
|
-
closely enough to act on. Nothing was closed automatically.
|
|
779
|
-
</p>
|
|
780
|
-
<ul className="mt-1 space-y-1">
|
|
781
|
-
{sweep.needsReview.map((entry) => (
|
|
782
|
-
<li key={`${entry.commitmentId}:${entry.documentId}`}>
|
|
783
|
-
<button
|
|
784
|
-
type="button"
|
|
785
|
-
className="text-sm underline"
|
|
786
|
-
onClick={() => onOpenDocument?.(entry.documentId)}
|
|
787
|
-
>
|
|
788
|
-
“{stripMarkdown(entry.quote).slice(0, 120)}”
|
|
789
|
-
</button>
|
|
790
|
-
</li>
|
|
791
|
-
))}
|
|
792
|
-
</ul>
|
|
793
|
-
</div>
|
|
794
|
-
) : null}
|
|
795
|
-
|
|
796
749
|
{totals.droppedOutOfScope > 0 ? (
|
|
797
750
|
<p className={cn.error} role="status">
|
|
798
751
|
{totals.droppedOutOfScope} record{totals.droppedOutOfScope === 1 ? '' : 's'} from another
|
|
@@ -803,85 +756,6 @@ function SweepPanel({
|
|
|
803
756
|
);
|
|
804
757
|
}
|
|
805
758
|
|
|
806
|
-
/**
|
|
807
|
-
* What the last run did, in the terms that make it arguable.
|
|
808
|
-
*
|
|
809
|
-
* `fromRules` vs `fromModel` is here on purpose: it is the measurement of what
|
|
810
|
-
* the model is actually contributing over the structure the summariser already
|
|
811
|
-
* wrote, and if that number is ever zero the model call should be switched off
|
|
812
|
-
* rather than paid for.
|
|
813
|
-
*/
|
|
814
|
-
function RunSummary({
|
|
815
|
-
result, classNames: cn, onOpenDocument,
|
|
816
|
-
}: {
|
|
817
|
-
result: ExtractionResult;
|
|
818
|
-
classNames: Record<TrackerSlot, string>;
|
|
819
|
-
onOpenDocument?: (documentId: string) => void;
|
|
820
|
-
}) {
|
|
821
|
-
return (
|
|
822
|
-
<div className={cn.card}>
|
|
823
|
-
<p className="text-sm text-gray-800">
|
|
824
|
-
Read {result.documentsProcessed} meeting{result.documentsProcessed === 1 ? '' : 's'}:{' '}
|
|
825
|
-
{result.created} new, {result.merged} matched to something already tracked,{' '}
|
|
826
|
-
{result.resolved} closed by a later meeting.
|
|
827
|
-
</p>
|
|
828
|
-
<p className={cn.muted}>
|
|
829
|
-
{result.fromRules} came from the meetings’ own next-step lists, {result.fromModel} were read
|
|
830
|
-
out of the notes by {result.provider.live ? `${result.provider.provider} · ${result.provider.model}` : 'no live model'}.
|
|
831
|
-
</p>
|
|
832
|
-
|
|
833
|
-
{/* WHAT THE CHECK THREW AWAY, on the screen.
|
|
834
|
-
Measured over the sixteen real meetings: the model proposes about
|
|
835
|
-
ninety items and roughly two thirds of them do not survive. That is not
|
|
836
|
-
a bug to hide — it is the number that keeps the list believable, and
|
|
837
|
-
hiding it would leave "the model read 30 out of the notes" looking like
|
|
838
|
-
the model is simply better than it is. If `verified` is ever false the
|
|
839
|
-
run says so rather than implying a check that did not happen. */}
|
|
840
|
-
{result.fromModel || result.ungrounded || result.unconfirmed ? (
|
|
841
|
-
<p className={cn.muted}>
|
|
842
|
-
{result.verified
|
|
843
|
-
? `Checked against the meetings themselves: ${result.unconfirmed + result.ungrounded} more were proposed and dropped — ` +
|
|
844
|
-
`${result.ungrounded} quoted something the record does not say, ` +
|
|
845
|
-
`${result.unconfirmed} could not be confirmed as something anyone actually took on.`
|
|
846
|
-
: 'These were NOT checked against the meetings — the verification step did not run, so treat them as suggestions.'}
|
|
847
|
-
</p>
|
|
848
|
-
) : null}
|
|
849
|
-
|
|
850
|
-
{result.needsReview.length ? (
|
|
851
|
-
// Weak resolution matches are shown, never applied. A to-do list that
|
|
852
|
-
// quietly empties itself is the one failure with no symptom.
|
|
853
|
-
<div className={`mt-2 ${cn.warning}`} role="status">
|
|
854
|
-
<p>
|
|
855
|
-
{result.needsReview.length} meeting statement
|
|
856
|
-
{result.needsReview.length === 1 ? '' : 's'} looked like they closed something, but not
|
|
857
|
-
closely enough to act on. Nothing was closed automatically.
|
|
858
|
-
</p>
|
|
859
|
-
<ul className="mt-1 space-y-1">
|
|
860
|
-
{result.needsReview.map((entry) => (
|
|
861
|
-
<li key={`${entry.commitmentId}:${entry.documentId}`}>
|
|
862
|
-
<button
|
|
863
|
-
type="button"
|
|
864
|
-
className="text-sm underline"
|
|
865
|
-
onClick={() => onOpenDocument?.(entry.documentId)}
|
|
866
|
-
>
|
|
867
|
-
“{stripMarkdown(entry.quote).slice(0, 120)}”
|
|
868
|
-
</button>
|
|
869
|
-
</li>
|
|
870
|
-
))}
|
|
871
|
-
</ul>
|
|
872
|
-
</div>
|
|
873
|
-
) : null}
|
|
874
|
-
|
|
875
|
-
{result.droppedOutOfScope > 0 ? (
|
|
876
|
-
<p className={cn.error} role="status">
|
|
877
|
-
{result.droppedOutOfScope} record{result.droppedOutOfScope === 1 ? '' : 's'} from another
|
|
878
|
-
workspace were returned by the data API and excluded before extracting.
|
|
879
|
-
</p>
|
|
880
|
-
) : null}
|
|
881
|
-
</div>
|
|
882
|
-
);
|
|
883
|
-
}
|
|
884
|
-
|
|
885
759
|
// ---------------------------------------------------------------------------
|
|
886
760
|
|
|
887
761
|
|
|
@@ -146,6 +146,25 @@ export function ConnectionCard({
|
|
|
146
146
|
{/* THE CONTROL THIS PAGE WAS MISSING. A vendor key gets rotated —
|
|
147
147
|
that is normal operations, not an exception — and the only place
|
|
148
148
|
to put the new one was a form that creates a second account. */}
|
|
149
|
+
{entry?.auth_mode === 'oauth' ? (
|
|
150
|
+
/* An OAuth card has no key to paste: when the vendor stops accepting
|
|
151
|
+
the grant, the fix is to consent again, on this same card. */
|
|
152
|
+
api.oauthInitiate && connection.status !== 'connected' ? (
|
|
153
|
+
<button
|
|
154
|
+
type="button"
|
|
155
|
+
className={cn.button}
|
|
156
|
+
disabled={Boolean(busy)}
|
|
157
|
+
onClick={() => void guard('reconnect', async () => {
|
|
158
|
+
const { authorization_url: url } = await api.oauthInitiate!(connection.id, {
|
|
159
|
+
return_to: typeof window !== 'undefined' ? window.location.href : undefined,
|
|
160
|
+
});
|
|
161
|
+
if (typeof window !== 'undefined') window.location.assign(url);
|
|
162
|
+
})}
|
|
163
|
+
>
|
|
164
|
+
{busy === 'reconnect' ? 'Opening…' : 'Reconnect'}
|
|
165
|
+
</button>
|
|
166
|
+
) : null
|
|
167
|
+
) : (
|
|
149
168
|
<button
|
|
150
169
|
type="button"
|
|
151
170
|
className={cn.button}
|
|
@@ -158,6 +177,7 @@ export function ConnectionCard({
|
|
|
158
177
|
>
|
|
159
178
|
{replacing ? 'Cancel' : 'Replace key'}
|
|
160
179
|
</button>
|
|
180
|
+
)}
|
|
161
181
|
{/* DISCOVER -> WIRE -> FIRE is foundry-level and stays there. The
|
|
162
182
|
member router serves no choices, targets or actions at all, so
|
|
163
183
|
the control is gated on the verb EXISTING rather than on a mode
|
|
@@ -105,6 +105,8 @@ export interface BoundApi {
|
|
|
105
105
|
capabilities_enabled?: string[];
|
|
106
106
|
return_to?: string;
|
|
107
107
|
}): Promise<{ authorization_url: string; state: string; redirect_uri: string }>;
|
|
108
|
+
/** RE-consent an existing OAuth card whose grant the vendor stopped accepting. Personal mode only. */
|
|
109
|
+
oauthInitiate?(id: string, input?: { return_to?: string }): Promise<{ authorization_url: string }>;
|
|
108
110
|
setMemberConnectorPolicy?(connectorKey: string, allowed: boolean): Promise<unknown>;
|
|
109
111
|
memberConnections?(): Promise<{
|
|
110
112
|
results: MemberConnectionRow[]; permissions: ConnectionPermissions;
|