@agimon-ai/po-native 0.0.1-alpha.38 → 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 +6 -1
- 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 +25 -2
- package/src/screens/SettingsScreen.tsx +34 -21
- package/src/services/apiTransport/index.ts +32 -5
- package/src/services/logExport/index.ts +4 -1
- 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
|
@@ -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,
|
|
@@ -1196,7 +1197,11 @@ function SettingsRoute(
|
|
|
1196
1197
|
// An older computer has no MCP settings route; the row then simply shows no count.
|
|
1197
1198
|
...('servers' in mcp ? { mcpServers: mcpServersSummary(mcp.servers) } : {}),
|
|
1198
1199
|
...('state' in read ? { remote: read.state } : {}),
|
|
1199
|
-
...('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
|
+
: {}),
|
|
1200
1205
|
};
|
|
1201
1206
|
});
|
|
1202
1207
|
// A package this computer does not run leaves its row without a value.
|
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} />
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PoNativeProvider } from '@agimon-ai/po-native-components';
|
|
1
|
+
import { PoNativeProvider, Select } from '@agimon-ai/po-native-components';
|
|
2
2
|
import type {
|
|
3
3
|
LoginFlowSnapshot,
|
|
4
4
|
ProviderAuthSummary,
|
|
@@ -14,7 +14,7 @@ import type { Appearance } from '../app/appearance';
|
|
|
14
14
|
import { AppearanceScreen } from './AppearanceScreen';
|
|
15
15
|
import { ProvidersScreen } from './ProvidersScreen';
|
|
16
16
|
import { type McpClientView, RemoteControlScreen } from './RemoteControlScreen';
|
|
17
|
-
import { SettingsScreen } from './SettingsScreen';
|
|
17
|
+
import { CardBody, GlobalSettingsView, Group, SettingsScreen } from './SettingsScreen';
|
|
18
18
|
import { WorkspaceDefaultsScreen, WorkspaceHubView } from './WorkspaceSettingsScreen';
|
|
19
19
|
|
|
20
20
|
/** The runtime Settings screens over fixed data, for comparison with the approved Settings Parity targets. */
|
|
@@ -209,14 +209,33 @@ const PANEL_GROUPS = COMPUTERS.map((host) => ({
|
|
|
209
209
|
label: host.label,
|
|
210
210
|
panels: [{ id: 'tools', pluginId: 'po-tools', label: 'Tools', detail: 'Which tools Po can use' }],
|
|
211
211
|
}));
|
|
212
|
+
/** The Global group as a signed-in teammate sees it: the team, the editor and its saved notice. */
|
|
213
|
+
const GLOBAL_SECTION = (
|
|
214
|
+
<Group label="Global" hint="Your portable preferences across hosts.">
|
|
215
|
+
<CardBody>
|
|
216
|
+
<Select
|
|
217
|
+
title="Account network"
|
|
218
|
+
value="team"
|
|
219
|
+
options={[
|
|
220
|
+
{ value: 'team', label: 'Acme Studio' },
|
|
221
|
+
{ value: 'personal', label: 'Personal' },
|
|
222
|
+
]}
|
|
223
|
+
onValueChange={noop}
|
|
224
|
+
/>
|
|
225
|
+
</CardBody>
|
|
226
|
+
<GlobalSettingsView yaml={'voice:\n language: de'} onChange={noop} onSave={noop} notice="Global settings saved." />
|
|
227
|
+
</Group>
|
|
228
|
+
);
|
|
212
229
|
function AllHostsStory({
|
|
213
230
|
scheme,
|
|
214
231
|
updateRequired = false,
|
|
215
232
|
team,
|
|
233
|
+
global = false,
|
|
216
234
|
}: {
|
|
217
235
|
scheme: 'light' | 'dark';
|
|
218
236
|
updateRequired?: boolean;
|
|
219
237
|
team?: string;
|
|
238
|
+
global?: boolean;
|
|
220
239
|
}) {
|
|
221
240
|
return (
|
|
222
241
|
<Phone scheme={scheme}>
|
|
@@ -227,6 +246,7 @@ function AllHostsStory({
|
|
|
227
246
|
panelGroups={PANEL_GROUPS}
|
|
228
247
|
appearance="Match iPhone"
|
|
229
248
|
{...(team ? { team } : {})}
|
|
249
|
+
{...(global ? { globalSection: GLOBAL_SECTION } : {})}
|
|
230
250
|
notices={
|
|
231
251
|
updateRequired
|
|
232
252
|
? [{ id: 'a', message: 'Update Po to use all plugins from MacBook. Other features still work.' }]
|
|
@@ -246,6 +266,9 @@ export const AllHostsDark = { render: () => <AllHostsStory scheme="dark" /> };
|
|
|
246
266
|
/** Signed in to a Po Cloud team: its row sits under Account in This phone. */
|
|
247
267
|
export const TeamRowLight = { render: () => <AllHostsStory scheme="light" team="Acme Studio" /> };
|
|
248
268
|
export const TeamRowDark = { render: () => <AllHostsStory scheme="dark" team="Acme Studio" /> };
|
|
269
|
+
/** Global settings on the phone: a card's own controls sit at the inset of its rows. */
|
|
270
|
+
export const GlobalLight = { render: () => <AllHostsStory scheme="light" global /> };
|
|
271
|
+
export const GlobalDark = { render: () => <AllHostsStory scheme="dark" global /> };
|
|
249
272
|
|
|
250
273
|
export const AppearanceLight = { render: () => <AppearanceStory scheme="light" initial="system" /> };
|
|
251
274
|
export const AppearanceDark = { render: () => <AppearanceStory scheme="dark" initial="dark" /> };
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
InfoStrip,
|
|
11
11
|
LockIcon,
|
|
12
12
|
MessageIcon,
|
|
13
|
+
MonitorIcon,
|
|
13
14
|
PaletteIcon,
|
|
14
15
|
Panel,
|
|
15
16
|
SectionLabel,
|
|
@@ -108,6 +109,10 @@ export function OnComputer({ children }: { children: string }) {
|
|
|
108
109
|
);
|
|
109
110
|
}
|
|
110
111
|
|
|
112
|
+
/** A card's own controls, such as a field and its button, at the inset of the card's rows. */
|
|
113
|
+
export function CardBody({ children }: { children: ReactNode }) {
|
|
114
|
+
return <View style={styles.cardBody}>{children}</View>;
|
|
115
|
+
}
|
|
111
116
|
export function ErrorLine({ children }: { children?: string }) {
|
|
112
117
|
return children ? (
|
|
113
118
|
<Text style={styles.error} accessibilityRole="alert">
|
|
@@ -267,7 +272,12 @@ export function SettingsScreen({
|
|
|
267
272
|
value={providers}
|
|
268
273
|
onPress={() => onOpen('SettingsProviders')}
|
|
269
274
|
/>
|
|
270
|
-
<NavRow
|
|
275
|
+
<NavRow
|
|
276
|
+
Icon={MonitorIcon}
|
|
277
|
+
title="Devices"
|
|
278
|
+
value="Names and where voice is active"
|
|
279
|
+
onPress={() => onOpen('SettingsDevices')}
|
|
280
|
+
/>
|
|
271
281
|
<NavRow Icon={WrenchIcon} title="MCP servers" value={mcpServers} onPress={() => onOpen('SettingsMcp')} />
|
|
272
282
|
<NavRow
|
|
273
283
|
Icon={LockIcon}
|
|
@@ -338,7 +348,7 @@ export function SettingsScreen({
|
|
|
338
348
|
<NavRow
|
|
339
349
|
key={panel.id}
|
|
340
350
|
title={panel.label}
|
|
341
|
-
value={panel.detail}
|
|
351
|
+
value={sentenceCase(panel.detail)}
|
|
342
352
|
onPress={() => onOpenPanel?.(panel.id)}
|
|
343
353
|
last={index === panels.length - 1}
|
|
344
354
|
/>
|
|
@@ -354,7 +364,7 @@ export function SettingsScreen({
|
|
|
354
364
|
<NavRow
|
|
355
365
|
key={`${group.hostId}/${panel.pluginId ?? ''}/${panel.id}`}
|
|
356
366
|
title={panel.label}
|
|
357
|
-
value={panel.detail}
|
|
367
|
+
value={sentenceCase(panel.detail)}
|
|
358
368
|
onPress={() => onOpenPanel?.(panel.id, group.hostId)}
|
|
359
369
|
last={index === group.panels.length - 1}
|
|
360
370
|
/>
|
|
@@ -414,6 +424,7 @@ const styles = StyleSheet.create((theme) => {
|
|
|
414
424
|
groupHead: { gap: theme.spacing(1), paddingHorizontal: theme.spacing(1) },
|
|
415
425
|
groupHint: { ...text('sm', theme.colors.dim), lineHeight: theme.lineHeightRelaxed.sm },
|
|
416
426
|
card: { padding: 0, overflow: 'hidden' },
|
|
427
|
+
cardBody: { paddingHorizontal: theme.spacing(4), paddingVertical: theme.spacing(3), gap: theme.spacing(3) },
|
|
417
428
|
row: {
|
|
418
429
|
flexDirection: 'row',
|
|
419
430
|
alignItems: 'center',
|
|
@@ -468,24 +479,26 @@ export function GlobalSettingsView({
|
|
|
468
479
|
description="Modes, subagents, web, native, and voice language only. Host settings override Global."
|
|
469
480
|
last
|
|
470
481
|
/>
|
|
471
|
-
<
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
<
|
|
482
|
-
{
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
482
|
+
<CardBody>
|
|
483
|
+
<Textarea
|
|
484
|
+
accessibilityLabel="Global settings YAML"
|
|
485
|
+
value={yaml}
|
|
486
|
+
onChangeText={onChange}
|
|
487
|
+
rows={8}
|
|
488
|
+
disabled={busy}
|
|
489
|
+
/>
|
|
490
|
+
<ErrorLine>{error}</ErrorLine>
|
|
491
|
+
{notice ? (
|
|
492
|
+
<Panel style={styles.gentleNotice}>
|
|
493
|
+
<Text accessibilityLiveRegion="polite" style={styles.noticeText}>
|
|
494
|
+
{notice}
|
|
495
|
+
</Text>
|
|
496
|
+
</Panel>
|
|
497
|
+
) : null}
|
|
498
|
+
<Button size="lg" onPress={onSave} disabled={busy}>
|
|
499
|
+
Save Global settings
|
|
500
|
+
</Button>
|
|
501
|
+
</CardBody>
|
|
489
502
|
</>
|
|
490
503
|
);
|
|
491
504
|
}
|
|
@@ -92,9 +92,38 @@ export function hostApiPath(hostId: string, input: string): string {
|
|
|
92
92
|
return parts.join('/') + (queryAt === -1 ? '' : input.slice(queryAt));
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
type Send = (request: SealedHttpRequest, signal?: AbortSignal) => Promise<Response>;
|
|
96
|
+
|
|
97
|
+
// Po Cloud hosts are reached with the person's sign-in, not a paired sealed channel.
|
|
98
|
+
const cloudApis = new Map<string, Send>();
|
|
99
|
+
|
|
100
|
+
/** Names how a signed-in Po Cloud host is called. Returns the undo. */
|
|
101
|
+
export function bindCloudApi(hostId: string, send: Send): () => void {
|
|
102
|
+
cloudApis.set(hostId, send);
|
|
103
|
+
return () => {
|
|
104
|
+
if (cloudApis.get(hostId) === send) cloudApis.delete(hostId);
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* One host's exchange: its paired sealed channel, or Po Cloud when the host is one. With no host named
|
|
110
|
+
* and no computer paired, the only signed-in Po Cloud host answers.
|
|
111
|
+
*/
|
|
112
|
+
function sendTo(hostId?: string): Send {
|
|
113
|
+
return (request, signal) => {
|
|
114
|
+
const candidate =
|
|
115
|
+
hostId === undefined ? (cloudApis.size === 1 ? [...cloudApis.values()][0] : undefined) : cloudApis.get(hostId);
|
|
116
|
+
// A paired computer keeps its own sealed channel.
|
|
117
|
+
const cloud = candidate !== undefined && !currentSession(hostId) ? candidate : undefined;
|
|
118
|
+
if (cloud) return cloud(request, signal);
|
|
119
|
+
if (hostId !== undefined) return fetchWithStepUp(request, undefined, signal, hostId);
|
|
120
|
+
return signal === undefined ? fetchWithStepUp(request) : fetchWithStepUp(request, undefined, signal);
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
95
124
|
/** A composition's HTTP capability is permanently bound to the host that supplied its code. */
|
|
96
125
|
export function apiTransportForHost(hostId: string): ApiTransport {
|
|
97
|
-
const transport = createHostApiTransport((
|
|
126
|
+
const transport = createHostApiTransport(sendTo(hostId));
|
|
98
127
|
return (input, init) => {
|
|
99
128
|
try {
|
|
100
129
|
return transport(hostApiPath(hostId, input), init);
|
|
@@ -109,7 +138,7 @@ export function apiTransportForHost(hostId: string): ApiTransport {
|
|
|
109
138
|
* `/api/remote` routes (remote access, trusted devices), which a composition's transport refuses.
|
|
110
139
|
*/
|
|
111
140
|
export function settingsTransportForHost(hostId: string): ApiTransport {
|
|
112
|
-
const shell = createHostApiTransport((
|
|
141
|
+
const shell = createHostApiTransport(sendTo(hostId));
|
|
113
142
|
const scoped = apiTransportForHost(hostId);
|
|
114
143
|
return (input, init) =>
|
|
115
144
|
input === '/api/remote' || input.startsWith('/api/remote/') ? shell(input, init) : scoped(input, init);
|
|
@@ -177,9 +206,7 @@ export function transportForHost(hostId: string): ApiTransport {
|
|
|
177
206
|
}
|
|
178
207
|
|
|
179
208
|
/** Shell calls with qualified workspace paths route by ownership, never by last connected host. */
|
|
180
|
-
const defaultTransport = createHostApiTransport((
|
|
181
|
-
signal === undefined ? fetchWithStepUp(request) : fetchWithStepUp(request, undefined, signal),
|
|
182
|
-
);
|
|
209
|
+
const defaultTransport = createHostApiTransport(sendTo());
|
|
183
210
|
export const hostApiTransport: ApiTransport = (input, init) => {
|
|
184
211
|
const workspace = /^\/api\/workspaces\/([^/?]+)/u.exec(input)?.[1];
|
|
185
212
|
if (workspace !== undefined) {
|
|
@@ -127,7 +127,10 @@ export async function flushNativeLogs(): Promise<boolean> {
|
|
|
127
127
|
],
|
|
128
128
|
});
|
|
129
129
|
try {
|
|
130
|
-
|
|
130
|
+
const response = await send(LOGS_ROUTE, body);
|
|
131
|
+
// A computer that refuses this phone's logs is not asked again on this connection.
|
|
132
|
+
if (response.status === 401 || response.status === 403) senders.delete(target!);
|
|
133
|
+
return response.ok;
|
|
131
134
|
} catch {
|
|
132
135
|
// ponytail: no retry. Add a bounded one if hosts often drop sends mid-flight.
|
|
133
136
|
return false;
|
|
@@ -164,12 +164,16 @@ export function logoutProvider(providerId: string, hostId?: string): Promise<Res
|
|
|
164
164
|
return request(`${AUTH_PROVIDERS_API_ROUTE}/${encodeURIComponent(providerId)}`, { method: 'DELETE' }, ok, hostId);
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
+
/** What `readRemote` answers for a host with no remote access of its own, such as Po Cloud. Not a failure. */
|
|
168
|
+
export const NO_REMOTE_ACCESS = 'This host has no remote access settings.';
|
|
169
|
+
|
|
167
170
|
export function readRemote(hostId?: string): Promise<Result<{ state: RemoteAccessStateView }>> {
|
|
168
171
|
return request(
|
|
169
172
|
REMOTE_API_ROUTE,
|
|
170
173
|
undefined,
|
|
171
174
|
(body) => (isRecord(body.state) ? { state: body.state as unknown as RemoteAccessStateView } : undefined),
|
|
172
175
|
hostId,
|
|
176
|
+
NO_REMOTE_ACCESS,
|
|
173
177
|
);
|
|
174
178
|
}
|
|
175
179
|
|