@agimon-ai/po-native 0.0.1-alpha.33 → 0.0.1-alpha.34
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 +12 -12
- package/src/app/AccountRoute.tsx +2 -2
- package/src/app/App.tsx +55 -16
- package/src/app/GrantNotices.tsx +39 -3
- package/src/app/railWorkspaces.ts +2 -2
- package/src/components/GrantNotice.tsx +15 -0
- package/src/components/SessionSheets.stories.tsx +7 -1
- package/src/components/SessionSheets.tsx +39 -8
- package/src/screens/AccountOnboarding.stories.tsx +1 -1
- package/src/screens/AccountScreen.tsx +35 -22
- package/src/screens/Grants.stories.tsx +21 -2
- package/src/screens/SettingsScreen.tsx +11 -6
- package/src/services/hostActions/index.ts +7 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agimon-ai/po-native",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.34",
|
|
4
4
|
"description": "Po for iOS and Android",
|
|
5
5
|
"homepage": "https://agimon.ai",
|
|
6
6
|
"bugs": {
|
|
@@ -29,17 +29,17 @@
|
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@agimon-ai/po-core": "0.0.0-alpha.
|
|
33
|
-
"@agimon-ai/po-expo-signing": "0.0.1-alpha.
|
|
34
|
-
"@agimon-ai/po-identity": "0.0.2-alpha.
|
|
35
|
-
"@agimon-ai/po-native-components": "0.0.0-alpha.
|
|
36
|
-
"@agimon-ai/po-native-dashboard": "0.0.0-alpha.
|
|
37
|
-
"@agimon-ai/po-template-advanced": "0.0.0-alpha.
|
|
38
|
-
"@agimon-ai/po-template-elegant": "0.0.0-alpha.
|
|
39
|
-
"@agimon-ai/po-voice": "0.0.0-alpha.
|
|
40
|
-
"@agimon-ai/po-web-components": "0.0.0-alpha.
|
|
41
|
-
"@agimon-ai/po-web-dashboard": "0.0.0-alpha.
|
|
42
|
-
"@agimon-ai/po-web-security": "0.0.0-alpha.
|
|
32
|
+
"@agimon-ai/po-core": "0.0.0-alpha.154",
|
|
33
|
+
"@agimon-ai/po-expo-signing": "0.0.1-alpha.34",
|
|
34
|
+
"@agimon-ai/po-identity": "0.0.2-alpha.101",
|
|
35
|
+
"@agimon-ai/po-native-components": "0.0.0-alpha.154",
|
|
36
|
+
"@agimon-ai/po-native-dashboard": "0.0.0-alpha.26",
|
|
37
|
+
"@agimon-ai/po-template-advanced": "0.0.0-alpha.154",
|
|
38
|
+
"@agimon-ai/po-template-elegant": "0.0.0-alpha.154",
|
|
39
|
+
"@agimon-ai/po-voice": "0.0.0-alpha.154",
|
|
40
|
+
"@agimon-ai/po-web-components": "0.0.0-alpha.154",
|
|
41
|
+
"@agimon-ai/po-web-dashboard": "0.0.0-alpha.154",
|
|
42
|
+
"@agimon-ai/po-web-security": "0.0.0-alpha.154",
|
|
43
43
|
"@better-auth/expo": "1.7.12",
|
|
44
44
|
"@config-plugins/react-native-webrtc": "15.0.2",
|
|
45
45
|
"@earendil-works/chord": "1.5.1",
|
package/src/app/AccountRoute.tsx
CHANGED
|
@@ -111,7 +111,7 @@ export function AccountRoute({
|
|
|
111
111
|
now?: () => number;
|
|
112
112
|
}) {
|
|
113
113
|
const [page, setPage] = useState<AccountPage>(firstRun ? 'welcome' : 'account');
|
|
114
|
-
// First run's "Sign in
|
|
114
|
+
// First run's "Sign in with Po" leaves the welcome screen for the sign-in methods.
|
|
115
115
|
const [cloudSignIn, setCloudSignIn] = useState(false);
|
|
116
116
|
const [cloudHost, setCloudHost] = useState<CloudHostRecord>();
|
|
117
117
|
const [providerKey, setProviderKey] = useState('');
|
|
@@ -615,7 +615,7 @@ export function AccountRoute({
|
|
|
615
615
|
active = false;
|
|
616
616
|
};
|
|
617
617
|
}, [record]);
|
|
618
|
-
// "Sign in
|
|
618
|
+
// "Sign in with Po" connects once the phone is trusted and any recovery code is saved; a failure
|
|
619
619
|
// leaves "Use Po Cloud" to try again.
|
|
620
620
|
useEffect(() => {
|
|
621
621
|
if (!cloudSignIn || cloudConnecting.current || busy || page !== 'account') return;
|
package/src/app/App.tsx
CHANGED
|
@@ -90,6 +90,7 @@ import {
|
|
|
90
90
|
webPluginRegistryForHost,
|
|
91
91
|
parseDashboardTileData,
|
|
92
92
|
HOST_SLOTS,
|
|
93
|
+
renderRegion,
|
|
93
94
|
hostSlotFills,
|
|
94
95
|
webPluginRegistryRevision,
|
|
95
96
|
hostPluginProviders,
|
|
@@ -102,6 +103,7 @@ import {
|
|
|
102
103
|
settingsKeyOf,
|
|
103
104
|
homeActivity,
|
|
104
105
|
filterEntries,
|
|
106
|
+
botCoordinatorBlocked,
|
|
105
107
|
} from '@agimon-ai/po-web-dashboard/core';
|
|
106
108
|
import { NATIVE_PAIRING_LINK_PREFIX, type SettingsRepository } from '@agimon-ai/po-web-dashboard/types';
|
|
107
109
|
import { type BottomTabBarProps, createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
|
@@ -256,7 +258,7 @@ import { setActivityLoad, useActivityLoad } from './activityLoads';
|
|
|
256
258
|
import { appearanceStore, loadAppearance, setAppearance } from './appearance';
|
|
257
259
|
import { addCloudCoordinator, createCloudSession, deleteCloudSession, setCloudSessionRole } from './cloudRuntime';
|
|
258
260
|
import { loadSentFromPhone, markSentFromPhone, sentFromPhoneStore } from './firstSteps';
|
|
259
|
-
import { GrantNotices } from './GrantNotices';
|
|
261
|
+
import { GrantNotices, SignInAskWhenSignedOut } from './GrantNotices';
|
|
260
262
|
import type { HomeReadState } from './homeState';
|
|
261
263
|
import { HostBackdrop, useBackdropFills } from './HostBackdrop';
|
|
262
264
|
import { createHostRuntimes, type HostRuntimes, type HostRuntimeState } from './hostRuntimes';
|
|
@@ -1222,6 +1224,14 @@ function SettingsRoute(
|
|
|
1222
1224
|
return (
|
|
1223
1225
|
<SettingsScreen
|
|
1224
1226
|
globalSection={<GlobalSettings />}
|
|
1227
|
+
accountRegion={(entry) =>
|
|
1228
|
+
renderRegion(
|
|
1229
|
+
HOST_SLOTS.accountRegion,
|
|
1230
|
+
entry,
|
|
1231
|
+
{ ...nativeSlotProps('', {}, () => undefined), sessionId: null },
|
|
1232
|
+
null,
|
|
1233
|
+
)
|
|
1234
|
+
}
|
|
1225
1235
|
{...props}
|
|
1226
1236
|
{...(providers ? { providers } : {})}
|
|
1227
1237
|
{...(mcpServers ? { mcpServers } : {})}
|
|
@@ -1792,6 +1802,7 @@ function SessionsRoute({
|
|
|
1792
1802
|
return host && isCloudHost(host) ? host : undefined;
|
|
1793
1803
|
};
|
|
1794
1804
|
const actionHostId = allowGlobalActions ? currentSession()?.hostId : undefined;
|
|
1805
|
+
/** Opens the add-bot sheet. A Po Cloud host offers no profile choice yet, so it still adds its coordinator directly. */
|
|
1795
1806
|
const createCoordinator = async (workspaceId?: string, explicitHostId?: string) => {
|
|
1796
1807
|
const workspaceHostId = workspaceId === undefined ? undefined : splitHostId(workspaceId)?.hostId;
|
|
1797
1808
|
if (workspaceHostId && explicitHostId && workspaceHostId !== explicitHostId)
|
|
@@ -1805,14 +1816,13 @@ function SessionsRoute({
|
|
|
1805
1816
|
const owner = workspaceId ?? qualifyHostId(hostId, 'home');
|
|
1806
1817
|
if (!canMutate(owner)) return unavailable;
|
|
1807
1818
|
const cloud = cloudHostFor(owner);
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
setCoordinatorTarget({ hostId, workspaceId, owner });
|
|
1812
|
-
return undefined;
|
|
1813
|
-
}
|
|
1814
|
-
return result;
|
|
1819
|
+
if (!cloud) {
|
|
1820
|
+
setCoordinatorTarget({ hostId, workspaceId, owner });
|
|
1821
|
+
return undefined;
|
|
1815
1822
|
}
|
|
1823
|
+
// ponytail: Po Cloud bots are always coordinators until its routes accept a profile.
|
|
1824
|
+
const result = await addCloudCoordinator(cloud, workspaceId);
|
|
1825
|
+
if ('error' in result) return result;
|
|
1816
1826
|
const error = await openWhenListed(owner, result.sessionId);
|
|
1817
1827
|
return error === undefined ? undefined : { error };
|
|
1818
1828
|
};
|
|
@@ -2175,11 +2185,27 @@ function SessionsRoute({
|
|
|
2175
2185
|
</Sheet>
|
|
2176
2186
|
<CoordinatorProfileSheet
|
|
2177
2187
|
target={coordinatorTarget}
|
|
2188
|
+
coordinatorBlocked={
|
|
2189
|
+
coordinatorTarget
|
|
2190
|
+
? botCoordinatorBlocked(
|
|
2191
|
+
coordinatorTarget,
|
|
2192
|
+
workspacesStore.state.byId,
|
|
2193
|
+
Object.values(sessionsStore.state.byId).map(({ summary }) => summary),
|
|
2194
|
+
)
|
|
2195
|
+
: undefined
|
|
2196
|
+
}
|
|
2178
2197
|
onClose={() => setCoordinatorTarget(null)}
|
|
2179
|
-
onCreate={async (target, profile) => {
|
|
2198
|
+
onCreate={async (target, profile, actAsCoordinator) => {
|
|
2180
2199
|
if (!canMutate(target.owner)) return unavailable.error;
|
|
2181
|
-
const
|
|
2200
|
+
const hostId = splitHostId(target.owner)?.hostId;
|
|
2201
|
+
const result = actAsCoordinator
|
|
2202
|
+
? await addCoordinator(target.workspaceId, target.hostId, profile)
|
|
2203
|
+
: target.workspaceId === undefined
|
|
2204
|
+
? await createGeneralSession(target.hostId, undefined, profile)
|
|
2205
|
+
: await createWorkspaceSession(target.workspaceId, undefined, profile);
|
|
2182
2206
|
if ('error' in result) return result.error;
|
|
2207
|
+
if ('workspace' in result && result.workspace) applyWorkspaceUpsert({ workspace: result.workspace }, hostId);
|
|
2208
|
+
if ('session' in result && result.session) applySessionUpsert({ session: result.session }, hostId);
|
|
2183
2209
|
return openWhenListed(target.owner, result.sessionId);
|
|
2184
2210
|
}}
|
|
2185
2211
|
/>
|
|
@@ -2299,7 +2325,15 @@ function HomeRoute({
|
|
|
2299
2325
|
const onShowEarlier = useCallback(() => setShowEarlier(true), []);
|
|
2300
2326
|
const appsSlot = useMemo(() => <HomeTiles hostStates={hostStates} />, [hostStates]);
|
|
2301
2327
|
const attentionSlot = useMemo(() => <HomeAttentionFills hostStates={hostStates} />, [hostStates]);
|
|
2302
|
-
const grantNotices = useMemo(
|
|
2328
|
+
const grantNotices = useMemo(
|
|
2329
|
+
() => (
|
|
2330
|
+
<>
|
|
2331
|
+
{signedOut ? null : <SignInAskWhenSignedOut />}
|
|
2332
|
+
<GrantNotices />
|
|
2333
|
+
</>
|
|
2334
|
+
),
|
|
2335
|
+
[signedOut],
|
|
2336
|
+
);
|
|
2303
2337
|
const connection = useMemo(
|
|
2304
2338
|
() => (connect ? { ...connect, cameraEnabled: focused && connect.cameraEnabled !== false } : undefined),
|
|
2305
2339
|
[connect, focused],
|
|
@@ -3155,11 +3189,16 @@ export function App({ nativeHost }: { nativeHost?: (sessionId: string) => Native
|
|
|
3155
3189
|
<Tab.Screen name="Home">
|
|
3156
3190
|
{() =>
|
|
3157
3191
|
hydrated && hostStates.length === 0 ? (
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3192
|
+
renderRegion(
|
|
3193
|
+
HOST_SLOTS.onboardingRegion,
|
|
3194
|
+
<AccountRoute
|
|
3195
|
+
firstRun
|
|
3196
|
+
onScan={() => navigation.navigate('AddHost')}
|
|
3197
|
+
onUseCloud={connectCloud}
|
|
3198
|
+
/>,
|
|
3199
|
+
{ ...nativeSlotProps('', {}, () => undefined), sessionId: null },
|
|
3200
|
+
null,
|
|
3201
|
+
)
|
|
3163
3202
|
) : (
|
|
3164
3203
|
<HomeRoute
|
|
3165
3204
|
hostStates={scopedStates}
|
package/src/app/GrantNotices.tsx
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
import { useIsFocused, useNavigation } from '@react-navigation/native';
|
|
2
|
+
import type { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
|
1
3
|
import { useStore } from '@tanstack/react-store';
|
|
2
|
-
import { useState } from 'react';
|
|
4
|
+
import { useEffect, useState } from 'react';
|
|
3
5
|
|
|
4
|
-
import { GrantNotice } from '../components/GrantNotice';
|
|
5
|
-
import {
|
|
6
|
+
import { GrantNotice, SignInAsk } from '../components/GrantNotice';
|
|
7
|
+
import {
|
|
8
|
+
accountGeneration,
|
|
9
|
+
accountGrants,
|
|
10
|
+
loadLocalAccount,
|
|
11
|
+
pausedGrants,
|
|
12
|
+
selectedIdentityIssuer,
|
|
13
|
+
} from '../services/accountClient';
|
|
6
14
|
import type { SavedGrant } from '../services/accountGrants';
|
|
7
15
|
|
|
8
16
|
function PausedGrant({ saved }: { saved: SavedGrant }) {
|
|
@@ -35,3 +43,31 @@ export function GrantNotices() {
|
|
|
35
43
|
const notices = useStore(pausedGrants, (state) => state);
|
|
36
44
|
return notices.map((saved) => <PausedGrant key={saved.envelope.payload.grantId} saved={saved} />);
|
|
37
45
|
}
|
|
46
|
+
|
|
47
|
+
/** True when this phone could sign in but has no account. A build without an identity home asks nothing. */
|
|
48
|
+
export async function shouldAskToSignIn(): Promise<boolean> {
|
|
49
|
+
try {
|
|
50
|
+
return (await loadLocalAccount(await selectedIdentityIssuer())) === undefined;
|
|
51
|
+
} catch {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Asks a phone that pairs without an account to sign in, rechecked each time Home regains focus. */
|
|
57
|
+
export function SignInAskWhenSignedOut() {
|
|
58
|
+
const navigation = useNavigation<NativeStackNavigationProp<{ SettingsAccount: undefined }>>();
|
|
59
|
+
const focused = useIsFocused();
|
|
60
|
+
const generation = useStore(accountGeneration);
|
|
61
|
+
const [signedOut, setSignedOut] = useState(false);
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
if (!focused) return;
|
|
64
|
+
let live = true;
|
|
65
|
+
void shouldAskToSignIn().then((value) => {
|
|
66
|
+
if (live) setSignedOut(value);
|
|
67
|
+
});
|
|
68
|
+
return () => {
|
|
69
|
+
live = false;
|
|
70
|
+
};
|
|
71
|
+
}, [focused, generation]);
|
|
72
|
+
return signedOut ? <SignInAsk onSignIn={() => navigation.navigate('SettingsAccount')} /> : null;
|
|
73
|
+
}
|
|
@@ -2,7 +2,7 @@ import type { WebTemplateRailWorkspace } from '@agimon-ai/po-core/native';
|
|
|
2
2
|
import {
|
|
3
3
|
buildRailWorkspaces,
|
|
4
4
|
splitHostId,
|
|
5
|
-
|
|
5
|
+
railParentIds,
|
|
6
6
|
sessionsStore,
|
|
7
7
|
useRailEntries,
|
|
8
8
|
workspacesStore,
|
|
@@ -39,7 +39,7 @@ export function useRailWorkspaces(
|
|
|
39
39
|
activeId,
|
|
40
40
|
workspaceOrder,
|
|
41
41
|
workspacesById,
|
|
42
|
-
nested:
|
|
42
|
+
nested: railParentIds(byId, order),
|
|
43
43
|
now: Date.now(),
|
|
44
44
|
restarts: NO_RESTARTS,
|
|
45
45
|
avatarUrls: {},
|
|
@@ -31,6 +31,21 @@ export function GrantNotice({
|
|
|
31
31
|
</Panel>
|
|
32
32
|
);
|
|
33
33
|
}
|
|
34
|
+
|
|
35
|
+
/** Storyboard v4's Home ask while this phone has paired computers but no account. Never a failure. */
|
|
36
|
+
export function SignInAsk({ onSignIn }: { onSignIn: () => void }) {
|
|
37
|
+
return (
|
|
38
|
+
<Panel style={styles.panel}>
|
|
39
|
+
<Text accessibilityRole="header" style={styles.title}>
|
|
40
|
+
Your Po Cloud sessions can live here too
|
|
41
|
+
</Text>
|
|
42
|
+
<Text style={styles.body}>Sign in whenever you are ready. Paired computers keep working.</Text>
|
|
43
|
+
<Button variant="secondary" size="lg" onPress={onSignIn}>
|
|
44
|
+
Sign in with Po
|
|
45
|
+
</Button>
|
|
46
|
+
</Panel>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
34
49
|
const styles = StyleSheet.create((theme) => ({
|
|
35
50
|
panel: {
|
|
36
51
|
padding: theme.spacing(4),
|
|
@@ -17,11 +17,12 @@ function Preview({
|
|
|
17
17
|
state = 'ready',
|
|
18
18
|
}: {
|
|
19
19
|
scheme?: 'light' | 'dark';
|
|
20
|
-
state?: 'ready' | 'loading' | 'empty' | 'error';
|
|
20
|
+
state?: 'ready' | 'loading' | 'empty' | 'error' | 'coordinator' | 'coordinator-taken';
|
|
21
21
|
}) {
|
|
22
22
|
UnistylesRuntime.setAdaptiveThemes(false);
|
|
23
23
|
UnistylesRuntime.setTheme(scheme);
|
|
24
24
|
const [profile, setProfile] = useState<string>();
|
|
25
|
+
const [actAsCoordinator, setActAsCoordinator] = useState(state === 'coordinator');
|
|
25
26
|
return (
|
|
26
27
|
<PoNativeProvider>
|
|
27
28
|
<Sheet open>
|
|
@@ -31,6 +32,9 @@ function Preview({
|
|
|
31
32
|
busy={false}
|
|
32
33
|
profile={profile}
|
|
33
34
|
onProfile={setProfile}
|
|
35
|
+
actAsCoordinator={actAsCoordinator}
|
|
36
|
+
onActAsCoordinator={setActAsCoordinator}
|
|
37
|
+
{...(state === 'coordinator-taken' ? { coordinatorBlocked: 'Home already has a coordinator.' } : {})}
|
|
34
38
|
catalog={{
|
|
35
39
|
readiness: 'ready',
|
|
36
40
|
profiles:
|
|
@@ -62,6 +66,8 @@ export const Dark = () => <Preview scheme="dark" />;
|
|
|
62
66
|
export const Loading = () => <Preview state="loading" />;
|
|
63
67
|
export const Empty = () => <Preview state="empty" />;
|
|
64
68
|
export const Failure = () => <Preview state="error" />;
|
|
69
|
+
export const ActAsCoordinator = () => <Preview state="coordinator" />;
|
|
70
|
+
export const CoordinatorTaken = () => <Preview state="coordinator-taken" />;
|
|
65
71
|
|
|
66
72
|
function NewProfilePreview({ scheme = 'light' }: { scheme?: 'light' | 'dark' }) {
|
|
67
73
|
UnistylesRuntime.setAdaptiveThemes(false);
|
|
@@ -3,12 +3,14 @@ import {
|
|
|
3
3
|
Button,
|
|
4
4
|
Input,
|
|
5
5
|
Label,
|
|
6
|
+
ListRow,
|
|
6
7
|
Select,
|
|
7
8
|
Sheet,
|
|
8
9
|
SheetBody,
|
|
9
10
|
SheetContent,
|
|
10
11
|
SheetHeader,
|
|
11
12
|
SheetTitle,
|
|
13
|
+
Switch,
|
|
12
14
|
} from '@agimon-ai/po-native-components';
|
|
13
15
|
import { HOST_SLOTS, workspaceSlotFills } from '@agimon-ai/po-web-dashboard/core';
|
|
14
16
|
import type { PiSessionHistoryItem } from '@agimon-ai/po-web-dashboard/types';
|
|
@@ -112,15 +114,18 @@ export function NewSessionSheet({ target, context, slotProps }: NewSessionSheetP
|
|
|
112
114
|
|
|
113
115
|
type CoordinatorTarget = { hostId: string; workspaceId?: string; owner: string };
|
|
114
116
|
|
|
115
|
-
/**
|
|
117
|
+
/** Adds a bot from a launch-only profile choice, optionally as the coordinator. Closing never posts or changes a default. */
|
|
116
118
|
export function CoordinatorProfileSheet({
|
|
117
119
|
target,
|
|
120
|
+
coordinatorBlocked,
|
|
118
121
|
onClose,
|
|
119
122
|
onCreate,
|
|
120
123
|
}: {
|
|
121
124
|
target: CoordinatorTarget | null;
|
|
125
|
+
/** Why this bot cannot act as coordinator, such as an existing one. Absent offers the choice. */
|
|
126
|
+
coordinatorBlocked?: string;
|
|
122
127
|
onClose: () => void;
|
|
123
|
-
onCreate: (target: CoordinatorTarget, profile: string) => Promise<string | undefined>;
|
|
128
|
+
onCreate: (target: CoordinatorTarget, profile: string, actAsCoordinator: boolean) => Promise<string | undefined>;
|
|
124
129
|
}) {
|
|
125
130
|
const [busy, setBusy] = useState(false);
|
|
126
131
|
return (
|
|
@@ -130,6 +135,7 @@ export function CoordinatorProfileSheet({
|
|
|
130
135
|
<CoordinatorProfileForm
|
|
131
136
|
key={JSON.stringify(target)}
|
|
132
137
|
target={target}
|
|
138
|
+
coordinatorBlocked={coordinatorBlocked}
|
|
133
139
|
onClose={onClose}
|
|
134
140
|
onCreate={onCreate}
|
|
135
141
|
busy={busy}
|
|
@@ -143,14 +149,16 @@ export function CoordinatorProfileSheet({
|
|
|
143
149
|
|
|
144
150
|
function CoordinatorProfileForm({
|
|
145
151
|
target,
|
|
152
|
+
coordinatorBlocked,
|
|
146
153
|
onClose,
|
|
147
154
|
onCreate,
|
|
148
155
|
busy,
|
|
149
156
|
setBusy,
|
|
150
157
|
}: {
|
|
151
158
|
target: CoordinatorTarget;
|
|
159
|
+
coordinatorBlocked?: string;
|
|
152
160
|
onClose: () => void;
|
|
153
|
-
onCreate: (target: CoordinatorTarget, profile: string) => Promise<string | undefined>;
|
|
161
|
+
onCreate: (target: CoordinatorTarget, profile: string, actAsCoordinator: boolean) => Promise<string | undefined>;
|
|
154
162
|
busy: boolean;
|
|
155
163
|
setBusy: (busy: boolean) => void;
|
|
156
164
|
}) {
|
|
@@ -158,6 +166,7 @@ function CoordinatorProfileForm({
|
|
|
158
166
|
const [loading, setLoading] = useState(true);
|
|
159
167
|
const [revision, setRevision] = useState(0);
|
|
160
168
|
const [profile, setProfile] = useState<string>();
|
|
169
|
+
const [actAsCoordinator, setActAsCoordinator] = useState(false);
|
|
161
170
|
const [error, setError] = useState('');
|
|
162
171
|
const [draft, setDraft] = useState<CreateProfileInput>();
|
|
163
172
|
useEffect(() => {
|
|
@@ -175,11 +184,11 @@ function CoordinatorProfileForm({
|
|
|
175
184
|
setBusy(true);
|
|
176
185
|
setError('');
|
|
177
186
|
try {
|
|
178
|
-
const failure = await onCreate(target, profile);
|
|
187
|
+
const failure = await onCreate(target, profile, actAsCoordinator && !coordinatorBlocked);
|
|
179
188
|
if (failure === undefined) onClose();
|
|
180
189
|
else setError(failure);
|
|
181
190
|
} catch {
|
|
182
|
-
setError('Po could not add the
|
|
191
|
+
setError('Po could not add the bot. Try again.');
|
|
183
192
|
} finally {
|
|
184
193
|
setBusy(false);
|
|
185
194
|
}
|
|
@@ -216,9 +225,12 @@ function CoordinatorProfileForm({
|
|
|
216
225
|
catalog={catalog}
|
|
217
226
|
loading={loading}
|
|
218
227
|
profile={profile}
|
|
228
|
+
actAsCoordinator={actAsCoordinator}
|
|
229
|
+
coordinatorBlocked={coordinatorBlocked}
|
|
219
230
|
busy={busy}
|
|
220
231
|
error={error}
|
|
221
232
|
onProfile={setProfile}
|
|
233
|
+
onActAsCoordinator={setActAsCoordinator}
|
|
222
234
|
onReload={() => setRevision((value) => value + 1)}
|
|
223
235
|
onNewProfile={() => {
|
|
224
236
|
setDraft({ displayName: '', alias: '', preset: 'focused' });
|
|
@@ -319,9 +331,12 @@ export function CoordinatorProfileSheetView({
|
|
|
319
331
|
catalog,
|
|
320
332
|
loading,
|
|
321
333
|
profile,
|
|
334
|
+
actAsCoordinator = false,
|
|
335
|
+
coordinatorBlocked,
|
|
322
336
|
busy,
|
|
323
337
|
error,
|
|
324
338
|
onProfile,
|
|
339
|
+
onActAsCoordinator,
|
|
325
340
|
onReload,
|
|
326
341
|
onNewProfile,
|
|
327
342
|
onCreate,
|
|
@@ -330,9 +345,12 @@ export function CoordinatorProfileSheetView({
|
|
|
330
345
|
catalog?: LaunchProfileCatalog;
|
|
331
346
|
loading: boolean;
|
|
332
347
|
profile?: string;
|
|
348
|
+
actAsCoordinator?: boolean;
|
|
349
|
+
coordinatorBlocked?: string;
|
|
333
350
|
busy: boolean;
|
|
334
351
|
error: string;
|
|
335
352
|
onProfile: (profile: string) => void;
|
|
353
|
+
onActAsCoordinator: (value: boolean) => void;
|
|
336
354
|
onReload: () => void;
|
|
337
355
|
onNewProfile: () => void;
|
|
338
356
|
onCreate: () => void;
|
|
@@ -341,10 +359,10 @@ export function CoordinatorProfileSheetView({
|
|
|
341
359
|
return (
|
|
342
360
|
<>
|
|
343
361
|
<SheetHeader>
|
|
344
|
-
<SheetTitle>
|
|
362
|
+
<SheetTitle>Create bot</SheetTitle>
|
|
345
363
|
</SheetHeader>
|
|
346
364
|
<SheetBody style={styles.body}>
|
|
347
|
-
<Text style={styles.root}>Choose a profile for
|
|
365
|
+
<Text style={styles.root}>Choose a profile for the new bot. Your defaults stay unchanged.</Text>
|
|
348
366
|
<Select
|
|
349
367
|
title="Profile"
|
|
350
368
|
placeholder="Choose a profile"
|
|
@@ -371,6 +389,19 @@ export function CoordinatorProfileSheetView({
|
|
|
371
389
|
<Button variant="outline" disabled={busy} onPress={onNewProfile}>
|
|
372
390
|
New profile
|
|
373
391
|
</Button>
|
|
392
|
+
<ListRow
|
|
393
|
+
title="Act as coordinator"
|
|
394
|
+
description={coordinatorBlocked || 'Oversees the other sessions here and keeps their logbook.'}
|
|
395
|
+
disclosure={false}
|
|
396
|
+
trailing={
|
|
397
|
+
<Switch
|
|
398
|
+
value={actAsCoordinator && !coordinatorBlocked}
|
|
399
|
+
onValueChange={onActAsCoordinator}
|
|
400
|
+
disabled={busy || Boolean(coordinatorBlocked)}
|
|
401
|
+
accessibilityLabel="Act as coordinator"
|
|
402
|
+
/>
|
|
403
|
+
}
|
|
404
|
+
/>
|
|
374
405
|
{error ? (
|
|
375
406
|
<Text style={styles.error} accessibilityRole="alert">
|
|
376
407
|
{error}
|
|
@@ -383,7 +414,7 @@ export function CoordinatorProfileSheetView({
|
|
|
383
414
|
disabled={loading || !profile || !catalog?.profiles.some((item) => item.name === profile)}
|
|
384
415
|
onPress={onCreate}
|
|
385
416
|
>
|
|
386
|
-
Create
|
|
417
|
+
Create bot
|
|
387
418
|
</Button>
|
|
388
419
|
<Button variant="ghost" disabled={busy} onPress={onClose}>
|
|
389
420
|
Cancel
|
|
@@ -73,7 +73,7 @@ export const RecoveredAccount = {
|
|
|
73
73
|
</PhoneFrame>
|
|
74
74
|
),
|
|
75
75
|
};
|
|
76
|
-
// First run's "Sign in
|
|
76
|
+
// First run's "Sign in with Po" opens these sign-in methods with a Back to the welcome screen.
|
|
77
77
|
export const CloudSignIn = {
|
|
78
78
|
render: () => (
|
|
79
79
|
<PhoneFrame scheme="light">
|
|
@@ -68,7 +68,7 @@ export interface AccountViewProps {
|
|
|
68
68
|
onCode?: (value: string) => void;
|
|
69
69
|
/** Po Cloud on this phone: absent when unset, `connected` once the cloud host is saved. */
|
|
70
70
|
cloud?: { connected: boolean; label?: string };
|
|
71
|
-
/** First run's "Sign in
|
|
71
|
+
/** First run's "Sign in with Po" opens the sign-in methods, which lead back to the welcome screen. */
|
|
72
72
|
welcomeBack?: boolean;
|
|
73
73
|
providerKey?: string;
|
|
74
74
|
onProviderKey?: (value: string) => void;
|
|
@@ -96,34 +96,47 @@ export function AccountView(props: AccountViewProps) {
|
|
|
96
96
|
</View>
|
|
97
97
|
<View style={styles.welcomeIntro}>
|
|
98
98
|
<Text accessibilityRole="header" style={styles.title}>
|
|
99
|
-
|
|
99
|
+
Po handles it.
|
|
100
100
|
</Text>
|
|
101
|
-
<Text style={styles.welcomeBody}>
|
|
101
|
+
<Text style={styles.welcomeBody}>One account for this phone, your computers and Po Cloud.</Text>
|
|
102
102
|
</View>
|
|
103
103
|
<View style={styles.welcomeConnect}>
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
104
|
+
{props.signInUnavailable ? (
|
|
105
|
+
<>
|
|
106
|
+
<Button
|
|
107
|
+
variant="primary"
|
|
108
|
+
size="lg"
|
|
109
|
+
loading={busy}
|
|
110
|
+
loadingLabel="Po is working on it"
|
|
111
|
+
style={styles.welcomeAction}
|
|
112
|
+
onPress={() => onAction('scan')}
|
|
113
|
+
>
|
|
114
|
+
<Text style={styles.welcomeActionLabel}>Connect a computer</Text>
|
|
115
|
+
</Button>
|
|
116
|
+
<Text style={styles.welcomeHint}>Scan a code or paste a link. No account needed.</Text>
|
|
117
|
+
</>
|
|
118
|
+
) : (
|
|
116
119
|
<>
|
|
120
|
+
<Button
|
|
121
|
+
variant="primary"
|
|
122
|
+
size="lg"
|
|
123
|
+
loading={busy}
|
|
124
|
+
loadingLabel="Po is working on it"
|
|
125
|
+
style={styles.welcomeAction}
|
|
126
|
+
onPress={() => onAction('cloud-sign-in')}
|
|
127
|
+
>
|
|
128
|
+
<Text style={styles.welcomeActionLabel}>Sign in with Po</Text>
|
|
129
|
+
</Button>
|
|
117
130
|
<Button
|
|
118
131
|
variant="outline"
|
|
119
132
|
size="lg"
|
|
120
133
|
disabled={busy}
|
|
121
134
|
style={styles.welcomeAction}
|
|
122
|
-
onPress={() => onAction('
|
|
135
|
+
onPress={() => onAction('scan')}
|
|
123
136
|
>
|
|
124
|
-
|
|
137
|
+
Connect a computer without an account
|
|
125
138
|
</Button>
|
|
126
|
-
<Text style={styles.welcomeHint}>
|
|
139
|
+
<Text style={styles.welcomeHint}>You can sign in later in Settings, Account.</Text>
|
|
127
140
|
</>
|
|
128
141
|
)}
|
|
129
142
|
</View>
|
|
@@ -161,7 +174,7 @@ export function AccountView(props: AccountViewProps) {
|
|
|
161
174
|
);
|
|
162
175
|
const titles: Record<AccountPage, string> = {
|
|
163
176
|
welcome: 'Po handles it.',
|
|
164
|
-
methods: 'Sign
|
|
177
|
+
methods: 'Sign in with Po',
|
|
165
178
|
email: 'Continue with email',
|
|
166
179
|
'email-code': 'Your email code',
|
|
167
180
|
'recovery-chooser': 'Find your way back',
|
|
@@ -215,7 +228,7 @@ export function AccountView(props: AccountViewProps) {
|
|
|
215
228
|
{page === 'welcome' ? (
|
|
216
229
|
<>
|
|
217
230
|
<Text style={styles.body}>
|
|
218
|
-
|
|
231
|
+
One account for this phone, your computers and Po Cloud. Or connect to Po on your computer without one.
|
|
219
232
|
</Text>
|
|
220
233
|
{(props.providers ?? []).map((provider) => {
|
|
221
234
|
const method = ACCOUNT_METHODS.find((item) => item.toLowerCase() === provider.toLowerCase());
|
|
@@ -244,7 +257,7 @@ export function AccountView(props: AccountViewProps) {
|
|
|
244
257
|
onChangeText={props.onDeviceName}
|
|
245
258
|
maxLength={64}
|
|
246
259
|
/>
|
|
247
|
-
<Text style={styles.detail}>You can sign
|
|
260
|
+
<Text style={styles.detail}>You can sign in later in Settings, Account.</Text>
|
|
248
261
|
</>
|
|
249
262
|
) : null}
|
|
250
263
|
{page === 'methods' ? (
|
|
@@ -420,7 +433,7 @@ export function AccountView(props: AccountViewProps) {
|
|
|
420
433
|
</Panel>
|
|
421
434
|
) : null}
|
|
422
435
|
{!props.signedIn ? (
|
|
423
|
-
action('Sign
|
|
436
|
+
action('Sign in with Po', 'welcome', true)
|
|
424
437
|
) : (
|
|
425
438
|
<>
|
|
426
439
|
<Panel>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { View } from 'react-native';
|
|
2
2
|
|
|
3
|
-
import { GrantNotice } from '../components/GrantNotice';
|
|
3
|
+
import { GrantNotice, SignInAsk } from '../components/GrantNotice';
|
|
4
4
|
import { PhoneFrame } from './designFrame';
|
|
5
5
|
|
|
6
6
|
const noop = () => undefined;
|
|
7
|
-
const meta = { title: 'Native/Design/Grants', tags: ['style-system', 'mockup', 'native'] };
|
|
7
|
+
export const meta = { title: 'Native/Design/Grants', tags: ['style-system', 'mockup', 'native'] };
|
|
8
8
|
export default meta;
|
|
9
9
|
export const Playground = {
|
|
10
10
|
render: () => (
|
|
@@ -45,3 +45,22 @@ export const Retry = {
|
|
|
45
45
|
</PhoneFrame>
|
|
46
46
|
),
|
|
47
47
|
};
|
|
48
|
+
/** Storyboard v4, 1b: Home on a phone paired without an account. */
|
|
49
|
+
export const SignInAskLight = {
|
|
50
|
+
render: () => (
|
|
51
|
+
<PhoneFrame scheme="light">
|
|
52
|
+
<View style={{ padding: 16 }}>
|
|
53
|
+
<SignInAsk onSignIn={noop} />
|
|
54
|
+
</View>
|
|
55
|
+
</PhoneFrame>
|
|
56
|
+
),
|
|
57
|
+
};
|
|
58
|
+
export const SignInAskDark = {
|
|
59
|
+
render: () => (
|
|
60
|
+
<PhoneFrame scheme="dark">
|
|
61
|
+
<View style={{ padding: 16 }}>
|
|
62
|
+
<SignInAsk onSignIn={noop} />
|
|
63
|
+
</View>
|
|
64
|
+
</PhoneFrame>
|
|
65
|
+
),
|
|
66
|
+
};
|
|
@@ -181,6 +181,8 @@ export interface SettingsScreenProps {
|
|
|
181
181
|
/** All hosts is chosen: hide computer-specific built-in settings, but keep each host's plugin pages. */
|
|
182
182
|
phoneOnly?: boolean;
|
|
183
183
|
globalSection?: ReactNode;
|
|
184
|
+
/** The host's `account-region`: a person's package may decorate or replace the Account entry. */
|
|
185
|
+
accountRegion?: (entry: ReactNode) => ReactNode;
|
|
184
186
|
}
|
|
185
187
|
|
|
186
188
|
/** The frame around a settings page a package draws: the menu's detail as the lede, as this screen leads with its own. */
|
|
@@ -229,6 +231,7 @@ export function SettingsScreen({
|
|
|
229
231
|
computer,
|
|
230
232
|
phoneOnly = false,
|
|
231
233
|
globalSection,
|
|
234
|
+
accountRegion = (entry) => entry,
|
|
232
235
|
}: SettingsScreenProps) {
|
|
233
236
|
const summary = remote ? remoteSummary(remote) : undefined;
|
|
234
237
|
const several = computers.length > 1;
|
|
@@ -356,12 +359,14 @@ export function SettingsScreen({
|
|
|
356
359
|
)}
|
|
357
360
|
{globalSection}
|
|
358
361
|
<Group label="This phone">
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
362
|
+
{accountRegion(
|
|
363
|
+
<NavRow
|
|
364
|
+
Icon={UserIcon}
|
|
365
|
+
title="Account"
|
|
366
|
+
value="Sign in with Po, devices and recovery"
|
|
367
|
+
onPress={() => onOpen('SettingsAccount')}
|
|
368
|
+
/>,
|
|
369
|
+
)}
|
|
365
370
|
<Row
|
|
366
371
|
leading={<MessageIcon size={18} color="dim" />}
|
|
367
372
|
title="Notifications"
|
|
@@ -79,11 +79,15 @@ async function sessionDetail(workspaceId: string, sessionId: string): Promise<Se
|
|
|
79
79
|
: undefined;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
/** A named profile pins the session to it; leaving it out lets the workspace default apply. */
|
|
82
83
|
export async function createWorkspaceSession(
|
|
83
84
|
workspaceId: string,
|
|
84
85
|
name?: string,
|
|
86
|
+
profile?: string,
|
|
85
87
|
): Promise<Result<{ sessionId: string; session?: SessionSummary }>> {
|
|
86
|
-
const result = await host
|
|
88
|
+
const result = await host
|
|
89
|
+
.workspace(workspaceId)
|
|
90
|
+
.createSession({ body: { name, ...(profile === undefined ? {} : { selection: { profile } }) } });
|
|
87
91
|
const body = result.data;
|
|
88
92
|
if (!result.ok || !isRecord(body) || typeof body.sessionId !== 'string') return errorOf(body, result.status);
|
|
89
93
|
const session = await sessionDetail(workspaceId, body.sessionId);
|
|
@@ -136,13 +140,14 @@ async function rootRequest(
|
|
|
136
140
|
export async function createGeneralSession(
|
|
137
141
|
hostId: string,
|
|
138
142
|
name?: string,
|
|
143
|
+
profile?: string,
|
|
139
144
|
): Promise<Result<{ sessionId: string; session?: SessionSummary; workspace?: WorkspaceSummary }>> {
|
|
140
145
|
const { ok, body, status } = await rootRequest(
|
|
141
146
|
'/api/sessions',
|
|
142
147
|
{
|
|
143
148
|
method: 'POST',
|
|
144
149
|
headers: { 'content-type': 'application/json' },
|
|
145
|
-
body: JSON.stringify({ name }),
|
|
150
|
+
body: JSON.stringify({ name, ...(profile === undefined ? {} : { selection: { profile } }) }),
|
|
146
151
|
},
|
|
147
152
|
hostId,
|
|
148
153
|
);
|