@startsimpli/integrations 0.2.226 → 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 +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 +1 -1
- 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/converse/DriveScreen.tsx +0 -47
- package/src/native/converse/__tests__/driveScreen.test.tsx +0 -54
|
@@ -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: [] };
|
|
@@ -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();
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { Pressable, Text as RNText, View } from 'react-native';
|
|
2
|
-
import { useTheme } from '@startsimpli/ui-native';
|
|
3
|
-
import { useControllerState } from '../components/useControllerState';
|
|
4
|
-
import type { MeetingController, MeetingPhase } from '../../corpus/converse/meeting';
|
|
5
|
-
import { MEETING_DEFAULTS } from '../../corpus/converse/meeting-config';
|
|
6
|
-
|
|
7
|
-
/** The word glanced at from a car: one of three states, huge. */
|
|
8
|
-
export function driveWord(phase: MeetingPhase): 'LISTENING' | 'SPEAKING' | 'THINKING' | 'READY' | 'SAVING' {
|
|
9
|
-
switch (phase) {
|
|
10
|
-
case 'listening': return 'LISTENING';
|
|
11
|
-
case 'speaking': return 'SPEAKING';
|
|
12
|
-
case 'thinking': return 'THINKING';
|
|
13
|
-
case 'ending': return 'SAVING';
|
|
14
|
-
default: return 'READY';
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* DRIVE mode: nothing to tap per turn. It listens all the time, you can talk over it, and it heals itself when something sticks.
|
|
20
|
-
* One control: Start (idle), Interrupt (while it speaks or thinks), End (while it listens). Big state word, big last line.
|
|
21
|
-
*/
|
|
22
|
-
export function DriveScreen({ controller, onExit, assistantName = MEETING_DEFAULTS.assistantName }: { controller: MeetingController; onExit?: () => void; assistantName?: string }) {
|
|
23
|
-
const theme = useTheme();
|
|
24
|
-
const s = useControllerState({ getState: controller.getState, subscribe: (l: () => void) => controller.subscribe(l) });
|
|
25
|
-
const word = driveWord(s.phase);
|
|
26
|
-
const idle = word === 'READY' || s.phase === 'ended' || s.phase === 'stopped';
|
|
27
|
-
const talking = s.phase === 'speaking' || s.phase === 'thinking';
|
|
28
|
-
const last = [...s.lines].reverse().find((l) => l.role === 'assistant' || l.role === 'relay');
|
|
29
|
-
const color = word === 'LISTENING' ? theme.colors.success ?? theme.colors.primary : word === 'SPEAKING' ? theme.colors.primary : word === 'THINKING' ? theme.colors.mutedForeground : theme.colors.foreground;
|
|
30
|
-
const label = idle ? 'Start' : talking ? 'Interrupt' : 'End';
|
|
31
|
-
const press = () => { if (idle) controller.start(); else if (talking) controller.stop(); else void controller.end(); };
|
|
32
|
-
return (
|
|
33
|
-
<View testID="drive-screen" style={{ flex: 1, padding: theme.spacing.lg, gap: theme.spacing.lg, justifyContent: 'space-between' }}>
|
|
34
|
-
<View style={{ alignItems: 'center', gap: theme.spacing.md }}>
|
|
35
|
-
<RNText testID="drive-state" accessibilityLiveRegion="polite" style={{ color, fontSize: 56, fontWeight: '800', letterSpacing: 2 }}>{idle && s.phase !== 'stopped' ? 'READY' : word}</RNText>
|
|
36
|
-
{s.error ? <RNText testID="drive-error" style={{ color: theme.colors.destructive, fontSize: 22, textAlign: 'center' }}>{s.error}</RNText> : null}
|
|
37
|
-
</View>
|
|
38
|
-
<RNText testID="drive-line" style={{ color: theme.colors.foreground, fontSize: 30, lineHeight: 40, textAlign: 'center' }} numberOfLines={8}>{last?.text ?? `${assistantName} here. Tap Start, then just talk.`}</RNText>
|
|
39
|
-
<View style={{ gap: theme.spacing.md }}>
|
|
40
|
-
<Pressable testID="drive-control" accessibilityRole="button" accessibilityLabel={label} onPress={press} style={{ minHeight: 120, borderRadius: 60, backgroundColor: idle ? theme.colors.primary : talking ? theme.colors.destructive : theme.colors.muted, alignItems: 'center', justifyContent: 'center' }}>
|
|
41
|
-
<RNText style={{ color: idle || talking ? theme.colors.primaryForeground : theme.colors.foreground, fontSize: 36, fontWeight: '800' }}>{label}</RNText>
|
|
42
|
-
</Pressable>
|
|
43
|
-
{onExit && idle ? <Pressable testID="drive-exit" accessibilityRole="button" onPress={onExit}><RNText style={{ color: theme.colors.mutedForeground, fontSize: 18, textAlign: 'center' }}>Back to Talk</RNText></Pressable> : null}
|
|
44
|
-
</View>
|
|
45
|
-
</View>
|
|
46
|
-
);
|
|
47
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
-
|
|
3
|
-
vi.mock('react-native', async () => ({ ...(await import('../../../../../ui-native/test/rn-stub')) }));
|
|
4
|
-
|
|
5
|
-
import { act, hostById, maybeById, render } from '../../../../../ui-native/test/render';
|
|
6
|
-
import type { MeetingController } from '../../../corpus/converse/meeting';
|
|
7
|
-
import { DriveScreen } from '../DriveScreen';
|
|
8
|
-
|
|
9
|
-
const make = (phase: string, lines: unknown[] = [{ role: 'assistant', text: 'Question 1 of 2: TEST SAMPLE. Yes or no?' }]) => {
|
|
10
|
-
const state = { phase, micOn: phase !== 'idle', retryable: false, lines, error: null, noAudio: null, conversationId: 'c1', saved: null, relayNotice: null, micLive: true };
|
|
11
|
-
const calls = { start: 0, end: 0, stop: 0 };
|
|
12
|
-
const controller = {
|
|
13
|
-
start() { calls.start += 1; }, stop() { calls.stop += 1; }, mic() {}, end: async () => { calls.end += 1; return null; },
|
|
14
|
-
getState: () => state, state: () => state, subscribe: () => () => undefined,
|
|
15
|
-
} as unknown as MeetingController;
|
|
16
|
-
return { controller, calls };
|
|
17
|
-
};
|
|
18
|
-
const text = (r: ReturnType<typeof render>, id: string) => String(hostById(r, id).props.children ?? '');
|
|
19
|
-
|
|
20
|
-
describe('Drive screen: one control, one big word', () => {
|
|
21
|
-
it.each([['listening', 'LISTENING'], ['thinking', 'THINKING'], ['speaking', 'SPEAKING']])('%s shows %s', (phase, word) => {
|
|
22
|
-
const r = render(<DriveScreen controller={make(phase).controller} />);
|
|
23
|
-
expect(text(r, 'drive-state')).toBe(word);
|
|
24
|
-
});
|
|
25
|
-
it('shows the last assistant line in big text', () => {
|
|
26
|
-
const r = render(<DriveScreen controller={make('speaking').controller} />);
|
|
27
|
-
expect(text(r, 'drive-line')).toContain('Question 1 of 2');
|
|
28
|
-
});
|
|
29
|
-
it('idle: the one control starts the drive; running: it interrupts when speaking and ends otherwise', async () => {
|
|
30
|
-
const idle = make('idle', []);
|
|
31
|
-
const r = render(<DriveScreen controller={idle.controller} />);
|
|
32
|
-
await act(async () => { hostById(r, 'drive-control').props.onPress(); });
|
|
33
|
-
expect(idle.calls.start).toBe(1);
|
|
34
|
-
const talking = make('speaking');
|
|
35
|
-
const r2 = render(<DriveScreen controller={talking.controller} />);
|
|
36
|
-
await act(async () => { hostById(r2, 'drive-control').props.onPress(); });
|
|
37
|
-
expect(talking.calls.stop).toBe(1);
|
|
38
|
-
const quiet = make('listening');
|
|
39
|
-
const r3 = render(<DriveScreen controller={quiet.controller} />);
|
|
40
|
-
await act(async () => { hostById(r3, 'drive-control').props.onPress(); });
|
|
41
|
-
expect(quiet.calls.end).toBe(1);
|
|
42
|
-
});
|
|
43
|
-
it('idle greets by the configured assistant name, default Roci', () => {
|
|
44
|
-
const r = render(<DriveScreen controller={make('idle', []).controller} />);
|
|
45
|
-
expect(text(r, 'drive-line')).toContain('Roci here');
|
|
46
|
-
const r2 = render(<DriveScreen controller={make('idle', []).controller} assistantName="Pip" />);
|
|
47
|
-
expect(text(r2, 'drive-line')).toContain('Pip here');
|
|
48
|
-
});
|
|
49
|
-
it('has no text box, no speed row, no Voice/Text switch', () => {
|
|
50
|
-
const r = render(<DriveScreen controller={make('listening').controller} />);
|
|
51
|
-
expect(maybeById(r, 'converse-input')).toHaveLength(0);
|
|
52
|
-
expect(maybeById(r, 'converse-speed')).toHaveLength(0);
|
|
53
|
-
});
|
|
54
|
-
});
|