@startsimpli/integrations 0.2.187 → 0.2.189
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__/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/ConverseScreen.tsx +101 -78
- package/src/native/converse/__tests__/liveScreen.test.tsx +46 -13
- package/src/native/converse/io.ts +2 -1
- package/src/native/talk/TalkTab.tsx +15 -24
- package/src/native/talk/__tests__/talk-tab.test.tsx +8 -21
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { FlatList, KeyboardAvoidingView, Platform, Pressable, Text as RNText, TextInput, View } from 'react-native';
|
|
3
|
-
import { Alert, Button,
|
|
3
|
+
import { Alert, Button, Header, Icon, MessageBubble, Spinner, useHaptics, useTheme } from '@startsimpli/ui-native';
|
|
4
4
|
import { useControllerState } from '../components/useControllerState';
|
|
5
|
-
import type { MeetingController } from '../../corpus/converse/meeting';
|
|
6
|
-
import {
|
|
5
|
+
import type { MeetingController, MeetingLine } from '../../corpus/converse/meeting';
|
|
6
|
+
import type { ConverseSource } from '../../corpus/converse/types';
|
|
7
|
+
import { statusLine } from './format';
|
|
7
8
|
import { SPEEDS, speedLabel, type SpeedStore } from './speed';
|
|
8
9
|
|
|
9
|
-
const
|
|
10
|
+
const MIC = 52;
|
|
10
11
|
|
|
11
|
-
/** Seconds since `since` while `on`, ticking once a second. */
|
|
12
12
|
function useElapsed(on: boolean): number {
|
|
13
13
|
const [sec, setSec] = useState(0);
|
|
14
14
|
useEffect(() => {
|
|
@@ -21,113 +21,136 @@ function useElapsed(on: boolean): number {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
24
|
+
* ONE screen to talk to Tandem: a thread that is always readable, a text box with a small mic beside it, and a small Done.
|
|
25
|
+
* No modes and no start button over the thread. Tap the mic to talk (it sends when you pause, the reply is spoken and the
|
|
26
|
+
* text stays here), tap it again to stop listening; type any time. Done files the conversation (notes become to-dos).
|
|
27
|
+
* Leaving the tab does not end anything.
|
|
26
28
|
*/
|
|
27
|
-
export function ConverseScreen({ controller, speed, embedded }: { controller: MeetingController; speed?: SpeedStore; /** The Talk tab draws the title above this screen. */ embedded?: boolean }) {
|
|
29
|
+
export function ConverseScreen({ controller, speed, embedded, onOpenSource }: { controller: MeetingController; speed?: SpeedStore; /** The Talk tab draws the title above this screen. */ embedded?: boolean; /** Opens a cited source (a document or project) in its own tab. */ onOpenSource?: (source: ConverseSource) => void }) {
|
|
28
30
|
const theme = useTheme();
|
|
29
31
|
const haptic = useHaptics();
|
|
30
32
|
const s = useControllerState({ getState: controller.getState, subscribe: (l: () => void) => controller.subscribe(l) });
|
|
31
33
|
const rate = useControllerState({ getState: speed ? speed.get : () => 1, subscribe: (l: () => void) => (speed ? speed.subscribe(l) : () => undefined) });
|
|
32
34
|
const [draft, setDraft] = useState('');
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
|
|
35
|
+
const list = useRef<FlatList<MeetingLine>>(null);
|
|
36
|
+
const lines = s.lines;
|
|
37
|
+
// `micOn` is the preference (true even before anything has started): it is listening only while a conversation is running.
|
|
38
|
+
const listening = s.micOn && (s.phase === 'listening' || s.phase === 'thinking' || s.phase === 'speaking');
|
|
39
|
+
const thinking = s.phase === 'thinking';
|
|
40
|
+
const speaking = s.phase === 'speaking';
|
|
36
41
|
const busy = s.phase === 'ending';
|
|
42
|
+
// A conversation is open while the mic listens, a turn runs, or there is a thread that has not been filed (typing still works with the mic off).
|
|
43
|
+
const open = listening || thinking || speaking || s.phase === 'stopped' || (lines.length > 0 && s.phase !== 'ended' && s.phase !== 'ending');
|
|
37
44
|
const sec = useElapsed(s.phase === 'listening');
|
|
38
|
-
const
|
|
45
|
+
const micColor = listening ? theme.colors.destructive : speaking ? theme.colors.success ?? theme.colors.primary : theme.colors.primary;
|
|
46
|
+
|
|
47
|
+
const send = () => { const t = draft.trim(); if (!t) return; setDraft(''); haptic('light', 'converse.send'); void controller.sendText(t); };
|
|
48
|
+
const toggleMic = () => {
|
|
49
|
+
haptic('medium', listening ? 'converse.mic-off' : 'converse.mic-on');
|
|
50
|
+
controller.mic(!listening);
|
|
51
|
+
};
|
|
39
52
|
|
|
40
53
|
return (
|
|
41
54
|
<KeyboardAvoidingView style={{ flex: 1 }} behavior={Platform.OS === 'ios' ? 'padding' : undefined} testID="converse-screen">
|
|
42
|
-
{embedded ? null : <Header
|
|
55
|
+
{embedded ? null : <Header testID="converse-header" title="Talk" subtitle="Talk or type to Tandem" />}
|
|
43
56
|
<FlatList
|
|
44
57
|
ref={list}
|
|
45
58
|
testID="converse-transcript"
|
|
46
59
|
style={{ flex: 1 }}
|
|
47
|
-
data={
|
|
60
|
+
data={lines}
|
|
48
61
|
keyExtractor={(_, i) => String(i)}
|
|
49
62
|
onContentSizeChange={() => list.current?.scrollToEnd?.({ animated: true })}
|
|
50
63
|
contentContainerStyle={{ padding: theme.spacing.lg, gap: theme.spacing.md, flexGrow: 1 }}
|
|
51
64
|
ListEmptyComponent={
|
|
52
|
-
<
|
|
65
|
+
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center', paddingHorizontal: theme.spacing.lg }}>
|
|
66
|
+
<RNText testID="converse-empty" style={{ color: theme.colors.mutedForeground, fontSize: theme.fontSizes.lg, textAlign: 'center' }}>
|
|
67
|
+
Say or type anything: a note, a question, a to-do. Tap the mic to talk.
|
|
68
|
+
</RNText>
|
|
69
|
+
</View>
|
|
53
70
|
}
|
|
54
|
-
renderItem={({ item, index }) =>
|
|
71
|
+
renderItem={({ item, index }) => (item.role === 'system'
|
|
72
|
+
? <RNText testID={`converse-line-${index}`} style={{ color: theme.colors.mutedForeground, fontSize: theme.fontSizes.sm, textAlign: 'center' }}>{item.text}</RNText>
|
|
73
|
+
: (
|
|
74
|
+
<View style={{ gap: theme.spacing.xs }}>
|
|
75
|
+
<MessageBubble role={item.role === 'user' ? 'user' : 'assistant'} text={item.role === 'relay' ? `Relay: ${item.text}` : item.text} testID={`converse-line-${index}`} />
|
|
76
|
+
{item.sources?.length && onOpenSource ? (
|
|
77
|
+
<View style={{ flexDirection: 'row', flexWrap: 'wrap', gap: theme.spacing.xs }}>
|
|
78
|
+
{item.sources.map((src, i) => (
|
|
79
|
+
<Pressable key={`${src.id}-${i}`} testID={`converse-source-${index}-${i}`} accessibilityRole="button" accessibilityLabel={`Open ${src.title}`} onPress={() => onOpenSource(src)} style={{ paddingHorizontal: theme.spacing.sm, paddingVertical: theme.spacing.xs, borderRadius: 999, backgroundColor: theme.colors.muted }}>
|
|
80
|
+
<RNText numberOfLines={1} style={{ color: theme.colors.foreground, fontSize: theme.fontSizes.sm }}>{src.title}</RNText>
|
|
81
|
+
</Pressable>
|
|
82
|
+
))}
|
|
83
|
+
</View>
|
|
84
|
+
) : null}
|
|
85
|
+
</View>
|
|
86
|
+
))}
|
|
55
87
|
/>
|
|
56
|
-
<View style={{
|
|
88
|
+
<View style={{ gap: theme.spacing.sm, paddingBottom: theme.spacing.md, paddingHorizontal: theme.spacing.lg }}>
|
|
57
89
|
{s.relayNotice ? (
|
|
58
90
|
<Pressable testID="converse-relay-notice" accessibilityRole="button" accessibilityLabel="Dismiss the relay message" onPress={() => controller.dismissNotice()} style={{ alignSelf: 'stretch' }}>
|
|
59
91
|
<Alert variant="default">{`Relay: ${s.relayNotice}`}</Alert>
|
|
60
92
|
</Pressable>
|
|
61
93
|
) : null}
|
|
62
94
|
{s.error ? (
|
|
63
|
-
<View style={{
|
|
95
|
+
<View testID="converse-error" style={{ alignSelf: 'stretch' }}>
|
|
64
96
|
<Alert variant="destructive">{s.error}</Alert>
|
|
65
97
|
</View>
|
|
66
98
|
) : null}
|
|
67
|
-
{s.noAudio &&
|
|
68
|
-
{
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
{
|
|
72
|
-
<
|
|
73
|
-
{statusLine(s.phase, sec)}
|
|
74
|
-
</RNText>
|
|
75
|
-
</View>
|
|
76
|
-
) : (
|
|
77
|
-
<>
|
|
78
|
-
<Pressable
|
|
79
|
-
testID="converse-talk"
|
|
80
|
-
accessibilityRole="button"
|
|
81
|
-
accessibilityLabel="Start the meeting"
|
|
82
|
-
onPress={() => { haptic('medium', 'converse.start'); controller.start(); }}
|
|
83
|
-
style={{ width: BIG, height: BIG, borderRadius: BIG / 2, backgroundColor: color, alignItems: 'center', justifyContent: 'center' }}
|
|
84
|
-
>
|
|
85
|
-
<RNText style={{ color: theme.colors.primaryForeground, fontSize: 32, fontWeight: '800' }}>{indicatorLabel(s.phase)}</RNText>
|
|
86
|
-
</Pressable>
|
|
87
|
-
<RNText testID="converse-status" style={{ color: theme.colors.foreground, fontSize: theme.fontSizes.lg, fontWeight: '600', textAlign: 'center' }}>
|
|
88
|
-
{statusLine(s.phase, sec)}
|
|
89
|
-
</RNText>
|
|
90
|
-
</>
|
|
91
|
-
)}
|
|
92
|
-
{/* Typing starts a conversation too: the Talk tab is start-talking OR a type box. */}
|
|
93
|
-
{active || embedded ? (
|
|
94
|
-
<View style={{ flexDirection: 'row', alignItems: 'center', gap: theme.spacing.sm, alignSelf: 'stretch' }}>
|
|
95
|
-
<TextInput
|
|
96
|
-
testID="converse-input"
|
|
97
|
-
value={draft}
|
|
98
|
-
onChangeText={setDraft}
|
|
99
|
-
onSubmitEditing={send}
|
|
100
|
-
returnKeyType="send"
|
|
101
|
-
placeholder="Or type here"
|
|
102
|
-
placeholderTextColor={theme.colors.mutedForeground}
|
|
103
|
-
accessibilityLabel="Type a message"
|
|
104
|
-
style={{ flex: 1, minHeight: 44, paddingHorizontal: theme.spacing.md, borderRadius: 22, borderWidth: 1, borderColor: theme.colors.border, color: theme.colors.foreground, fontSize: theme.fontSizes.lg }}
|
|
105
|
-
/>
|
|
106
|
-
<Button testID="converse-send" title="Send" variant="outline" disabled={!draft.trim()} onPress={send} />
|
|
99
|
+
{s.noAudio && !speaking ? <RNText testID="converse-no-audio" style={{ color: theme.colors.mutedForeground, fontSize: theme.fontSizes.sm, textAlign: 'center' }}>{`No sound for that reply: ${s.noAudio}`}</RNText> : null}
|
|
100
|
+
{open || busy || s.phase === 'ended' ? (
|
|
101
|
+
<View testID="converse-live" style={{ flexDirection: 'row', alignItems: 'center', gap: theme.spacing.sm }}>
|
|
102
|
+
{busy || thinking ? <Spinner /> : <View style={{ width: 10, height: 10, borderRadius: 5, backgroundColor: s.phase === 'ended' ? theme.colors.mutedForeground : micColor }} />}
|
|
103
|
+
<RNText testID="converse-status" numberOfLines={1} style={{ flex: 1, color: theme.colors.mutedForeground, fontSize: theme.fontSizes.sm }}>{!listening && s.phase === 'idle' ? 'Mic is off. Type, or tap the mic.' : statusLine(s.phase, sec)}</RNText>
|
|
104
|
+
{s.phase === 'ended' ? null : <Button testID="converse-end" title="Done" variant="outline" size="sm" disabled={busy} onPress={() => { haptic('warning', 'converse.end'); void controller.end(); }} />}
|
|
107
105
|
</View>
|
|
108
106
|
) : null}
|
|
109
|
-
{
|
|
110
|
-
<
|
|
111
|
-
|
|
112
|
-
{
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
107
|
+
<View style={{ flexDirection: 'row', alignItems: 'center', gap: theme.spacing.sm }}>
|
|
108
|
+
<TextInput
|
|
109
|
+
testID="converse-input"
|
|
110
|
+
value={draft}
|
|
111
|
+
onChangeText={setDraft}
|
|
112
|
+
onSubmitEditing={send}
|
|
113
|
+
returnKeyType="send"
|
|
114
|
+
placeholder="Type, or tap the mic"
|
|
115
|
+
placeholderTextColor={theme.colors.mutedForeground}
|
|
116
|
+
accessibilityLabel="Type a message"
|
|
117
|
+
style={{ flex: 1, minHeight: MIC, paddingHorizontal: theme.spacing.md, borderRadius: MIC / 2, borderWidth: 1, borderColor: theme.colors.border, color: theme.colors.foreground, fontSize: theme.fontSizes.lg }}
|
|
118
|
+
/>
|
|
119
|
+
{draft.trim() ? <Button testID="converse-send" title="Send" variant="outline" onPress={send} /> : null}
|
|
120
|
+
<Pressable
|
|
121
|
+
testID="converse-mic"
|
|
122
|
+
accessibilityRole="button"
|
|
123
|
+
accessibilityLabel={listening ? 'Stop listening' : 'Talk'}
|
|
124
|
+
accessibilityState={{ selected: listening }}
|
|
125
|
+
disabled={busy}
|
|
126
|
+
onPress={toggleMic}
|
|
127
|
+
style={{ width: MIC, height: MIC, borderRadius: MIC / 2, backgroundColor: micColor, alignItems: 'center', justifyContent: 'center', opacity: busy ? 0.5 : 1 }}
|
|
128
|
+
>
|
|
129
|
+
{thinking ? <Spinner /> : <Icon name="mic" size={24} color={theme.colors.primaryForeground} />}
|
|
130
|
+
</Pressable>
|
|
131
|
+
</View>
|
|
132
|
+
{speed || lines.length ? (
|
|
133
|
+
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'center', gap: theme.spacing.sm }}>
|
|
134
|
+
{lines.length ? <Button testID="converse-repeat" title="Replay" variant="ghost" size="sm" disabled={busy || thinking} onPress={() => { haptic('light', 'converse.replay'); void controller.replay(); }} /> : null}
|
|
135
|
+
{speed ? (
|
|
136
|
+
<View testID="converse-speed" accessibilityLabel="Reply speed" style={{ flexDirection: 'row', alignItems: 'center', gap: theme.spacing.xs }}>
|
|
137
|
+
{SPEEDS.map((r) => (
|
|
138
|
+
<Pressable
|
|
139
|
+
key={r}
|
|
140
|
+
testID={`converse-speed-${r}`}
|
|
141
|
+
accessibilityRole="button"
|
|
142
|
+
accessibilityState={{ selected: rate === r }}
|
|
143
|
+
accessibilityLabel={`Speak at ${speedLabel(r)}`}
|
|
144
|
+
onPress={() => { haptic('light', 'converse.speed'); speed.set(r); }}
|
|
145
|
+
style={{ paddingHorizontal: theme.spacing.sm, paddingVertical: theme.spacing.xs, borderRadius: 999, backgroundColor: rate === r ? theme.colors.primary : theme.colors.muted }}
|
|
146
|
+
>
|
|
147
|
+
<RNText style={{ color: rate === r ? theme.colors.primaryForeground : theme.colors.foreground, fontSize: theme.fontSizes.sm, fontWeight: '600' }}>{speedLabel(r)}</RNText>
|
|
148
|
+
</Pressable>
|
|
149
|
+
))}
|
|
150
|
+
</View>
|
|
151
|
+
) : null}
|
|
125
152
|
</View>
|
|
126
153
|
) : null}
|
|
127
|
-
<View style={{ flexDirection: 'row', gap: theme.spacing.md }}>
|
|
128
|
-
<Button testID="converse-repeat" title="Replay" variant="outline" size="lg" disabled={!s.lines.length || busy || s.phase === 'thinking'} onPress={() => { haptic('light', 'converse.replay'); void controller.replay(); }} />
|
|
129
|
-
<Button testID="converse-end" title="End meeting" variant={active ? "destructive" : "outline"} size="lg" disabled={busy || (!active && s.phase !== 'stopped')} onPress={() => { haptic('warning', 'converse.end'); void controller.end(); }} />
|
|
130
|
-
</View>
|
|
131
154
|
</View>
|
|
132
155
|
</KeyboardAvoidingView>
|
|
133
156
|
);
|
|
@@ -6,15 +6,16 @@ import { act, hostById, maybeById, render } from '../../../../../ui-native/test/
|
|
|
6
6
|
import type { MeetingController } from '../../../corpus/converse/meeting';
|
|
7
7
|
import { ConverseScreen } from '../ConverseScreen';
|
|
8
8
|
|
|
9
|
-
const base = { retryable: false, lines: [{ role: 'user', text: 'plan my day' }, { role: 'assistant', text: 'Here is a plan' }], error: null, noAudio: null, conversationId: 'c1', saved: null, relayNotice: null };
|
|
10
|
-
const make = (phase: string) => {
|
|
11
|
-
const state = { ...base, phase };
|
|
9
|
+
const base = { micOn: false, retryable: false, lines: [{ role: 'user', text: 'plan my day' }, { role: 'assistant', text: 'Here is a plan' }], error: null, noAudio: null, conversationId: 'c1', saved: null, relayNotice: null };
|
|
10
|
+
const make = (phase: string, micPreference = false) => {
|
|
11
|
+
const state = { ...base, phase, micOn: phase !== 'idle' || phase === 'idle' && micPreference };
|
|
12
|
+
const mics: boolean[] = [];
|
|
12
13
|
const calls = { end: 0, start: 0, text: [] as string[] };
|
|
13
14
|
const controller = {
|
|
14
|
-
start() { calls.start += 1; }, end: async () => { calls.end += 1; return null; }, replay: async () => {}, sendText: async (t: string) => { calls.text.push(t); }, dismissNotice() {},
|
|
15
|
+
start() { calls.start += 1; }, mic(on: boolean) { mics.push(on); }, end: async () => { calls.end += 1; return null; }, replay: async () => {}, sendText: async (t: string) => { calls.text.push(t); }, dismissNotice() {},
|
|
15
16
|
getState: () => state, state: () => state, subscribe: () => () => undefined,
|
|
16
17
|
} as unknown as MeetingController;
|
|
17
|
-
return { controller, calls };
|
|
18
|
+
return { controller, calls, mics };
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
describe('Converse while a meeting runs', () => {
|
|
@@ -35,24 +36,56 @@ describe('Converse while a meeting runs', () => {
|
|
|
35
36
|
await act(async () => { hostById(r2, 'converse-end').props.onPress(); });
|
|
36
37
|
expect(calls.end).toBe(1);
|
|
37
38
|
});
|
|
38
|
-
it('
|
|
39
|
-
const { controller,
|
|
39
|
+
it('has no start circle at all: when idle (even with the controller\'s default mic preference on) the mic turns listening on', async () => {
|
|
40
|
+
const { controller, mics } = make('idle', true);
|
|
41
|
+
(controller.getState() as { lines: unknown[] }).lines = [];
|
|
40
42
|
const r = render(<ConverseScreen controller={controller} />);
|
|
43
|
+
expect(maybeById(r, 'converse-talk')).toHaveLength(0);
|
|
41
44
|
expect(maybeById(r, 'converse-live')).toHaveLength(0);
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
expect(hostById(r, 'converse-input')).toBeTruthy();
|
|
46
|
+
await act(async () => { hostById(r, 'converse-mic').props.onPress(); });
|
|
47
|
+
expect(mics).toEqual([true]);
|
|
48
|
+
});
|
|
49
|
+
it('the mic stops listening without ending the conversation', async () => {
|
|
50
|
+
const { controller, calls, mics } = make('listening');
|
|
51
|
+
const r = render(<ConverseScreen controller={controller} />);
|
|
52
|
+
await act(async () => { hostById(r, 'converse-mic').props.onPress(); });
|
|
53
|
+
expect(mics).toEqual([false]);
|
|
54
|
+
expect(calls.end).toBe(0);
|
|
55
|
+
});
|
|
56
|
+
it('with the mic off and a thread open it still offers Done and says the mic is off', () => {
|
|
57
|
+
const { controller } = make('idle');
|
|
58
|
+
const r = render(<ConverseScreen controller={controller} />);
|
|
59
|
+
expect(hostById(r, 'converse-end')).toBeTruthy();
|
|
60
|
+
expect(JSON.stringify(r.toJSON())).toContain('Mic is off');
|
|
61
|
+
});
|
|
62
|
+
it('a cited source opens through onOpenSource', async () => {
|
|
63
|
+
const { controller } = make('idle');
|
|
64
|
+
(controller.getState() as { lines: unknown[] }).lines = [{ role: 'assistant', text: 'From your plan', sources: [{ kind: 'document', title: 'Launch checklist', id: 'd1' }] }];
|
|
65
|
+
const opened: unknown[] = [];
|
|
66
|
+
const r = render(<ConverseScreen controller={controller} onOpenSource={(src) => opened.push(src)} />);
|
|
67
|
+
await act(async () => { hostById(r, 'converse-source-0-0').props.onPress(); });
|
|
68
|
+
expect(opened).toEqual([{ kind: 'document', title: 'Launch checklist', id: 'd1' }]);
|
|
44
69
|
});
|
|
45
70
|
it('lets him type while a meeting runs: Send passes the text to the meeting and clears the box', async () => {
|
|
46
71
|
const { controller, calls } = make('listening');
|
|
47
72
|
const r = render(<ConverseScreen controller={controller} />);
|
|
48
|
-
expect(
|
|
73
|
+
expect(maybeById(r, 'converse-send')).toHaveLength(0);
|
|
49
74
|
await act(async () => { hostById(r, 'converse-input').props.onChangeText(' move the car service to Friday '); });
|
|
50
75
|
await act(async () => { hostById(r, 'converse-send').props.onPress(); });
|
|
51
76
|
expect(calls.text).toEqual(['move the car service to Friday']);
|
|
52
77
|
expect(hostById(r, 'converse-input').props.value).toBe('');
|
|
53
78
|
});
|
|
54
|
-
it('
|
|
55
|
-
const { controller } = make('
|
|
56
|
-
|
|
79
|
+
it('after Done it says the meeting is saved and offers no Done again', () => {
|
|
80
|
+
const { controller } = make('ended');
|
|
81
|
+
const r = render(<ConverseScreen controller={controller} />);
|
|
82
|
+
expect(JSON.stringify(r.toJSON())).toContain('Meeting saved');
|
|
83
|
+
expect(maybeById(r, 'converse-end')).toHaveLength(0);
|
|
84
|
+
});
|
|
85
|
+
it('shows a quiet Filed marker after a note was filed', () => {
|
|
86
|
+
const { controller } = make('listening');
|
|
87
|
+
(controller.getState() as { lines: unknown[] }).lines = [{ role: 'user', text: 'note' }, { role: 'assistant', text: 'Got it.' }, { role: 'system', text: 'Filed: 2 to-dos' }];
|
|
88
|
+
const r = render(<ConverseScreen controller={controller} />);
|
|
89
|
+
expect(JSON.stringify(r.toJSON())).toContain('Filed: 2 to-dos');
|
|
57
90
|
});
|
|
58
91
|
});
|
|
@@ -65,7 +65,8 @@ export function createMeetingIO(deps: {
|
|
|
65
65
|
const finish = (why: NonNullable<typeof h.why>) => { if (!h.why) { h.why = why; wake?.(); } };
|
|
66
66
|
const t0 = now();
|
|
67
67
|
broken = () => finish('broken');
|
|
68
|
-
|
|
68
|
+
// Aborted with reason 'finish' (the mic button): if he was speaking, that is the end of the utterance (it is sent); otherwise a plain stop.
|
|
69
|
+
const onAbort = () => finish(signal.reason === 'finish' && startedAt !== null ? 'end' : 'abort');
|
|
69
70
|
signal.addEventListener('abort', onAbort, { once: true });
|
|
70
71
|
try {
|
|
71
72
|
await deps.audio.start({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { useMemo
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
|
-
import { Header
|
|
4
|
-
import { TAB_COPY
|
|
3
|
+
import { Header } from '@startsimpli/ui-native';
|
|
4
|
+
import { TAB_COPY } from '../../corpus/nav-copy';
|
|
5
5
|
import { projectIdOf } from '../../corpus/ask-projects';
|
|
6
6
|
import type { MeetingController } from '../../corpus/converse/meeting';
|
|
7
7
|
import type { FoundryTab, TabContext } from '../components/FoundryTabsShell';
|
|
@@ -27,38 +27,29 @@ export interface TalkTabOptions {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
function TalkBody({ opts, ctx }: { opts: TalkTabOptions; ctx: TabContext }) {
|
|
30
|
-
const theme = useTheme();
|
|
31
30
|
const { api, converse, speed, libraryKey = 'library', planKey } = opts;
|
|
32
|
-
const
|
|
33
|
-
// `-tgTab talk -tgDetail ask` (and a link) land on Ask.
|
|
34
|
-
const [mode, setMode] = useState<TalkMode>(ctx.route?.id === 'ask' || !converse ? 'ask' : 'talk');
|
|
35
|
-
const ask = useMemo(() => createAskController({ api: api.ask, scope: api.scope, listProjects: async () => (await api.corpus.listFocusChoices?.()) ?? [] }), [api]);
|
|
36
|
-
const current = modes.find((m) => m.key === mode) ?? modes[0];
|
|
31
|
+
const ask = useMemo(() => (converse ? null : createAskController({ api: api.ask, scope: api.scope, listProjects: async () => (await api.corpus.listFocusChoices?.()) ?? [] })), [api, converse]);
|
|
37
32
|
return (
|
|
38
33
|
<View style={{ flex: 1 }} testID="talk-screen">
|
|
39
34
|
<Header large testID="talk-header" title={TAB_COPY.talk.label} subtitle={TAB_COPY.talk.subtitle} />
|
|
40
|
-
|
|
41
|
-
{modes.length > 1 ? (
|
|
42
|
-
<SegmentedControl<TalkMode> testID="talk-mode" value={current.key} onChange={setMode} options={modes.map((m) => ({ value: m.key, label: m.label }))} />
|
|
43
|
-
) : null}
|
|
44
|
-
<Text variant="footnote" testID="talk-mode-subtitle">{current.subtitle}</Text>
|
|
45
|
-
</View>
|
|
46
|
-
{/* Both stay mounted: switching modes must not end a meeting in progress. */}
|
|
35
|
+
{/* ONE conversation: notes, questions, to-dos and the relay all go through the same thread, no modes. */}
|
|
47
36
|
{converse ? (
|
|
48
|
-
<
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
37
|
+
<ConverseScreen
|
|
38
|
+
controller={converse}
|
|
39
|
+
speed={speed ?? undefined}
|
|
40
|
+
embedded
|
|
41
|
+
onOpenSource={(src) => { const project = src.kind === 'project' ? src.id : projectIdOf(src.id); if (project && planKey) ctx.openTab(planKey, `project/${project}`); else ctx.openTab(libraryKey, src.id); }}
|
|
42
|
+
/>
|
|
43
|
+
) : ask ? (
|
|
53
44
|
<AskScreen controller={ask} onOpenDocument={(id) => { const project = projectIdOf(id); if (project && planKey) ctx.openTab(planKey, `project/${project}`); else ctx.openTab(libraryKey, id); }} embedded />
|
|
54
|
-
|
|
45
|
+
) : null}
|
|
55
46
|
</View>
|
|
56
47
|
);
|
|
57
48
|
}
|
|
58
49
|
|
|
59
50
|
/**
|
|
60
|
-
* The Talk tab: ONE place to speak to Tandem
|
|
61
|
-
*
|
|
51
|
+
* The Talk tab: ONE place to speak to Tandem, a single thread with a type box and a small mic. No modes. Without
|
|
52
|
+
* `features.converse` it falls back to Ask alone. Leaving the tab does not end a conversation.
|
|
62
53
|
*/
|
|
63
54
|
export function talkTab(opts: TalkTabOptions): FoundryTab {
|
|
64
55
|
return { key: opts.key ?? TALK_TAB, label: opts.label ?? TAB_COPY.talk.label, render: (ctx) => <TalkBody opts={opts} ctx={ctx} /> };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { describe, expect, it, vi } from 'vitest';
|
|
2
2
|
|
|
3
3
|
vi.mock('react-native', async () => ({ ...(await import('../../../../../ui-native/test/rn-stub')) }));
|
|
4
|
-
import { act, allText,
|
|
5
|
-
import {
|
|
4
|
+
import { act, allText, render } from '../../../../../ui-native/test/render';
|
|
5
|
+
import { TAB_COPY } from '../../../corpus/nav-copy';
|
|
6
6
|
import type { TabContext } from '../../components/FoundryTabsShell';
|
|
7
7
|
import { createFakeNativeCorpusApi } from '../../corpus/fake';
|
|
8
8
|
import type { MeetingController } from '../../../corpus/converse/meeting';
|
|
@@ -22,30 +22,17 @@ const has = (r: ReturnType<typeof render>, id: string) => r.root.findAllByProps(
|
|
|
22
22
|
const ctx = (over: Partial<TabContext> = {}): TabContext => ({ tab: 'talk', active: true, route: null, push: vi.fn(), back: vi.fn(), openTab: vi.fn(), ...over });
|
|
23
23
|
|
|
24
24
|
describe('Talk tab', () => {
|
|
25
|
-
it('
|
|
25
|
+
it('is ONE thread: a type box, a small mic, the one-line copy, no start circle and no mode toggle', async () => {
|
|
26
26
|
const { controller } = idleMeeting();
|
|
27
27
|
const r = render(<>{talkTab({ api: createFakeNativeCorpusApi(), converse: controller }).render(ctx())}</>);
|
|
28
28
|
await tick();
|
|
29
29
|
expect(allText(r)).toContain(TAB_COPY.talk.subtitle);
|
|
30
|
-
expect(has(r, 'converse-talk')).toBe(true);
|
|
31
30
|
expect(has(r, 'converse-input')).toBe(true);
|
|
32
|
-
expect(has(r, '
|
|
33
|
-
expect(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const { controller } = idleMeeting();
|
|
38
|
-
const c = ctx({ route: { id: 'ask' } });
|
|
39
|
-
const r = render(<>{talkTab({ api: createFakeNativeCorpusApi(), converse: controller }).render(c)}</>);
|
|
40
|
-
await tick();
|
|
41
|
-
expect(allText(r)).toContain(TALK_MODES[1].subtitle);
|
|
42
|
-
act(() => { hostById(r, 'ask-composer-input').props.onChangeText('Debug launch checklist'); });
|
|
43
|
-
press(hostById(r, 'ask-composer-send'));
|
|
44
|
-
await tick(); await tick();
|
|
45
|
-
const cite = r.root.findAll((n) => typeof n.props.testID === 'string' && n.props.testID.startsWith('ask-citation-') && typeof n.props.onPress === 'function')[0];
|
|
46
|
-
expect(cite).toBeTruthy();
|
|
47
|
-
press(cite);
|
|
48
|
-
expect(c.openTab).toHaveBeenCalledWith('library', expect.any(String));
|
|
31
|
+
expect(has(r, 'converse-mic')).toBe(true);
|
|
32
|
+
expect(has(r, 'converse-talk')).toBe(false);
|
|
33
|
+
expect(has(r, 'talk-mode')).toBe(false);
|
|
34
|
+
expect(has(r, 'talk-mode-ask')).toBe(false);
|
|
35
|
+
expect(has(r, 'ask-composer-input')).toBe(false);
|
|
49
36
|
});
|
|
50
37
|
|
|
51
38
|
it('without a meeting controller Talk is Ask alone', async () => {
|