@startsimpli/integrations 0.2.179 → 0.2.180
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__/converse-handoff.test.ts +129 -0
- package/src/__tests__/converse-meeting.test.ts +41 -0
- package/src/__tests__/converse-relay.test.ts +19 -3
- package/src/__tests__/home-brief.test.tsx +12 -24
- package/src/__tests__/home-needs-your-call.test.tsx +13 -16
- package/src/__tests__/plan-shell.test.tsx +160 -0
- package/src/components/DocumentDetail.tsx +15 -4
- package/src/components/documentText.ts +24 -0
- package/src/components/index.ts +1 -0
- package/src/components/pages/LibraryPage.tsx +4 -0
- package/src/components/pages/PlanningPage.tsx +20 -10
- package/src/components/pages/TrackerPage.tsx +16 -3
- package/src/components/pages/home/DueSoonLine.tsx +28 -0
- package/src/components/pages/home/HomeBriefPage.tsx +19 -52
- package/src/components/pages/home/index.ts +1 -3
- package/src/components/pages/plan/ProjectsPage.tsx +54 -0
- package/src/components/pages/plan/TalkPage.tsx +48 -0
- package/src/components/pages/plan/TimelinePage.tsx +33 -0
- package/src/components/pages/plan/index.ts +6 -0
- package/src/corpus/converse/handle.ts +10 -3
- package/src/corpus/converse/handled-asks.ts +29 -0
- package/src/corpus/converse/handoff.ts +52 -0
- package/src/corpus/converse/index.ts +4 -2
- package/src/corpus/converse/meeting.ts +23 -7
- package/src/corpus/converse/relay.ts +8 -4
- package/src/corpus/converse/store.ts +2 -0
- package/src/corpus/converse/transcript.ts +9 -0
- package/src/corpus/converse/types.ts +14 -0
- package/src/corpus/index.ts +2 -0
- package/src/corpus/nav-copy.ts +31 -0
- package/src/corpus/view-text.ts +3 -2
- package/src/native/__tests__/design-screens.test.tsx +3 -2
- package/src/native/app/FoundryApp.tsx +1 -1
- package/src/native/app/__tests__/plan-talk-registry.test.tsx +74 -0
- package/src/native/app/briefingServices.ts +1 -0
- package/src/native/app/config/defaults.ts +8 -2
- package/src/native/app/config/types.ts +1 -1
- package/src/native/app/converseServices.ts +1 -0
- package/src/native/app/registry.tsx +26 -6
- package/src/native/app/services.ts +3 -2
- package/src/native/components/NoteDetailScreen.tsx +16 -4
- package/src/native/components/__tests__/notes-screens.test.tsx +8 -8
- package/src/native/converse/ConverseScreen.tsx +24 -5
- package/src/native/converse/__tests__/liveScreen.test.tsx +15 -2
- package/src/native/home/HomeScreen.tsx +20 -7
- package/src/native/home/controller.ts +15 -5
- package/src/native/home/tab.tsx +31 -6
- package/src/native/plan/NewProjectRow.tsx +30 -0
- package/src/native/plan/PlanTab.tsx +105 -0
- package/src/native/plan/ProjectTodos.tsx +24 -0
- package/src/native/plan/TimelineScreen.tsx +68 -0
- package/src/native/plan/__tests__/plan-tab.test.tsx +76 -0
- package/src/native/plan/index.ts +5 -0
- package/src/native/plan/timeline.ts +56 -0
- package/src/native/recording/__tests__/recorderAudio.test.ts +10 -2
- package/src/native/recording/recorderAudio.ts +6 -2
- package/src/native/screens/__tests__/tabs.test.tsx +13 -0
- package/src/native/screens/ask/AskScreen.tsx +4 -2
- package/src/native/screens/library/LibraryDetailScreen.tsx +11 -4
- package/src/native/screens/planning/PlanningScreens.tsx +30 -13
- package/src/native/screens/tabs.tsx +5 -4
- package/src/native/talk/TalkTab.tsx +62 -0
- package/src/native/talk/__tests__/talk-tab.test.tsx +57 -0
- package/src/native/tracker/TrackerListScreen.tsx +7 -3
- package/src/native/tracker/tab.tsx +33 -8
- package/src/components/pages/home/DueAcrossProjects.tsx +0 -76
- package/src/components/pages/home/RecentNotes.tsx +0 -69
|
@@ -9,9 +9,9 @@ import { ConverseScreen } from '../ConverseScreen';
|
|
|
9
9
|
const base = { retryable: false, lines: [{ role: 'user', text: 'plan my day' }, { role: 'assistant', text: 'Here is a plan' }], error: null, noAudio: null, conversationId: 'c1', saved: null, relayNotice: null };
|
|
10
10
|
const make = (phase: string) => {
|
|
11
11
|
const state = { ...base, phase };
|
|
12
|
-
const calls = { end: 0, start: 0 };
|
|
12
|
+
const calls = { end: 0, start: 0, text: [] as string[] };
|
|
13
13
|
const controller = {
|
|
14
|
-
start() { calls.start += 1; }, end: async () => { calls.end += 1; return null; }, replay: async () => {}, sendText: async () => {}, dismissNotice() {},
|
|
14
|
+
start() { calls.start += 1; }, end: async () => { calls.end += 1; return null; }, replay: async () => {}, sendText: async (t: string) => { calls.text.push(t); }, dismissNotice() {},
|
|
15
15
|
getState: () => state, state: () => state, subscribe: () => () => undefined,
|
|
16
16
|
} as unknown as MeetingController;
|
|
17
17
|
return { controller, calls };
|
|
@@ -42,4 +42,17 @@ describe('Converse while a meeting runs', () => {
|
|
|
42
42
|
await act(async () => { hostById(r, 'converse-talk').props.onPress(); });
|
|
43
43
|
expect(calls.start).toBe(1);
|
|
44
44
|
});
|
|
45
|
+
it('lets him type while a meeting runs: Send passes the text to the meeting and clears the box', async () => {
|
|
46
|
+
const { controller, calls } = make('listening');
|
|
47
|
+
const r = render(<ConverseScreen controller={controller} />);
|
|
48
|
+
expect(hostById(r, 'converse-send').props.disabled).toBe(true);
|
|
49
|
+
await act(async () => { hostById(r, 'converse-input').props.onChangeText(' move the car service to Friday '); });
|
|
50
|
+
await act(async () => { hostById(r, 'converse-send').props.onPress(); });
|
|
51
|
+
expect(calls.text).toEqual(['move the car service to Friday']);
|
|
52
|
+
expect(hostById(r, 'converse-input').props.value).toBe('');
|
|
53
|
+
});
|
|
54
|
+
it('has no text box before a meeting starts', () => {
|
|
55
|
+
const { controller } = make('idle');
|
|
56
|
+
expect(maybeById(render(<ConverseScreen controller={controller} />), 'converse-input')).toHaveLength(0);
|
|
57
|
+
});
|
|
45
58
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
1
|
+
import { useEffect, type ReactNode } from 'react';
|
|
2
2
|
import { FlatList, Pressable, RefreshControl, View } from 'react-native';
|
|
3
|
-
import { Alert, Button, EmptyState, Header, IconTile, ListRow, SectionHeader, Skeleton, StatTile, useHaptics, useTheme } from '@startsimpli/ui-native';
|
|
3
|
+
import { Alert, Button, EmptyState, Text, Header, IconTile, ListRow, SectionHeader, Skeleton, StatTile, useHaptics, useTheme } from '@startsimpli/ui-native';
|
|
4
4
|
import { iconName, toneKey } from '../screens/shared/displayView';
|
|
5
5
|
import { useControllerState } from '../components/useControllerState';
|
|
6
6
|
import { timeAgo, type HomeArrival, type HomeController } from './controller';
|
|
@@ -9,8 +9,15 @@ export interface HomeScreenProps {
|
|
|
9
9
|
controller: HomeController;
|
|
10
10
|
brand: string;
|
|
11
11
|
tagline?: string;
|
|
12
|
-
/**
|
|
13
|
-
|
|
12
|
+
/** The way into Talk (the one mic entry). Omit to hide the button. */
|
|
13
|
+
onTalk?: () => void;
|
|
14
|
+
/** The way into Plan, from the due-soon line. */
|
|
15
|
+
onOpenPlan?: () => void;
|
|
16
|
+
/** "What's on the plate": the spoken briefing card, moved here from the removed GO tab. */
|
|
17
|
+
briefing?: ReactNode;
|
|
18
|
+
/** The tab's title and the one plain line under it. */
|
|
19
|
+
title?: string;
|
|
20
|
+
subtitle?: string;
|
|
14
21
|
/** A metric tile was tapped. */
|
|
15
22
|
onOpenType?: (typeKey: string) => void;
|
|
16
23
|
/** An arrival was tapped. */
|
|
@@ -21,14 +28,14 @@ export interface HomeScreenProps {
|
|
|
21
28
|
}
|
|
22
29
|
|
|
23
30
|
/** The front door, as the web Home draws it: brand, "What has come in" counts, "Latest arrivals". */
|
|
24
|
-
export function HomeScreen({ controller, brand, tagline,
|
|
31
|
+
export function HomeScreen({ controller, brand, tagline, onTalk, onOpenPlan, briefing, title, subtitle, onOpenType, onOpenArrival, active = true, now = Date.now }: HomeScreenProps) {
|
|
25
32
|
const theme = useTheme();
|
|
26
33
|
const haptic = useHaptics();
|
|
27
34
|
const s = useControllerState(controller);
|
|
28
35
|
useEffect(() => { if (active) void controller.load(); }, [controller, active]);
|
|
29
36
|
return (
|
|
30
37
|
<View style={{ flex: 1 }}>
|
|
31
|
-
<Header large title={brand} subtitle={tagline} />
|
|
38
|
+
<Header large testID="home-header" title={title ?? brand} subtitle={subtitle ?? tagline} />
|
|
32
39
|
<FlatList
|
|
33
40
|
testID="home-list"
|
|
34
41
|
data={s.arrivals}
|
|
@@ -37,7 +44,13 @@ export function HomeScreen({ controller, brand, tagline, onRecord, onOpenType, o
|
|
|
37
44
|
contentContainerStyle={{ paddingHorizontal: theme.layout.gutter, paddingBottom: theme.spacing.xl, flexGrow: 1 }}
|
|
38
45
|
ListHeaderComponent={
|
|
39
46
|
<View style={{ gap: theme.spacing.xs, paddingBottom: theme.spacing.xs }}>
|
|
40
|
-
{
|
|
47
|
+
{briefing ? <View testID="home-briefing" style={{ marginTop: theme.spacing.sm, paddingBottom: theme.spacing.sm }}>{briefing}</View> : null}
|
|
48
|
+
{s.dueSoon ? (
|
|
49
|
+
<Pressable accessibilityRole="button" accessibilityLabel={`${s.dueSoon}. Open Plan`} disabled={!onOpenPlan} onPress={onOpenPlan} testID="home-due-soon" hitSlop={8}>
|
|
50
|
+
<Text variant="callout">{s.dueSoon}{onOpenPlan ? ' ›' : ''}</Text>
|
|
51
|
+
</Pressable>
|
|
52
|
+
) : null}
|
|
53
|
+
{onTalk ? <Button testID="home-talk" title="Talk to Tandem" size="lg" style={{ marginTop: theme.spacing.sm }} onPress={onTalk} /> : null}
|
|
41
54
|
{s.error ? <Alert variant="destructive">{s.error}</Alert> : null}
|
|
42
55
|
<SectionHeader title="What has come in" />
|
|
43
56
|
<View style={{ flexDirection: 'row', gap: theme.spacing.sm }}>
|
|
@@ -29,6 +29,8 @@ export interface HomeState {
|
|
|
29
29
|
loading: boolean;
|
|
30
30
|
metrics: HomeMetric[];
|
|
31
31
|
arrivals: HomeArrival[];
|
|
32
|
+
/** "1 overdue · 2 due this week": the one line Today keeps about to-dos (the list itself is Plan's). Null until read, or when unavailable. */
|
|
33
|
+
dueSoon: string | null;
|
|
32
34
|
error: string | null;
|
|
33
35
|
}
|
|
34
36
|
|
|
@@ -48,6 +50,10 @@ export interface HomeControllerOptions {
|
|
|
48
50
|
now?: () => number;
|
|
49
51
|
/** The tenant's per-type display declarations (`api.schema.displays`). A failed read leaves the built-in defaults. */
|
|
50
52
|
displays?: () => Promise<Record<string, TypeDisplayConfig>>;
|
|
53
|
+
/** Reads the due-soon line. A failed read leaves the line off, never the screen. */
|
|
54
|
+
dueSoon?: () => Promise<string>;
|
|
55
|
+
/** Record types whose rows are NOT listed under Latest arrivals (to-dos live only in Plan). Counts still include them. */
|
|
56
|
+
hideArrivals?: string[];
|
|
51
57
|
}
|
|
52
58
|
|
|
53
59
|
const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
@@ -66,20 +72,23 @@ export function timeAgo(iso: string, now: number): string {
|
|
|
66
72
|
|
|
67
73
|
const stamp = (e: TenantEntity) => String(e.created_at ?? e.createdAt ?? '');
|
|
68
74
|
|
|
69
|
-
export function createHomeController({ api, types, limit = 8, displays }: HomeControllerOptions): HomeController {
|
|
70
|
-
let state: HomeState = { loading: true, metrics: types.map((t) => ({ key: t.key, label: t.label, count: null })), arrivals: [], error: null };
|
|
75
|
+
export function createHomeController({ api, types, limit = 8, displays, dueSoon, hideArrivals = [] }: HomeControllerOptions): HomeController {
|
|
76
|
+
let state: HomeState = { loading: true, metrics: types.map((t) => ({ key: t.key, label: t.label, count: null })), arrivals: [], dueSoon: null, error: null };
|
|
71
77
|
const listeners = new Set<() => void>();
|
|
72
78
|
const set = (patch: Partial<HomeState>) => { state = { ...state, ...patch }; listeners.forEach((l) => l()); };
|
|
73
79
|
|
|
74
80
|
async function load() {
|
|
75
81
|
// TWO reads for the whole screen, however many types it summarises: the count
|
|
76
82
|
// per type (one grouped read) and the newest rows across those types.
|
|
77
|
-
const
|
|
83
|
+
const arrivalTypes = types.map((t) => t.key).filter((k) => !hideArrivals.includes(k));
|
|
84
|
+
const [counts, recent, declared, line] = await Promise.all([
|
|
78
85
|
api.entities.counts({ groupBy: ['type'], filters: { typeIn: types.map((t) => t.key) } })
|
|
79
86
|
.then((p) => countsBy(p.items, 'type')).catch(() => null),
|
|
80
|
-
|
|
81
|
-
.then((p) => p.items).catch(() => null)
|
|
87
|
+
arrivalTypes.length
|
|
88
|
+
? api.entities.list({ filters: { typeIn: arrivalTypes }, order: 'recent', pageSize: limit }).then((p) => p.items).catch(() => null)
|
|
89
|
+
: Promise.resolve([] as TenantEntity[]),
|
|
82
90
|
displays ? displays().catch(() => null) : Promise.resolve(null),
|
|
91
|
+
dueSoon ? dueSoon().catch(() => null) : Promise.resolve(null),
|
|
83
92
|
]);
|
|
84
93
|
const display = layerDisplays(declared);
|
|
85
94
|
const label = new Map(types.map((t) => [t.key, t.label]));
|
|
@@ -93,6 +102,7 @@ export function createHomeController({ api, types, limit = 8, displays }: HomeCo
|
|
|
93
102
|
// A type with no rows is absent from the grouped answer: zero there, null only when the read failed.
|
|
94
103
|
metrics: types.map((t) => ({ key: t.key, label: t.label, count: counts ? (counts[t.key] ?? 0) : null })),
|
|
95
104
|
arrivals,
|
|
105
|
+
dueSoon: line,
|
|
96
106
|
error: counts === null && recent === null ? 'Could not load your workspace.' : null,
|
|
97
107
|
});
|
|
98
108
|
}
|
package/src/native/home/tab.tsx
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { groupDue } from '../../corpus/due-groups';
|
|
3
|
+
import { isTask } from '../../corpus/tracker-groups';
|
|
4
|
+
import { dueSoonText } from '../../components/pages/home/DueSoonLine';
|
|
1
5
|
import type { FoundryTab } from '../components/FoundryTabsShell';
|
|
2
6
|
import type { NativeCorpusApi } from '../corpus/api';
|
|
3
7
|
import { createHomeController, type HomeController, type HomeType } from './controller';
|
|
4
8
|
import { HomeScreen } from './HomeScreen';
|
|
5
9
|
|
|
6
10
|
export interface HomeTabOptions {
|
|
7
|
-
api: Pick<NativeCorpusApi, 'entities'> & Partial<Pick<NativeCorpusApi, 'schema'>>;
|
|
11
|
+
api: Pick<NativeCorpusApi, 'entities'> & Partial<Pick<NativeCorpusApi, 'schema' | 'corpus'>>;
|
|
8
12
|
brand: string;
|
|
9
13
|
tagline?: string;
|
|
10
14
|
key?: string;
|
|
@@ -14,12 +18,29 @@ export interface HomeTabOptions {
|
|
|
14
18
|
controller?: HomeController;
|
|
15
19
|
/** Tab keys by record type, e.g. `{ commitment: 'tracker', source_document: 'library' }`. A type with no tab is not tappable. */
|
|
16
20
|
tabs?: Record<string, string>;
|
|
17
|
-
/** Tab key of the
|
|
18
|
-
|
|
21
|
+
/** Tab key of Talk, the one mic entry; shows "Talk to Tandem". */
|
|
22
|
+
talkKey?: string;
|
|
23
|
+
/** Tab key of Plan: the due-soon line and the To-dos tile open it. */
|
|
24
|
+
planKey?: string;
|
|
25
|
+
/** "What's on the plate". Read at render so a re-render of the app updates it without rebuilding the tabs. */
|
|
26
|
+
briefing?: () => ReactNode;
|
|
27
|
+
/** The Today framing: its title and one plain line (`TAB_COPY.today`). Absent: the brand and tagline. */
|
|
28
|
+
copy?: { label: string; subtitle: string };
|
|
29
|
+
timeZone?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** The to-dos counted on the due-soon line: one server page of what is still owed. */
|
|
33
|
+
function dueSoonReader(api: HomeTabOptions['api'], timeZone?: string) {
|
|
34
|
+
const corpus = api.corpus;
|
|
35
|
+
if (!corpus) return undefined;
|
|
36
|
+
return async () => {
|
|
37
|
+
const page = await corpus.listCommitments({ status: ['open', 'in_progress', 'blocked'], pageSize: 200 });
|
|
38
|
+
return dueSoonText(groupDue(page.results.filter(isTask), { now: Date.now(), timeZone }));
|
|
39
|
+
};
|
|
19
40
|
}
|
|
20
41
|
|
|
21
42
|
/** The Home tab as one `FoundryTabsShell` entry. */
|
|
22
|
-
export function homeTab({ api, brand, tagline, key = 'home', label = 'Home', types, controller = createHomeController({ api, types, displays: api.schema ? () => api.schema!.displays() : undefined }), tabs = {},
|
|
43
|
+
export function homeTab({ api, brand, tagline, key = 'home', label = 'Home', types, controller = createHomeController({ api, types, displays: api.schema ? () => api.schema!.displays() : undefined, dueSoon: dueSoonReader(api), hideArrivals: ['commitment'] }), tabs = {}, talkKey, planKey, briefing, copy }: HomeTabOptions): FoundryTab {
|
|
23
44
|
return {
|
|
24
45
|
key, label,
|
|
25
46
|
render: ({ openTab, active }) => (
|
|
@@ -28,13 +49,17 @@ export function homeTab({ api, brand, tagline, key = 'home', label = 'Home', typ
|
|
|
28
49
|
active={active}
|
|
29
50
|
brand={brand}
|
|
30
51
|
tagline={tagline}
|
|
31
|
-
|
|
52
|
+
title={copy?.label}
|
|
53
|
+
subtitle={copy?.subtitle}
|
|
54
|
+
briefing={briefing?.()}
|
|
55
|
+
onTalk={talkKey ? () => openTab(talkKey) : undefined}
|
|
56
|
+
onOpenPlan={planKey ? () => openTab(planKey) : undefined}
|
|
32
57
|
onOpenType={(type) => { if (tabs[type]) openTab(tabs[type]); }}
|
|
33
58
|
onOpenArrival={(a) => {
|
|
34
59
|
const tab = tabs[a.type];
|
|
35
60
|
if (!tab) return;
|
|
36
61
|
// A voice note opens on Notes by its document id; everything else opens its own tab (detail where it has one).
|
|
37
|
-
openTab(tab,
|
|
62
|
+
openTab(tab, (a.entity.data as { source?: string } | undefined)?.source === 'voice' ? a.id : undefined);
|
|
38
63
|
}}
|
|
39
64
|
/>
|
|
40
65
|
),
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { Alert, Button, ChatComposer, useTheme } from '@startsimpli/ui-native';
|
|
4
|
+
|
|
5
|
+
/** "New project": a project and a goal are one thing, so this is also how a goal is created. One field, then it is on the list. */
|
|
6
|
+
export function NewProjectRow({ onCreate }: { onCreate: (title: string) => Promise<void> }) {
|
|
7
|
+
const theme = useTheme();
|
|
8
|
+
const [open, setOpen] = useState(false);
|
|
9
|
+
const [busy, setBusy] = useState(false);
|
|
10
|
+
const [error, setError] = useState<string | null>(null);
|
|
11
|
+
if (!open) {
|
|
12
|
+
return (
|
|
13
|
+
<View style={{ paddingHorizontal: theme.layout.gutter, paddingBottom: theme.spacing.sm, alignItems: 'flex-start' }}>
|
|
14
|
+
<Button testID="project-new" title="New project" variant="outline" size="sm" onPress={() => setOpen(true)} />
|
|
15
|
+
</View>
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
return (
|
|
19
|
+
<View style={{ paddingBottom: theme.spacing.sm, gap: theme.spacing.xs }}>
|
|
20
|
+
{error ? <View style={{ paddingHorizontal: theme.layout.gutter }}><Alert variant="destructive">{error}</Alert></View> : null}
|
|
21
|
+
<ChatComposer
|
|
22
|
+
testID="project-new-input" placeholder="What are you trying to achieve?" sending={busy}
|
|
23
|
+
onSend={(title) => {
|
|
24
|
+
setBusy(true); setError(null);
|
|
25
|
+
onCreate(title).then(() => setOpen(false)).catch((e) => setError(e instanceof Error ? e.message : 'Could not create the project.')).finally(() => setBusy(false));
|
|
26
|
+
}}
|
|
27
|
+
/>
|
|
28
|
+
</View>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { Header, SegmentedControl, Text, useTheme } from '@startsimpli/ui-native';
|
|
4
|
+
import { PLAN_TABS, TAB_COPY, type PlanTabKey } from '../../corpus/nav-copy';
|
|
5
|
+
import type { FoundryTab, TabContext } from '../components/FoundryTabsShell';
|
|
6
|
+
import type { NativeCorpusApi } from '../corpus/api';
|
|
7
|
+
import { PlanningDetailScreen, PlanningListScreen, usePlanningController } from '../screens/planning/PlanningScreens';
|
|
8
|
+
import { createTrackerController, type TrackerController } from '../tracker/controller';
|
|
9
|
+
import { TrackerBody, type TrackerTabOptions } from '../tracker/tab';
|
|
10
|
+
import { NewProjectRow } from './NewProjectRow';
|
|
11
|
+
import { ProjectTodos } from './ProjectTodos';
|
|
12
|
+
import { TimelineScreen } from './TimelineScreen';
|
|
13
|
+
import { createTimelineController, type TimelineController } from './timeline';
|
|
14
|
+
|
|
15
|
+
export const PLAN_TAB = 'plan';
|
|
16
|
+
const TODO = 'todo/';
|
|
17
|
+
const PROJECT = 'project/';
|
|
18
|
+
const SUBS = new Set<string>(PLAN_TABS.map((t) => t.key));
|
|
19
|
+
|
|
20
|
+
export interface PlanTabOptions {
|
|
21
|
+
api: TrackerTabOptions['api'] & Pick<NativeCorpusApi, 'lists' | 'standings'>;
|
|
22
|
+
key?: string;
|
|
23
|
+
label?: string;
|
|
24
|
+
/** Voice notes tab: a to-do from a note offers "Open note". */
|
|
25
|
+
notesKey?: string;
|
|
26
|
+
/** The Library tab: a project's filed notes open there. */
|
|
27
|
+
documentTab?: string;
|
|
28
|
+
memberConnections?: TrackerTabOptions['memberConnections'];
|
|
29
|
+
openUrl?: TrackerTabOptions['openUrl'];
|
|
30
|
+
/** Something else edited items (a spoken reply): the to-do list re-reads. */
|
|
31
|
+
itemsChanged?: TrackerTabOptions['itemsChanged'];
|
|
32
|
+
timeZone?: string;
|
|
33
|
+
now?: () => number;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** The route ids the Plan tab understands: `todo/<id>`, `project/<id>`, and (launch args) a bare sub-tab name. */
|
|
37
|
+
export const planRoute = {
|
|
38
|
+
todo: (id: string) => `${TODO}${id}`,
|
|
39
|
+
project: (id: string) => `${PROJECT}${id}`,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
function PlanBody({ opts, tracker, timeline, ctx }: { opts: PlanTabOptions; tracker: TrackerController; timeline: TimelineController; ctx: TabContext }) {
|
|
43
|
+
const theme = useTheme();
|
|
44
|
+
const { api, notesKey, documentTab, memberConnections, openUrl } = opts;
|
|
45
|
+
const planning = usePlanningController(api);
|
|
46
|
+
const routeId = ctx.route?.id ?? null;
|
|
47
|
+
const [sub, setSub] = useState<PlanTabKey>(() => (routeId && SUBS.has(routeId) ? (routeId as PlanTabKey) : 'todos'));
|
|
48
|
+
useEffect(() => { if (routeId && SUBS.has(routeId)) setSub(routeId as PlanTabKey); }, [routeId]);
|
|
49
|
+
const current = PLAN_TABS.find((t) => t.key === sub) ?? PLAN_TABS[0];
|
|
50
|
+
const todoId = routeId?.startsWith(TODO) ? routeId.slice(TODO.length) : null;
|
|
51
|
+
const projectId = routeId?.startsWith(PROJECT) ? routeId.slice(PROJECT.length) : null;
|
|
52
|
+
const openTodo = (id: string) => ctx.push(planRoute.todo(id));
|
|
53
|
+
|
|
54
|
+
if (todoId) {
|
|
55
|
+
return <TrackerBody api={api} controller={tracker} todoId={todoId} onOpen={openTodo} onBack={ctx.back} notesKey={notesKey} openTab={ctx.openTab} memberConnections={memberConnections} openUrl={openUrl} />;
|
|
56
|
+
}
|
|
57
|
+
if (projectId) {
|
|
58
|
+
return (
|
|
59
|
+
<PlanningDetailScreen
|
|
60
|
+
api={api} focusId={projectId} onBack={ctx.back}
|
|
61
|
+
onOpenDocument={documentTab ? (id) => ctx.openTab(documentTab, id) : undefined}
|
|
62
|
+
renderTodos={() => <ProjectTodos api={api} focusId={projectId} onOpen={openTodo} openTab={ctx.openTab} notesKey={notesKey} memberConnections={memberConnections} openUrl={openUrl} />}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<View style={{ flex: 1 }} testID="plan-screen">
|
|
69
|
+
<Header large testID="plan-header" title={TAB_COPY.plan.label} subtitle={TAB_COPY.plan.subtitle} />
|
|
70
|
+
<View style={{ paddingHorizontal: theme.layout.gutter, gap: theme.spacing.xs, paddingBottom: theme.spacing.sm }}>
|
|
71
|
+
<SegmentedControl<PlanTabKey> testID="plan-subtabs" value={sub} onChange={setSub} options={PLAN_TABS.map((t) => ({ value: t.key, label: t.label }))} />
|
|
72
|
+
<Text variant="footnote" testID="plan-subtitle">{current.subtitle}</Text>
|
|
73
|
+
</View>
|
|
74
|
+
{sub === 'todos' ? (
|
|
75
|
+
<TrackerBody api={api} controller={tracker} todoId={null} onOpen={openTodo} onBack={ctx.back} notesKey={notesKey} openTab={ctx.openTab} memberConnections={memberConnections} openUrl={openUrl} embedded />
|
|
76
|
+
) : null}
|
|
77
|
+
{sub === 'timeline' ? <TimelineScreen controller={timeline} /> : null}
|
|
78
|
+
{sub === 'projects' ? (
|
|
79
|
+
<View style={{ flex: 1 }}>
|
|
80
|
+
{api.corpus.createFocus ? (
|
|
81
|
+
<NewProjectRow onCreate={async (title) => { await api.corpus.createFocus!({ title, status: 'active' }); await planning.refresh(); }} />
|
|
82
|
+
) : null}
|
|
83
|
+
<PlanningListScreen controller={planning} onOpen={(f) => ctx.push(planRoute.project(f.id))} embedded />
|
|
84
|
+
</View>
|
|
85
|
+
) : null}
|
|
86
|
+
</View>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The Plan tab: ONE tab for everything owed and everything aimed at, with three sub-tabs. To-dos is the one list;
|
|
92
|
+
* Timeline is the created / done / overdue chart and its day table; Projects is projects and goals as one list with
|
|
93
|
+
* progress, and opening one shows its to-dos as the same list filtered. Tracker, Planning and Goals are not tabs.
|
|
94
|
+
*/
|
|
95
|
+
export function planTab(opts: PlanTabOptions): FoundryTab {
|
|
96
|
+
const { api, key = PLAN_TAB, label = TAB_COPY.plan.label, itemsChanged, timeZone, now } = opts;
|
|
97
|
+
// One controller each for the tab's lifetime: switching sub-tabs or opening a to-do and coming back does not re-read.
|
|
98
|
+
const tracker = createTrackerController({ api });
|
|
99
|
+
const timeline = createTimelineController({ timeline: (api.corpus as { timeline?: TrackerBodyTimeline }).timeline?.bind(api.corpus), timeZone, now });
|
|
100
|
+
itemsChanged?.subscribe(() => { void tracker.refresh(); });
|
|
101
|
+
return { key, label, resetOnLeave: true, render: (ctx) => <PlanBody opts={opts} tracker={tracker} timeline={timeline} ctx={ctx} /> };
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
type TrackerBodyTimeline = NonNullable<import('../../corpus/types').CommitmentTrackerApi['timeline']>;
|
|
105
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useEffect, useMemo } from 'react';
|
|
2
|
+
import { createTrackerController } from '../tracker/controller';
|
|
3
|
+
import { TrackerBody, type TrackerTabOptions } from '../tracker/tab';
|
|
4
|
+
|
|
5
|
+
/** One project's to-dos: the SHARED to-do list with its controller filtered to the project. Never a list of its own. */
|
|
6
|
+
export function ProjectTodos({ api, focusId, onOpen, openTab, notesKey, memberConnections, openUrl }: {
|
|
7
|
+
api: TrackerTabOptions['api'];
|
|
8
|
+
focusId: string;
|
|
9
|
+
onOpen: (todoId: string) => void;
|
|
10
|
+
openTab: (tab: string, id?: string) => void;
|
|
11
|
+
notesKey?: string;
|
|
12
|
+
memberConnections?: TrackerTabOptions['memberConnections'];
|
|
13
|
+
openUrl?: TrackerTabOptions['openUrl'];
|
|
14
|
+
}) {
|
|
15
|
+
const controller = useMemo(() => createTrackerController({ api }), [api]);
|
|
16
|
+
useEffect(() => { void controller.setFocus(focusId); }, [controller, focusId]);
|
|
17
|
+
return (
|
|
18
|
+
<TrackerBody
|
|
19
|
+
api={api} controller={controller} todoId={null} onOpen={onOpen} onBack={() => undefined}
|
|
20
|
+
notesKey={notesKey} openTab={openTab} memberConnections={memberConnections} openUrl={openUrl}
|
|
21
|
+
embedded projectLocked
|
|
22
|
+
/>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { FlatList, View } from 'react-native';
|
|
3
|
+
import { Alert, EmptyState, ListRow, SegmentedControl, Spinner, Text, TrendChart, useTheme } from '@startsimpli/ui-native';
|
|
4
|
+
import { useControllerState } from '../components/useControllerState';
|
|
5
|
+
import { TIMELINE_RANGES, lastDays, type TimelineController } from './timeline';
|
|
6
|
+
|
|
7
|
+
const SERIES_COLOR: Record<string, string> = { created: '#3B82F6', done: '#16A34A', overdue: '#DC2626' };
|
|
8
|
+
|
|
9
|
+
/** "Mon, Nov 9" from a YYYY-MM-DD day. */
|
|
10
|
+
const dayLabel = (iso: string) => new Date(`${iso}T00:00:00Z`).toLocaleDateString(undefined, { weekday: 'short', month: 'short', day: 'numeric', timeZone: 'UTC' });
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Plan > Timeline: what was created, finished and overdue over time. One chart per series over the chosen range, then the
|
|
14
|
+
* days that had activity with the to-dos behind them (the web strip's chart and event table, in a phone's shape).
|
|
15
|
+
*/
|
|
16
|
+
export function TimelineScreen({ controller }: { controller: TimelineController }) {
|
|
17
|
+
const s = useControllerState(controller);
|
|
18
|
+
const theme = useTheme();
|
|
19
|
+
const [range, setRange] = useState<string>('30');
|
|
20
|
+
useEffect(() => { void controller.load(); }, [controller]);
|
|
21
|
+
const days = TIMELINE_RANGES.find((r) => r.value === range)?.days ?? 30;
|
|
22
|
+
const rows = s.built ? s.built.points.filter((p) => s.built!.series[0].points.slice(-days).some((q) => q.date === p.date)).reverse() : [];
|
|
23
|
+
|
|
24
|
+
const header = (
|
|
25
|
+
<View style={{ gap: theme.spacing.md, paddingBottom: theme.spacing.md }}>
|
|
26
|
+
<SegmentedControl<string> testID="timeline-range" value={range} onChange={setRange} options={TIMELINE_RANGES.map((r) => ({ value: r.value, label: r.label }))} />
|
|
27
|
+
{s.built ? s.built.series.map((series) => {
|
|
28
|
+
const values = lastDays(series.points, days);
|
|
29
|
+
const total = values.reduce((a, b) => a + b, 0);
|
|
30
|
+
return (
|
|
31
|
+
<View key={series.id} testID={`timeline-series-${series.id}`} style={{ gap: theme.spacing.xs }}>
|
|
32
|
+
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
|
|
33
|
+
<Text variant="headline">{series.name}</Text>
|
|
34
|
+
<Text variant="headline" style={{ color: SERIES_COLOR[series.id] }}>{String(total)}</Text>
|
|
35
|
+
</View>
|
|
36
|
+
<TrendChart data={values.length > 1 ? values : [0, ...values]} height={96} color={SERIES_COLOR[series.id]} gridLines={1} />
|
|
37
|
+
</View>
|
|
38
|
+
);
|
|
39
|
+
}) : null}
|
|
40
|
+
{s.built && s.built.estimatedDone > 0 ? <Text variant="footnote">{`${s.built.estimatedDone} done to-do${s.built.estimatedDone === 1 ? '' : 's'} sit on an estimated day.`}</Text> : null}
|
|
41
|
+
{s.built ? <Text variant="headline" testID="timeline-table-title">To-dos in this window</Text> : null}
|
|
42
|
+
</View>
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
if (!s.available) return <EmptyState icon="list" title="No timeline here" description="This workspace cannot serve the per-day counts the timeline needs." />;
|
|
46
|
+
return (
|
|
47
|
+
<View style={{ flex: 1 }} testID="timeline-screen">
|
|
48
|
+
{s.error ? <View style={{ padding: theme.spacing.lg }}><Alert variant="destructive">{s.error}</Alert></View> : null}
|
|
49
|
+
<FlatList
|
|
50
|
+
testID="timeline-table"
|
|
51
|
+
data={rows}
|
|
52
|
+
keyExtractor={(p) => p.date}
|
|
53
|
+
contentContainerStyle={{ paddingHorizontal: theme.layout.gutter, paddingBottom: theme.spacing.xl, flexGrow: 1 }}
|
|
54
|
+
ListHeaderComponent={header}
|
|
55
|
+
ListEmptyComponent={s.loading ? <Spinner /> : s.built ? <EmptyState icon="list" title="Nothing in this window" description="Created, finished and overdue to-dos show up here by day." /> : null}
|
|
56
|
+
renderItem={({ item }) => (
|
|
57
|
+
<ListRow
|
|
58
|
+
testID={`timeline-day-${item.date}`}
|
|
59
|
+
title={dayLabel(item.date)}
|
|
60
|
+
subtitle={(item.events ?? []).slice(0, 3).map((e) => `${e.status}: ${e.label}`).join('\n')}
|
|
61
|
+
meta={`${item.value} to-do${item.value === 1 ? '' : 's'}`}
|
|
62
|
+
chevron={false}
|
|
63
|
+
/>
|
|
64
|
+
)}
|
|
65
|
+
/>
|
|
66
|
+
</View>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
+
|
|
3
|
+
vi.mock('react-native', async () => ({ ...(await import('../../../../../ui-native/test/rn-stub')) }));
|
|
4
|
+
import { act, allText, hostById, maybeById, press, render } from '../../../../../ui-native/test/render';
|
|
5
|
+
import { PLAN_TABS, TAB_COPY } from '../../../corpus/nav-copy';
|
|
6
|
+
import type { TabContext } from '../../components/FoundryTabsShell';
|
|
7
|
+
import { createFakeNativeCorpusApi } from '../../corpus/fake';
|
|
8
|
+
import { planRoute, planTab } from '../PlanTab';
|
|
9
|
+
import { createTimelineController } from '../timeline';
|
|
10
|
+
|
|
11
|
+
const tick = () => act(async () => { await new Promise((res) => setTimeout(res, 40)); });
|
|
12
|
+
const ctx = (over: Partial<TabContext> = {}): TabContext => ({ tab: 'plan', active: true, route: null, push: vi.fn(), back: vi.fn(), openTab: vi.fn(), ...over });
|
|
13
|
+
const has = (r: ReturnType<typeof render>, id: string) => r.root.findAllByProps({ testID: id }).length > 0;
|
|
14
|
+
const mount = (c: TabContext) => render(<>{planTab({ api: createFakeNativeCorpusApi() }).render(c)}</>);
|
|
15
|
+
|
|
16
|
+
describe('Plan tab', () => {
|
|
17
|
+
it('is one tab with the three sub-tabs and says what Plan and each sub-tab are for', async () => {
|
|
18
|
+
const r = mount(ctx());
|
|
19
|
+
await tick();
|
|
20
|
+
const text = allText(r);
|
|
21
|
+
expect(text).toContain(TAB_COPY.plan.subtitle);
|
|
22
|
+
for (const t of PLAN_TABS) expect(text).toContain(t.label);
|
|
23
|
+
expect(allText(r)).toContain(PLAN_TABS[0].subtitle);
|
|
24
|
+
for (const t of PLAN_TABS) expect(has(r, `plan-subtabs-${t.key}`)).toBe(true);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('To-dos is the one list: rows, and a tap pushes the to-do', async () => {
|
|
28
|
+
const c = ctx();
|
|
29
|
+
const r = mount(c);
|
|
30
|
+
await tick();
|
|
31
|
+
expect(has(r, 'tracker-list')).toBe(true);
|
|
32
|
+
const row = r.root.findByProps({ testID: 'todo-c2' }).findAll((n) => typeof n.props.onPress === 'function' && !n.props.testID?.includes('action'))[0];
|
|
33
|
+
press(row);
|
|
34
|
+
// The to-do detail opens inside Plan under the `todo/` route, never in a tab of its own.
|
|
35
|
+
expect(c.push).toHaveBeenCalledWith('todo/c2');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('a launch route names the sub-tab: Timeline shows its chart range and table, Projects its list and a New project button', async () => {
|
|
39
|
+
const t = mount(ctx({ route: { id: 'timeline' } }));
|
|
40
|
+
await tick();
|
|
41
|
+
expect(allText(t)).toContain(PLAN_TABS[1].subtitle);
|
|
42
|
+
expect(has(t, 'timeline-screen')).toBe(true);
|
|
43
|
+
expect(has(t, 'timeline-range-30')).toBe(true);
|
|
44
|
+
const p = mount(ctx({ route: { id: 'projects' } }));
|
|
45
|
+
await tick();
|
|
46
|
+
expect(allText(p)).toContain(PLAN_TABS[2].subtitle);
|
|
47
|
+
expect(has(p, 'planning-list')).toBe(true);
|
|
48
|
+
expect(has(p, 'project-new')).toBe(true);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('opening a project shows its to-dos as the shared list, filtered, with no Open/Closed item lists of its own', async () => {
|
|
52
|
+
const c = ctx({ route: { id: planRoute.project('f287') } });
|
|
53
|
+
const r = mount(c);
|
|
54
|
+
await tick(); await tick();
|
|
55
|
+
expect(has(r, 'planning-detail')).toBe(true);
|
|
56
|
+
expect(has(r, 'tracker-list')).toBe(true);
|
|
57
|
+
expect(maybeById(r, 'planning-items')).toHaveLength(0);
|
|
58
|
+
expect(allText(r)).toContain('To-dos');
|
|
59
|
+
expect(allText(r)).toContain('Notes');
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
describe('timeline controller', () => {
|
|
64
|
+
it('builds the three series from the same server reads the web strip uses', async () => {
|
|
65
|
+
const api = createFakeNativeCorpusApi();
|
|
66
|
+
const controller = createTimelineController({ timeline: (api.corpus as any).timeline?.bind(api.corpus), now: () => Date.parse('2026-11-16T12:00:00Z') });
|
|
67
|
+
await controller.load();
|
|
68
|
+
const s = controller.getState();
|
|
69
|
+
expect(s.error).toBeNull();
|
|
70
|
+
expect(s.built?.series.map((x) => x.id)).toEqual(['created', 'done', 'overdue']);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('says so when the workspace cannot serve a timeline', () => {
|
|
74
|
+
expect(createTimelineController({ timeline: undefined }).getState().available).toBe(false);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { planTab, planRoute, PLAN_TAB } from './PlanTab';
|
|
2
|
+
export type { PlanTabOptions } from './PlanTab';
|
|
3
|
+
export { createTimelineController } from './timeline';
|
|
4
|
+
export type { TimelineController, TimelineState } from './timeline';
|
|
5
|
+
export { TimelineScreen } from './TimelineScreen';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Plan > Timeline data as a framework-free controller: the same server reads and the same `buildTimeline` the web
|
|
3
|
+
* strip uses (created / done / overdue per day, and the to-dos behind the days), over the native corpus api.
|
|
4
|
+
*/
|
|
5
|
+
import { buildTimeline, type BuiltTimeline } from '../../corpus/tracker-timeline';
|
|
6
|
+
import type { CommitmentTrackerApi } from '../../corpus/types';
|
|
7
|
+
import { createStore, errorMessage } from '../screens/store';
|
|
8
|
+
|
|
9
|
+
export interface TimelineState {
|
|
10
|
+
loading: boolean;
|
|
11
|
+
error: string | null;
|
|
12
|
+
/** Null until the first read lands, and when this workspace cannot serve a timeline. */
|
|
13
|
+
built: BuiltTimeline | null;
|
|
14
|
+
available: boolean;
|
|
15
|
+
anchor: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface TimelineController {
|
|
19
|
+
getState(): TimelineState;
|
|
20
|
+
subscribe(listener: () => void): () => void;
|
|
21
|
+
load(): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function createTimelineController({ timeline, now = Date.now, timeZone }: {
|
|
25
|
+
timeline: CommitmentTrackerApi['timeline'] | undefined;
|
|
26
|
+
now?: () => number;
|
|
27
|
+
timeZone?: string;
|
|
28
|
+
}): TimelineController {
|
|
29
|
+
const store = createStore<TimelineState>({ loading: Boolean(timeline), error: null, built: null, available: Boolean(timeline), anchor: '' });
|
|
30
|
+
return {
|
|
31
|
+
getState: store.getState,
|
|
32
|
+
subscribe: store.subscribe,
|
|
33
|
+
async load() {
|
|
34
|
+
if (!timeline) return;
|
|
35
|
+
store.set({ loading: true, error: null });
|
|
36
|
+
try {
|
|
37
|
+
const clock = now();
|
|
38
|
+
const read = await timeline({}, { now: clock, timeZone });
|
|
39
|
+
store.set({ loading: false, built: buildTimeline(read, clock, timeZone), anchor: read.anchor });
|
|
40
|
+
} catch (e) {
|
|
41
|
+
store.set({ loading: false, error: errorMessage(e, 'Could not load the timeline.') });
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The last `days` values of a series, oldest first, for one chart. */
|
|
48
|
+
export function lastDays(points: Array<{ value: number }>, days: number): number[] {
|
|
49
|
+
return points.slice(-days).map((p) => p.value);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const TIMELINE_RANGES = [
|
|
53
|
+
{ value: '7', label: '7 days', days: 7 },
|
|
54
|
+
{ value: '30', label: '30 days', days: 30 },
|
|
55
|
+
{ value: '90', label: '90 days', days: 90 },
|
|
56
|
+
] as const;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { describe, expect, it, vi, type Mock } from 'vitest';
|
|
2
2
|
import { createRecorderAudio, type AudioDriver, type SessionInspector } from '../recorderAudio';
|
|
3
3
|
|
|
4
|
-
function setup(sizes: number[] = [0, 4000, 8000, 8000], sessionOver: Record<string, unknown> = {}) {
|
|
4
|
+
function setup(sizes: number[] = [0, 4000, 8000, 8000], sessionOver: Record<string, unknown> = {}, kind?: 'note' | 'transient') {
|
|
5
5
|
const order: string[] = [];
|
|
6
6
|
let status = { url: 'file:///docs/x.m4a', durationMillis: 2500, metering: -30 as number | undefined, isRecording: true };
|
|
7
7
|
const driver: AudioDriver = {
|
|
@@ -24,11 +24,19 @@ function setup(sizes: number[] = [0, 4000, 8000, 8000], sessionOver: Record<stri
|
|
|
24
24
|
const poll = vi.fn((fn: () => void) => { tick = fn; return () => { tick = undefined; }; });
|
|
25
25
|
const diag = { log: vi.fn() };
|
|
26
26
|
const onInterrupted = vi.fn();
|
|
27
|
-
const audio = createRecorderAudio({ driver, session, fs, poll, sleep: async () => undefined, diag, onInterrupted, stepTimeoutMs: 30 });
|
|
27
|
+
const audio = createRecorderAudio({ driver, session, fs, poll, sleep: async () => undefined, diag, onInterrupted, stepTimeoutMs: 30, ...(kind ? { kind } : {}) });
|
|
28
28
|
return { audio, driver, order, fs, diag, listeners, onInterrupted, tick: () => tick?.(), setStatus: (s: Partial<typeof status>) => { status = { ...status, ...s }; } };
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
describe('recorder audio adapter', () => {
|
|
32
|
+
it('tells the driver what the recording is for (a Converse utterance is transient, a note is the default)', async () => {
|
|
33
|
+
const t = setup(undefined, {}, 'transient');
|
|
34
|
+
await t.audio.start({ onLevel: vi.fn() });
|
|
35
|
+
expect((t.driver.create as Mock).mock.calls[0]).toEqual(['normal', 'transient']);
|
|
36
|
+
const n = setup();
|
|
37
|
+
await n.audio.start({ onLevel: vi.fn() });
|
|
38
|
+
expect((n.driver.create as Mock).mock.calls[0]).toEqual(['normal', undefined]);
|
|
39
|
+
});
|
|
32
40
|
it('pins the order: session configured+active -> recorder CREATED -> prepared -> record (the DevHQ failure)', async () => {
|
|
33
41
|
const s = setup();
|
|
34
42
|
await s.audio.start({ onLevel: vi.fn() });
|