@startsimpli/integrations 0.2.179 → 0.2.181
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 +1 -1
- 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__/corpus-ask-projects.test.ts +74 -0
- package/src/__tests__/home-brief.test.tsx +12 -24
- package/src/__tests__/home-needs-your-call.test.tsx +13 -16
- package/src/__tests__/library-asks-line.test.ts +27 -0
- package/src/__tests__/plan-shell.test.tsx +160 -0
- package/src/components/DocumentDetail.tsx +15 -4
- package/src/components/documentText.ts +33 -0
- package/src/components/index.ts +1 -0
- package/src/components/pages/AskPage.tsx +9 -1
- 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/ask-projects.ts +94 -0
- package/src/corpus/ask.ts +21 -2
- 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 +5 -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 +65 -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
|
@@ -0,0 +1,74 @@
|
|
|
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, allText, maybeById, render } from '../../../../../ui-native/test/render';
|
|
6
|
+
import { planTabs } from '../../shell/overflow';
|
|
7
|
+
import type { TabContext } from '../../components/FoundryTabsShell';
|
|
8
|
+
import { createFakeNativeCorpusApi } from '../../corpus/fake';
|
|
9
|
+
import { createFakeVoiceApi } from '../../voice/fake';
|
|
10
|
+
import { createVoiceNotesController } from '../../voice/controller';
|
|
11
|
+
import { createFakeConnectionsApi } from '../../screens/connections/fake';
|
|
12
|
+
import { createFakeMcpTokensApi } from '../../screens/connect-claude/fake';
|
|
13
|
+
import { resolveFoundryApp } from '../config/validate';
|
|
14
|
+
import { buildFoundryTabs } from '../registry';
|
|
15
|
+
import { foundryStrings } from '../strings';
|
|
16
|
+
import { createBriefingController } from '../../briefing/controller';
|
|
17
|
+
|
|
18
|
+
const tick = () => act(async () => { await new Promise((res) => setTimeout(res, 50)); });
|
|
19
|
+
const ctx = (over: Partial<TabContext> = {}): TabContext => ({ tab: 't', active: true, route: null, push: () => {}, back: () => {}, openTab: () => {}, ...over });
|
|
20
|
+
|
|
21
|
+
// The shape of tandem-ios/foundry.config.json after the Plan/Talk cleanup.
|
|
22
|
+
const config = resolveFoundryApp({
|
|
23
|
+
app: { name: 'Tandem Go' }, tenant: { url: 'https://acme.example.com' }, maxVisibleTabs: 4,
|
|
24
|
+
features: { recording: true, notes: true, tracker: true, library: true, ask: true, planning: true, connections: true, connectClaude: true, briefing: true, converse: false, notifications: false },
|
|
25
|
+
tabs: [
|
|
26
|
+
{ screen: 'home', label: 'Today', options: { copy: 'today' } },
|
|
27
|
+
{ screen: 'talk' },
|
|
28
|
+
{ screen: 'plan' },
|
|
29
|
+
{ screen: 'notes', priority: 65 },
|
|
30
|
+
{ screen: 'library' },
|
|
31
|
+
{ screen: 'connections' },
|
|
32
|
+
],
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const deps = () => ({
|
|
36
|
+
config, corpus: createFakeNativeCorpusApi(), notes: createVoiceNotesController({ api: createFakeVoiceApi() }), record: () => null,
|
|
37
|
+
member: { connections: createFakeConnectionsApi(), mcpTokens: createFakeMcpTokensApi() },
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe('the Tandem Go tab set', () => {
|
|
41
|
+
it('has exactly Today, Talk and Plan in the bar, with More behind it holding the rest', () => {
|
|
42
|
+
const tabs = buildFoundryTabs(deps());
|
|
43
|
+
const { primary, overflow } = planTabs(tabs, config.maxVisibleTabs);
|
|
44
|
+
expect(primary.map((t) => t.label)).toEqual(['Today', 'Talk', 'Plan']);
|
|
45
|
+
expect(overflow.map((t) => t.label)).toEqual(expect.arrayContaining(['Library', 'Connections']));
|
|
46
|
+
for (const gone of ['To-dos', 'Planning', 'Ask', 'Converse', 'GO']) expect([...primary, ...overflow].map((t) => t.label)).not.toContain(gone);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('Today: the briefing card (moved here from GO), a due-soon line and the Talk entry, and no to-do rows', async () => {
|
|
50
|
+
const strings = foundryStrings(config);
|
|
51
|
+
const controller = createBriefingController({
|
|
52
|
+
api: { fetch: async () => { throw new Error('unused'); }, audioSource: async () => null } as never, player: { getState: () => ({}), subscribe: () => () => undefined } as never,
|
|
53
|
+
messages: { failed: strings.briefingFailed, empty: strings.briefingEmpty, textOnly: strings.briefingTextOnly, audioFailed: strings.briefingAudioFailed },
|
|
54
|
+
});
|
|
55
|
+
const tabs = buildFoundryTabs({ ...deps(), briefing: { controller, reply: null }, strings });
|
|
56
|
+
const home = tabs.find((t) => t.key === 'home')!;
|
|
57
|
+
const r = render(<>{home.render(ctx({ openTab: vi.fn() }))}</>);
|
|
58
|
+
await tick();
|
|
59
|
+
const text = allText(r);
|
|
60
|
+
expect(text).toContain('Today');
|
|
61
|
+
expect(r.root.findAllByProps({ testID: 'briefing-play' }).length).toBeGreaterThan(0);
|
|
62
|
+
expect(text).toContain('Your morning brief and what is due soon.');
|
|
63
|
+
expect(r.root.findAllByProps({ testID: 'home-talk' }).length).toBeGreaterThan(0);
|
|
64
|
+
expect(r.root.findAllByProps({ testID: 'home-due-soon' }).length).toBeGreaterThan(0);
|
|
65
|
+
expect(maybeById(r, 'home-record')).toHaveLength(0);
|
|
66
|
+
// Latest arrivals never list a to-do.
|
|
67
|
+
expect(r.root.findAllByProps({ testID: 'home-metric-commitment' }).length).toBeGreaterThan(0);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('the Talk tab is Ask alone without a meeting, and Plan is registered', () => {
|
|
71
|
+
const tabs = buildFoundryTabs(deps());
|
|
72
|
+
expect(tabs.map((t) => t.key)).toEqual(expect.arrayContaining(['talk', 'plan']));
|
|
73
|
+
});
|
|
74
|
+
});
|
|
@@ -61,6 +61,7 @@ export function createBriefing(deps: {
|
|
|
61
61
|
if (!rec) throw new Error('features.briefing.reply needs the recording bindings (features.recording on, device.recording supplied)');
|
|
62
62
|
// Its own recorder audio: an interruption here cancels nothing else, and a reply never reaches the upload queue.
|
|
63
63
|
const audio = createRecorderAudio({
|
|
64
|
+
kind: 'transient',
|
|
64
65
|
driver: rec.driver, session: rec.session, fs: { size: rec.fileSize }, poll: tick, sleep: wait, diag, onInterrupted: () => undefined,
|
|
65
66
|
});
|
|
66
67
|
const permissions = createPermissionFlow({ perms: rec.permissions, openSettings: rec.openSettings, log: diag.log });
|
|
@@ -10,11 +10,12 @@ export const DEFAULT_FEATURES: FoundryFeatures = {
|
|
|
10
10
|
export const SCREEN_FEATURE: Partial<Record<string, keyof FoundryFeatures>> = {
|
|
11
11
|
record: 'recording', notes: 'notes', tracker: 'tracker', library: 'library', ask: 'ask',
|
|
12
12
|
planning: 'planning', connections: 'connections', 'connect-claude': 'connectClaude', converse: 'converse', decisions: 'notifications',
|
|
13
|
+
plan: 'tracker',
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
/** Entity types a built-in screen shows (the `entity` screen names its own in `options.entityType`). */
|
|
16
17
|
export const SCREEN_ENTITY_TYPES: Record<string, string[]> = {
|
|
17
|
-
tracker: ['commitment'], notes: ['source_document'], library: ['source_document'], planning: ['focus'],
|
|
18
|
+
tracker: ['commitment'], notes: ['source_document'], library: ['source_document'], planning: ['focus'], plan: ['commitment', 'focus'],
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
export const DEFAULT_HOME_TYPES: FoundryHomeType[] = [
|
|
@@ -37,14 +38,19 @@ export const SCREEN_DEFAULTS: Record<string, { label: string; description?: stri
|
|
|
37
38
|
converse: { label: 'Converse', icon: 'mic', description: 'Talk it through with your assistant', priority: 85 },
|
|
38
39
|
decisions: { label: 'Decisions', icon: 'check', description: 'Questions waiting for you' },
|
|
39
40
|
entity: { label: 'Records', icon: 'list' },
|
|
41
|
+
plan: { label: 'Plan', icon: 'check', description: 'Everything you owe, and what you are aiming for', priority: 80 },
|
|
42
|
+
talk: { label: 'Talk', icon: 'mic', description: 'Talk or type to Tandem', priority: 90 },
|
|
40
43
|
};
|
|
41
44
|
|
|
45
|
+
/** Screens an app asks for by name: the grouped Plan and Talk tabs replace Tracker/Planning and Ask/Converse, so a default tab list must not carry both. */
|
|
46
|
+
const OPT_IN_SCREENS: readonly string[] = ['plan', 'talk'];
|
|
47
|
+
|
|
42
48
|
/** The tab each built-in screen takes when the config names no tabs. `record` keeps the key `go`. */
|
|
43
49
|
const DEFAULT_KEYS: Record<string, string> = { record: 'go' };
|
|
44
50
|
|
|
45
51
|
export function defaultTabs(features: FoundryFeatures): FoundryTabConfig[] {
|
|
46
52
|
const on = (screen: string) => { const f = SCREEN_FEATURE[screen]; return !f || features[f]; };
|
|
47
|
-
return BUILTIN_SCREENS.filter((s) => s !== 'entity' && on(s)).map((screen) => ({ key: DEFAULT_KEYS[screen] ?? screen, screen }));
|
|
53
|
+
return BUILTIN_SCREENS.filter((s) => s !== 'entity' && !OPT_IN_SCREENS.includes(s) && on(s)).map((screen) => ({ key: DEFAULT_KEYS[screen] ?? screen, screen }));
|
|
48
54
|
}
|
|
49
55
|
|
|
50
56
|
export function defaultBrandTagline(): string { return 'Your workspace'; }
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
/** Screen kinds the shell ships. An app can add or override kinds through a screen registry. */
|
|
7
7
|
export const BUILTIN_SCREENS = [
|
|
8
|
-
'home', 'record', 'notes', 'tracker', 'library', 'ask', 'planning', 'connections', 'connect-claude', 'converse', 'decisions', 'entity',
|
|
8
|
+
'home', 'record', 'notes', 'tracker', 'library', 'ask', 'planning', 'connections', 'connect-claude', 'converse', 'decisions', 'entity', 'plan', 'talk',
|
|
9
9
|
] as const;
|
|
10
10
|
export type BuiltinScreen = (typeof BUILTIN_SCREENS)[number];
|
|
11
11
|
|
|
@@ -44,6 +44,7 @@ export function createConverse(deps: {
|
|
|
44
44
|
void speed.load();
|
|
45
45
|
let broken: (() => void) | null = null;
|
|
46
46
|
const audio = createRecorderAudio({
|
|
47
|
+
kind: 'transient',
|
|
47
48
|
driver: rec.driver, session: rec.session, fs: { size: rec.fileSize }, poll: tick, sleep: wait, diag,
|
|
48
49
|
onInterrupted: () => broken?.(),
|
|
49
50
|
onInterruptionEnded: () => undefined,
|
|
@@ -11,6 +11,13 @@ import { createConnectionsTab } from '../screens/connections/tab';
|
|
|
11
11
|
import { createPlanningTab } from '../screens/planning/tab';
|
|
12
12
|
import { askTab, libraryTab } from '../screens/tabs';
|
|
13
13
|
import { trackerTab } from '../tracker/tab';
|
|
14
|
+
import { planTab } from '../plan/PlanTab';
|
|
15
|
+
import { talkTab } from '../talk/TalkTab';
|
|
16
|
+
import { BriefingCard } from '../briefing/BriefingCard';
|
|
17
|
+
import type { BriefingController } from '../briefing/controller';
|
|
18
|
+
import type { BriefingReplyController } from '../briefing/reply';
|
|
19
|
+
import type { FoundryStrings } from './strings';
|
|
20
|
+
import { TAB_COPY } from '../../corpus/nav-copy';
|
|
14
21
|
import type { MeetingController } from '../../corpus/converse/meeting';
|
|
15
22
|
import { converseTab } from '../converse/tab';
|
|
16
23
|
import type { SpeedStore } from '../converse/speed';
|
|
@@ -44,6 +51,9 @@ export interface ScreenDeps {
|
|
|
44
51
|
/** Decisions and push; null when `features.notifications` is off. */
|
|
45
52
|
notify?: { decisions: DecisionsController; push: PushController } | null;
|
|
46
53
|
itemsChanged?: { subscribe(listener: () => void): () => void };
|
|
54
|
+
/** "What's on the plate" (the spoken briefing); null when `features.briefing` is off. Drawn on the Home tab. */
|
|
55
|
+
briefing?: { controller: BriefingController; reply: BriefingReplyController | null } | null;
|
|
56
|
+
strings?: FoundryStrings;
|
|
47
57
|
}
|
|
48
58
|
|
|
49
59
|
/** Builds one shell tab from its config entry. */
|
|
@@ -60,23 +70,33 @@ export interface ScreenRegistry {
|
|
|
60
70
|
const firstKey = (config: FoundryAppConfig, screen: string) => config.tabs.find((t) => t.screen === screen)?.key;
|
|
61
71
|
|
|
62
72
|
export const BUILTIN_FACTORIES: Record<string, ScreenFactory> = {
|
|
63
|
-
home: ({ config, corpus }, tab) => {
|
|
73
|
+
home: ({ config, corpus, briefing, strings }, tab) => {
|
|
64
74
|
const tabs: Record<string, string> = {};
|
|
65
75
|
for (const t of config.home.types) { const k = tabForEntityType(config, t.key); if (k) tabs[t.key] = k; }
|
|
66
|
-
|
|
76
|
+
// `options.copy: "today"` is the Today framing (title, one plain line, Talk and Plan entries); other apps keep the brand title.
|
|
77
|
+
const today = tab.options?.copy === 'today';
|
|
78
|
+
return homeTab({
|
|
79
|
+
api: corpus, brand: config.brand.name, tagline: config.brand.tagline, key: tab.key, label: tabLabel(tab), types: config.home.types, tabs,
|
|
80
|
+
talkKey: firstKey(config, 'talk') ?? firstKey(config, 'converse'), planKey: firstKey(config, 'plan'),
|
|
81
|
+
briefing: briefing && strings ? () => <BriefingCard controller={briefing.controller} reply={briefing.reply} strings={strings} /> : undefined,
|
|
82
|
+
copy: today ? TAB_COPY.today : undefined,
|
|
83
|
+
});
|
|
67
84
|
},
|
|
68
85
|
record: ({ record }, tab) => ({ key: tab.key, label: tabLabel(tab), safeArea: false, render: () => record() }),
|
|
69
|
-
notes: ({ notes, corpus }, tab) => {
|
|
86
|
+
notes: ({ config, notes, corpus }, tab) => {
|
|
87
|
+
const planKey = firstKey(config, 'plan');
|
|
70
88
|
if (!notes) throw new Error(`tab "${tab.key}": the notes screen needs a notes controller`);
|
|
71
89
|
return {
|
|
72
90
|
key: tab.key, label: tabLabel(tab), resetOnLeave: true,
|
|
73
|
-
render: ({ route, push, back }) => (route
|
|
74
|
-
? <NoteDetailScreen controller={notes} noteId={route.id} onBack={back} />
|
|
91
|
+
render: ({ route, push, back, openTab }) => (route
|
|
92
|
+
? <NoteDetailScreen controller={notes} noteId={route.id} onBack={back} onOpenPlan={planKey ? () => openTab(planKey) : undefined} />
|
|
75
93
|
: <NotesListScreen controller={notes} displays={corpus.schema?.displays} onOpen={(n) => push(n.id)} />),
|
|
76
94
|
};
|
|
77
95
|
},
|
|
78
96
|
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 }),
|
|
79
|
-
|
|
97
|
+
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 }),
|
|
98
|
+
talk: ({ config, corpus, converse, converseSpeed }, tab) => talkTab({ api: corpus, converse, speed: converseSpeed, key: tab.key, label: tabLabel(tab), libraryKey: firstKey(config, 'library'), planKey: firstKey(config, 'plan') }),
|
|
99
|
+
library: ({ config, corpus }, tab) => libraryTab(corpus, { key: tab.key, label: tabLabel(tab), planKey: firstKey(config, 'plan') }),
|
|
80
100
|
ask: ({ corpus }, tab) => askTab(corpus, { key: tab.key, label: tabLabel(tab) }),
|
|
81
101
|
planning: ({ config, corpus }, tab) => createPlanningTab({ api: corpus, key: tab.key, label: tabLabel(tab), documentTab: firstKey(config, 'library') }),
|
|
82
102
|
connections: ({ config, member, openUrl }, tab) => createConnectionsTab({ api: member.connections, key: tab.key, label: tabLabel(tab), openUrl, returnTo: `${config.app.scheme}://${tab.key}` }),
|
|
@@ -135,10 +135,11 @@ export function createFoundryServices(deps: { config: FoundryAppConfig; device:
|
|
|
135
135
|
const notify = config.features.notifications ? createNotify({ config, device, session, diag, fake: Boolean(deps.fakeConverse), handleLink: (url) => handleLink(url) }) : null;
|
|
136
136
|
|
|
137
137
|
let open: (tab: string, id?: string) => void = () => undefined;
|
|
138
|
-
|
|
138
|
+
// The briefing lives on GO when the app has one, else on Home (Today): the morning notification lands there.
|
|
139
|
+
const goTab = (config.tabs.find((t) => t.screen === 'record') ?? config.tabs.find((t) => t.screen === 'home'))?.key;
|
|
139
140
|
const deepLink = createDeepLink({
|
|
140
141
|
openBriefing: () => {
|
|
141
|
-
// The morning notification: land on
|
|
142
|
+
// The morning notification: land on the briefing's tab and play today's briefing (a briefing already playing is left alone).
|
|
142
143
|
if (goTab) open(goTab);
|
|
143
144
|
const phase = briefing?.controller.getState().phase;
|
|
144
145
|
if (phase !== 'playing' && phase !== 'loading') void briefing?.controller.start();
|
|
@@ -12,6 +12,8 @@ export interface NoteDetailScreenProps {
|
|
|
12
12
|
controller: VoiceNotesController;
|
|
13
13
|
noteId: string;
|
|
14
14
|
onBack: () => void;
|
|
15
|
+
/** Open the Plan tab: a note's to-dos are listed there, never here. Omit and the line is plain text. */
|
|
16
|
+
onOpenPlan?: () => void;
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
function ProjectPicker({ focuses, value, onPick }: { focuses: VoiceFocus[]; value: string | null; onPick: (id: string | null) => void }) {
|
|
@@ -25,7 +27,7 @@ function ProjectPicker({ focuses, value, onPick }: { focuses: VoiceFocus[]; valu
|
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
/** One note: summary (per section when the note has them), to-dos, project, transcript, retry, delete. */
|
|
28
|
-
export function NoteDetailScreen({ controller, noteId, onBack }: NoteDetailScreenProps) {
|
|
30
|
+
export function NoteDetailScreen({ controller, noteId, onBack, onOpenPlan }: NoteDetailScreenProps) {
|
|
29
31
|
const state = useVoiceNotes(controller);
|
|
30
32
|
const theme = useTheme();
|
|
31
33
|
const haptic = useHaptics();
|
|
@@ -51,6 +53,7 @@ export function NoteDetailScreen({ controller, noteId, onBack }: NoteDetailScree
|
|
|
51
53
|
]);
|
|
52
54
|
const meta = [formatNoteDate(note.occurredAt), formatDuration(note.durationMs)].filter(Boolean).join(' · ');
|
|
53
55
|
const lead = noteLead(note);
|
|
56
|
+
const todoCount = sections.reduce((n, s) => n + s.items.length, 0);
|
|
54
57
|
|
|
55
58
|
return (
|
|
56
59
|
<DetailScreen
|
|
@@ -81,12 +84,21 @@ export function NoteDetailScreen({ controller, noteId, onBack }: NoteDetailScree
|
|
|
81
84
|
<View key={`${s.label}-${i}`} testID={`section-${i}`}>
|
|
82
85
|
<Section title={sections.length > 1 || s.label ? `${s.label || focusTitle(s.focusId)}${s.kind === 'personal' ? ' (personal)' : ''}` : 'Summary'} footer={sections.length > 1 && s.focusId ? `Filed under ${focusTitle(s.focusId)}` : undefined}>
|
|
83
86
|
{s.summary ? <View style={{ paddingVertical: theme.spacing.md, paddingRight: theme.spacing.xs }}><Text variant="body">{s.summary}</Text></View> : null}
|
|
84
|
-
{s.items.map((item, j) => (
|
|
85
|
-
<ListRow key={j} title={item} titleLines={4} leading={<Icon name="check" size={20} color={theme.colors.mutedForeground} />} />
|
|
86
|
-
))}
|
|
87
87
|
</Section>
|
|
88
88
|
</View>
|
|
89
89
|
))}
|
|
90
|
+
{todoCount > 0 ? (
|
|
91
|
+
<Section title="To-dos">
|
|
92
|
+
<ListRow
|
|
93
|
+
testID="note-todos-in-plan"
|
|
94
|
+
title={`${todoCount} to-do${todoCount === 1 ? '' : 's'} from this note`}
|
|
95
|
+
subtitle="They are in Plan, in the one list."
|
|
96
|
+
leading={<Icon name="check" size={20} color={theme.colors.mutedForeground} />}
|
|
97
|
+
onPress={onOpenPlan}
|
|
98
|
+
chevron={Boolean(onOpenPlan)}
|
|
99
|
+
/>
|
|
100
|
+
</Section>
|
|
101
|
+
) : null}
|
|
90
102
|
|
|
91
103
|
<Section title="Project">
|
|
92
104
|
<View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: theme.spacing.md, paddingVertical: theme.spacing.md, paddingRight: theme.spacing.xs }}>
|
|
@@ -135,22 +135,22 @@ describe('NoteDetailScreen delete (bd startsim-ij1lw.2)', () => {
|
|
|
135
135
|
});
|
|
136
136
|
|
|
137
137
|
describe('NoteDetailScreen', () => {
|
|
138
|
-
it('
|
|
138
|
+
it('shows the note summary but never its own to-do list: the to-dos are in Plan', async () => {
|
|
139
139
|
const { r } = await mountDetail('n1');
|
|
140
140
|
const text = allText(r);
|
|
141
|
-
expect(text).toContain('Finish exhibit list');
|
|
142
|
-
expect(text).toContain('Call Megan about the filing receipt');
|
|
143
|
-
expect(text).toContain('Move weekly report to Monday');
|
|
144
|
-
expect(text).toContain('Book the dentist');
|
|
145
141
|
expect(text).toContain('Finish the exhibit list before the hearing.');
|
|
142
|
+
expect(text).not.toContain('Call Megan about the filing receipt');
|
|
143
|
+
expect(text).not.toContain('Book the dentist');
|
|
144
|
+
expect(text).toContain('4 to-dos from this note');
|
|
145
|
+
expect(text).toContain('They are in Plan, in the one list.');
|
|
146
146
|
});
|
|
147
147
|
|
|
148
|
-
it('a note without sections
|
|
148
|
+
it('counts a note without sections from its summary bullets, and links into Plan', async () => {
|
|
149
149
|
const { r } = await mountDetail('n2', {
|
|
150
150
|
notes: [{ id: 'n2', title: 'Garage', status: 'ready', occurredAt: null, focusId: null, transcript: '', summary: 'Garage plans.\n\n## Next Steps\n- **Buy brackets** (Quinn)\n- **Cut shelves**' }],
|
|
151
151
|
});
|
|
152
|
-
expect(allText(r)).toContain('
|
|
153
|
-
expect(allText(r)).toContain('
|
|
152
|
+
expect(allText(r)).toContain('2 to-dos from this note');
|
|
153
|
+
expect(allText(r)).not.toContain('Buy brackets');
|
|
154
154
|
});
|
|
155
155
|
|
|
156
156
|
it('a note past the first page still opens (fetched by id)', async () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from 'react';
|
|
2
|
-
import { FlatList, Pressable, Text as RNText, View } from 'react-native';
|
|
2
|
+
import { FlatList, KeyboardAvoidingView, Platform, Pressable, Text as RNText, TextInput, View } from 'react-native';
|
|
3
3
|
import { Alert, Button, EmptyState, Header, MessageBubble, Spinner, useHaptics, useTheme } from '@startsimpli/ui-native';
|
|
4
4
|
import { useControllerState } from '../components/useControllerState';
|
|
5
5
|
import type { MeetingController } from '../../corpus/converse/meeting';
|
|
@@ -24,11 +24,13 @@ function useElapsed(on: boolean): number {
|
|
|
24
24
|
* Converse is a live meeting. One tap on Start; from then on it listens, notices when you stop talking, sends, speaks the
|
|
25
25
|
* reply and listens again until End. The reply text stays on screen and Replay says it again.
|
|
26
26
|
*/
|
|
27
|
-
export function ConverseScreen({ controller, speed }: { controller: MeetingController; speed?: SpeedStore }) {
|
|
27
|
+
export function ConverseScreen({ controller, speed, embedded }: { controller: MeetingController; speed?: SpeedStore; /** The Talk tab draws the title above this screen. */ embedded?: boolean }) {
|
|
28
28
|
const theme = useTheme();
|
|
29
29
|
const haptic = useHaptics();
|
|
30
30
|
const s = useControllerState({ getState: controller.getState, subscribe: (l: () => void) => controller.subscribe(l) });
|
|
31
31
|
const rate = useControllerState({ getState: speed ? speed.get : () => 1, subscribe: (l: () => void) => (speed ? speed.subscribe(l) : () => undefined) });
|
|
32
|
+
const [draft, setDraft] = useState('');
|
|
33
|
+
const send = () => { const t = draft.trim(); if (!t) return; setDraft(''); haptic('light', 'converse.send'); void controller.sendText(t); };
|
|
32
34
|
const list = useRef<FlatList<{ role: string; text: string }>>(null);
|
|
33
35
|
const active = s.phase === 'listening' || s.phase === 'thinking' || s.phase === 'speaking';
|
|
34
36
|
const busy = s.phase === 'ending';
|
|
@@ -36,8 +38,8 @@ export function ConverseScreen({ controller, speed }: { controller: MeetingContr
|
|
|
36
38
|
const color = s.phase === 'listening' ? theme.colors.destructive : s.phase === 'speaking' ? theme.colors.success ?? theme.colors.primary : theme.colors.primary;
|
|
37
39
|
|
|
38
40
|
return (
|
|
39
|
-
<
|
|
40
|
-
<Header large={!active && !busy} testID="converse-header" title="
|
|
41
|
+
<KeyboardAvoidingView style={{ flex: 1 }} behavior={Platform.OS === 'ios' ? 'padding' : undefined} testID="converse-screen">
|
|
42
|
+
{embedded ? null : <Header large={!active && !busy} testID="converse-header" title="Talk" subtitle={active ? 'Meeting in progress' : 'Talk it through'} />}
|
|
41
43
|
<FlatList
|
|
42
44
|
ref={list}
|
|
43
45
|
testID="converse-transcript"
|
|
@@ -87,6 +89,23 @@ export function ConverseScreen({ controller, speed }: { controller: MeetingContr
|
|
|
87
89
|
</RNText>
|
|
88
90
|
</>
|
|
89
91
|
)}
|
|
92
|
+
{/* Typing starts a conversation too: the Talk tab is start-talking OR a type box. */}
|
|
93
|
+
{active || embedded ? (
|
|
94
|
+
<View style={{ flexDirection: 'row', alignItems: 'center', gap: theme.spacing.sm, alignSelf: 'stretch' }}>
|
|
95
|
+
<TextInput
|
|
96
|
+
testID="converse-input"
|
|
97
|
+
value={draft}
|
|
98
|
+
onChangeText={setDraft}
|
|
99
|
+
onSubmitEditing={send}
|
|
100
|
+
returnKeyType="send"
|
|
101
|
+
placeholder="Or type here"
|
|
102
|
+
placeholderTextColor={theme.colors.mutedForeground}
|
|
103
|
+
accessibilityLabel="Type a message"
|
|
104
|
+
style={{ flex: 1, minHeight: 44, paddingHorizontal: theme.spacing.md, borderRadius: 22, borderWidth: 1, borderColor: theme.colors.border, color: theme.colors.foreground, fontSize: theme.fontSizes.lg }}
|
|
105
|
+
/>
|
|
106
|
+
<Button testID="converse-send" title="Send" variant="outline" disabled={!draft.trim()} onPress={send} />
|
|
107
|
+
</View>
|
|
108
|
+
) : null}
|
|
90
109
|
{speed ? (
|
|
91
110
|
<View testID="converse-speed" accessibilityLabel="Reply speed" style={{ flexDirection: 'row', alignItems: 'center', gap: theme.spacing.sm }}>
|
|
92
111
|
<RNText style={{ color: theme.colors.mutedForeground, fontSize: theme.fontSizes.sm }}>Speed</RNText>
|
|
@@ -110,6 +129,6 @@ export function ConverseScreen({ controller, speed }: { controller: MeetingContr
|
|
|
110
129
|
<Button testID="converse-end" title="End meeting" variant={active ? "destructive" : "outline"} size="lg" disabled={busy || (!active && s.phase !== 'stopped')} onPress={() => { haptic('warning', 'converse.end'); void controller.end(); }} />
|
|
111
130
|
</View>
|
|
112
131
|
</View>
|
|
113
|
-
</
|
|
132
|
+
</KeyboardAvoidingView>
|
|
114
133
|
);
|
|
115
134
|
}
|
|
@@ -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
|
+
}
|