@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
|
@@ -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,7 +209,34 @@ 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
|
-
|
|
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
|
+
);
|
|
229
|
+
function AllHostsStory({
|
|
230
|
+
scheme,
|
|
231
|
+
updateRequired = false,
|
|
232
|
+
team,
|
|
233
|
+
global = false,
|
|
234
|
+
}: {
|
|
235
|
+
scheme: 'light' | 'dark';
|
|
236
|
+
updateRequired?: boolean;
|
|
237
|
+
team?: string;
|
|
238
|
+
global?: boolean;
|
|
239
|
+
}) {
|
|
213
240
|
return (
|
|
214
241
|
<Phone scheme={scheme}>
|
|
215
242
|
<SettingsScreen
|
|
@@ -218,6 +245,8 @@ function AllHostsStory({ scheme, updateRequired = false }: { scheme: 'light' | '
|
|
|
218
245
|
computers={COMPUTERS}
|
|
219
246
|
panelGroups={PANEL_GROUPS}
|
|
220
247
|
appearance="Match iPhone"
|
|
248
|
+
{...(team ? { team } : {})}
|
|
249
|
+
{...(global ? { globalSection: GLOBAL_SECTION } : {})}
|
|
221
250
|
notices={
|
|
222
251
|
updateRequired
|
|
223
252
|
? [{ id: 'a', message: 'Update Po to use all plugins from MacBook. Other features still work.' }]
|
|
@@ -234,6 +263,12 @@ export const AllHostsLight = { render: () => <AllHostsStory scheme="light" /> };
|
|
|
234
263
|
export const UpdateRequiredLight = { render: () => <AllHostsStory scheme="light" updateRequired /> };
|
|
235
264
|
export const UpdateRequiredDark = { render: () => <AllHostsStory scheme="dark" updateRequired /> };
|
|
236
265
|
export const AllHostsDark = { render: () => <AllHostsStory scheme="dark" /> };
|
|
266
|
+
/** Signed in to a Po Cloud team: its row sits under Account in This phone. */
|
|
267
|
+
export const TeamRowLight = { render: () => <AllHostsStory scheme="light" team="Acme Studio" /> };
|
|
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 /> };
|
|
237
272
|
|
|
238
273
|
export const AppearanceLight = { render: () => <AppearanceStory scheme="light" initial="system" /> };
|
|
239
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,
|
|
@@ -17,6 +18,7 @@ import {
|
|
|
17
18
|
TaskIcon,
|
|
18
19
|
Textarea,
|
|
19
20
|
UserIcon,
|
|
21
|
+
UsersIcon,
|
|
20
22
|
WrenchIcon,
|
|
21
23
|
} from '@agimon-ai/po-native-components';
|
|
22
24
|
import type { RemoteAccessStateView } from '@agimon-ai/po-web-dashboard/types';
|
|
@@ -107,6 +109,10 @@ export function OnComputer({ children }: { children: string }) {
|
|
|
107
109
|
);
|
|
108
110
|
}
|
|
109
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
|
+
}
|
|
110
116
|
export function ErrorLine({ children }: { children?: string }) {
|
|
111
117
|
return children ? (
|
|
112
118
|
<Text style={styles.error} accessibilityRole="alert">
|
|
@@ -137,7 +143,8 @@ export type SettingsSection =
|
|
|
137
143
|
| 'SettingsPlugins'
|
|
138
144
|
| 'SettingsMetrics'
|
|
139
145
|
| 'SettingsAppearance'
|
|
140
|
-
| 'SettingsAccount'
|
|
146
|
+
| 'SettingsAccount'
|
|
147
|
+
| 'SettingsTeam';
|
|
141
148
|
|
|
142
149
|
interface SettingsPanelEntry {
|
|
143
150
|
id: string;
|
|
@@ -183,6 +190,8 @@ export interface SettingsScreenProps {
|
|
|
183
190
|
globalSection?: ReactNode;
|
|
184
191
|
/** The host's `account-region`: a person's package may decorate or replace the Account entry. */
|
|
185
192
|
accountRegion?: (entry: ReactNode) => ReactNode;
|
|
193
|
+
/** The phone's hosted Po Cloud team, when it is in one; its row opens the Team screen. */
|
|
194
|
+
team?: string;
|
|
186
195
|
}
|
|
187
196
|
|
|
188
197
|
/** The frame around a settings page a package draws: the menu's detail as the lede, as this screen leads with its own. */
|
|
@@ -232,6 +241,7 @@ export function SettingsScreen({
|
|
|
232
241
|
phoneOnly = false,
|
|
233
242
|
globalSection,
|
|
234
243
|
accountRegion = (entry) => entry,
|
|
244
|
+
team,
|
|
235
245
|
}: SettingsScreenProps) {
|
|
236
246
|
const summary = remote ? remoteSummary(remote) : undefined;
|
|
237
247
|
const several = computers.length > 1;
|
|
@@ -262,7 +272,12 @@ export function SettingsScreen({
|
|
|
262
272
|
value={providers}
|
|
263
273
|
onPress={() => onOpen('SettingsProviders')}
|
|
264
274
|
/>
|
|
265
|
-
<NavRow
|
|
275
|
+
<NavRow
|
|
276
|
+
Icon={MonitorIcon}
|
|
277
|
+
title="Devices"
|
|
278
|
+
value="Names and where voice is active"
|
|
279
|
+
onPress={() => onOpen('SettingsDevices')}
|
|
280
|
+
/>
|
|
266
281
|
<NavRow Icon={WrenchIcon} title="MCP servers" value={mcpServers} onPress={() => onOpen('SettingsMcp')} />
|
|
267
282
|
<NavRow
|
|
268
283
|
Icon={LockIcon}
|
|
@@ -333,7 +348,7 @@ export function SettingsScreen({
|
|
|
333
348
|
<NavRow
|
|
334
349
|
key={panel.id}
|
|
335
350
|
title={panel.label}
|
|
336
|
-
value={panel.detail}
|
|
351
|
+
value={sentenceCase(panel.detail)}
|
|
337
352
|
onPress={() => onOpenPanel?.(panel.id)}
|
|
338
353
|
last={index === panels.length - 1}
|
|
339
354
|
/>
|
|
@@ -349,7 +364,7 @@ export function SettingsScreen({
|
|
|
349
364
|
<NavRow
|
|
350
365
|
key={`${group.hostId}/${panel.pluginId ?? ''}/${panel.id}`}
|
|
351
366
|
title={panel.label}
|
|
352
|
-
value={panel.detail}
|
|
367
|
+
value={sentenceCase(panel.detail)}
|
|
353
368
|
onPress={() => onOpenPanel?.(panel.id, group.hostId)}
|
|
354
369
|
last={index === group.panels.length - 1}
|
|
355
370
|
/>
|
|
@@ -367,6 +382,9 @@ export function SettingsScreen({
|
|
|
367
382
|
onPress={() => onOpen('SettingsAccount')}
|
|
368
383
|
/>,
|
|
369
384
|
)}
|
|
385
|
+
{team === undefined ? null : (
|
|
386
|
+
<NavRow Icon={UsersIcon} title="Team" value={team} onPress={() => onOpen('SettingsTeam')} />
|
|
387
|
+
)}
|
|
370
388
|
<Row
|
|
371
389
|
leading={<MessageIcon size={18} color="dim" />}
|
|
372
390
|
title="Notifications"
|
|
@@ -406,6 +424,7 @@ const styles = StyleSheet.create((theme) => {
|
|
|
406
424
|
groupHead: { gap: theme.spacing(1), paddingHorizontal: theme.spacing(1) },
|
|
407
425
|
groupHint: { ...text('sm', theme.colors.dim), lineHeight: theme.lineHeightRelaxed.sm },
|
|
408
426
|
card: { padding: 0, overflow: 'hidden' },
|
|
427
|
+
cardBody: { paddingHorizontal: theme.spacing(4), paddingVertical: theme.spacing(3), gap: theme.spacing(3) },
|
|
409
428
|
row: {
|
|
410
429
|
flexDirection: 'row',
|
|
411
430
|
alignItems: 'center',
|
|
@@ -460,24 +479,26 @@ export function GlobalSettingsView({
|
|
|
460
479
|
description="Modes, subagents, web, native, and voice language only. Host settings override Global."
|
|
461
480
|
last
|
|
462
481
|
/>
|
|
463
|
-
<
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
<
|
|
474
|
-
{
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
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>
|
|
481
502
|
</>
|
|
482
503
|
);
|
|
483
504
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { PhoneFrame } from './designFrame';
|
|
2
|
+
import { TeamView, type TeamInvite, type TeamPerson, type TeamRole, type TeamViewProps } from './TeamView';
|
|
3
|
+
|
|
4
|
+
export const teamMeta = { title: 'Native/Design/Team', tags: ['style-system', 'mockup', 'native'] };
|
|
5
|
+
export default teamMeta;
|
|
6
|
+
|
|
7
|
+
// One Team throughout, seen by its owner Alex or its member Sam.
|
|
8
|
+
const people = (you: string): TeamPerson[] => [
|
|
9
|
+
{ id: 'alex', name: 'Alex Chen', email: 'alex@riverside.studio', role: 'owner', you: you === 'alex' },
|
|
10
|
+
{ id: 'priya', name: 'Priya Nair', email: 'priya@riverside.studio', role: 'admin', you: you === 'priya' },
|
|
11
|
+
{ id: 'sam', name: 'Sam Okafor', email: 'sam@riverside.studio', role: 'member', you: you === 'sam' },
|
|
12
|
+
];
|
|
13
|
+
const invites: TeamInvite[] = [{ id: 'jo', email: 'jo@riverside.studio', role: 'member', expires: '21 Nov' }];
|
|
14
|
+
const noop = () => undefined;
|
|
15
|
+
|
|
16
|
+
function Target({
|
|
17
|
+
role = 'owner',
|
|
18
|
+
dark = false,
|
|
19
|
+
...overrides
|
|
20
|
+
}: Partial<TeamViewProps> & { role?: TeamRole; dark?: boolean }) {
|
|
21
|
+
return (
|
|
22
|
+
<PhoneFrame scheme={dark ? 'dark' : 'light'}>
|
|
23
|
+
<TeamView
|
|
24
|
+
name="Riverside Studio"
|
|
25
|
+
role={role}
|
|
26
|
+
people={people(role === 'owner' ? 'alex' : 'sam')}
|
|
27
|
+
invites={invites}
|
|
28
|
+
status="ready"
|
|
29
|
+
onRetry={noop}
|
|
30
|
+
onRename={noop}
|
|
31
|
+
onLeave={noop}
|
|
32
|
+
onDelete={noop}
|
|
33
|
+
onRole={noop}
|
|
34
|
+
onRemove={noop}
|
|
35
|
+
onInvite={noop}
|
|
36
|
+
onCancelInvite={noop}
|
|
37
|
+
{...overrides}
|
|
38
|
+
/>
|
|
39
|
+
</PhoneFrame>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const Playground = { render: () => <Target /> };
|
|
44
|
+
export const AsMember = { render: () => <Target role="member" /> };
|
|
45
|
+
export const Invite = { render: () => <Target initial={{ sheet: 'invite', inviteEmail: 'jo@riverside.studio' }} /> };
|
|
46
|
+
export const InviteSent = {
|
|
47
|
+
render: () => <Target notice="Invitation sent to jo@riverside.studio. It expires in 7 days." />,
|
|
48
|
+
};
|
|
49
|
+
export const Rename = { render: () => <Target initial={{ sheet: 'rename' }} /> };
|
|
50
|
+
export const DeleteConfirm = { render: () => <Target initial={{ sheet: 'delete', deleteTyped: 'Riverside' }} /> };
|
|
51
|
+
export const LeaveConfirm = { render: () => <Target role="member" initial={{ sheet: 'leave' }} /> };
|
|
52
|
+
export const Loading = { render: () => <Target status="loading" /> };
|
|
53
|
+
export const Failure = {
|
|
54
|
+
render: () => <Target status="error" error="Your connection may have dropped. Nothing changed." />,
|
|
55
|
+
};
|
|
56
|
+
export const Dark = { render: () => <Target dark /> };
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AgentAvatar,
|
|
3
|
+
Button,
|
|
4
|
+
DropdownMenu,
|
|
5
|
+
DropdownMenuContent,
|
|
6
|
+
DropdownMenuItem,
|
|
7
|
+
DropdownMenuTrigger,
|
|
8
|
+
fontOf,
|
|
9
|
+
SegmentedControl,
|
|
10
|
+
Sheet,
|
|
11
|
+
SheetBody,
|
|
12
|
+
SheetContent,
|
|
13
|
+
SheetDescription,
|
|
14
|
+
SheetHeader,
|
|
15
|
+
SheetTitle,
|
|
16
|
+
} from '@agimon-ai/po-native-components';
|
|
17
|
+
import { useState } from 'react';
|
|
18
|
+
import { Text, View } from 'react-native';
|
|
19
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
20
|
+
|
|
21
|
+
import { FieldRow } from './SettingsFields';
|
|
22
|
+
import { ErrorLine, Group, Row, SectionPage } from './SettingsScreen';
|
|
23
|
+
|
|
24
|
+
export type TeamRole = 'owner' | 'admin' | 'member';
|
|
25
|
+
type InviteRole = Exclude<TeamRole, 'owner'>;
|
|
26
|
+
|
|
27
|
+
export interface TeamPerson {
|
|
28
|
+
id: string;
|
|
29
|
+
name: string;
|
|
30
|
+
email: string;
|
|
31
|
+
role: TeamRole;
|
|
32
|
+
you?: boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface TeamInvite {
|
|
36
|
+
id: string;
|
|
37
|
+
email: string;
|
|
38
|
+
role: InviteRole;
|
|
39
|
+
/** Already formatted for the reader, such as "21 Nov". */
|
|
40
|
+
expires: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
type TeamSheet = 'invite' | 'rename' | 'delete' | 'leave';
|
|
44
|
+
|
|
45
|
+
export interface TeamViewProps {
|
|
46
|
+
name: string;
|
|
47
|
+
role: TeamRole;
|
|
48
|
+
people: readonly TeamPerson[];
|
|
49
|
+
invites: readonly TeamInvite[];
|
|
50
|
+
status: 'loading' | 'ready' | 'error';
|
|
51
|
+
pending?: boolean;
|
|
52
|
+
error?: string;
|
|
53
|
+
/** A quiet confirmation of the last change. */
|
|
54
|
+
notice?: string;
|
|
55
|
+
/** Opens a sheet at first render; stories pin these states. */
|
|
56
|
+
initial?: { sheet?: TeamSheet; inviteEmail?: string; deleteTyped?: string };
|
|
57
|
+
onRetry: () => void;
|
|
58
|
+
onRename: (name: string) => void;
|
|
59
|
+
onLeave: () => void;
|
|
60
|
+
onDelete: () => void;
|
|
61
|
+
onRole: (person: TeamPerson, role: InviteRole) => void;
|
|
62
|
+
onRemove: (person: TeamPerson) => void;
|
|
63
|
+
onInvite: (email: string, role: InviteRole) => void;
|
|
64
|
+
onCancelInvite: (invite: TeamInvite) => void;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const ROLE_LABEL: Record<TeamRole, string> = { owner: 'Owner', admin: 'Admin', member: 'Member' };
|
|
68
|
+
const ROLES = [
|
|
69
|
+
{ value: 'member', label: 'Member' },
|
|
70
|
+
{ value: 'admin', label: 'Admin' },
|
|
71
|
+
] as const;
|
|
72
|
+
|
|
73
|
+
/** Settings › Team on the phone: the stack header names the screen, so the body carries no title. */
|
|
74
|
+
export function TeamView(p: TeamViewProps) {
|
|
75
|
+
const canEdit = p.role === 'owner' || p.role === 'admin';
|
|
76
|
+
const owner = p.role === 'owner';
|
|
77
|
+
const [sheet, setSheet] = useState<TeamSheet | undefined>(p.initial?.sheet);
|
|
78
|
+
const [draft, setDraft] = useState(p.name);
|
|
79
|
+
const [email, setEmail] = useState(p.initial?.inviteEmail ?? '');
|
|
80
|
+
const [role, setRole] = useState<InviteRole>('member');
|
|
81
|
+
const [typed, setTyped] = useState(p.initial?.deleteTyped ?? '');
|
|
82
|
+
const nameInvalid = !draft.trim() || Array.from(draft.trim()).length > 64;
|
|
83
|
+
const emailValid = /^[^\s@]+@[^\s@]+\.[^\s@]+$/u.test(email.trim());
|
|
84
|
+
const close = () => {
|
|
85
|
+
if (!p.pending) setSheet(undefined);
|
|
86
|
+
};
|
|
87
|
+
if (p.status !== 'ready')
|
|
88
|
+
return (
|
|
89
|
+
<SectionPage>
|
|
90
|
+
<Group label="Team">
|
|
91
|
+
<Row title={p.status === 'loading' ? 'Loading your team…' : 'Po could not load your team.'} last />
|
|
92
|
+
</Group>
|
|
93
|
+
<ErrorLine>{p.error}</ErrorLine>
|
|
94
|
+
{p.status === 'error' ? (
|
|
95
|
+
<Button variant="outline" onPress={p.onRetry}>
|
|
96
|
+
Try again
|
|
97
|
+
</Button>
|
|
98
|
+
) : null}
|
|
99
|
+
</SectionPage>
|
|
100
|
+
);
|
|
101
|
+
return (
|
|
102
|
+
<SectionPage>
|
|
103
|
+
{p.notice ? (
|
|
104
|
+
<Text accessibilityLiveRegion="polite" style={styles.notice}>
|
|
105
|
+
{p.notice}
|
|
106
|
+
</Text>
|
|
107
|
+
) : null}
|
|
108
|
+
<ErrorLine>{p.error}</ErrorLine>
|
|
109
|
+
<Group label="Team">
|
|
110
|
+
<Row title={p.name} description={`Your role: ${ROLE_LABEL[p.role]}`} last>
|
|
111
|
+
{canEdit ? (
|
|
112
|
+
<Button
|
|
113
|
+
variant="outline"
|
|
114
|
+
size="sm"
|
|
115
|
+
disabled={p.pending}
|
|
116
|
+
onPress={() => {
|
|
117
|
+
setDraft(p.name);
|
|
118
|
+
setSheet('rename');
|
|
119
|
+
}}
|
|
120
|
+
>
|
|
121
|
+
Rename
|
|
122
|
+
</Button>
|
|
123
|
+
) : null}
|
|
124
|
+
</Row>
|
|
125
|
+
</Group>
|
|
126
|
+
{canEdit ? (
|
|
127
|
+
<Button variant="primary" size="lg" disabled={p.pending} onPress={() => setSheet('invite')}>
|
|
128
|
+
Invite someone
|
|
129
|
+
</Button>
|
|
130
|
+
) : null}
|
|
131
|
+
<Group label="People" hint={canEdit ? undefined : 'Only owners and admins can invite or change people.'}>
|
|
132
|
+
{p.people.map((person, index) => {
|
|
133
|
+
const editable = canEdit && !person.you && person.role !== 'owner';
|
|
134
|
+
return (
|
|
135
|
+
<Row
|
|
136
|
+
key={person.id}
|
|
137
|
+
title={person.name}
|
|
138
|
+
description={person.email}
|
|
139
|
+
leading={<AgentAvatar name={person.name} seed={person.email} size="sm" />}
|
|
140
|
+
last={index === p.people.length - 1}
|
|
141
|
+
>
|
|
142
|
+
<Text style={styles.role}>
|
|
143
|
+
{ROLE_LABEL[person.role]}
|
|
144
|
+
{person.you ? ' · you' : ''}
|
|
145
|
+
</Text>
|
|
146
|
+
{editable ? (
|
|
147
|
+
<DropdownMenu>
|
|
148
|
+
<DropdownMenuTrigger variant="ghost" accessibilityLabel={`Actions for ${person.name}`}>
|
|
149
|
+
•••
|
|
150
|
+
</DropdownMenuTrigger>
|
|
151
|
+
<DropdownMenuContent>
|
|
152
|
+
<DropdownMenuItem onSelect={() => p.onRole(person, person.role === 'admin' ? 'member' : 'admin')}>
|
|
153
|
+
{person.role === 'admin' ? 'Make member' : 'Make admin'}
|
|
154
|
+
</DropdownMenuItem>
|
|
155
|
+
<DropdownMenuItem variant="destructive" onSelect={() => p.onRemove(person)}>
|
|
156
|
+
Remove from team
|
|
157
|
+
</DropdownMenuItem>
|
|
158
|
+
</DropdownMenuContent>
|
|
159
|
+
</DropdownMenu>
|
|
160
|
+
) : null}
|
|
161
|
+
</Row>
|
|
162
|
+
);
|
|
163
|
+
})}
|
|
164
|
+
</Group>
|
|
165
|
+
{p.invites.length > 0 ? (
|
|
166
|
+
<Group label="Pending invitations">
|
|
167
|
+
{p.invites.map((invite, index) => (
|
|
168
|
+
<Row
|
|
169
|
+
key={invite.id}
|
|
170
|
+
title={invite.email}
|
|
171
|
+
description={`${ROLE_LABEL[invite.role]} · expires ${invite.expires}`}
|
|
172
|
+
last={index === p.invites.length - 1}
|
|
173
|
+
>
|
|
174
|
+
{canEdit ? (
|
|
175
|
+
<DropdownMenu>
|
|
176
|
+
<DropdownMenuTrigger variant="ghost" accessibilityLabel={`Actions for ${invite.email}`}>
|
|
177
|
+
•••
|
|
178
|
+
</DropdownMenuTrigger>
|
|
179
|
+
<DropdownMenuContent>
|
|
180
|
+
<DropdownMenuItem variant="destructive" onSelect={() => p.onCancelInvite(invite)}>
|
|
181
|
+
Cancel invitation
|
|
182
|
+
</DropdownMenuItem>
|
|
183
|
+
</DropdownMenuContent>
|
|
184
|
+
</DropdownMenu>
|
|
185
|
+
) : null}
|
|
186
|
+
</Row>
|
|
187
|
+
))}
|
|
188
|
+
</Group>
|
|
189
|
+
) : null}
|
|
190
|
+
<View style={styles.danger}>
|
|
191
|
+
<Button variant="danger-outline" disabled={p.pending} onPress={() => setSheet(owner ? 'delete' : 'leave')}>
|
|
192
|
+
{owner ? 'Delete team' : 'Leave team'}
|
|
193
|
+
</Button>
|
|
194
|
+
<Text style={styles.hint}>
|
|
195
|
+
{owner
|
|
196
|
+
? 'Everyone loses access, and its sessions, files and calendar are deleted.'
|
|
197
|
+
: `You lose access to ${p.name}'s sessions and files.`}
|
|
198
|
+
</Text>
|
|
199
|
+
</View>
|
|
200
|
+
<Sheet open={sheet === 'invite'} onOpenChange={(open) => (open ? setSheet('invite') : close())}>
|
|
201
|
+
<SheetContent keep>
|
|
202
|
+
<SheetHeader>
|
|
203
|
+
<SheetTitle>Invite someone</SheetTitle>
|
|
204
|
+
</SheetHeader>
|
|
205
|
+
<SheetBody>
|
|
206
|
+
<FieldRow title="Email" value={email} placeholder="name@example.com" onChangeText={setEmail} last />
|
|
207
|
+
<View style={styles.actions}>
|
|
208
|
+
<SegmentedControl
|
|
209
|
+
accessibilityLabel="Role"
|
|
210
|
+
options={ROLES}
|
|
211
|
+
value={role}
|
|
212
|
+
onValueChange={(value) => setRole(value as InviteRole)}
|
|
213
|
+
/>
|
|
214
|
+
<SheetDescription>They get an email link that expires in 7 days.</SheetDescription>
|
|
215
|
+
<Button
|
|
216
|
+
variant="primary"
|
|
217
|
+
disabled={!emailValid || p.pending}
|
|
218
|
+
onPress={() => {
|
|
219
|
+
p.onInvite(email.trim(), role);
|
|
220
|
+
setEmail('');
|
|
221
|
+
setSheet(undefined);
|
|
222
|
+
}}
|
|
223
|
+
>
|
|
224
|
+
Send invitation
|
|
225
|
+
</Button>
|
|
226
|
+
</View>
|
|
227
|
+
</SheetBody>
|
|
228
|
+
</SheetContent>
|
|
229
|
+
</Sheet>
|
|
230
|
+
<Sheet open={sheet === 'rename'} onOpenChange={(open) => (open ? setSheet('rename') : close())}>
|
|
231
|
+
<SheetContent keep>
|
|
232
|
+
<SheetHeader>
|
|
233
|
+
<SheetTitle>Rename team</SheetTitle>
|
|
234
|
+
</SheetHeader>
|
|
235
|
+
<SheetBody>
|
|
236
|
+
<FieldRow title="Team name" value={draft} onChangeText={setDraft} last />
|
|
237
|
+
<View style={styles.actions}>
|
|
238
|
+
<Button
|
|
239
|
+
variant="primary"
|
|
240
|
+
disabled={nameInvalid || p.pending}
|
|
241
|
+
onPress={() => {
|
|
242
|
+
p.onRename(draft.trim());
|
|
243
|
+
setSheet(undefined);
|
|
244
|
+
}}
|
|
245
|
+
>
|
|
246
|
+
Save name
|
|
247
|
+
</Button>
|
|
248
|
+
<Button variant="ghost" disabled={p.pending} onPress={close}>
|
|
249
|
+
Cancel
|
|
250
|
+
</Button>
|
|
251
|
+
</View>
|
|
252
|
+
</SheetBody>
|
|
253
|
+
</SheetContent>
|
|
254
|
+
</Sheet>
|
|
255
|
+
<Sheet open={sheet === 'delete'} onOpenChange={(open) => (open ? setSheet('delete') : close())}>
|
|
256
|
+
<SheetContent keep>
|
|
257
|
+
<SheetHeader>
|
|
258
|
+
<SheetTitle>Delete {p.name}?</SheetTitle>
|
|
259
|
+
</SheetHeader>
|
|
260
|
+
<SheetBody>
|
|
261
|
+
<SheetDescription>
|
|
262
|
+
Everyone loses access. Its sessions, files and calendar are deleted. This cannot be undone.
|
|
263
|
+
</SheetDescription>
|
|
264
|
+
<FieldRow title={`Type ${p.name} to confirm`} value={typed} onChangeText={setTyped} last />
|
|
265
|
+
<View style={styles.actions}>
|
|
266
|
+
<Button variant="danger" disabled={typed !== p.name || p.pending} onPress={p.onDelete}>
|
|
267
|
+
Delete team
|
|
268
|
+
</Button>
|
|
269
|
+
<Button variant="ghost" disabled={p.pending} onPress={close}>
|
|
270
|
+
Keep team
|
|
271
|
+
</Button>
|
|
272
|
+
</View>
|
|
273
|
+
</SheetBody>
|
|
274
|
+
</SheetContent>
|
|
275
|
+
</Sheet>
|
|
276
|
+
<Sheet open={sheet === 'leave'} onOpenChange={(open) => (open ? setSheet('leave') : close())}>
|
|
277
|
+
<SheetContent keep>
|
|
278
|
+
<SheetHeader>
|
|
279
|
+
<SheetTitle>Leave {p.name}?</SheetTitle>
|
|
280
|
+
</SheetHeader>
|
|
281
|
+
<SheetBody>
|
|
282
|
+
<SheetDescription>
|
|
283
|
+
You lose access to its sessions and files. An owner or admin can invite you again.
|
|
284
|
+
</SheetDescription>
|
|
285
|
+
<View style={styles.actions}>
|
|
286
|
+
<Button variant="danger" disabled={p.pending} onPress={p.onLeave}>
|
|
287
|
+
Leave team
|
|
288
|
+
</Button>
|
|
289
|
+
<Button variant="ghost" disabled={p.pending} onPress={close}>
|
|
290
|
+
Stay
|
|
291
|
+
</Button>
|
|
292
|
+
</View>
|
|
293
|
+
</SheetBody>
|
|
294
|
+
</SheetContent>
|
|
295
|
+
</Sheet>
|
|
296
|
+
</SectionPage>
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
const styles = StyleSheet.create((theme) => ({
|
|
301
|
+
actions: { padding: 16, gap: 12 },
|
|
302
|
+
danger: { gap: 8 },
|
|
303
|
+
role: { color: theme.colors.dim, fontFamily: fontOf(theme.fontFamily.sans), fontSize: theme.fontSize.sm },
|
|
304
|
+
hint: { color: theme.colors.dim, fontFamily: fontOf(theme.fontFamily.sans), fontSize: theme.fontSize.sm },
|
|
305
|
+
notice: { color: theme.colors.green, fontFamily: fontOf(theme.fontFamily.sans), fontSize: theme.fontSize.sm },
|
|
306
|
+
}));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createHostedAccount, createPhoneAccount } from '@agimon-ai/po-identity/phone';
|
|
2
|
+
import { createTeamClient, type TeamClient, teamRequestOver } from '@agimon-ai/po-identity/team';
|
|
2
3
|
import * as AppleAuthentication from 'expo-apple-authentication';
|
|
3
4
|
import Constants from 'expo-constants';
|
|
4
5
|
import * as SecureStore from 'expo-secure-store';
|
|
@@ -73,3 +74,21 @@ export const hostedAccount = createHostedAccount({
|
|
|
73
74
|
export function cloudCookie(host: Pick<CloudHostRecord, 'hosted' | 'person'>): Promise<string | undefined> {
|
|
74
75
|
return host.hosted ? hostedAccount.cookie(host.person.issuer) : identityCookie(host.person.issuer);
|
|
75
76
|
}
|
|
77
|
+
|
|
78
|
+
/** The app scheme hosted Po Cloud admits as the Origin of the phone's cookie calls. */
|
|
79
|
+
const APP_ORIGIN = 'po://';
|
|
80
|
+
|
|
81
|
+
/** This phone's hosted Po Cloud team over its own session cookie, or undefined when it is in none. */
|
|
82
|
+
export async function hostedTeam(): Promise<{ issuer: string; name: string; client: TeamClient } | undefined> {
|
|
83
|
+
const bootstrap = await hostedAccount.discover(await selectedIdentityIssuer());
|
|
84
|
+
const session = bootstrap?.session;
|
|
85
|
+
const cookie = bootstrap && session?.org ? await hostedAccount.cookie(bootstrap.issuer) : undefined;
|
|
86
|
+
if (!bootstrap || !session?.org || !cookie) return undefined;
|
|
87
|
+
return {
|
|
88
|
+
issuer: bootstrap.issuer,
|
|
89
|
+
name: session.orgName ?? 'Team',
|
|
90
|
+
client: createTeamClient(
|
|
91
|
+
teamRequestOver((input, init) => fetchNative(input, init), bootstrap.issuer, { cookie, origin: APP_ORIGIN }),
|
|
92
|
+
),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
@@ -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) {
|