@startsimpli/integrations 0.2.225 → 0.2.227
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 +3 -3
- package/src/__tests__/attention-orgs.test.ts +61 -0
- package/src/__tests__/attention-run.test.ts +3 -3
- package/src/__tests__/converse-meeting-interrupted.test.ts +74 -0
- package/src/__tests__/converse-meeting-vad.test.ts +25 -3
- package/src/__tests__/converse-meeting.test.ts +29 -0
- package/src/__tests__/converse-roci-transcript.test.ts +36 -0
- package/src/__tests__/converse-soak.test.ts +28 -0
- package/src/__tests__/converse-tts.test.ts +128 -0
- package/src/__tests__/converse.test.ts +38 -1
- package/src/__tests__/relay-items.test.ts +1 -1
- package/src/corpus/attention/importance.ts +1 -1
- package/src/corpus/attention/index.ts +1 -0
- package/src/corpus/attention/orgs.ts +41 -0
- package/src/corpus/attention/policy.ts +2 -0
- package/src/corpus/attention/push.ts +2 -1
- package/src/corpus/attention/queue.ts +3 -1
- package/src/corpus/attention/run-steps.ts +1 -1
- package/src/corpus/attention/run.ts +4 -3
- package/src/corpus/attention/types.ts +1 -1
- package/src/corpus/converse/handle.ts +12 -4
- package/src/corpus/converse/meeting-config.ts +8 -2
- package/src/corpus/converse/meeting.ts +24 -5
- package/src/corpus/converse/respond.ts +2 -2
- package/src/corpus/converse/speak-chunks.ts +33 -0
- package/src/corpus/converse/speak.ts +17 -4
- package/src/corpus/converse/types.ts +2 -0
- package/src/corpus/converse/vad.ts +16 -1
- package/src/corpus/notify/types.ts +2 -0
- package/src/native/app/FoundryApp.tsx +37 -2
- package/src/native/app/__tests__/briefingServices.test.ts +26 -0
- package/src/native/app/__tests__/haptics.test.tsx +55 -0
- package/src/native/app/__tests__/launch.test.ts +23 -1
- package/src/native/app/briefingServices.ts +9 -0
- package/src/native/app/converseServices.ts +17 -5
- package/src/native/app/device.ts +7 -0
- package/src/native/app/launch.ts +24 -0
- package/src/native/app/registry.tsx +6 -1
- package/src/native/app/services.ts +2 -2
- package/src/native/briefing/__tests__/playerPauseResume.test.ts +47 -0
- package/src/native/briefing/audioPlayer.ts +16 -1
- package/src/native/converse/ConverseScreen.tsx +45 -78
- package/src/native/converse/__tests__/bargeInIO.test.ts +49 -0
- package/src/native/converse/__tests__/liveScreen.test.tsx +59 -63
- package/src/native/converse/__tests__/meetingIO.test.ts +89 -23
- package/src/native/converse/__tests__/mock.test.ts +58 -0
- package/src/native/converse/__tests__/speedScreen.test.tsx +6 -2
- package/src/native/converse/index.ts +4 -1
- package/src/native/converse/io.ts +34 -20
- package/src/native/converse/mock.ts +136 -0
- package/src/native/converse/stateBanner.tsx +41 -0
- package/src/native/index.ts +1 -0
- package/src/native/push/NeedsYouCard.tsx +11 -7
- package/src/native/push/__tests__/decisionsApp.test.tsx +2 -3
- package/src/native/push/__tests__/needsYou.test.tsx +23 -9
- package/src/native/push/fake.ts +5 -5
- package/src/native/recording/recorder.ts +2 -1
- package/src/native/recording/recorderAudio.ts +14 -1
- package/src/native/talk/TalkTab.tsx +16 -13
- package/src/native/talk/__tests__/talk-tab.test.tsx +18 -0
- package/src/native/voice-session/__tests__/bargeIn.test.ts +93 -0
- package/src/native/voice-session/__tests__/bindings.test.ts +84 -0
- package/src/native/voice-session/__tests__/events.test.ts +72 -0
- package/src/native/voice-session/__tests__/inspector.test.ts +28 -0
- package/src/native/voice-session/__tests__/lifecycle.test.ts +197 -0
- package/src/native/voice-session/__tests__/music.test.ts +86 -0
- package/src/native/voice-session/__tests__/routes.test.ts +121 -0
- package/src/native/voice-session/__tests__/voiceSession.test.ts +177 -0
- package/src/native/voice-session/bindMeeting.ts +33 -0
- package/src/native/voice-session/fake.ts +21 -0
- package/src/native/voice-session/index.ts +142 -0
- package/src/native/voice-session/inspector.ts +14 -0
- package/src/native/voice-session/machine.ts +41 -0
- package/src/native/voice-session/nowPlaying.ts +35 -0
- package/src/native/voice-session/types.ts +45 -0
- package/src/native/voice-session/wire.ts +47 -0
- package/src/native/converse/DriveScreen.tsx +0 -47
- package/src/native/converse/__tests__/driveScreen.test.tsx +0 -54
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `-tgVoiceMock <scenario>`: the audio-free test path. The meeting loop, the shared utterance detector, VoiceSession and the
|
|
3
|
+
* real AVAudioSession all run on the phone; only the two edges are replaced:
|
|
4
|
+
* - the microphone: scripted synthetic levels (dB) fed to the recorder's `onLevel`, on a timeline, so "the person speaks"
|
|
5
|
+
* is data, never sound from a speaker;
|
|
6
|
+
* - the reply player: a muted player that reports `playing` for the reply's duration and plays nothing.
|
|
7
|
+
* Every scripted edge is logged (`mock.*`) on the phone's clock, so the harness asserts timing (reply cut off within N ms of
|
|
8
|
+
* the interjection) from the event list.
|
|
9
|
+
*
|
|
10
|
+
* What this proves: the state machine and the loop's decisions (speech start/end, barge-in cut-off, no barge-in from a quiet
|
|
11
|
+
* level while playing, mic reopen). What only real acoustics prove (NOT covered): echo cancellation, speaker-to-mic leakage at
|
|
12
|
+
* volume, route changes, other apps' audio, Bluetooth. Those stay listed as unproven.
|
|
13
|
+
*/
|
|
14
|
+
import type { PlaybackSource, PlayerState } from '../briefing/audioPlayer';
|
|
15
|
+
import type { RecorderAudio } from '../recording/recorder';
|
|
16
|
+
import type { MeetingSpeaker } from './io';
|
|
17
|
+
|
|
18
|
+
export interface MockTurn {
|
|
19
|
+
/** The person starts speaking this long after the mic opens for the turn. */
|
|
20
|
+
sayAfterMs: number;
|
|
21
|
+
sayMs: number;
|
|
22
|
+
/** The muted reply plays this long unless something stops it. */
|
|
23
|
+
replyMs: number;
|
|
24
|
+
/** Speech starting this long after the reply starts (a barge-in), lasting `interjectMs`. */
|
|
25
|
+
interjectAfterMs?: number;
|
|
26
|
+
interjectMs?: number;
|
|
27
|
+
/** A steady level (dB) heard on the mic while the reply plays: the reply leaking in. Must NOT count as speech. */
|
|
28
|
+
echoDb?: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const SPEECH_DB = -14;
|
|
32
|
+
export const SILENCE_DB = -80;
|
|
33
|
+
const TICK_MS = 50;
|
|
34
|
+
|
|
35
|
+
export const MOCK_SCENARIOS: Record<string, MockTurn[]> = {
|
|
36
|
+
/** A long reply nobody interrupts: room to background the app or change state while it plays. */
|
|
37
|
+
'long-reply': [{ sayAfterMs: 1500, sayMs: 1500, replyMs: 40_000 }],
|
|
38
|
+
/** One turn, nobody interrupts. */
|
|
39
|
+
plain: [{ sayAfterMs: 1500, sayMs: 1500, replyMs: 3000 }],
|
|
40
|
+
/** The person talks over a long reply 2.5 s in: it must stop within 3 s, the mic stays open and what follows is heard. */
|
|
41
|
+
'barge-in': [{ sayAfterMs: 1500, sayMs: 1500, replyMs: 20_000, interjectAfterMs: 2500, interjectMs: 1500 }],
|
|
42
|
+
/** A quiet steady level while the reply plays (the reply's own echo): the reply must play to its end, with no barge-in. */
|
|
43
|
+
'echo-only': [{ sayAfterMs: 1500, sayMs: 1500, replyMs: 6000, echoDb: -30 }],
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export interface MockLog { log(event: string, fields?: Record<string, unknown>): void }
|
|
47
|
+
|
|
48
|
+
export function readMockScenario(name: string): MockTurn[] | null {
|
|
49
|
+
return MOCK_SCENARIOS[name] ?? null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function createMockVoice(deps: { turns: MockTurn[]; diag: MockLog; now?: () => number; setInterval?: typeof setInterval; clearInterval?: typeof clearInterval; setTimeout?: typeof setTimeout; clearTimeout?: typeof clearTimeout }) {
|
|
53
|
+
const now = deps.now ?? Date.now;
|
|
54
|
+
const every = deps.setInterval ?? setInterval;
|
|
55
|
+
const stopEvery = deps.clearInterval ?? clearInterval;
|
|
56
|
+
const later = deps.setTimeout ?? setTimeout;
|
|
57
|
+
const cancel = deps.clearTimeout ?? clearTimeout;
|
|
58
|
+
const log = (event: string, fields?: Record<string, unknown>) => deps.diag.log(`mock.${event}`, fields);
|
|
59
|
+
|
|
60
|
+
const turns: Array<MockTurn & { said?: boolean }> = deps.turns.map((t) => ({ ...t }));
|
|
61
|
+
let turn = 0;
|
|
62
|
+
/** Scripted speech: absolute [from, to) windows on the phone clock. */
|
|
63
|
+
const windows: Array<{ from: number; to: number; kind: 'say' | 'interject'; started?: boolean; ended?: boolean }> = [];
|
|
64
|
+
let playingSince: number | null = null;
|
|
65
|
+
let echoDb: number | null = null;
|
|
66
|
+
|
|
67
|
+
const level = (t: number): number => {
|
|
68
|
+
let speech = false;
|
|
69
|
+
for (const w of windows) {
|
|
70
|
+
if (t >= w.from && t < w.to) {
|
|
71
|
+
speech = true;
|
|
72
|
+
if (!w.started) { w.started = true; log(`${w.kind}-start`, { turn }); }
|
|
73
|
+
} else if (t >= w.to && w.started && !w.ended) { w.ended = true; log(`${w.kind}-end`, { turn }); }
|
|
74
|
+
}
|
|
75
|
+
if (speech) return SPEECH_DB;
|
|
76
|
+
return playingSince !== null && echoDb !== null ? echoDb : SILENCE_DB;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
let timer: ReturnType<typeof setInterval> | null = null;
|
|
80
|
+
const audio: RecorderAudio = {
|
|
81
|
+
async start(handlers) {
|
|
82
|
+
const t = now();
|
|
83
|
+
const cur = turns[turn];
|
|
84
|
+
// The turn's utterance is scheduled once, at the first time the mic opens while no reply plays and nothing is pending.
|
|
85
|
+
if (cur && playingSince === null && !windows.some((w) => w.to > t) && !cur.said) {
|
|
86
|
+
cur.said = true;
|
|
87
|
+
windows.push({ from: t + cur.sayAfterMs, to: t + cur.sayAfterMs + cur.sayMs, kind: 'say' });
|
|
88
|
+
}
|
|
89
|
+
if (timer) stopEvery(timer);
|
|
90
|
+
timer = every(() => handlers.onLevel(level(now())), TICK_MS);
|
|
91
|
+
log('mic-open', { turn });
|
|
92
|
+
return { echoCancelled: true };
|
|
93
|
+
},
|
|
94
|
+
async stop() {
|
|
95
|
+
if (timer) { stopEvery(timer); timer = null; }
|
|
96
|
+
log('mic-close', { turn });
|
|
97
|
+
// A file with bytes: the loop sends it to the (fake) assistant.
|
|
98
|
+
return { uri: `fake://mock-utterance-${turn}`, durationMs: 1800, bytes: 1 };
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
let state: PlayerState = { phase: 'idle', positionMillis: 0, durationMillis: 0 };
|
|
103
|
+
const subs = new Set<(s: PlayerState) => void>();
|
|
104
|
+
let endTimer: ReturnType<typeof setTimeout> | null = null;
|
|
105
|
+
const set = (s: PlayerState) => { state = s; subs.forEach((cb) => { try { cb(s); } catch { /* a listener must not break the player */ } }); };
|
|
106
|
+
|
|
107
|
+
const finish = (why: 'ended' | 'stopped') => {
|
|
108
|
+
if (playingSince === null) return;
|
|
109
|
+
const playedMs = now() - playingSince;
|
|
110
|
+
playingSince = null;
|
|
111
|
+
echoDb = null;
|
|
112
|
+
if (endTimer) { cancel(endTimer); endTimer = null; }
|
|
113
|
+
log('reply-stop', { why, playedMs, turn });
|
|
114
|
+
turn += 1;
|
|
115
|
+
set({ phase: why === 'ended' ? 'ended' : 'idle', positionMillis: playedMs, durationMillis: playedMs });
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const speaker: MeetingSpeaker = {
|
|
119
|
+
getState: () => state,
|
|
120
|
+
subscribe(cb) { subs.add(cb); return () => { subs.delete(cb); }; },
|
|
121
|
+
async play(_source: PlaybackSource) {
|
|
122
|
+
const cur = turns[turn] ?? { sayAfterMs: 0, sayMs: 0, replyMs: 2000 };
|
|
123
|
+
const t = now();
|
|
124
|
+
playingSince = t;
|
|
125
|
+
echoDb = cur.echoDb ?? null;
|
|
126
|
+
if (cur.interjectAfterMs !== undefined) windows.push({ from: t + cur.interjectAfterMs, to: t + cur.interjectAfterMs + (cur.interjectMs ?? 1500), kind: 'interject' });
|
|
127
|
+
log('reply-start', { turn, replyMs: cur.replyMs, interjectAfterMs: cur.interjectAfterMs ?? null });
|
|
128
|
+
set({ phase: 'playing', positionMillis: 0, durationMillis: cur.replyMs });
|
|
129
|
+
endTimer = later(() => finish('ended'), cur.replyMs);
|
|
130
|
+
},
|
|
131
|
+
async stop() { finish('stopped'); },
|
|
132
|
+
async handoffToRecording() { /* nothing to hand over: no real playback */ },
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
return { audio, speaker };
|
|
136
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Text as RNText, View } from 'react-native';
|
|
2
|
+
import { useTheme } from '@startsimpli/ui-native';
|
|
3
|
+
import type { MeetingPhase } from '../../corpus/converse/meeting';
|
|
4
|
+
|
|
5
|
+
/** The device's drive audio: take the session for a conversation (mix with the car's music, duck it while the reply speaks, screen awake) and give it back. */
|
|
6
|
+
export interface DriveAudio {
|
|
7
|
+
begin(): Promise<void>;
|
|
8
|
+
end(): Promise<void>;
|
|
9
|
+
/** Where route/port lines go (the app's diagnostics.json). */
|
|
10
|
+
setLog?(fn: (event: string, fields?: Record<string, unknown>) => void): void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type StateWord = 'LISTENING' | 'SPEAKING' | 'THINKING' | 'SAVING' | 'MIC OFF' | 'READY' | 'PROBLEM';
|
|
14
|
+
|
|
15
|
+
/** The word glanced at from a car. `micOn` false while a conversation runs means the mic is muted. */
|
|
16
|
+
export function stateWord(s: { phase: MeetingPhase; micOn: boolean; error: string | null }): StateWord {
|
|
17
|
+
if (s.error) return 'PROBLEM';
|
|
18
|
+
switch (s.phase) {
|
|
19
|
+
case 'speaking': return 'SPEAKING';
|
|
20
|
+
case 'thinking': return 'THINKING';
|
|
21
|
+
case 'ending': return 'SAVING';
|
|
22
|
+
case 'listening': return s.micOn ? 'LISTENING' : 'MIC OFF';
|
|
23
|
+
default: return 'READY';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Saturated fields with white text (>= 5:1), the same in light and dark so the state reads across the car. */
|
|
28
|
+
export const STATE_TONE: Record<StateWord, string> = {
|
|
29
|
+
LISTENING: '#0B6E3A', SPEAKING: '#1D4ED8', THINKING: '#9A4A06', SAVING: '#374151', 'MIC OFF': '#374151', READY: '#374151', PROBLEM: '#B91C1C',
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/** The status banner at the top of Talk: one big word. */
|
|
33
|
+
export function StateBanner({ word, detail }: { word: StateWord; detail?: string | null }) {
|
|
34
|
+
const theme = useTheme();
|
|
35
|
+
return (
|
|
36
|
+
<View testID="converse-banner" style={{ backgroundColor: STATE_TONE[word], paddingVertical: theme.spacing.md, paddingHorizontal: theme.spacing.lg, alignItems: 'center', gap: theme.spacing.xs }}>
|
|
37
|
+
<RNText testID="converse-status" accessibilityLiveRegion="polite" adjustsFontSizeToFit numberOfLines={1} style={{ color: '#FFFFFF', fontSize: 44, fontWeight: '800', letterSpacing: 2 }}>{word}</RNText>
|
|
38
|
+
{detail ? <RNText testID="converse-error" style={{ color: '#FFFFFF', fontSize: 18, textAlign: 'center' }}>{detail}</RNText> : null}
|
|
39
|
+
</View>
|
|
40
|
+
);
|
|
41
|
+
}
|
package/src/native/index.ts
CHANGED
|
@@ -17,6 +17,7 @@ export { FoundryTabsShell, type FoundryTab, type FoundryTabsShellProps, type Tab
|
|
|
17
17
|
export * from './recording';
|
|
18
18
|
export * from './briefing';
|
|
19
19
|
export * from './converse';
|
|
20
|
+
export * from './voice-session';
|
|
20
21
|
export * from './push';
|
|
21
22
|
export * from './app';
|
|
22
23
|
export * from './shell/navigator';
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
import { Pressable, Text as RNText, View } from 'react-native';
|
|
3
|
-
import {
|
|
3
|
+
import { useTheme } from '@startsimpli/ui-native';
|
|
4
4
|
import type { QueuedItem } from '../../corpus/attention/types';
|
|
5
5
|
import { useControllerState } from '../components/useControllerState';
|
|
6
6
|
import type { NeedsYouController } from './needsYou';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* What is waiting on you: ONE queue read from the server, drawn on Talk and on Decisions. A decision row opens its card;
|
|
10
|
-
* the
|
|
10
|
+
* tapping the Talk mic opens the conversation with the briefing when anything waits. Each row says who asked. Answered items leave on the next read (Talk re-reads as the thread grows); hidden when nothing waits.
|
|
11
11
|
*/
|
|
12
|
-
export function NeedsYouCard({ needsYou, active = true,
|
|
12
|
+
export function NeedsYouCard({ needsYou, active = true, onOpenDecision }: { needsYou: NeedsYouController; active?: boolean; onOpenDecision?: (decisionId: string) => void }) {
|
|
13
13
|
const theme = useTheme();
|
|
14
14
|
const s = useControllerState({ getState: needsYou.getState, subscribe: needsYou.subscribe });
|
|
15
15
|
useEffect(() => { if (active) void needsYou.refresh(); }, [needsYou, active]);
|
|
16
16
|
const items = (s.queue?.items ?? []).filter((i) => i.class === 'urgent' || i.class === 'needs-answer');
|
|
17
17
|
if (!s.queue || !items.length) return null;
|
|
18
|
-
const row = (i: QueuedItem, n: number) => {
|
|
18
|
+
const row = (i: QueuedItem, n: number, all: QueuedItem[]) => {
|
|
19
|
+
// Who asked is said once per run of the same source, not on every row.
|
|
20
|
+
const showFrom = n === 0 || all[n - 1].source !== i.source;
|
|
19
21
|
const body = (
|
|
20
22
|
<View style={{ flexDirection: 'row', alignItems: 'flex-start', gap: theme.spacing.sm }}>
|
|
21
23
|
{i.class === 'urgent' ? (
|
|
@@ -23,7 +25,10 @@ export function NeedsYouCard({ needsYou, active = true, onTalk, onOpenDecision }
|
|
|
23
25
|
<RNText style={{ color: '#FFFFFF', fontSize: theme.fontSizes.xs ?? 11, fontWeight: '700' }}>URGENT</RNText>
|
|
24
26
|
</View>
|
|
25
27
|
) : null}
|
|
26
|
-
<
|
|
28
|
+
<View style={{ flex: 1 }}>
|
|
29
|
+
{showFrom ? <RNText testID={`needs-you-from-${n}`} style={{ color: theme.colors.mutedForeground, fontSize: theme.fontSizes.xs ?? 11 }}>{i.source === 'fleet' ? 'Asked by your agents' : 'A decision waiting on you'}</RNText> : null}
|
|
30
|
+
<RNText testID={`needs-you-${n}`} numberOfLines={2} style={{ color: theme.colors.foreground, fontSize: theme.fontSizes.sm }}>{i.text}</RNText>
|
|
31
|
+
</View>
|
|
27
32
|
</View>
|
|
28
33
|
);
|
|
29
34
|
return i.ref && onOpenDecision
|
|
@@ -35,8 +40,7 @@ export function NeedsYouCard({ needsYou, active = true, onTalk, onOpenDecision }
|
|
|
35
40
|
<RNText testID="needs-you-title" style={{ color: theme.colors.foreground, fontSize: theme.fontSizes.base, fontWeight: '600' }}>
|
|
36
41
|
{items.length === 1 ? '1 thing needs you' : `${items.length} things need you`}
|
|
37
42
|
</RNText>
|
|
38
|
-
{items.slice(0, 5).map(row)}
|
|
39
|
-
{onTalk ? <Button testID="needs-you-talk" title="Talk it through" size="sm" onPress={() => onTalk()} /> : null}
|
|
43
|
+
{items.slice(0, 5).map((i, n, all) => row(i, n, all))}
|
|
40
44
|
</View>
|
|
41
45
|
);
|
|
42
46
|
}
|
|
@@ -66,15 +66,14 @@ describe('Decisions over the fakes', () => {
|
|
|
66
66
|
expect(hostById(r, 'converse-screen')).toBeTruthy();
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
-
it('a tapped urgent / call-me push opens Talk
|
|
69
|
+
it('a tapped urgent / call-me push opens Talk already listening', async () => {
|
|
70
70
|
open({} as never);
|
|
71
71
|
const talkConfig = { ...(config as object), tabs: [{ screen: 'record' }, { screen: 'talk' }, { screen: 'decisions' }] } as never;
|
|
72
72
|
const r = render(<FoundryApp config={talkConfig} device={device()} />);
|
|
73
73
|
await tick();
|
|
74
74
|
await act(async () => { taps.cb?.({ kind: 'attention', ping_id: 'q-fake0001' }); await new Promise((res) => setTimeout(res, 150)); });
|
|
75
75
|
expect(hostById(r, 'talk-screen')).toBeTruthy();
|
|
76
|
-
expect(hostById(r, '
|
|
77
|
-
expect(hostById(r, 'drive-state')).toBeTruthy();
|
|
76
|
+
expect(hostById(r, 'converse-mic')).toBeTruthy();
|
|
78
77
|
});
|
|
79
78
|
|
|
80
79
|
it('the list shows the pending decision and the notifications switch is on', async () => {
|
|
@@ -14,35 +14,49 @@ const IDLE = { phase: 'idle', retryable: false, lines: [], error: null, noAudio:
|
|
|
14
14
|
const ctx = (over: Partial<TabContext> = {}): TabContext => ({ tab: 'talk', active: true, route: null, push: vi.fn(), back: vi.fn(), openTab: vi.fn(), ...over });
|
|
15
15
|
|
|
16
16
|
describe('needs-you on the Talk tab', () => {
|
|
17
|
-
it('shows what is waiting, urgent first, and
|
|
18
|
-
let started = 0;
|
|
17
|
+
it('shows what is waiting, urgent first, and the Talk mic (no separate button) makes the assistant itself open with the briefing', async () => {
|
|
18
|
+
let started = 0; let began = 0; let mics = 0;
|
|
19
19
|
const typed: string[] = [];
|
|
20
|
-
const controller = { start() {}, end: async () => null, sendText: async (t: string) => { typed.push(t); }, startBriefing: async () => { started += 1; }, dismissNotice() {}, getState: () => IDLE, subscribe: () => () => undefined } as unknown as MeetingController;
|
|
20
|
+
const controller = { start() { began += 1; }, mic() { mics += 1; }, end: async () => null, sendText: async (t: string) => { typed.push(t); }, startBriefing: async () => { started += 1; }, dismissNotice() {}, getState: () => IDLE, subscribe: () => () => undefined } as unknown as MeetingController;
|
|
21
21
|
const needsYou = createNeedsYouController({ client: createFakeNotify().client });
|
|
22
22
|
const r = render(<>{talkTab({ api: createFakeNativeCorpusApi(), converse: controller, needsYou }).render(ctx())}</>);
|
|
23
23
|
await tick();
|
|
24
|
-
|
|
25
|
-
expect(
|
|
26
|
-
|
|
24
|
+
// Talk has NO pinned card: what waits on him is spoken and lives in the thread, once.
|
|
25
|
+
expect(r.root.findAllByProps({ testID: 'needs-you' })).toHaveLength(0);
|
|
26
|
+
expect(r.root.findAllByProps({ testID: 'needs-you-talk' })).toHaveLength(0);
|
|
27
|
+
await act(async () => { r.root.findByProps({ testID: 'converse-mic' }).props.onPress(); });
|
|
28
|
+
expect(began).toBe(1);
|
|
27
29
|
expect(started).toBe(1);
|
|
30
|
+
expect(mics).toBe(0);
|
|
28
31
|
expect(typed).toEqual([]); // the card text is never posted as something he said
|
|
29
32
|
});
|
|
30
33
|
|
|
31
|
-
it('a tapped attention push
|
|
34
|
+
it('a tapped attention push opens Talk already listening, with the briefing speaking', async () => {
|
|
32
35
|
let started = 0; let began = 0;
|
|
33
36
|
const controller = { start() { began += 1; }, end: async () => null, sendText: async () => undefined, startBriefing: async () => { started += 1; }, dismissNotice() {}, getState: () => IDLE, subscribe: () => () => undefined } as unknown as MeetingController;
|
|
34
37
|
const needsYou = createNeedsYouController({ client: createFakeNotify().client });
|
|
35
38
|
const r = render(<>{talkTab({ api: createFakeNativeCorpusApi(), converse: controller, needsYou }).render(ctx())}</>);
|
|
36
39
|
await tick();
|
|
37
|
-
expect(
|
|
40
|
+
expect(began).toBe(0);
|
|
38
41
|
await act(async () => { needsYou.requestBriefing(); });
|
|
39
42
|
await tick();
|
|
40
|
-
expect(r.root.findAllByProps({ testID: 'drive-screen' })
|
|
43
|
+
expect(r.root.findAllByProps({ testID: 'drive-screen' })).toHaveLength(0); // no separate mode: it is the Talk screen
|
|
41
44
|
expect(began).toBe(1);
|
|
42
45
|
expect(started).toBe(1);
|
|
43
46
|
expect(needsYou.getState().briefRequested).toBe(false);
|
|
44
47
|
});
|
|
45
48
|
|
|
49
|
+
it('with nothing waiting the mic just listens (no briefing)', async () => {
|
|
50
|
+
let started = 0; const mics: boolean[] = [];
|
|
51
|
+
const empty = { needsYou: async () => ({ items: [], counts: { urgent: 0, 'needs-answer': 0, digest: 0, noise: 0 }, callMe: false, waiting: 0 }) };
|
|
52
|
+
const controller = { start() {}, mic(on: boolean) { mics.push(on); }, end: async () => null, sendText: async () => undefined, startBriefing: async () => { started += 1; }, dismissNotice() {}, getState: () => IDLE, subscribe: () => () => undefined } as unknown as MeetingController;
|
|
53
|
+
const r = render(<>{talkTab({ api: createFakeNativeCorpusApi(), converse: controller, needsYou: createNeedsYouController({ client: empty }) }).render(ctx())}</>);
|
|
54
|
+
await tick();
|
|
55
|
+
await act(async () => { r.root.findByProps({ testID: 'converse-mic' }).props.onPress(); });
|
|
56
|
+
expect(mics).toEqual([true]);
|
|
57
|
+
expect(started).toBe(0);
|
|
58
|
+
});
|
|
59
|
+
|
|
46
60
|
it('draws nothing when nothing is waiting', async () => {
|
|
47
61
|
const empty = { needsYou: async () => ({ items: [], counts: { urgent: 0, 'needs-answer': 0, digest: 0, noise: 0 }, callMe: false, waiting: 0 }) };
|
|
48
62
|
const controller = { start() {}, end: async () => null, sendText: async () => undefined, dismissNotice() {}, getState: () => IDLE, subscribe: () => () => undefined } as unknown as MeetingController;
|
package/src/native/push/fake.ts
CHANGED
|
@@ -6,7 +6,7 @@ export function createFakeNotify(): { client: NotifyClient; registered: string[]
|
|
|
6
6
|
let push = true;
|
|
7
7
|
let attention: AttentionSettings = { quiet_mode: 'off', quiet: { enabled: true, start: 22, end: 7, timeZone: 'America/Los_Angeles' }, quiet_active: false, urgent_words: [], call_me_at: 3, brief_hour: 8, wrap_hour: 18, notify_scope: 'decisions+fleet' };
|
|
8
8
|
const decision: DecisionRecord = {
|
|
9
|
-
id: 'dec-1', title: '
|
|
9
|
+
id: 'dec-1', title: 'TEST SAMPLE: which colour first?', status: 'pending', created_at: '2026-11-13T12:00:00Z',
|
|
10
10
|
questions: [{ n: 1, text: 'Ship the Siri Shortcut build now?', options: ['Yes', 'Not yet'] }, { n: 2, text: 'Anything to change first?' }],
|
|
11
11
|
answers: [],
|
|
12
12
|
};
|
|
@@ -23,11 +23,11 @@ export function createFakeNotify(): { client: NotifyClient; registered: string[]
|
|
|
23
23
|
setAttention: async (patch) => { attention = { ...attention, ...patch, quiet: { ...attention.quiet, ...patch.quiet } } as AttentionSettings; attention.quiet_active = attention.quiet_mode === 'on'; return attention; },
|
|
24
24
|
needsYou: async () => ({
|
|
25
25
|
items: [
|
|
26
|
-
{ id: 'q-fake0001', text: 'TEST:
|
|
27
|
-
{ id: 'q-fake0002', text: '
|
|
28
|
-
{ id: 'q-fake0003', text: decision.title, source: 'decision', class: 'needs-answer' },
|
|
26
|
+
{ id: 'q-fake0001', text: 'TEST SAMPLE: pick a colour', source: 'fleet', class: 'needs-answer', importance: 50 },
|
|
27
|
+
{ id: 'q-fake0002', text: 'TEST SAMPLE: approve the sample report', source: 'fleet', class: 'needs-answer', importance: 50 },
|
|
28
|
+
{ id: 'q-fake0003', text: decision.title, source: 'decision', class: 'needs-answer', importance: 60 },
|
|
29
29
|
],
|
|
30
|
-
counts: { urgent:
|
|
30
|
+
counts: { urgent: 0, 'needs-answer': 3, digest: 0, noise: 0 }, callMe: true, waiting: 3,
|
|
31
31
|
}),
|
|
32
32
|
};
|
|
33
33
|
return { client, registered: [] };
|
|
@@ -11,7 +11,8 @@ export interface StoppedRecording {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export interface RecorderAudio {
|
|
14
|
-
|
|
14
|
+
/** Resolves with what the recorder knows about itself: `echoCancelled: false` = voice processing did not turn on (a reply would leak into the mic). */
|
|
15
|
+
start(handlers: { onLevel: (db: number) => void }): Promise<void | { echoCancelled?: boolean }>;
|
|
15
16
|
/** Resolves only when the file is finalized on disk. */
|
|
16
17
|
stop(): Promise<StoppedRecording>;
|
|
17
18
|
}
|
|
@@ -16,7 +16,8 @@ export interface AudioDriver {
|
|
|
16
16
|
prepare(): Promise<void>;
|
|
17
17
|
record(): void;
|
|
18
18
|
stop(): Promise<void>;
|
|
19
|
-
|
|
19
|
+
/** `voiceProcessing`: the echo-cancelling input is really on (only a Converse utterance asks for it). */
|
|
20
|
+
status(): { url: string | null; durationMillis: number; metering?: number; isRecording: boolean; voiceProcessing?: boolean };
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
export interface SessionInfo {
|
|
@@ -25,6 +26,12 @@ export interface SessionInfo {
|
|
|
25
26
|
options: string[];
|
|
26
27
|
sampleRate: number;
|
|
27
28
|
inputs: Array<{ type: string; name: string }>;
|
|
29
|
+
/** Read back for device runs (absent from older native builds). */
|
|
30
|
+
outputs?: Array<{ type: string; name: string }>;
|
|
31
|
+
otherAudioPlaying?: boolean;
|
|
32
|
+
secondaryAudioShouldBeSilencedHint?: boolean;
|
|
33
|
+
/** Title/rate/elapsed of the lock-screen entry, or null when none is registered. */
|
|
34
|
+
nowPlaying?: { title?: string; artist?: string; rate?: number; elapsed?: number } | null;
|
|
28
35
|
}
|
|
29
36
|
|
|
30
37
|
/** AVAudioSession facts and events (real binding: the local foundry-audio-session module). */
|
|
@@ -32,6 +39,8 @@ export interface SessionInspector {
|
|
|
32
39
|
info(): Promise<SessionInfo>;
|
|
33
40
|
onInterruption(cb: (e: { type: 'began' | 'ended'; shouldResume?: boolean }) => void): () => void;
|
|
34
41
|
onRouteChange(cb: (e: { reason: string; inputs?: SessionInfo['inputs'] }) => void): () => void;
|
|
42
|
+
/** Device runs: write a JPEG of the app's window to `fileUri` (resolves false when it could not). Absent on older native builds. */
|
|
43
|
+
snapshot?(fileUri: string): Promise<boolean>;
|
|
35
44
|
}
|
|
36
45
|
|
|
37
46
|
const RECORD_CATEGORIES = ['playAndRecord', 'record'];
|
|
@@ -151,6 +160,10 @@ export function createRecorderAudio(deps: {
|
|
|
151
160
|
onLevel(db);
|
|
152
161
|
}
|
|
153
162
|
}, POLL_MS));
|
|
163
|
+
// Only an explicit `false` (a recorder that asked for voice processing and did not get it) switches voice barge-in off.
|
|
164
|
+
const vp = deps.driver.status().voiceProcessing;
|
|
165
|
+
if (vp === false && deps.kind === 'transient') { deps.diag.log('audio.no-voice-processing', {}); return { echoCancelled: false }; }
|
|
166
|
+
return { echoCancelled: vp === true ? true : undefined };
|
|
154
167
|
},
|
|
155
168
|
|
|
156
169
|
async stop(): Promise<StoppedRecording> {
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import { useEffect, useMemo
|
|
1
|
+
import { useEffect, useMemo } from 'react';
|
|
2
2
|
import { useControllerState } from '../components/useControllerState';
|
|
3
3
|
import { View } from 'react-native';
|
|
4
|
-
import { Button, Header } from '@startsimpli/ui-native';
|
|
5
4
|
import { TAB_COPY } from '../../corpus/nav-copy';
|
|
6
5
|
import { projectIdOf } from '../../corpus/ask-projects';
|
|
7
6
|
import type { MeetingController } from '../../corpus/converse/meeting';
|
|
8
7
|
import type { FoundryTab, TabContext } from '../components/FoundryTabsShell';
|
|
9
8
|
import type { NativeCorpusApi } from '../corpus/api';
|
|
10
9
|
import { ConverseScreen } from '../converse/ConverseScreen';
|
|
11
|
-
import {
|
|
10
|
+
import type { DriveAudio } from '../converse/stateBanner';
|
|
12
11
|
import type { SpeedStore } from '../converse/speed';
|
|
13
|
-
import { NeedsYouCard } from '../push/NeedsYouCard';
|
|
14
12
|
import type { NeedsYouController } from '../push/needsYou';
|
|
15
13
|
import { AskScreen } from '../screens/ask/AskScreen';
|
|
16
14
|
import { createAskController } from '../screens/ask/controller';
|
|
@@ -22,6 +20,10 @@ export interface TalkTabOptions {
|
|
|
22
20
|
/** Absent when `features.converse` is off: Talk is then Ask alone. */
|
|
23
21
|
converse?: MeetingController | null;
|
|
24
22
|
speed?: SpeedStore | null;
|
|
23
|
+
/** The device's drive audio session, held while a conversation runs; absent: the default session. */
|
|
24
|
+
drive?: DriveAudio | null;
|
|
25
|
+
/** Start the conversation as soon as Talk opens (`-tgDrive 1`). */
|
|
26
|
+
startInDrive?: boolean;
|
|
25
27
|
key?: string;
|
|
26
28
|
label?: string;
|
|
27
29
|
/** What is waiting on the person; drawn above the thread when anything is. Absent when notifications are off. */
|
|
@@ -37,29 +39,30 @@ function TalkBody({ opts, ctx }: { opts: TalkTabOptions; ctx: TabContext }) {
|
|
|
37
39
|
// Answers given in a briefing leave the queue: re-read it as the thread grows.
|
|
38
40
|
const lineCount = useControllerState(converse ? { getState: () => converse.getState().lines.length, subscribe: (l: () => void) => converse.subscribe(l) } : { getState: () => 0, subscribe: () => () => undefined });
|
|
39
41
|
useEffect(() => { if (lineCount > 0) void opts.needsYou?.refresh(); }, [lineCount, opts.needsYou]);
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
+
// Read what waits on him whenever Talk comes on screen (the mic's first tap opens with the briefing when something does).
|
|
43
|
+
useEffect(() => { if (ctx.active) void opts.needsYou?.refresh(); }, [ctx.active, opts.needsYou]);
|
|
44
|
+
// `-tgDrive 1`: start listening as soon as Talk opens.
|
|
45
|
+
useEffect(() => { if (opts.startInDrive && converse) converse.start(); }, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
46
|
+
// Anything waiting on him: the first tap on the mic opens with the briefing instead of just listening.
|
|
47
|
+
const waiting = useControllerState(opts.needsYou ? { getState: () => (opts.needsYou!.getState().queue?.items ?? []).some((i) => i.class === 'urgent' || i.class === 'needs-answer'), subscribe: (l: () => void) => opts.needsYou!.subscribe(l) } : { getState: () => false, subscribe: () => () => undefined });
|
|
42
48
|
const briefRequested = useControllerState(opts.needsYou ? { getState: () => opts.needsYou!.getState().briefRequested, subscribe: (l: () => void) => opts.needsYou!.subscribe(l) } : { getState: () => false, subscribe: () => () => undefined });
|
|
43
49
|
useEffect(() => {
|
|
44
50
|
if (!briefRequested || !converse) return;
|
|
45
51
|
opts.needsYou?.clearBriefRequest();
|
|
46
|
-
|
|
52
|
+
// A tapped attention push opens Talk already listening, with the briefing speaking.
|
|
47
53
|
converse.start();
|
|
48
54
|
void converse.startBriefing();
|
|
49
55
|
}, [briefRequested, converse, opts.needsYou]);
|
|
50
56
|
const ask = useMemo(() => (converse ? null : createAskController({ api: api.ask, scope: api.scope, listProjects: async () => (await api.corpus.listFocusChoices?.()) ?? [] })), [api, converse]);
|
|
51
|
-
if (drive && converse) return <View style={{ flex: 1 }} testID="talk-screen"><DriveScreen controller={converse} onExit={() => setDrive(false)} /></View>;
|
|
52
57
|
return (
|
|
53
58
|
<View style={{ flex: 1 }} testID="talk-screen">
|
|
54
|
-
|
|
55
|
-
{/* ONE conversation: notes, questions, to-dos and the relay all go through the same thread, no modes. */}
|
|
56
|
-
{converse && opts.needsYou ? <NeedsYouCard needsYou={opts.needsYou} active={ctx.active} onTalk={() => void converse.startBriefing()} /> : null}
|
|
57
|
-
{converse ? <Button testID="talk-drive" title="Drive mode: hands-free" variant="outline" size="sm" onPress={() => { setDrive(true); converse.start(); }} /> : null}
|
|
59
|
+
{/* ONE conversation: notes, questions, to-dos, the relay and what waits on him all live in the same thread, once: no pinned card. */}
|
|
58
60
|
{converse ? (
|
|
59
61
|
<ConverseScreen
|
|
60
62
|
controller={converse}
|
|
61
63
|
speed={speed ?? undefined}
|
|
62
|
-
|
|
64
|
+
drive={opts.drive ?? undefined}
|
|
65
|
+
briefOnTalk={waiting}
|
|
63
66
|
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); }}
|
|
64
67
|
/>
|
|
65
68
|
) : ask ? (
|
|
@@ -35,6 +35,24 @@ describe('Talk tab', () => {
|
|
|
35
35
|
expect(has(r, 'ask-composer-input')).toBe(false);
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
+
it('has no second mode: no Drive button, no top title or subtitle, no Voice/Text pills', async () => {
|
|
39
|
+
const { controller } = idleMeeting();
|
|
40
|
+
const r = render(<>{talkTab({ api: createFakeNativeCorpusApi(), converse: controller }).render(ctx())}</>);
|
|
41
|
+
await tick();
|
|
42
|
+
for (const gone of ['talk-drive', 'talk-header', 'drive-screen', 'converse-mode-voice', 'converse-mode-text']) expect(has(r, gone)).toBe(false);
|
|
43
|
+
expect(allText(r)).not.toContain(TAB_COPY.talk.subtitle);
|
|
44
|
+
expect(has(r, 'converse-status')).toBe(false); // no status bar: the mic shows the state
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('startInDrive starts the conversation as soon as Talk opens', async () => {
|
|
48
|
+
const { controller } = idleMeeting();
|
|
49
|
+
let started = 0;
|
|
50
|
+
(controller as unknown as { start: () => void }).start = () => { started += 1; };
|
|
51
|
+
render(<>{talkTab({ api: createFakeNativeCorpusApi(), converse: controller, startInDrive: true }).render(ctx())}</>);
|
|
52
|
+
await tick();
|
|
53
|
+
expect(started).toBe(1);
|
|
54
|
+
});
|
|
55
|
+
|
|
38
56
|
it('without a meeting controller Talk is Ask alone', async () => {
|
|
39
57
|
const r = render(<>{talkTab({ api: createFakeNativeCorpusApi(), converse: null }).render(ctx())}</>);
|
|
40
58
|
await tick();
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// @vitest-environment node
|
|
2
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
3
|
+
import { createMeetingController, type MeetingApi, type MeetingIO } from '../../../corpus/converse';
|
|
4
|
+
import { bindMeeting } from '../bindMeeting';
|
|
5
|
+
import { createVoiceSession, type SessionProfile } from '../index';
|
|
6
|
+
import { createFakeNativeSession } from '../fake';
|
|
7
|
+
|
|
8
|
+
const blob = () => new Blob([new Uint8Array([1])], { type: 'audio/mp4' });
|
|
9
|
+
const settle = async (check: () => boolean) => { for (let i = 0; i < 300 && !check(); i += 1) await new Promise((r) => setTimeout(r, 5)); };
|
|
10
|
+
|
|
11
|
+
/** A real meeting (duplex io) bound to a real VoiceSession over the fake native layer. */
|
|
12
|
+
function rig() {
|
|
13
|
+
let n = 0;
|
|
14
|
+
const client: MeetingApi<Blob> = {
|
|
15
|
+
turn: vi.fn(async () => { n += 1; return { conversation_id: 'c1', turn_id: `t${n}`, turn: n, transcript: `said ${n}`, reply_text: `reply ${n}`, audio_url: `/a/${n}`, audio_reason: null }; }),
|
|
16
|
+
end: vi.fn(async () => ({ saved: true as const, conversation_id: 'c1', record_id: '1', turns: n, asks: [], decisions: [] })) as never,
|
|
17
|
+
};
|
|
18
|
+
const heard: Array<{ hooks?: { onSpeechStart?: () => void }; deliver: (a: Blob | null) => void }> = [];
|
|
19
|
+
const io: MeetingIO<Blob> = {
|
|
20
|
+
duplex: true,
|
|
21
|
+
listen: (signal, _c, hooks) => new Promise((resolve) => {
|
|
22
|
+
heard.push({ hooks, deliver: (a) => resolve(a ? { audio: a } : { audio: null }) });
|
|
23
|
+
signal.addEventListener('abort', () => resolve({ audio: null, cancelled: true }));
|
|
24
|
+
}),
|
|
25
|
+
speak: (_r, signal) => new Promise<void>((resolve) => signal.addEventListener('abort', () => resolve())),
|
|
26
|
+
};
|
|
27
|
+
const native = createFakeNativeSession();
|
|
28
|
+
const voice = createVoiceSession({ native, log: vi.fn() });
|
|
29
|
+
const c = createMeetingController({ client, io });
|
|
30
|
+
bindMeeting(c, voice);
|
|
31
|
+
const toSpeaking = async () => {
|
|
32
|
+
c.start();
|
|
33
|
+
await settle(() => heard.length >= 1);
|
|
34
|
+
heard[0].deliver(blob());
|
|
35
|
+
await settle(() => c.state().phase === 'speaking');
|
|
36
|
+
await settle(() => heard.length >= 2);
|
|
37
|
+
await voice.settled();
|
|
38
|
+
};
|
|
39
|
+
const applies = () => native.calls.filter((x) => x[0] === 'apply').map((x) => x[1] as SessionProfile);
|
|
40
|
+
return { c, voice, native, heard, toSpeaking, applies };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
describe('barge-in drives VoiceSession speaking -> hearing (startsim-1x6kv.7)', () => {
|
|
44
|
+
it('speaking holds the duck; the voice over the reply moves to hearing, lifts the duck and keeps the session', async () => {
|
|
45
|
+
const r = rig();
|
|
46
|
+
await r.toSpeaking();
|
|
47
|
+
expect(r.voice.state).toBe('speaking');
|
|
48
|
+
expect(r.applies().at(-1)?.duckOthers).toBe(true);
|
|
49
|
+
r.heard[1].hooks?.onSpeechStart?.();
|
|
50
|
+
await settle(() => r.voice.state !== 'speaking');
|
|
51
|
+
await r.voice.settled();
|
|
52
|
+
expect(r.voice.state).toBe('hearing');
|
|
53
|
+
expect(r.applies().at(-1)?.duckOthers).toBe(false);
|
|
54
|
+
expect(r.native.calls.some((x) => x[0] === 'release')).toBe(false);
|
|
55
|
+
await r.c.end();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('the person goes on talking: hearing -> thinking, then the next reply speaks', async () => {
|
|
59
|
+
const r = rig();
|
|
60
|
+
await r.toSpeaking();
|
|
61
|
+
r.heard[1].hooks?.onSpeechStart?.();
|
|
62
|
+
await settle(() => r.voice.state === 'hearing');
|
|
63
|
+
expect(r.voice.state).toBe('hearing');
|
|
64
|
+
r.heard[1].deliver(blob());
|
|
65
|
+
await settle(() => r.voice.state === 'speaking');
|
|
66
|
+
expect(r.voice.state).toBe('speaking');
|
|
67
|
+
await r.c.end();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('a cough that cut the reply off ends in listening, never stuck in hearing', async () => {
|
|
71
|
+
const r = rig();
|
|
72
|
+
await r.toSpeaking();
|
|
73
|
+
r.heard[1].hooks?.onSpeechStart?.();
|
|
74
|
+
await settle(() => r.voice.state === 'hearing');
|
|
75
|
+
expect(r.voice.state).toBe('hearing');
|
|
76
|
+
r.heard[1].deliver(null); // the take was noise: dropped, listening resumes
|
|
77
|
+
await settle(() => r.voice.state === 'listening');
|
|
78
|
+
expect(r.voice.state).toBe('listening');
|
|
79
|
+
await r.c.end();
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('the Interrupt tap leaves speaking for listening with the duck lifted and the session held', async () => {
|
|
83
|
+
const r = rig();
|
|
84
|
+
await r.toSpeaking();
|
|
85
|
+
r.c.stop();
|
|
86
|
+
await settle(() => r.voice.state === 'listening');
|
|
87
|
+
await r.voice.settled();
|
|
88
|
+
expect(r.voice.state).toBe('listening');
|
|
89
|
+
expect(r.applies().at(-1)?.duckOthers).toBe(false);
|
|
90
|
+
expect(r.native.calls.some((x) => x[0] === 'release')).toBe(false);
|
|
91
|
+
await r.c.end();
|
|
92
|
+
});
|
|
93
|
+
});
|