@startsimpli/integrations 0.2.226 → 0.2.228
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__/attention-orgs.test.ts +61 -0
- package/src/__tests__/attention-run.test.ts +3 -3
- package/src/__tests__/converse-meeting-vad.test.ts +25 -3
- package/src/__tests__/converse-meeting.test.ts +29 -0
- package/src/__tests__/converse-soak.test.ts +28 -0
- package/src/__tests__/converse.test.ts +23 -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 +7 -2
- package/src/corpus/converse/meeting-config.ts +8 -2
- package/src/corpus/converse/meeting.ts +5 -3
- package/src/corpus/converse/respond.ts +2 -2
- 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 +3 -3
- package/src/native/app/__tests__/launch.test.ts +4 -1
- package/src/native/app/converseServices.ts +2 -1
- package/src/native/app/device.ts +3 -0
- package/src/native/app/launch.ts +4 -0
- package/src/native/app/registry.tsx +6 -1
- package/src/native/briefing/audioPlayer.ts +2 -1
- package/src/native/converse/ConverseScreen.tsx +45 -78
- package/src/native/converse/__tests__/bargeInIO.test.ts +3 -0
- package/src/native/converse/__tests__/liveScreen.test.tsx +59 -63
- package/src/native/converse/__tests__/speedScreen.test.tsx +6 -2
- package/src/native/converse/index.ts +2 -1
- package/src/native/converse/stateBanner.tsx +41 -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/talk/TalkTab.tsx +16 -13
- package/src/native/talk/__tests__/talk-tab.test.tsx +18 -0
- package/src/native/voice-session/__tests__/inspector.test.ts +9 -0
- package/src/native/voice-session/inspector.ts +3 -1
- package/src/native/converse/DriveScreen.tsx +0 -47
- package/src/native/converse/__tests__/driveScreen.test.tsx +0 -54
|
@@ -150,7 +150,7 @@ function Root({ config, device, registry }: { config: FoundryAppConfig; device:
|
|
|
150
150
|
const recordRef = useRef<ReactNode>(record);
|
|
151
151
|
recordRef.current = record;
|
|
152
152
|
const tabs = useMemo(
|
|
153
|
-
() => buildFoundryTabs({ config: appConfig, corpus: data.corpus, notes: data.notes, record: () => recordRef.current, member: data.member, itemsChanged: services.briefing?.itemsChanged, briefing: services.briefing ? { controller: services.briefing.controller, reply: services.briefing.reply } : null, strings, converse: services.converse?.controller ?? null, converseSpeed: services.converse?.speed ?? null, notify: services.notify, openUrl: data.openUrl ?? ((url) => Linking.openURL(url)) }, registry),
|
|
153
|
+
() => buildFoundryTabs({ config: appConfig, corpus: data.corpus, notes: data.notes, record: () => recordRef.current, member: data.member, itemsChanged: services.briefing?.itemsChanged, briefing: services.briefing ? { controller: services.briefing.controller, reply: services.briefing.reply } : null, strings, converse: services.converse?.controller ?? null, converseSpeed: services.converse?.speed ?? null, converseDrive: services.converse?.drive ?? null, startInDrive: launch.drive, notify: services.notify, openUrl: data.openUrl ?? ((url) => Linking.openURL(url)) }, registry),
|
|
154
154
|
[appConfig, data, registry],
|
|
155
155
|
);
|
|
156
156
|
|
|
@@ -201,10 +201,10 @@ function Root({ config, device, registry }: { config: FoundryAppConfig; device:
|
|
|
201
201
|
useEffect(() => {
|
|
202
202
|
const snap = device.recording?.session.snapshot;
|
|
203
203
|
if (!launch.shotEveryMs || !snap || auth !== 'signedIn') return undefined;
|
|
204
|
-
const shoot = () => {
|
|
204
|
+
const shoot = () => { const uri = device.documentUri(`shots/${Date.now()}.jpg`); void snap(uri).then((ok) => services.diag.log('shot.result', { ok }), (e: unknown) => services.diag.log('shot.result', { ok: false, error: String(e) })); };
|
|
205
205
|
const t = setInterval(shoot, launch.shotEveryMs);
|
|
206
206
|
return () => clearInterval(t);
|
|
207
|
-
}, [launch, device, auth]);
|
|
207
|
+
}, [launch, device, auth, services]);
|
|
208
208
|
useEffect(() => {
|
|
209
209
|
if (!nav) return undefined;
|
|
210
210
|
services.bindOpen((tab, id) => nav.open(tab, id ? { id } : null));
|
|
@@ -7,7 +7,10 @@ const args = (o: Record<string, string>) => (k: string) => o[k];
|
|
|
7
7
|
|
|
8
8
|
describe('readLaunch', () => {
|
|
9
9
|
it('a plain launch is real mode with nothing to open', () => {
|
|
10
|
-
expect(readLaunch(args({}), config)).toEqual({ fake: false, scenario: 'normal', target: null, autostop: null, scheme: null, hapticProbe: false, voiceAuto: false, voiceMock: null, devLogin: false, audioProbeMs: null, shotEveryMs: null, fakeBriefing: false, fakeConverse: false, fakeConverseSound: false, fakeReply: [] });
|
|
10
|
+
expect(readLaunch(args({}), config)).toEqual({ fake: false, scenario: 'normal', target: null, autostop: null, scheme: null, hapticProbe: false, voiceAuto: false, voiceMock: null, devLogin: false, audioProbeMs: null, shotEveryMs: null, fakeBriefing: false, fakeConverse: false, fakeConverseSound: false, drive: false, fakeReply: [] });
|
|
11
|
+
});
|
|
12
|
+
it('-tgDrive 1 opens Talk in drive mode', () => {
|
|
13
|
+
expect(readLaunch(args({ tgDrive: '1' }), config).drive).toBe(true);
|
|
11
14
|
});
|
|
12
15
|
it('-tgFakeTabs with -tgTab and -tgDetail', () => {
|
|
13
16
|
expect(readLaunch(args({ tgFakeTabs: '1', tgTab: 'tracker', tgDetail: 'c1' }), config)).toMatchObject({ fake: true, target: { tab: 'tracker', id: 'c1' } });
|
|
@@ -55,6 +55,7 @@ export function createConverse(deps: {
|
|
|
55
55
|
onInterrupted: () => broken?.(),
|
|
56
56
|
onInterruptionEnded: () => undefined,
|
|
57
57
|
});
|
|
58
|
+
device.drive?.setLog?.((e, f) => diag.log(e, f));
|
|
58
59
|
const permissions = createPermissionFlow({ perms: rec.permissions, openSettings: rec.openSettings, log: diag.log });
|
|
59
60
|
|
|
60
61
|
const mockTurns = deps.voiceMock ? readMockScenario(deps.voiceMock) : null;
|
|
@@ -78,5 +79,5 @@ export function createConverse(deps: {
|
|
|
78
79
|
onChange: (s) => diag.log('meeting.state', { phase: s.phase, micLive: s.micLive, error: s.error, noAudio: s.noAudio, hearing: s.hearing, lines: s.lines.length }),
|
|
79
80
|
});
|
|
80
81
|
if (device.voiceSession) bindMeeting(controller, device.voiceSession);
|
|
81
|
-
return { controller, player, speed };
|
|
82
|
+
return { controller, player, speed, drive: device.drive ?? null };
|
|
82
83
|
}
|
package/src/native/app/device.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { SecretStore } from '../recording/session';
|
|
2
|
+
import type { DriveAudio } from '../converse/stateBanner';
|
|
2
3
|
import type { AudioDriver, SessionInspector } from '../recording/recorderAudio';
|
|
3
4
|
import type { BackgroundTasks } from '../recording/lifecycle';
|
|
4
5
|
import type { PermissionsApi } from '../recording/permissions';
|
|
@@ -62,6 +63,8 @@ export interface FoundryDevice {
|
|
|
62
63
|
briefing?: BriefingDevice;
|
|
63
64
|
/** Push (expo-notifications in the template): permission, APNs token, notification taps. Without it the Decisions tab still works, there are just no pushes. */
|
|
64
65
|
push?: PushDevice;
|
|
66
|
+
/** Drive mode's audio session (mix with the car's music, duck it while the reply speaks, screen awake). Without it drive mode still works on the default session. */
|
|
67
|
+
drive?: DriveAudio;
|
|
65
68
|
/** The one owner of the audio session. With it, Converse's meeting drives the session (duck only while Roci speaks, released when the meeting ends). */
|
|
66
69
|
voiceSession?: import('../voice-session').VoiceSession;
|
|
67
70
|
}
|
package/src/native/app/launch.ts
CHANGED
|
@@ -14,6 +14,7 @@ import type { FoundryAppConfig } from './config/types';
|
|
|
14
14
|
* -tgFakeBriefing 1 'What's on the plate' plays a bundled clip over a fixed briefing: no server, no sign-in (add -tgFakeTabs 1)
|
|
15
15
|
* -tgFakeReply "a|b" what the fake reply 'hears' on each hold-to-talk, in order (needs -tgFakeBriefing); default "move this one to later"
|
|
16
16
|
* -tgFakeConverse 1 the Converse tab talks to a scripted assistant: no server, no sign-in (add -tgFakeTabs 1)
|
|
17
|
+
* -tgDrive 1 the Talk tab opens in drive mode (one control, big LISTENING / SPEAKING / THINKING banner)
|
|
17
18
|
* -tgFakeConverseSound 1 with -tgFakeConverse: speak the replies with the bundled clip (audible: opt-in only)
|
|
18
19
|
* -tgHapticProbe 1 fire one haptic per interaction through the real engine; the diagnostics log shows each call and the engine's answer
|
|
19
20
|
* -tgVoiceAuto 1 after sign-in, turn the Talk mic on (starts a voice session) without a tap: unattended audio device runs
|
|
@@ -40,6 +41,8 @@ export interface LaunchArgs {
|
|
|
40
41
|
fakeConverse: boolean;
|
|
41
42
|
/** `-tgFakeConverseSound 1`: the fake assistant's replies are spoken with the bundled clip. Off by default so simulator runs are silent. */
|
|
42
43
|
fakeConverseSound: boolean;
|
|
44
|
+
/** `-tgDrive 1`: open Talk straight in drive mode. */
|
|
45
|
+
drive: boolean;
|
|
43
46
|
/** `-tgVoiceAuto 1`: start the Talk voice session by itself once signed in (device audio harness). */
|
|
44
47
|
voiceAuto: boolean;
|
|
45
48
|
/** `-tgVoiceMock <name>`: scripted mic + muted reply player (see converse/mock.ts). */
|
|
@@ -73,6 +76,7 @@ export function readLaunch(get: (key: string) => unknown, config: Pick<FoundryAp
|
|
|
73
76
|
autostop: Number.isFinite(n) && n > 0 ? n : null,
|
|
74
77
|
fakeConverse: str('tgFakeConverse') === '1',
|
|
75
78
|
fakeConverseSound: str('tgFakeConverseSound') === '1',
|
|
79
|
+
drive: str('tgDrive') === '1',
|
|
76
80
|
hapticProbe: str('tgHapticProbe') === '1',
|
|
77
81
|
voiceAuto: str('tgVoiceAuto') === '1',
|
|
78
82
|
voiceMock: str('tgVoiceMock') || null,
|
|
@@ -20,6 +20,7 @@ import type { FoundryStrings } from './strings';
|
|
|
20
20
|
import { TAB_COPY } from '../../corpus/nav-copy';
|
|
21
21
|
import type { MeetingController } from '../../corpus/converse/meeting';
|
|
22
22
|
import { converseTab } from '../converse/tab';
|
|
23
|
+
import type { DriveAudio } from '../converse/stateBanner';
|
|
23
24
|
import type { SpeedStore } from '../converse/speed';
|
|
24
25
|
import { decisionsTab } from '../push/tab';
|
|
25
26
|
import type { AttentionController } from '../../corpus/attention/controller';
|
|
@@ -50,6 +51,10 @@ export interface ScreenDeps {
|
|
|
50
51
|
converse?: MeetingController | null;
|
|
51
52
|
/** How fast Converse replies are spoken; null/absent hides the control. */
|
|
52
53
|
converseSpeed?: SpeedStore | null;
|
|
54
|
+
/** Drive mode's device audio (null: drive mode runs on the default session). */
|
|
55
|
+
converseDrive?: DriveAudio | null;
|
|
56
|
+
/** `-tgDrive 1`: the Talk tab opens straight in drive mode. */
|
|
57
|
+
startInDrive?: boolean;
|
|
53
58
|
/** Decisions and push; null when `features.notifications` is off. */
|
|
54
59
|
notify?: { decisions: DecisionsController; push: PushController; needsYou?: NeedsYouController; attention?: AttentionController } | null;
|
|
55
60
|
itemsChanged?: { subscribe(listener: () => void): () => void };
|
|
@@ -97,7 +102,7 @@ export const BUILTIN_FACTORIES: Record<string, ScreenFactory> = {
|
|
|
97
102
|
},
|
|
98
103
|
tracker: ({ config, corpus, member, openUrl, itemsChanged }, tab) => trackerTab({ api: corpus, itemsChanged, key: tab.key, label: tabLabel(tab), notesKey: firstKey(config, 'notes'), memberConnections: member.connections, openUrl }),
|
|
99
104
|
plan: ({ config, corpus, member, openUrl, itemsChanged }, tab) => planTab({ api: corpus, key: tab.key, label: tabLabel(tab), notesKey: firstKey(config, 'notes'), documentTab: firstKey(config, 'library'), memberConnections: member.connections, openUrl, itemsChanged }),
|
|
100
|
-
talk: ({ config, corpus, converse, converseSpeed, notify }, tab) => talkTab({ api: corpus, converse, speed: converseSpeed, needsYou: notify?.needsYou, key: tab.key, label: tabLabel(tab), libraryKey: firstKey(config, 'library'), planKey: firstKey(config, 'plan') }),
|
|
105
|
+
talk: ({ config, corpus, converse, converseSpeed, converseDrive, startInDrive, notify }, tab) => talkTab({ api: corpus, converse, speed: converseSpeed, drive: converseDrive, startInDrive, needsYou: notify?.needsYou, key: tab.key, label: tabLabel(tab), libraryKey: firstKey(config, 'library'), planKey: firstKey(config, 'plan') }),
|
|
101
106
|
library: ({ config, corpus }, tab) => libraryTab(corpus, { key: tab.key, label: tabLabel(tab), planKey: firstKey(config, 'plan') }),
|
|
102
107
|
ask: ({ corpus }, tab) => askTab(corpus, { key: tab.key, label: tabLabel(tab) }),
|
|
103
108
|
planning: ({ config, corpus }, tab) => createPlanningTab({ api: corpus, key: tab.key, label: tabLabel(tab), documentTab: firstKey(config, 'library') }),
|
|
@@ -82,7 +82,8 @@ export function createAudioPlayer(deps: {
|
|
|
82
82
|
|
|
83
83
|
const guarded = <T,>(name: string, work: Promise<T>): Promise<T> => {
|
|
84
84
|
step = name;
|
|
85
|
-
|
|
85
|
+
// A reply that has not started playing in 4 s is skipped (the conversation goes on), never waited on for 8.
|
|
86
|
+
const ms = deps.stepTimeoutMs ?? (name === 'start' ? 4000 : 8000);
|
|
86
87
|
let timer: ReturnType<typeof setTimeout>;
|
|
87
88
|
const timeout = new Promise<never>((_, reject) => { timer = setTimeout(() => reject(new Error(`${name} timed out after ${ms} ms`)), ms); });
|
|
88
89
|
return Promise.race([work, timeout]).finally(() => clearTimeout(timer));
|
|
@@ -1,56 +1,56 @@
|
|
|
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, Icon, MessageBubble, Spinner, useHaptics, useTheme } from '@startsimpli/ui-native';
|
|
4
4
|
import { useControllerState } from '../components/useControllerState';
|
|
5
5
|
import type { MeetingController, MeetingLine } from '../../corpus/converse/meeting';
|
|
6
6
|
import type { ConverseSource } from '../../corpus/converse/types';
|
|
7
7
|
import { converseView } from '../../corpus/converse/view';
|
|
8
|
-
import {
|
|
8
|
+
import type { DriveAudio } from './stateBanner';
|
|
9
9
|
import { SPEEDS, speedLabel, type SpeedStore } from './speed';
|
|
10
10
|
|
|
11
11
|
const MIC = 52;
|
|
12
12
|
|
|
13
|
-
function useElapsed(on: boolean): number {
|
|
14
|
-
const [sec, setSec] = useState(0);
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
if (!on) { setSec(0); return undefined; }
|
|
17
|
-
const t0 = Date.now();
|
|
18
|
-
const h = setInterval(() => setSec(Math.floor((Date.now() - t0) / 1000)), 1000);
|
|
19
|
-
return () => clearInterval(h);
|
|
20
|
-
}, [on]);
|
|
21
|
-
return sec;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
13
|
/**
|
|
25
|
-
* ONE screen to talk to Tandem:
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
14
|
+
* ONE screen to talk to Tandem: the thread, a text box, ONE mic control
|
|
15
|
+
* and a small settings menu. NO status bar: the mic itself shows the state by colour (listening green, thinking amber, speaking blue, muted grey). The mic IS the hands-free mode: one tap listens continuously (it sends when you pause, you can
|
|
16
|
+
* talk over the reply, the controller heals a stuck turn); while the reply speaks or thinks the same control interrupts;
|
|
17
|
+
* tap again to mute. While a conversation runs the drive audio session is held (the car's music mixes and ducks).
|
|
18
|
+
* Settings holds speed, replay and Save conversation (files notes as to-dos). Leaving the tab does not end anything.
|
|
29
19
|
*/
|
|
30
|
-
export function ConverseScreen({ controller, speed,
|
|
20
|
+
export function ConverseScreen({ controller, speed, drive, briefOnTalk, onOpenSource }: { controller: MeetingController; /** Something waits on him: the first Talk tap of a fresh conversation opens with the briefing. */ briefOnTalk?: boolean; speed?: SpeedStore; /** The device's drive audio session. */ drive?: DriveAudio; /** Opens a cited source (a document or project) in its own tab. */ onOpenSource?: (source: ConverseSource) => void }) {
|
|
31
21
|
const theme = useTheme();
|
|
32
22
|
const haptic = useHaptics();
|
|
33
23
|
const s = useControllerState({ getState: controller.getState, subscribe: (l: () => void) => controller.subscribe(l) });
|
|
34
24
|
const rate = useControllerState({ getState: speed ? speed.get : () => 1, subscribe: (l: () => void) => (speed ? speed.subscribe(l) : () => undefined) });
|
|
35
25
|
const [draft, setDraft] = useState('');
|
|
26
|
+
const [menu, setMenu] = useState(false);
|
|
36
27
|
const list = useRef<FlatList<MeetingLine>>(null);
|
|
37
28
|
const lines = s.lines;
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
29
|
+
const { listening, thinking, speaking, busy } = converseView(s);
|
|
30
|
+
const running = s.phase === 'listening' || thinking || speaking;
|
|
31
|
+
// The drive audio session is held only while a conversation runs, so voice notes keep their own session.
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (!drive) return undefined;
|
|
34
|
+
if (running) void drive.begin().catch(() => undefined);
|
|
35
|
+
else void drive.end().catch(() => undefined);
|
|
36
|
+
return undefined;
|
|
37
|
+
}, [drive, running]);
|
|
38
|
+
useEffect(() => () => { void drive?.end().catch(() => undefined); }, [drive]);
|
|
39
|
+
const open = lines.length > 0 && s.phase !== 'ended';
|
|
40
|
+
const micColor = thinking ? '#9A4A06' : speaking ? '#1D4ED8' : listening ? '#0B6E3A' : open ? theme.colors.mutedForeground : theme.colors.primary;
|
|
44
41
|
|
|
45
42
|
const send = () => { const t = draft.trim(); if (!t) return; setDraft(''); haptic('light', 'converse.send'); void controller.sendText(t); };
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
// ONE control: speaking/thinking -> interrupt; listening -> mute; otherwise -> listen continuously.
|
|
44
|
+
const micLabel = thinking || speaking ? 'Interrupt' : listening ? 'Mute' : 'Talk';
|
|
45
|
+
const pressMic = () => {
|
|
46
|
+
haptic('medium', `converse.${micLabel.toLowerCase()}`);
|
|
47
|
+
if (thinking || speaking) controller.stop();
|
|
48
|
+
else if (!listening && briefOnTalk && lines.length === 0 && s.phase !== 'ending') { controller.start(); void controller.startBriefing(); }
|
|
49
|
+
else controller.mic(!listening);
|
|
49
50
|
};
|
|
50
51
|
|
|
51
52
|
return (
|
|
52
53
|
<KeyboardAvoidingView style={{ flex: 1 }} behavior={Platform.OS === 'ios' ? 'padding' : undefined} testID="converse-screen">
|
|
53
|
-
{embedded ? null : <Header testID="converse-header" title="Talk" subtitle="Talk or type to Tandem" />}
|
|
54
54
|
<FlatList
|
|
55
55
|
ref={list}
|
|
56
56
|
testID="converse-transcript"
|
|
@@ -62,7 +62,7 @@ export function ConverseScreen({ controller, speed, embedded, onOpenSource }: {
|
|
|
62
62
|
ListEmptyComponent={
|
|
63
63
|
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center', paddingHorizontal: theme.spacing.lg }}>
|
|
64
64
|
<RNText testID="converse-empty" style={{ color: theme.colors.mutedForeground, fontSize: theme.fontSizes.lg, textAlign: 'center' }}>
|
|
65
|
-
|
|
65
|
+
Tap the mic and talk, or type.
|
|
66
66
|
</RNText>
|
|
67
67
|
</View>
|
|
68
68
|
}
|
|
@@ -89,47 +89,8 @@ export function ConverseScreen({ controller, speed, embedded, onOpenSource }: {
|
|
|
89
89
|
<Alert variant="default">{`Relay: ${s.relayNotice}`}</Alert>
|
|
90
90
|
</Pressable>
|
|
91
91
|
) : null}
|
|
92
|
-
{s.error ?
|
|
93
|
-
<View testID="converse-error" style={{ alignSelf: 'stretch' }}>
|
|
94
|
-
<Alert variant="destructive">{s.error}</Alert>
|
|
95
|
-
</View>
|
|
96
|
-
) : null}
|
|
92
|
+
{s.error ? <View testID="converse-error" style={{ alignSelf: 'stretch' }}><Alert variant="destructive">{s.error}</Alert></View> : null}
|
|
97
93
|
{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}
|
|
98
|
-
{open || busy || s.phase === 'ended' ? (
|
|
99
|
-
<View testID="converse-live" style={{ flexDirection: 'row', alignItems: 'center', gap: theme.spacing.sm }}>
|
|
100
|
-
{busy || thinking ? <Spinner /> : <View style={{ width: 10, height: 10, borderRadius: 5, backgroundColor: s.phase === 'ended' ? theme.colors.mutedForeground : micColor }} />}
|
|
101
|
-
<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>
|
|
102
|
-
{s.phase === 'ended' ? null : <Button testID="converse-end" title="Done" variant="outline" size="sm" disabled={busy} onPress={() => { haptic('warning', 'converse.end'); void controller.end(); }} />}
|
|
103
|
-
</View>
|
|
104
|
-
) : null}
|
|
105
|
-
{canStop ? (
|
|
106
|
-
<Pressable
|
|
107
|
-
testID="converse-stop"
|
|
108
|
-
accessibilityRole="button"
|
|
109
|
-
accessibilityLabel="Stop"
|
|
110
|
-
onPress={() => { haptic('warning', 'converse.stop'); controller.stop(); }}
|
|
111
|
-
style={{ alignSelf: 'stretch', minHeight: MIC, borderRadius: MIC / 2, backgroundColor: theme.colors.destructive, alignItems: 'center', justifyContent: 'center', flexDirection: 'row', gap: theme.spacing.sm }}
|
|
112
|
-
>
|
|
113
|
-
<View style={{ width: 16, height: 16, borderRadius: 3, backgroundColor: theme.colors.primaryForeground }} />
|
|
114
|
-
<RNText style={{ color: theme.colors.primaryForeground, fontSize: theme.fontSizes.lg, fontWeight: '700' }}>Stop</RNText>
|
|
115
|
-
</Pressable>
|
|
116
|
-
) : null}
|
|
117
|
-
<View testID="converse-mode" style={{ flexDirection: 'row', alignSelf: 'center', gap: theme.spacing.xs }}>
|
|
118
|
-
{([['voice', 'Voice', listening], ['text', 'Text', !listening]] as const).map(([key, label, on]) => (
|
|
119
|
-
<Pressable
|
|
120
|
-
key={key}
|
|
121
|
-
testID={`converse-mode-${key}`}
|
|
122
|
-
accessibilityRole="button"
|
|
123
|
-
accessibilityLabel={key === 'voice' ? 'Talk by voice' : 'Type instead'}
|
|
124
|
-
accessibilityState={{ selected: on }}
|
|
125
|
-
disabled={busy}
|
|
126
|
-
onPress={() => { if (on) return; haptic('medium', `converse.mode-${key}`); controller.mic(key === 'voice'); }}
|
|
127
|
-
style={{ paddingHorizontal: theme.spacing.lg, paddingVertical: theme.spacing.xs, borderRadius: 999, backgroundColor: on ? theme.colors.primary : theme.colors.muted }}
|
|
128
|
-
>
|
|
129
|
-
<RNText style={{ color: on ? theme.colors.primaryForeground : theme.colors.foreground, fontSize: theme.fontSizes.sm, fontWeight: '600' }}>{label}</RNText>
|
|
130
|
-
</Pressable>
|
|
131
|
-
))}
|
|
132
|
-
</View>
|
|
133
94
|
<View style={{ flexDirection: 'row', alignItems: 'center', gap: theme.spacing.sm }}>
|
|
134
95
|
<TextInput
|
|
135
96
|
testID="converse-input"
|
|
@@ -137,7 +98,7 @@ export function ConverseScreen({ controller, speed, embedded, onOpenSource }: {
|
|
|
137
98
|
onChangeText={setDraft}
|
|
138
99
|
onSubmitEditing={send}
|
|
139
100
|
returnKeyType="send"
|
|
140
|
-
placeholder="Type
|
|
101
|
+
placeholder="Type a message"
|
|
141
102
|
placeholderTextColor={theme.colors.mutedForeground}
|
|
142
103
|
accessibilityLabel="Type a message"
|
|
143
104
|
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 }}
|
|
@@ -146,20 +107,24 @@ export function ConverseScreen({ controller, speed, embedded, onOpenSource }: {
|
|
|
146
107
|
<Pressable
|
|
147
108
|
testID="converse-mic"
|
|
148
109
|
accessibilityRole="button"
|
|
149
|
-
accessibilityLabel={
|
|
110
|
+
accessibilityLabel={micLabel}
|
|
111
|
+
accessibilityHint={thinking ? 'Thinking' : speaking ? 'Speaking' : listening ? 'Listening' : open ? 'Muted' : 'Ready'}
|
|
150
112
|
accessibilityState={{ selected: listening }}
|
|
151
113
|
disabled={busy}
|
|
152
|
-
onPress={
|
|
114
|
+
onPress={pressMic}
|
|
153
115
|
style={{ width: MIC, height: MIC, borderRadius: MIC / 2, backgroundColor: micColor, alignItems: 'center', justifyContent: 'center', opacity: busy ? 0.5 : 1 }}
|
|
154
116
|
>
|
|
155
|
-
{thinking ? <Spinner /> : <Icon name="mic" size={24} color={theme.colors.primaryForeground} />}
|
|
117
|
+
{thinking ? <Spinner /> : speaking ? <View style={{ width: 18, height: 18, borderRadius: 3, backgroundColor: theme.colors.primaryForeground }} /> : <Icon name="mic" size={24} color={theme.colors.primaryForeground} />}
|
|
118
|
+
</Pressable>
|
|
119
|
+
<Pressable testID="converse-settings" accessibilityRole="button" accessibilityLabel="Settings" accessibilityState={{ expanded: menu }} onPress={() => setMenu((m) => !m)} hitSlop={8} style={{ width: 40, height: MIC, alignItems: 'center', justifyContent: 'center' }}>
|
|
120
|
+
<Icon name="more" size={24} color={theme.colors.mutedForeground} />
|
|
156
121
|
</Pressable>
|
|
157
122
|
</View>
|
|
158
|
-
{
|
|
159
|
-
<View style={{
|
|
160
|
-
{lines.length ? <Button testID="converse-repeat" title="Replay" variant="ghost" size="sm" disabled={busy || thinking} onPress={() => { haptic('light', 'converse.replay'); void controller.replay(); }} /> : null}
|
|
123
|
+
{menu ? (
|
|
124
|
+
<View testID="converse-menu" style={{ gap: theme.spacing.sm, padding: theme.spacing.md, borderRadius: 12, backgroundColor: theme.colors.muted }}>
|
|
161
125
|
{speed ? (
|
|
162
|
-
<View testID="converse-speed" accessibilityLabel="Reply speed" style={{ flexDirection: 'row', alignItems: 'center', gap: theme.spacing.xs }}>
|
|
126
|
+
<View testID="converse-speed" accessibilityLabel="Reply speed" style={{ flexDirection: 'row', alignItems: 'center', gap: theme.spacing.xs, flexWrap: 'wrap' }}>
|
|
127
|
+
<RNText style={{ color: theme.colors.mutedForeground, fontSize: theme.fontSizes.sm }}>Voice speed</RNText>
|
|
163
128
|
{SPEEDS.map((r) => (
|
|
164
129
|
<Pressable
|
|
165
130
|
key={r}
|
|
@@ -168,13 +133,15 @@ export function ConverseScreen({ controller, speed, embedded, onOpenSource }: {
|
|
|
168
133
|
accessibilityState={{ selected: rate === r }}
|
|
169
134
|
accessibilityLabel={`Speak at ${speedLabel(r)}`}
|
|
170
135
|
onPress={() => { haptic('light', 'converse.speed'); speed.set(r); }}
|
|
171
|
-
style={{ paddingHorizontal: theme.spacing.sm, paddingVertical: theme.spacing.xs, borderRadius: 999, backgroundColor: rate === r ? theme.colors.primary : theme.colors.
|
|
136
|
+
style={{ paddingHorizontal: theme.spacing.sm, paddingVertical: theme.spacing.xs, borderRadius: 999, backgroundColor: rate === r ? theme.colors.primary : theme.colors.background }}
|
|
172
137
|
>
|
|
173
138
|
<RNText style={{ color: rate === r ? theme.colors.primaryForeground : theme.colors.foreground, fontSize: theme.fontSizes.sm, fontWeight: '600' }}>{speedLabel(r)}</RNText>
|
|
174
139
|
</Pressable>
|
|
175
140
|
))}
|
|
176
141
|
</View>
|
|
177
142
|
) : null}
|
|
143
|
+
{lines.length ? <Button testID="converse-repeat" title="Replay last reply" variant="ghost" size="sm" disabled={busy || thinking} onPress={() => { haptic('light', 'converse.replay'); setMenu(false); void controller.replay(); }} /> : null}
|
|
144
|
+
{lines.length && s.phase !== 'ended' ? <Button testID="converse-end" title="Save conversation" variant="outline" size="sm" disabled={busy} onPress={() => { haptic('warning', 'converse.end'); setMenu(false); void controller.end(); }} /> : null}
|
|
178
145
|
</View>
|
|
179
146
|
) : null}
|
|
180
147
|
</View>
|
|
@@ -22,6 +22,7 @@ describe('the reply cannot cut itself off (startsim-1x6kv.7: no echo loop)', ()
|
|
|
22
22
|
const onSpeechStart = vi.fn();
|
|
23
23
|
void r.io.listen(new AbortController().signal, r.config, { onSpeechStart });
|
|
24
24
|
await tick();
|
|
25
|
+
r.feed(-60, 300); // the detector calibrates its background on the first samples: a mic opens on room sound, not on the voice
|
|
25
26
|
r.feed(LOUD, 1500);
|
|
26
27
|
expect(onSpeechStart).not.toHaveBeenCalled();
|
|
27
28
|
});
|
|
@@ -31,6 +32,7 @@ describe('the reply cannot cut itself off (startsim-1x6kv.7: no echo loop)', ()
|
|
|
31
32
|
const onSpeechStart = vi.fn();
|
|
32
33
|
void r.io.listen(new AbortController().signal, r.config, { onSpeechStart });
|
|
33
34
|
await tick();
|
|
35
|
+
r.feed(-60, 300); // the detector calibrates its background on the first samples: a mic opens on room sound, not on the voice
|
|
34
36
|
r.feed(LOUD, 1500);
|
|
35
37
|
expect(onSpeechStart).toHaveBeenCalledTimes(1);
|
|
36
38
|
});
|
|
@@ -40,6 +42,7 @@ describe('the reply cannot cut itself off (startsim-1x6kv.7: no echo loop)', ()
|
|
|
40
42
|
const onSpeechStart = vi.fn();
|
|
41
43
|
void r.io.listen(new AbortController().signal, r.config, { onSpeechStart });
|
|
42
44
|
await tick();
|
|
45
|
+
r.feed(-60, 300); // the detector calibrates its background on the first samples: a mic opens on room sound, not on the voice
|
|
43
46
|
r.feed(LOUD, 1500);
|
|
44
47
|
expect(onSpeechStart).toHaveBeenCalledTimes(1);
|
|
45
48
|
});
|
|
@@ -2,7 +2,7 @@ import { describe, expect, it, vi } from 'vitest';
|
|
|
2
2
|
|
|
3
3
|
vi.mock('react-native', async () => ({ ...(await import('../../../../../ui-native/test/rn-stub')) }));
|
|
4
4
|
|
|
5
|
-
import { act, hostById, maybeById, render } from '../../../../../ui-native/test/render';
|
|
5
|
+
import { act, allText, hostById, maybeById, render } from '../../../../../ui-native/test/render';
|
|
6
6
|
import type { MeetingController } from '../../../corpus/converse/meeting';
|
|
7
7
|
import { ConverseScreen } from '../ConverseScreen';
|
|
8
8
|
|
|
@@ -18,46 +18,67 @@ const make = (phase: string, micPreference = false) => {
|
|
|
18
18
|
return { controller, calls, mics };
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
const word = (r: ReturnType<typeof render>) => String(hostById(r, 'converse-status').props.children);
|
|
22
|
+
const openMenu = async (r: ReturnType<typeof render>) => { await act(async () => { hostById(r, 'converse-settings').props.onPress(); }); };
|
|
23
|
+
|
|
24
|
+
describe('Talk is one flow: thread, one mic (it shows the state), text box, settings', () => {
|
|
25
|
+
it.each([['listening', 'Listening'], ['thinking', 'Thinking'], ['speaking', 'Speaking'], ['idle', 'Muted']])('%s: NO status bar; the mic itself carries the state (%s)', (phase, hint) => {
|
|
26
|
+
const { controller } = make(phase);
|
|
27
|
+
const r = render(<ConverseScreen controller={controller} />);
|
|
28
|
+
expect(maybeById(r, 'converse-banner')).toHaveLength(0);
|
|
29
|
+
expect(maybeById(r, 'state-banner')).toHaveLength(0);
|
|
30
|
+
expect(hostById(r, 'converse-mic').props.accessibilityHint).toBe(hint);
|
|
31
|
+
});
|
|
32
|
+
it('has no header title, no subtitle, no Start circle, no Voice/Text pills, no Drive button, no Done, no Stop', () => {
|
|
23
33
|
const { controller } = make('listening');
|
|
24
34
|
const r = render(<ConverseScreen controller={controller} />);
|
|
25
|
-
|
|
26
|
-
expect(hostById(r, 'converse-live')).toBeTruthy();
|
|
35
|
+
for (const gone of ['converse-header', 'converse-talk', 'converse-mode', 'converse-mode-voice', 'converse-mode-text', 'talk-drive', 'converse-end', 'converse-stop', 'converse-speed', 'converse-repeat']) expect(maybeById(r, gone)).toHaveLength(0);
|
|
27
36
|
expect(hostById(r, 'converse-line-1')).toBeTruthy();
|
|
28
|
-
expect(hostById(r, 'converse-
|
|
37
|
+
expect(hostById(r, 'converse-mic')).toBeTruthy();
|
|
38
|
+
expect(hostById(r, 'converse-input')).toBeTruthy();
|
|
39
|
+
});
|
|
40
|
+
it('the ONE mic control: Talk when off, Mute while listening, Interrupt while it speaks or thinks', async () => {
|
|
41
|
+
const off = make('idle');
|
|
42
|
+
const r0 = render(<ConverseScreen controller={off.controller} />);
|
|
43
|
+
expect(hostById(r0, 'converse-mic').props.accessibilityLabel).toBe('Talk');
|
|
44
|
+
await act(async () => { hostById(r0, 'converse-mic').props.onPress(); });
|
|
45
|
+
expect(off.mics).toEqual([true]);
|
|
46
|
+
const live = make('listening');
|
|
47
|
+
const r1 = render(<ConverseScreen controller={live.controller} />);
|
|
48
|
+
expect(hostById(r1, 'converse-mic').props.accessibilityLabel).toBe('Mute');
|
|
49
|
+
await act(async () => { hostById(r1, 'converse-mic').props.onPress(); });
|
|
50
|
+
expect(live.mics).toEqual([false]);
|
|
51
|
+
for (const phase of ['speaking', 'thinking']) {
|
|
52
|
+
const t = make(phase);
|
|
53
|
+
const r = render(<ConverseScreen controller={t.controller} />);
|
|
54
|
+
expect(hostById(r, 'converse-mic').props.accessibilityLabel).toBe('Interrupt');
|
|
55
|
+
expect(hostById(r, 'converse-mic').props.disabled).toBeFalsy();
|
|
56
|
+
await act(async () => { hostById(r, 'converse-mic').props.onPress(); });
|
|
57
|
+
expect(t.calls.stop).toBe(1);
|
|
58
|
+
}
|
|
29
59
|
});
|
|
30
|
-
it('leaving the screen does not end the meeting; only
|
|
60
|
+
it('leaving the screen does not end the meeting; only Save conversation (in settings) does', async () => {
|
|
31
61
|
const { controller, calls } = make('speaking');
|
|
32
62
|
const r = render(<ConverseScreen controller={controller} />);
|
|
33
63
|
act(() => { r.unmount(); });
|
|
34
64
|
expect(calls.end).toBe(0);
|
|
35
65
|
const r2 = render(<ConverseScreen controller={controller} />);
|
|
66
|
+
await openMenu(r2);
|
|
36
67
|
await act(async () => { hostById(r2, 'converse-end').props.onPress(); });
|
|
37
68
|
expect(calls.end).toBe(1);
|
|
38
69
|
});
|
|
39
|
-
it('
|
|
40
|
-
const { controller
|
|
41
|
-
(controller.getState() as { lines: unknown[] }).lines = [];
|
|
42
|
-
const r = render(<ConverseScreen controller={controller} />);
|
|
43
|
-
expect(maybeById(r, 'converse-talk')).toHaveLength(0);
|
|
44
|
-
expect(maybeById(r, 'converse-live')).toHaveLength(0);
|
|
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');
|
|
70
|
+
it('after it is saved, Save conversation is not offered again', async () => {
|
|
71
|
+
const { controller } = make('ended');
|
|
51
72
|
const r = render(<ConverseScreen controller={controller} />);
|
|
52
|
-
await
|
|
53
|
-
expect(
|
|
54
|
-
expect(calls.end).toBe(0);
|
|
73
|
+
await openMenu(r);
|
|
74
|
+
expect(maybeById(r, 'converse-end')).toHaveLength(0);
|
|
55
75
|
});
|
|
56
|
-
it('
|
|
57
|
-
const { controller } = make('
|
|
76
|
+
it('a problem shows as a small alert, not in a banner', () => {
|
|
77
|
+
const { controller } = make('stopped');
|
|
78
|
+
(controller.getState() as { error: string | null }).error = 'No connection';
|
|
58
79
|
const r = render(<ConverseScreen controller={controller} />);
|
|
59
|
-
expect(hostById(r, 'converse-
|
|
60
|
-
expect(
|
|
80
|
+
expect(hostById(r, 'converse-error')).toBeTruthy();
|
|
81
|
+
expect(allText(r)).toContain('No connection');
|
|
61
82
|
});
|
|
62
83
|
it('a cited source opens through onOpenSource', async () => {
|
|
63
84
|
const { controller } = make('idle');
|
|
@@ -76,49 +97,24 @@ describe('Converse while a meeting runs', () => {
|
|
|
76
97
|
expect(calls.text).toEqual(['move the car service to Friday']);
|
|
77
98
|
expect(hostById(r, 'converse-input').props.value).toBe('');
|
|
78
99
|
});
|
|
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
100
|
it('shows a quiet Filed marker after a note was filed', () => {
|
|
86
101
|
const { controller } = make('listening');
|
|
87
102
|
(controller.getState() as { lines: unknown[] }).lines = [{ role: 'user', text: 'note' }, { role: 'assistant', text: 'Got it.' }, { role: 'system', text: 'Filed: 2 to-dos' }];
|
|
88
103
|
const r = render(<ConverseScreen controller={controller} />);
|
|
89
104
|
expect(JSON.stringify(r.toJSON())).toContain('Filed: 2 to-dos');
|
|
90
105
|
});
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
await act(async () => { hostById(r, 'converse-stop').props.onPress(); });
|
|
99
|
-
expect(calls.stop).toBe(1);
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
it('Stop is not shown when nothing is being said', () => {
|
|
103
|
-
const { controller } = make('listening');
|
|
104
|
-
const r = render(<ConverseScreen controller={controller} />);
|
|
105
|
-
expect(maybeById(r, 'converse-stop')).toHaveLength(0);
|
|
106
|
-
});
|
|
107
|
-
it('the mic stays on screen and tappable while it speaks', () => {
|
|
108
|
-
const { controller } = make('speaking');
|
|
109
|
-
const r = render(<ConverseScreen controller={controller} />);
|
|
110
|
-
expect(hostById(r, 'converse-mic').props.disabled).toBeFalsy();
|
|
111
|
-
});
|
|
112
|
-
it('Text turns the mic off and Voice turns it on', async () => {
|
|
106
|
+
it('holds the drive audio session only while a conversation runs', async () => {
|
|
107
|
+
const log: string[] = [];
|
|
108
|
+
const drive = { begin: async () => { log.push('begin'); }, end: async () => { log.push('end'); } };
|
|
109
|
+
const idle = make('idle');
|
|
110
|
+
render(<ConverseScreen controller={idle.controller} drive={drive} />);
|
|
111
|
+
await act(async () => { await Promise.resolve(); });
|
|
112
|
+
expect(log).toEqual(['end']);
|
|
113
113
|
const live = make('listening');
|
|
114
|
-
const r = render(<ConverseScreen controller={live.controller} />);
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const r2 = render(<ConverseScreen controller={off.controller} />);
|
|
120
|
-
expect(hostById(r2, 'converse-mode-text').props.accessibilityState).toEqual({ selected: true });
|
|
121
|
-
await act(async () => { hostById(r2, 'converse-mode-voice').props.onPress(); });
|
|
122
|
-
expect(off.mics).toEqual([true]);
|
|
114
|
+
const r = render(<ConverseScreen controller={live.controller} drive={drive} />);
|
|
115
|
+
await act(async () => { await Promise.resolve(); });
|
|
116
|
+
expect(log.at(-1)).toBe('begin');
|
|
117
|
+
act(() => { r.unmount(); });
|
|
118
|
+
expect(log.at(-1)).toBe('end');
|
|
123
119
|
});
|
|
124
120
|
});
|
|
@@ -18,13 +18,17 @@ describe('Converse speed control', () => {
|
|
|
18
18
|
it('shows 1x 1.25x 1.5x 2x, marks the current one and changes it on tap', async () => {
|
|
19
19
|
const speed = createSpeedStore({ path: 'p', files: { exists: async () => false, read: async () => '', write: async () => undefined } });
|
|
20
20
|
const r = render(<ConverseScreen controller={controller} speed={speed} />);
|
|
21
|
+
expect(maybeById(r, 'converse-speed')).toHaveLength(0); // lives in the settings menu
|
|
22
|
+
await act(async () => { hostById(r, 'converse-settings').props.onPress(); });
|
|
21
23
|
expect(hostById(r, 'converse-speed-1.25').props.accessibilityState).toEqual({ selected: true });
|
|
22
24
|
await act(async () => { hostById(r, 'converse-speed-2').props.onPress(); });
|
|
23
25
|
expect(speed.get()).toBe(2);
|
|
24
26
|
expect(hostById(r, 'converse-speed-2').props.accessibilityState).toEqual({ selected: true });
|
|
25
27
|
expect(hostById(r, 'converse-speed-1.25').props.accessibilityState).toEqual({ selected: false });
|
|
26
28
|
});
|
|
27
|
-
it('has no control when there is no speed store', () => {
|
|
28
|
-
|
|
29
|
+
it('has no control when there is no speed store', async () => {
|
|
30
|
+
const r = render(<ConverseScreen controller={controller} />);
|
|
31
|
+
await act(async () => { hostById(r, 'converse-settings').props.onPress(); });
|
|
32
|
+
expect(maybeById(r, 'converse-speed')).toHaveLength(0);
|
|
29
33
|
});
|
|
30
34
|
});
|
|
@@ -8,6 +8,7 @@ export { SPEEDS, DEFAULT_SPEED, createSpeedStore } from './speed';
|
|
|
8
8
|
export type { SpeedStore } from './speed';
|
|
9
9
|
export { converseTab } from './tab';
|
|
10
10
|
export { statusLine } from './format';
|
|
11
|
+
export { StateBanner, stateWord } from './stateBanner';
|
|
12
|
+
export type { DriveAudio } from './stateBanner';
|
|
11
13
|
export { createMockVoice, readMockScenario, MOCK_SCENARIOS } from './mock';
|
|
12
14
|
export type { MockTurn } from './mock';
|
|
13
|
-
export { DriveScreen, driveWord } from './DriveScreen';
|
|
@@ -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
|
+
}
|