@agimon-ai/po-native 0.0.1-alpha.37 → 0.0.1-alpha.39
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/adapters/remoteSocket.ts +4 -2
- package/src/app/AccountRoute.tsx +4 -2
- package/src/app/App.tsx +29 -4
- package/src/app/TeamRoute.tsx +98 -0
- package/src/app/cloudRuntime.ts +32 -1
- package/src/app/hostRuntimes.ts +4 -1
- package/src/screens/AccountOnboarding.stories.tsx +12 -1
- package/src/screens/AccountScreen.tsx +61 -39
- package/src/screens/GlobalSettings.tsx +10 -8
- package/src/screens/SettingsScreen.stories.tsx +38 -3
- package/src/screens/SettingsScreen.tsx +43 -22
- package/src/screens/Team.stories.tsx +56 -0
- package/src/screens/TeamView.tsx +306 -0
- package/src/services/accountClient/index.ts +19 -0
- package/src/services/apiTransport/index.ts +32 -5
- package/src/services/logExport/index.ts +4 -1
- package/src/services/pairing/index.ts +8 -3
- package/src/services/settingsApi/index.ts +4 -0
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.39",
|
|
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.159",
|
|
33
|
+
"@agimon-ai/po-expo-signing": "0.0.1-alpha.39",
|
|
34
|
+
"@agimon-ai/po-identity": "0.0.2-alpha.106",
|
|
35
|
+
"@agimon-ai/po-native-components": "0.0.0-alpha.159",
|
|
36
|
+
"@agimon-ai/po-native-dashboard": "0.0.0-alpha.31",
|
|
37
|
+
"@agimon-ai/po-template-advanced": "0.0.0-alpha.159",
|
|
38
|
+
"@agimon-ai/po-template-elegant": "0.0.0-alpha.159",
|
|
39
|
+
"@agimon-ai/po-voice": "0.0.0-alpha.159",
|
|
40
|
+
"@agimon-ai/po-web-components": "0.0.0-alpha.159",
|
|
41
|
+
"@agimon-ai/po-web-dashboard": "0.0.0-alpha.159",
|
|
42
|
+
"@agimon-ai/po-web-security": "0.0.0-alpha.159",
|
|
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",
|
|
@@ -147,8 +147,10 @@ export function createNativeProtocolLink(
|
|
|
147
147
|
: new Error('Client device probe failed.', { cause: result.error });
|
|
148
148
|
const response = result?.response;
|
|
149
149
|
if (response && response.status !== 404) {
|
|
150
|
-
|
|
151
|
-
|
|
150
|
+
// A team host keeps its device list from a teammate (403) and still takes the preface.
|
|
151
|
+
if (!response.ok && response.status !== 403)
|
|
152
|
+
throw new Error(`Client device probe failed (${response.status}).`);
|
|
153
|
+
const body: unknown = response.ok ? await response.json() : undefined;
|
|
152
154
|
if (typeof body === 'object' && body !== null && 'devices' in body && Array.isArray(body.devices)) {
|
|
153
155
|
const own = body.devices.find(
|
|
154
156
|
(device: unknown) =>
|
package/src/app/AccountRoute.tsx
CHANGED
|
@@ -200,14 +200,15 @@ function SelfHostedAccountRoute({
|
|
|
200
200
|
firstRun = false,
|
|
201
201
|
onScan,
|
|
202
202
|
onUseCloud,
|
|
203
|
+
onForgetCloud,
|
|
203
204
|
now = Date.now,
|
|
204
205
|
page,
|
|
205
206
|
onBack,
|
|
206
207
|
stack,
|
|
207
208
|
}: AccountRouteProps & { page?: 'methods'; onBack: () => void }) {
|
|
208
209
|
const [permission, requestPermission] = useCameraPermissions();
|
|
209
|
-
const latest = useRef({ permission, requestPermission, onScan, onUseCloud });
|
|
210
|
-
latest.current = { permission, requestPermission, onScan, onUseCloud };
|
|
210
|
+
const latest = useRef({ permission, requestPermission, onScan, onUseCloud, onForgetCloud });
|
|
211
|
+
latest.current = { permission, requestPermission, onScan, onUseCloud, onForgetCloud };
|
|
211
212
|
const [flow] = useState(() =>
|
|
212
213
|
createPhoneAccountFlow<CloudHostRecord>(
|
|
213
214
|
{
|
|
@@ -224,6 +225,7 @@ function SelfHostedAccountRoute({
|
|
|
224
225
|
latest.current.permission?.granted === true || (await latest.current.requestPermission()).granted,
|
|
225
226
|
onScan: () => latest.current.onScan(),
|
|
226
227
|
onUseCloud: (host) => latest.current.onUseCloud?.(host) ?? Promise.resolve(),
|
|
228
|
+
onForgetCloud: (issuer) => latest.current.onForgetCloud?.(issuer) ?? Promise.resolve(),
|
|
227
229
|
now,
|
|
228
230
|
},
|
|
229
231
|
// Reached from hosted sign-in, the selected issuer is hosted Po Cloud: never restore it as an identity home.
|
package/src/app/App.tsx
CHANGED
|
@@ -209,7 +209,7 @@ import {
|
|
|
209
209
|
WorkspaceDefaultsScreen,
|
|
210
210
|
WorkspaceSettingsScreen,
|
|
211
211
|
} from '../screens/WorkspaceSettingsScreen';
|
|
212
|
-
import { renewGrantsOnOpen } from '../services/accountClient';
|
|
212
|
+
import { hostedTeam, renewGrantsOnOpen } from '../services/accountClient';
|
|
213
213
|
import { apiTransportForHost } from '../services/apiTransport';
|
|
214
214
|
import { type CloudHostRecord, isCloudHost, loadCloudHosts, removeCloudHostsFor } from '../services/cloudHosts';
|
|
215
215
|
import { currentSession, hostDisplayName, loadHost, loadHosts } from '../services/deviceTrust';
|
|
@@ -248,6 +248,7 @@ import {
|
|
|
248
248
|
listMcpServers,
|
|
249
249
|
listProviders,
|
|
250
250
|
listRepositories,
|
|
251
|
+
NO_REMOTE_ACCESS,
|
|
251
252
|
readImageSettings,
|
|
252
253
|
readNativeTemplateChoice,
|
|
253
254
|
readRemote,
|
|
@@ -275,6 +276,7 @@ import {
|
|
|
275
276
|
import { loadOtherWorkspacesOpen, otherWorkspacesOpenStore, setOtherWorkspacesOpen } from './otherWorkspaces';
|
|
276
277
|
import { useRailWorkspaces } from './railWorkspaces';
|
|
277
278
|
import { loadSessionView, sessionViewStore, setSessionView } from './sessionView';
|
|
279
|
+
import { TeamRoute } from './TeamRoute';
|
|
278
280
|
import { useHome, useHomes } from './useHome';
|
|
279
281
|
type Routes = {
|
|
280
282
|
Tabs: undefined;
|
|
@@ -305,6 +307,7 @@ type Routes = {
|
|
|
305
307
|
SettingsMetrics: { hostId?: string } | undefined;
|
|
306
308
|
SettingsAppearance: undefined;
|
|
307
309
|
SettingsAccount: undefined;
|
|
310
|
+
SettingsTeam: undefined;
|
|
308
311
|
SettingsPanel: { id: string; title: string; hostId?: string };
|
|
309
312
|
/** A plugin's settings section, globally or, with `workspace`, as that repository overrides it. */
|
|
310
313
|
SettingsSection: {
|
|
@@ -333,6 +336,8 @@ const Tab = createBottomTabNavigator<TabRoutes>();
|
|
|
333
336
|
const HOST_OWNERSHIP_PENDING = 'Host-scoped Home and settings actions are not available yet.';
|
|
334
337
|
/** The longest the first frame waits for installed plugins to come back from disk. */
|
|
335
338
|
const BOOT_HOLD_MS = 1500;
|
|
339
|
+
/** The phone's hosted Po Cloud team name, which Settings shows as its Team row. */
|
|
340
|
+
const HOSTED_TEAM_KEY = 'hosted-team';
|
|
336
341
|
// Store-update and render rollups ride the same OTLP queue as warnings and crashes.
|
|
337
342
|
setUiTraceSink((records) => {
|
|
338
343
|
for (const record of records) recordNativeLog(record.level, record.event, undefined, record.attributes);
|
|
@@ -1192,7 +1197,11 @@ function SettingsRoute(
|
|
|
1192
1197
|
// An older computer has no MCP settings route; the row then simply shows no count.
|
|
1193
1198
|
...('servers' in mcp ? { mcpServers: mcpServersSummary(mcp.servers) } : {}),
|
|
1194
1199
|
...('state' in read ? { remote: read.state } : {}),
|
|
1195
|
-
...('error' in listed
|
|
1200
|
+
...('error' in listed
|
|
1201
|
+
? { error: listed.error }
|
|
1202
|
+
: 'error' in read && read.error !== NO_REMOTE_ACCESS
|
|
1203
|
+
? { error: read.error }
|
|
1204
|
+
: {}),
|
|
1196
1205
|
};
|
|
1197
1206
|
});
|
|
1198
1207
|
// A package this computer does not run leaves its row without a value.
|
|
@@ -1213,14 +1222,18 @@ function SettingsRoute(
|
|
|
1213
1222
|
const reloadSummary = summary.reload;
|
|
1214
1223
|
const reloadImages = imageSettings.reload;
|
|
1215
1224
|
const reloadSections = sectionRead.reload;
|
|
1225
|
+
const hostedTeamName = useCachedRequest(HOSTED_TEAM_KEY, async () => (await hostedTeam())?.name);
|
|
1226
|
+
const reloadTeam = hostedTeamName.reload;
|
|
1216
1227
|
useFocusEffect(
|
|
1217
1228
|
useCallback(() => {
|
|
1218
1229
|
void reloadSummary();
|
|
1219
1230
|
void reloadImages();
|
|
1220
1231
|
void reloadSections();
|
|
1221
|
-
|
|
1232
|
+
void reloadTeam();
|
|
1233
|
+
}, [reloadSummary, reloadImages, reloadSections, reloadTeam]),
|
|
1222
1234
|
);
|
|
1223
1235
|
const appearance = useStore(appearanceStore, (state) => state);
|
|
1236
|
+
const teamName = hostedTeamName.data;
|
|
1224
1237
|
return (
|
|
1225
1238
|
<SettingsScreen
|
|
1226
1239
|
globalSection={<GlobalSettings />}
|
|
@@ -1237,6 +1250,7 @@ function SettingsRoute(
|
|
|
1237
1250
|
{...(mcpServers ? { mcpServers } : {})}
|
|
1238
1251
|
{...(remote ? { remote } : {})}
|
|
1239
1252
|
appearance={appearanceLabel(appearance)}
|
|
1253
|
+
{...(teamName ? { team: teamName } : {})}
|
|
1240
1254
|
{...(images ? { images } : {})}
|
|
1241
1255
|
plugins={`${String(plugins)} installed`}
|
|
1242
1256
|
sections={sections.map((section) => {
|
|
@@ -1258,7 +1272,7 @@ function SettingsRoute(
|
|
|
1258
1272
|
}}
|
|
1259
1273
|
{...((props.error ?? loadError) ? { error: props.error ?? loadError } : {})}
|
|
1260
1274
|
onOpen={(section: SettingsSection) => {
|
|
1261
|
-
if (section === 'SettingsAppearance' || section === 'SettingsAccount') {
|
|
1275
|
+
if (section === 'SettingsAppearance' || section === 'SettingsAccount' || section === 'SettingsTeam') {
|
|
1262
1276
|
navigation.navigate(section);
|
|
1263
1277
|
return;
|
|
1264
1278
|
}
|
|
@@ -3423,6 +3437,17 @@ export function App({ nativeHost }: { nativeHost?: (sessionId: string) => Native
|
|
|
3423
3437
|
/>
|
|
3424
3438
|
)}
|
|
3425
3439
|
</Stack.Screen>
|
|
3440
|
+
<Stack.Screen name="SettingsTeam" options={{ title: 'Team', headerBackTitle: 'Settings' }}>
|
|
3441
|
+
{({ navigation: screen }) => (
|
|
3442
|
+
<TeamRoute
|
|
3443
|
+
onLeft={(issuer) => {
|
|
3444
|
+
// The team is gone from this phone: forget its Po Cloud host, then ask for another team.
|
|
3445
|
+
clearCached(HOSTED_TEAM_KEY);
|
|
3446
|
+
void forgetCloud(issuer).finally(() => screen.replace('SettingsAccount'));
|
|
3447
|
+
}}
|
|
3448
|
+
/>
|
|
3449
|
+
)}
|
|
3450
|
+
</Stack.Screen>
|
|
3426
3451
|
<Stack.Screen name="SettingsAccount" options={{ title: 'Account', headerBackTitle: 'Settings' }}>
|
|
3427
3452
|
{({ navigation: screen }) => (
|
|
3428
3453
|
<AccountRoute
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { Team, TeamClient } from '@agimon-ai/po-identity/team';
|
|
2
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
|
+
|
|
4
|
+
import { TeamView } from '../screens/TeamView';
|
|
5
|
+
import { hostedTeam } from '../services/accountClient';
|
|
6
|
+
|
|
7
|
+
const messageOf = (error: unknown): string => (error instanceof Error ? error.message : String(error));
|
|
8
|
+
const expiresOf = (iso: string): string =>
|
|
9
|
+
new Date(iso).toLocaleDateString(undefined, { day: 'numeric', month: 'short' });
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Settings, Team: the phone's hosted Po Cloud team over po-identity's Team client. Every change reads the team
|
|
13
|
+
* again. Leaving or deleting it hands back to `onLeft` with its issuer, so the phone can ask for another team.
|
|
14
|
+
*/
|
|
15
|
+
export function TeamRoute({ onLeft }: { onLeft: (issuer: string) => void }) {
|
|
16
|
+
const hosted = useRef<{ issuer: string; client: TeamClient }>(undefined);
|
|
17
|
+
const [team, setTeam] = useState<Team>();
|
|
18
|
+
const [status, setStatus] = useState<'loading' | 'ready' | 'error'>('loading');
|
|
19
|
+
const [error, setError] = useState<string>();
|
|
20
|
+
const [notice, setNotice] = useState<string>();
|
|
21
|
+
const [pending, setPending] = useState(false);
|
|
22
|
+
|
|
23
|
+
const load = useCallback(async () => {
|
|
24
|
+
setStatus('loading');
|
|
25
|
+
try {
|
|
26
|
+
const found = hosted.current ?? (await hostedTeam());
|
|
27
|
+
if (!found) throw new Error('This phone is not in a Po Cloud team. Sign in from Account.');
|
|
28
|
+
hosted.current = found;
|
|
29
|
+
setTeam(await found.client.read());
|
|
30
|
+
setError(undefined);
|
|
31
|
+
setStatus('ready');
|
|
32
|
+
} catch (failure) {
|
|
33
|
+
setError(messageOf(failure));
|
|
34
|
+
setStatus('error');
|
|
35
|
+
}
|
|
36
|
+
}, []);
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
void load();
|
|
39
|
+
}, [load]);
|
|
40
|
+
|
|
41
|
+
const act = async (run: (client: TeamClient, team: Team) => Promise<void>, done: string, left = false) => {
|
|
42
|
+
const current = hosted.current;
|
|
43
|
+
if (!current || !team || pending) return;
|
|
44
|
+
setPending(true);
|
|
45
|
+
setError(undefined);
|
|
46
|
+
setNotice(undefined);
|
|
47
|
+
try {
|
|
48
|
+
await run(current.client, team);
|
|
49
|
+
if (left) return onLeft(current.issuer);
|
|
50
|
+
setNotice(done);
|
|
51
|
+
setTeam(await current.client.read());
|
|
52
|
+
} catch (failure) {
|
|
53
|
+
setError(messageOf(failure));
|
|
54
|
+
} finally {
|
|
55
|
+
setPending(false);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<TeamView
|
|
61
|
+
name={team?.name ?? ''}
|
|
62
|
+
role={team?.role ?? 'member'}
|
|
63
|
+
people={team?.people ?? []}
|
|
64
|
+
invites={(team?.invites ?? []).map((invite) => ({ ...invite, expires: expiresOf(invite.expiresAt) }))}
|
|
65
|
+
status={status}
|
|
66
|
+
pending={pending}
|
|
67
|
+
{...(error ? { error } : {})}
|
|
68
|
+
{...(notice ? { notice } : {})}
|
|
69
|
+
onRetry={() => void load()}
|
|
70
|
+
onRename={(name) =>
|
|
71
|
+
void act((client, current) => client.rename(current, name), `The team is now called ${name}.`)
|
|
72
|
+
}
|
|
73
|
+
onLeave={() => void act((client, current) => client.leave(current), '', true)}
|
|
74
|
+
onDelete={() => void act((client, current) => client.delete(current), '', true)}
|
|
75
|
+
onRole={(person, role) =>
|
|
76
|
+
void act(
|
|
77
|
+
(client, current) => client.setRole(current, person.id, role),
|
|
78
|
+
`${person.name} is now ${role === 'admin' ? 'an admin' : 'a member'}.`,
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
onRemove={(person) =>
|
|
82
|
+
void act(
|
|
83
|
+
(client, current) => client.remove(current, person.id),
|
|
84
|
+
`${person.name} no longer has access to ${team?.name ?? 'the team'}.`,
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
onInvite={(email, role) =>
|
|
88
|
+
void act(
|
|
89
|
+
(client, current) => client.invite(current, email, role),
|
|
90
|
+
`Invitation sent to ${email}. It expires in 7 days.`,
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
onCancelInvite={(invite) =>
|
|
94
|
+
void act((client) => client.cancelInvite(invite.id), `The invitation to ${invite.email} is cancelled.`)
|
|
95
|
+
}
|
|
96
|
+
/>
|
|
97
|
+
);
|
|
98
|
+
}
|
package/src/app/cloudRuntime.ts
CHANGED
|
@@ -29,6 +29,7 @@ import type { LiveRuntime } from './liveRuntime';
|
|
|
29
29
|
export const CLOUD_REAUTHENTICATE_CLOSE = 4401;
|
|
30
30
|
const SOCKET_OPEN_TIMEOUT_MS = 15_000;
|
|
31
31
|
const SIGNED_OUT = 'Sign in again to reach Po Cloud.';
|
|
32
|
+
const HOSTED_WRITE_HEADERS = { origin: 'po://', 'x-po-csrf': '1' };
|
|
32
33
|
|
|
33
34
|
interface CloseEvent {
|
|
34
35
|
code?: number;
|
|
@@ -86,9 +87,12 @@ export function cloudFetch(host: CloudHostRecord, options: Pick<CloudRuntimeOpti
|
|
|
86
87
|
throw new Error('Expected a configured Po Cloud API target.');
|
|
87
88
|
const cookie = await readCookie();
|
|
88
89
|
if (!cookie) throw new Error(SIGNED_OUT);
|
|
90
|
+
// Hosted Po Cloud admits a cookie write only from the app scheme with its CSRF header.
|
|
91
|
+
const write = host.hosted !== undefined && init.method !== undefined && !['GET', 'HEAD'].includes(init.method);
|
|
89
92
|
return fetcher(url, {
|
|
90
93
|
...init,
|
|
91
94
|
headers: {
|
|
95
|
+
...(write ? HOSTED_WRITE_HEADERS : {}),
|
|
92
96
|
...init.headers,
|
|
93
97
|
...cloudHeaders(host, cookie),
|
|
94
98
|
'x-po-client-metadata': encodePoClientMetadata(currentClientMetadata()),
|
|
@@ -98,6 +102,33 @@ export function cloudFetch(host: CloudHostRecord, options: Pick<CloudRuntimeOpti
|
|
|
98
102
|
};
|
|
99
103
|
}
|
|
100
104
|
|
|
105
|
+
/**
|
|
106
|
+
* One Po API call to this cloud host, in the shape the paired-computer transport sends. Po Cloud answers
|
|
107
|
+
* the same `/api` routes under its prefix, so Settings reads it the way it reads a computer.
|
|
108
|
+
*/
|
|
109
|
+
export function cloudApiSend(host: CloudHostRecord, options: Pick<CloudRuntimeOptions, 'cookie' | 'fetch'> = {}) {
|
|
110
|
+
const send = cloudFetch(host, options);
|
|
111
|
+
return async (
|
|
112
|
+
request: {
|
|
113
|
+
method: string;
|
|
114
|
+
target: string;
|
|
115
|
+
headers?: readonly (readonly [string, string])[];
|
|
116
|
+
body?: string | Uint8Array;
|
|
117
|
+
},
|
|
118
|
+
signal?: AbortSignal,
|
|
119
|
+
): Promise<Response> => {
|
|
120
|
+
// ponytail: text bodies only. A route that uploads bytes to Po Cloud needs a byte path here.
|
|
121
|
+
if (request.body !== undefined && typeof request.body !== 'string')
|
|
122
|
+
throw new Error('Po Cloud takes text requests only.');
|
|
123
|
+
return send(`${cloudBase(host)}${request.target}`, {
|
|
124
|
+
method: request.method,
|
|
125
|
+
headers: Object.fromEntries(request.headers ?? []),
|
|
126
|
+
...(request.body === undefined ? {} : { body: request.body }),
|
|
127
|
+
...(signal === undefined ? {} : { signal }),
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
101
132
|
/** Saves or removes the org's model provider key. Only owners and admins are admitted by the cloud. */
|
|
102
133
|
export async function setCloudProviderKey(
|
|
103
134
|
host: CloudHostRecord,
|
|
@@ -125,7 +156,7 @@ export function cloudPushEnrollment(
|
|
|
125
156
|
options: Pick<CloudRuntimeOptions, 'cookie' | 'fetch'> = {},
|
|
126
157
|
): PushEnrollment {
|
|
127
158
|
const send = cloudFetch(host, options);
|
|
128
|
-
const headers =
|
|
159
|
+
const headers = HOSTED_WRITE_HEADERS;
|
|
129
160
|
// Read per call: a not-yet-ready identity then fails this attempt, not the connect that started it.
|
|
130
161
|
const url = async () =>
|
|
131
162
|
`${new URL(host.person.issuer).origin}/api/owner/push/installations/${encodeURIComponent(currentClientMetadata().deviceId)}`;
|
package/src/app/hostRuntimes.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
splitHostId,
|
|
10
10
|
} from '@agimon-ai/po-web-dashboard/core';
|
|
11
11
|
|
|
12
|
+
import { bindCloudApi } from '../services/apiTransport';
|
|
12
13
|
import { bundleCacheStorage } from '../services/bundleCache';
|
|
13
14
|
import { purgeNativeBundleUpdates, type NativeBundleUpdateChoice } from '../services/bundleUpdates';
|
|
14
15
|
import { type CloudHostRecord, isCloudHost, removeCloudHost, renameCloudHost } from '../services/cloudHosts';
|
|
@@ -28,7 +29,7 @@ import { hostSnapshots } from '../services/hostSnapshots';
|
|
|
28
29
|
import { startNativePush, startPushEnrollment, unregisterNativePush } from '../services/nativePush';
|
|
29
30
|
import { parsePairingUrl } from '../services/pairing';
|
|
30
31
|
import type { PluginCompatibility } from '../services/pluginRuntime';
|
|
31
|
-
import { cloudPushEnrollment, startCloudRuntime } from './cloudRuntime';
|
|
32
|
+
import { cloudApiSend, cloudPushEnrollment, startCloudRuntime } from './cloudRuntime';
|
|
32
33
|
import { type ActivityLoadState, type LiveRuntime, startLiveRuntime } from './liveRuntime';
|
|
33
34
|
import { activateNativeTemplateHost, resetNativeTemplateChoice } from './nativeTemplate';
|
|
34
35
|
|
|
@@ -169,6 +170,8 @@ export function createHostRuntimes(
|
|
|
169
170
|
},
|
|
170
171
|
});
|
|
171
172
|
entry.runtime = runtime;
|
|
173
|
+
// Settings and other host calls reach this Po Cloud host with the person's sign-in until it stops.
|
|
174
|
+
entry.controller.signal.addEventListener('abort', bindCloudApi(host.id, cloudApiSend(host)), { once: true });
|
|
172
175
|
entry.push = startPushEnrollment(cloudPushEnrollment(host), requestPermission);
|
|
173
176
|
runtime.open(focused !== null && splitHostId(focused)?.hostId === host.id ? focused : null);
|
|
174
177
|
changed();
|
|
@@ -4,11 +4,20 @@ import { AccountView } from './AccountScreen';
|
|
|
4
4
|
import { PhoneFrame, type DesignScheme } from './designFrame';
|
|
5
5
|
|
|
6
6
|
const noop = () => undefined;
|
|
7
|
-
function Target({
|
|
7
|
+
function Target({
|
|
8
|
+
page,
|
|
9
|
+
scheme = 'light',
|
|
10
|
+
cloudOffered,
|
|
11
|
+
}: {
|
|
12
|
+
page: AccountPage;
|
|
13
|
+
scheme?: DesignScheme;
|
|
14
|
+
cloudOffered?: boolean;
|
|
15
|
+
}) {
|
|
8
16
|
return (
|
|
9
17
|
<PhoneFrame scheme={scheme}>
|
|
10
18
|
<AccountView
|
|
11
19
|
page={page}
|
|
20
|
+
cloudOffered={cloudOffered}
|
|
12
21
|
providers={['apple', 'google', 'microsoft', 'github']}
|
|
13
22
|
emailOtp
|
|
14
23
|
deviceName="Alex’s iPhone"
|
|
@@ -52,6 +61,8 @@ export const LaterDevice = { render: () => <Target page="later-device" /> };
|
|
|
52
61
|
export const ApproveDevice = { render: () => <Target page="approve" /> };
|
|
53
62
|
export const RecoveryWait = { render: () => <Target page="wait" /> };
|
|
54
63
|
export const Account = { render: () => <Target page="account" /> };
|
|
64
|
+
/** A sign-in server on someone's own computer runs no Po Cloud, so Account offers none. */
|
|
65
|
+
export const AccountNoCloud = { render: () => <Target page="account" cloudOffered={false} /> };
|
|
55
66
|
export const SignUpLater = {
|
|
56
67
|
render: () => (
|
|
57
68
|
<PhoneFrame scheme="light">
|
|
@@ -64,6 +64,8 @@ export interface AccountViewProps {
|
|
|
64
64
|
onCode?: (value: string) => void;
|
|
65
65
|
/** Po Cloud on this phone: absent when unset, `connected` once the cloud host is saved. */
|
|
66
66
|
cloud?: { connected: boolean; label?: string };
|
|
67
|
+
/** False when the identity home runs no Po Cloud: Account then shows no Po Cloud section. */
|
|
68
|
+
cloudOffered?: boolean;
|
|
67
69
|
/** First run's "Sign in with Po" opens the sign-in methods, which lead back to the welcome screen. */
|
|
68
70
|
welcomeBack?: boolean;
|
|
69
71
|
providerKey?: string;
|
|
@@ -423,7 +425,7 @@ export function AccountView(props: AccountViewProps) {
|
|
|
423
425
|
{page === 'recovery-code' ? (
|
|
424
426
|
<>
|
|
425
427
|
<Text style={styles.body}>Save this somewhere private, away from this phone. Po shows it only once.</Text>
|
|
426
|
-
<Panel>
|
|
428
|
+
<Panel style={styles.panelBody}>
|
|
427
429
|
<Text selectable style={styles.code}>
|
|
428
430
|
{props.recoveryCode}
|
|
429
431
|
</Text>
|
|
@@ -439,7 +441,7 @@ export function AccountView(props: AccountViewProps) {
|
|
|
439
441
|
On a device you already trust, open Account › Approve a device and enter this code.
|
|
440
442
|
</Text>
|
|
441
443
|
{props.approvalCode ? <AccountQr value={props.approvalCode} /> : null}
|
|
442
|
-
<Panel>
|
|
444
|
+
<Panel style={styles.panelBody}>
|
|
443
445
|
<Text selectable style={styles.code}>
|
|
444
446
|
{props.approvalCode}
|
|
445
447
|
</Text>
|
|
@@ -517,7 +519,7 @@ export function AccountView(props: AccountViewProps) {
|
|
|
517
519
|
: 'An account is optional. Your paired computers keep working without one.'}
|
|
518
520
|
</Text>
|
|
519
521
|
{props.locked ? (
|
|
520
|
-
<Panel>
|
|
522
|
+
<Panel style={styles.panelBody}>
|
|
521
523
|
<Text style={styles.ask}>
|
|
522
524
|
Account recovered. Owner-level control stays locked at each computer until you scan its QR code.
|
|
523
525
|
</Text>
|
|
@@ -548,8 +550,12 @@ export function AccountView(props: AccountViewProps) {
|
|
|
548
550
|
? `Created ${new Date(props.recoveryCodeCreatedAt).toLocaleDateString()}`
|
|
549
551
|
: 'Creation date unavailable'
|
|
550
552
|
}
|
|
553
|
+
trailing={
|
|
554
|
+
<Button size="sm" variant="outline" disabled={busy} onPress={() => onAction('rotate-recovery')}>
|
|
555
|
+
Make a new one
|
|
556
|
+
</Button>
|
|
557
|
+
}
|
|
551
558
|
/>
|
|
552
|
-
{action('Make a new one', 'rotate-recovery')}
|
|
553
559
|
<ListRow
|
|
554
560
|
title="Recovery"
|
|
555
561
|
description="Check or cancel a waiting recovery"
|
|
@@ -557,33 +563,43 @@ export function AccountView(props: AccountViewProps) {
|
|
|
557
563
|
disclosure
|
|
558
564
|
/>
|
|
559
565
|
</Panel>
|
|
560
|
-
|
|
561
|
-
{props.cloud?.connected ? (
|
|
562
|
-
<Panel>
|
|
563
|
-
<ListRow title={props.cloud.label ?? 'Po Cloud'} description="Ready on this phone" />
|
|
564
|
-
<Label>Provider key</Label>
|
|
565
|
-
<Input
|
|
566
|
-
accessibilityLabel="Provider API key"
|
|
567
|
-
autoCapitalize="none"
|
|
568
|
-
secureTextEntry
|
|
569
|
-
placeholder="Paste an API key"
|
|
570
|
-
value={props.providerKey}
|
|
571
|
-
onChangeText={props.onProviderKey}
|
|
572
|
-
disabled={busy}
|
|
573
|
-
/>
|
|
574
|
-
<Text style={styles.detail}>
|
|
575
|
-
Po Cloud sessions use this key. It is stored encrypted and applies to new sessions.
|
|
576
|
-
</Text>
|
|
577
|
-
{action('Save provider key', 'provider-key-save')}
|
|
578
|
-
{action('Remove provider key', 'provider-key-remove')}
|
|
579
|
-
</Panel>
|
|
580
|
-
) : (
|
|
566
|
+
{props.cloudOffered === false ? null : (
|
|
581
567
|
<>
|
|
582
|
-
<
|
|
583
|
-
|
|
568
|
+
<View style={styles.sectionHead}>
|
|
569
|
+
<SectionLabel>Po Cloud</SectionLabel>
|
|
570
|
+
</View>
|
|
571
|
+
{props.cloud?.connected ? (
|
|
572
|
+
<Panel>
|
|
573
|
+
<ListRow title={props.cloud.label ?? 'Po Cloud'} description="Ready on this phone" />
|
|
574
|
+
<View style={styles.panelBody}>
|
|
575
|
+
<Label>Provider key</Label>
|
|
576
|
+
<Input
|
|
577
|
+
accessibilityLabel="Provider API key"
|
|
578
|
+
autoCapitalize="none"
|
|
579
|
+
secureTextEntry
|
|
580
|
+
placeholder="Paste an API key"
|
|
581
|
+
value={props.providerKey}
|
|
582
|
+
onChangeText={props.onProviderKey}
|
|
583
|
+
disabled={busy}
|
|
584
|
+
/>
|
|
585
|
+
<Text style={styles.detail}>
|
|
586
|
+
Po Cloud sessions use this key. It is stored encrypted and applies to new sessions.
|
|
587
|
+
</Text>
|
|
588
|
+
{action('Save provider key', 'provider-key-save')}
|
|
589
|
+
{action('Remove provider key', 'provider-key-remove')}
|
|
590
|
+
</View>
|
|
591
|
+
</Panel>
|
|
592
|
+
) : (
|
|
593
|
+
<>
|
|
594
|
+
<Text style={styles.detail}>A personal workspace in the cloud, ready whenever you are.</Text>
|
|
595
|
+
{action('Use Po Cloud', 'use-cloud', true)}
|
|
596
|
+
</>
|
|
597
|
+
)}
|
|
584
598
|
</>
|
|
585
599
|
)}
|
|
586
|
-
<
|
|
600
|
+
<View style={styles.sectionHead}>
|
|
601
|
+
<SectionLabel>Your computers</SectionLabel>
|
|
602
|
+
</View>
|
|
587
603
|
<Text style={styles.detail}>Unlinking keeps local workspaces, sessions, calendar and files.</Text>
|
|
588
604
|
{props.hubs?.map((hub) => (
|
|
589
605
|
<Panel key={hub.id}>
|
|
@@ -593,21 +609,23 @@ export function AccountView(props: AccountViewProps) {
|
|
|
593
609
|
hub.linked ? 'Linked to your account' : 'Scan this hub’s QR once to link it to your account.'
|
|
594
610
|
}
|
|
595
611
|
/>
|
|
596
|
-
{
|
|
597
|
-
|
|
598
|
-
|
|
612
|
+
<View style={styles.panelBody}>
|
|
613
|
+
{props.locked ? (
|
|
614
|
+
hub.pinned ? (
|
|
615
|
+
<Text style={styles.detail}>Already pinned on this phone</Text>
|
|
616
|
+
) : (
|
|
617
|
+
action('Scan to take control', 'scan')
|
|
618
|
+
)
|
|
619
|
+
) : hub.linked ? (
|
|
620
|
+
action('Unlink from account', `unlink:${hub.id}`)
|
|
599
621
|
) : (
|
|
600
|
-
action('Scan to
|
|
601
|
-
)
|
|
602
|
-
|
|
603
|
-
action('Unlink from account', `unlink:${hub.id}`)
|
|
604
|
-
) : (
|
|
605
|
-
action('Scan QR to link', 'scan')
|
|
606
|
-
)}
|
|
622
|
+
action('Scan QR to link', 'scan')
|
|
623
|
+
)}
|
|
624
|
+
</View>
|
|
607
625
|
</Panel>
|
|
608
626
|
))}
|
|
609
627
|
{action('Scan QR to connect a computer', 'scan')}
|
|
610
|
-
<Button variant="danger-outline" onPress={() => onAction('delete-page')}>
|
|
628
|
+
<Button size="lg" variant="danger-outline" onPress={() => onAction('delete-page')}>
|
|
611
629
|
Delete account
|
|
612
630
|
</Button>
|
|
613
631
|
</>
|
|
@@ -775,6 +793,10 @@ const styles = StyleSheet.create((theme, rt) => ({
|
|
|
775
793
|
contentInStack: { paddingTop: theme.spacing(5) },
|
|
776
794
|
titleRow: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: theme.spacing(3) },
|
|
777
795
|
titleRowEnd: { justifyContent: 'flex-end' },
|
|
796
|
+
// A card's own controls sit at its rows' inset, never against its border.
|
|
797
|
+
panelBody: { padding: theme.spacing(4), gap: theme.spacing(3) },
|
|
798
|
+
// A section label belongs to the card below it: more air above than beneath.
|
|
799
|
+
sectionHead: { marginTop: theme.spacing(3), marginBottom: -theme.spacing(2) },
|
|
778
800
|
title: {
|
|
779
801
|
flexShrink: 1,
|
|
780
802
|
fontFamily: fontOf(theme.fontFamily.sans),
|
|
@@ -4,7 +4,7 @@ import { useFocusEffect } from '@react-navigation/native';
|
|
|
4
4
|
import { useCallback, useRef, useState } from 'react';
|
|
5
5
|
|
|
6
6
|
import { createAccountClient, grantGlobalSettings, selectedIdentityIssuer } from '../services/accountClient';
|
|
7
|
-
import { GlobalSettingsView, Group, Row } from './SettingsScreen';
|
|
7
|
+
import { CardBody, GlobalSettingsView, Group, Row } from './SettingsScreen';
|
|
8
8
|
|
|
9
9
|
/** Reads the member tier directly from the signed-in issuer, not the selected computer. */
|
|
10
10
|
export function GlobalSettings() {
|
|
@@ -122,13 +122,15 @@ export function GlobalSettings() {
|
|
|
122
122
|
}
|
|
123
123
|
>
|
|
124
124
|
{organizations.length ? (
|
|
125
|
-
<
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
125
|
+
<CardBody>
|
|
126
|
+
<Select
|
|
127
|
+
title="Account network"
|
|
128
|
+
value={org}
|
|
129
|
+
options={organizations.map((item) => ({ value: item.id, label: item.name }))}
|
|
130
|
+
onValueChange={setOrg}
|
|
131
|
+
disabled={busy}
|
|
132
|
+
/>
|
|
133
|
+
</CardBody>
|
|
132
134
|
) : null}
|
|
133
135
|
{document ? (
|
|
134
136
|
<GlobalSettingsView yaml={yaml} onChange={setYaml} onSave={save} busy={busy} error={error} notice={notice} />
|