@agimon-ai/po-native 0.0.1-alpha.37 → 0.0.1-alpha.38

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agimon-ai/po-native",
3
- "version": "0.0.1-alpha.37",
3
+ "version": "0.0.1-alpha.38",
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.157",
33
- "@agimon-ai/po-expo-signing": "0.0.1-alpha.37",
34
- "@agimon-ai/po-identity": "0.0.2-alpha.104",
35
- "@agimon-ai/po-native-components": "0.0.0-alpha.157",
36
- "@agimon-ai/po-native-dashboard": "0.0.0-alpha.29",
37
- "@agimon-ai/po-template-advanced": "0.0.0-alpha.157",
38
- "@agimon-ai/po-template-elegant": "0.0.0-alpha.157",
39
- "@agimon-ai/po-voice": "0.0.0-alpha.157",
40
- "@agimon-ai/po-web-components": "0.0.0-alpha.157",
41
- "@agimon-ai/po-web-dashboard": "0.0.0-alpha.157",
42
- "@agimon-ai/po-web-security": "0.0.0-alpha.157",
32
+ "@agimon-ai/po-core": "0.0.0-alpha.158",
33
+ "@agimon-ai/po-expo-signing": "0.0.1-alpha.38",
34
+ "@agimon-ai/po-identity": "0.0.2-alpha.105",
35
+ "@agimon-ai/po-native-components": "0.0.0-alpha.158",
36
+ "@agimon-ai/po-native-dashboard": "0.0.0-alpha.30",
37
+ "@agimon-ai/po-template-advanced": "0.0.0-alpha.158",
38
+ "@agimon-ai/po-template-elegant": "0.0.0-alpha.158",
39
+ "@agimon-ai/po-voice": "0.0.0-alpha.158",
40
+ "@agimon-ai/po-web-components": "0.0.0-alpha.158",
41
+ "@agimon-ai/po-web-dashboard": "0.0.0-alpha.158",
42
+ "@agimon-ai/po-web-security": "0.0.0-alpha.158",
43
43
  "@better-auth/expo": "1.7.12",
44
44
  "@config-plugins/react-native-webrtc": "15.0.2",
45
45
  "@earendil-works/chord": "1.5.1",
package/src/app/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';
@@ -275,6 +275,7 @@ import {
275
275
  import { loadOtherWorkspacesOpen, otherWorkspacesOpenStore, setOtherWorkspacesOpen } from './otherWorkspaces';
276
276
  import { useRailWorkspaces } from './railWorkspaces';
277
277
  import { loadSessionView, sessionViewStore, setSessionView } from './sessionView';
278
+ import { TeamRoute } from './TeamRoute';
278
279
  import { useHome, useHomes } from './useHome';
279
280
  type Routes = {
280
281
  Tabs: undefined;
@@ -305,6 +306,7 @@ type Routes = {
305
306
  SettingsMetrics: { hostId?: string } | undefined;
306
307
  SettingsAppearance: undefined;
307
308
  SettingsAccount: undefined;
309
+ SettingsTeam: undefined;
308
310
  SettingsPanel: { id: string; title: string; hostId?: string };
309
311
  /** A plugin's settings section, globally or, with `workspace`, as that repository overrides it. */
310
312
  SettingsSection: {
@@ -333,6 +335,8 @@ const Tab = createBottomTabNavigator<TabRoutes>();
333
335
  const HOST_OWNERSHIP_PENDING = 'Host-scoped Home and settings actions are not available yet.';
334
336
  /** The longest the first frame waits for installed plugins to come back from disk. */
335
337
  const BOOT_HOLD_MS = 1500;
338
+ /** The phone's hosted Po Cloud team name, which Settings shows as its Team row. */
339
+ const HOSTED_TEAM_KEY = 'hosted-team';
336
340
  // Store-update and render rollups ride the same OTLP queue as warnings and crashes.
337
341
  setUiTraceSink((records) => {
338
342
  for (const record of records) recordNativeLog(record.level, record.event, undefined, record.attributes);
@@ -1213,14 +1217,18 @@ function SettingsRoute(
1213
1217
  const reloadSummary = summary.reload;
1214
1218
  const reloadImages = imageSettings.reload;
1215
1219
  const reloadSections = sectionRead.reload;
1220
+ const hostedTeamName = useCachedRequest(HOSTED_TEAM_KEY, async () => (await hostedTeam())?.name);
1221
+ const reloadTeam = hostedTeamName.reload;
1216
1222
  useFocusEffect(
1217
1223
  useCallback(() => {
1218
1224
  void reloadSummary();
1219
1225
  void reloadImages();
1220
1226
  void reloadSections();
1221
- }, [reloadSummary, reloadImages, reloadSections]),
1227
+ void reloadTeam();
1228
+ }, [reloadSummary, reloadImages, reloadSections, reloadTeam]),
1222
1229
  );
1223
1230
  const appearance = useStore(appearanceStore, (state) => state);
1231
+ const teamName = hostedTeamName.data;
1224
1232
  return (
1225
1233
  <SettingsScreen
1226
1234
  globalSection={<GlobalSettings />}
@@ -1237,6 +1245,7 @@ function SettingsRoute(
1237
1245
  {...(mcpServers ? { mcpServers } : {})}
1238
1246
  {...(remote ? { remote } : {})}
1239
1247
  appearance={appearanceLabel(appearance)}
1248
+ {...(teamName ? { team: teamName } : {})}
1240
1249
  {...(images ? { images } : {})}
1241
1250
  plugins={`${String(plugins)} installed`}
1242
1251
  sections={sections.map((section) => {
@@ -1258,7 +1267,7 @@ function SettingsRoute(
1258
1267
  }}
1259
1268
  {...((props.error ?? loadError) ? { error: props.error ?? loadError } : {})}
1260
1269
  onOpen={(section: SettingsSection) => {
1261
- if (section === 'SettingsAppearance' || section === 'SettingsAccount') {
1270
+ if (section === 'SettingsAppearance' || section === 'SettingsAccount' || section === 'SettingsTeam') {
1262
1271
  navigation.navigate(section);
1263
1272
  return;
1264
1273
  }
@@ -3423,6 +3432,17 @@ export function App({ nativeHost }: { nativeHost?: (sessionId: string) => Native
3423
3432
  />
3424
3433
  )}
3425
3434
  </Stack.Screen>
3435
+ <Stack.Screen name="SettingsTeam" options={{ title: 'Team', headerBackTitle: 'Settings' }}>
3436
+ {({ navigation: screen }) => (
3437
+ <TeamRoute
3438
+ onLeft={(issuer) => {
3439
+ // The team is gone from this phone: forget its Po Cloud host, then ask for another team.
3440
+ clearCached(HOSTED_TEAM_KEY);
3441
+ void forgetCloud(issuer).finally(() => screen.replace('SettingsAccount'));
3442
+ }}
3443
+ />
3444
+ )}
3445
+ </Stack.Screen>
3426
3446
  <Stack.Screen name="SettingsAccount" options={{ title: 'Account', headerBackTitle: 'Settings' }}>
3427
3447
  {({ navigation: screen }) => (
3428
3448
  <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
+ }
@@ -209,7 +209,15 @@ 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
- function AllHostsStory({ scheme, updateRequired = false }: { scheme: 'light' | 'dark'; updateRequired?: boolean }) {
212
+ function AllHostsStory({
213
+ scheme,
214
+ updateRequired = false,
215
+ team,
216
+ }: {
217
+ scheme: 'light' | 'dark';
218
+ updateRequired?: boolean;
219
+ team?: string;
220
+ }) {
213
221
  return (
214
222
  <Phone scheme={scheme}>
215
223
  <SettingsScreen
@@ -218,6 +226,7 @@ function AllHostsStory({ scheme, updateRequired = false }: { scheme: 'light' | '
218
226
  computers={COMPUTERS}
219
227
  panelGroups={PANEL_GROUPS}
220
228
  appearance="Match iPhone"
229
+ {...(team ? { team } : {})}
221
230
  notices={
222
231
  updateRequired
223
232
  ? [{ id: 'a', message: 'Update Po to use all plugins from MacBook. Other features still work.' }]
@@ -234,6 +243,9 @@ export const AllHostsLight = { render: () => <AllHostsStory scheme="light" /> };
234
243
  export const UpdateRequiredLight = { render: () => <AllHostsStory scheme="light" updateRequired /> };
235
244
  export const UpdateRequiredDark = { render: () => <AllHostsStory scheme="dark" updateRequired /> };
236
245
  export const AllHostsDark = { render: () => <AllHostsStory scheme="dark" /> };
246
+ /** Signed in to a Po Cloud team: its row sits under Account in This phone. */
247
+ export const TeamRowLight = { render: () => <AllHostsStory scheme="light" team="Acme Studio" /> };
248
+ export const TeamRowDark = { render: () => <AllHostsStory scheme="dark" team="Acme Studio" /> };
237
249
 
238
250
  export const AppearanceLight = { render: () => <AppearanceStory scheme="light" initial="system" /> };
239
251
  export const AppearanceDark = { render: () => <AppearanceStory scheme="dark" initial="dark" /> };
@@ -17,6 +17,7 @@ import {
17
17
  TaskIcon,
18
18
  Textarea,
19
19
  UserIcon,
20
+ UsersIcon,
20
21
  WrenchIcon,
21
22
  } from '@agimon-ai/po-native-components';
22
23
  import type { RemoteAccessStateView } from '@agimon-ai/po-web-dashboard/types';
@@ -137,7 +138,8 @@ export type SettingsSection =
137
138
  | 'SettingsPlugins'
138
139
  | 'SettingsMetrics'
139
140
  | 'SettingsAppearance'
140
- | 'SettingsAccount';
141
+ | 'SettingsAccount'
142
+ | 'SettingsTeam';
141
143
 
142
144
  interface SettingsPanelEntry {
143
145
  id: string;
@@ -183,6 +185,8 @@ export interface SettingsScreenProps {
183
185
  globalSection?: ReactNode;
184
186
  /** The host's `account-region`: a person's package may decorate or replace the Account entry. */
185
187
  accountRegion?: (entry: ReactNode) => ReactNode;
188
+ /** The phone's hosted Po Cloud team, when it is in one; its row opens the Team screen. */
189
+ team?: string;
186
190
  }
187
191
 
188
192
  /** 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 +236,7 @@ export function SettingsScreen({
232
236
  phoneOnly = false,
233
237
  globalSection,
234
238
  accountRegion = (entry) => entry,
239
+ team,
235
240
  }: SettingsScreenProps) {
236
241
  const summary = remote ? remoteSummary(remote) : undefined;
237
242
  const several = computers.length > 1;
@@ -367,6 +372,9 @@ export function SettingsScreen({
367
372
  onPress={() => onOpen('SettingsAccount')}
368
373
  />,
369
374
  )}
375
+ {team === undefined ? null : (
376
+ <NavRow Icon={UsersIcon} title="Team" value={team} onPress={() => onOpen('SettingsTeam')} />
377
+ )}
370
378
  <Row
371
379
  leading={<MessageIcon size={18} color="dim" />}
372
380
  title="Notifications"
@@ -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
+ }
@@ -172,7 +172,7 @@ export async function pairDevice(scanned: string, fetcher: typeof fetch, signal?
172
172
  const auth = await account.createAccountClient(issuer);
173
173
  const { claimPairedHub } = await import('@agimon-ai/po-identity/account');
174
174
  const keys = await import('../../../modules/po-device-key');
175
- await claimPairedHub(
175
+ const claimed = await claimPairedHub(
176
176
  {
177
177
  keys,
178
178
  now: Date.now,
@@ -202,8 +202,13 @@ export async function pairDevice(scanned: string, fetcher: typeof fetch, signal?
202
202
  },
203
203
  { pairingId, pairedAt },
204
204
  );
205
- linkedRecord = record;
206
- account.accountLinkNotice.setState(() => 'Your hub is linked to your account. Local data stays on the hub.');
205
+ // A teammate's pairing is not theirs to unlink, so it is not tied to the account on this phone.
206
+ if (claimed) linkedRecord = record;
207
+ account.accountLinkNotice.setState(() =>
208
+ claimed
209
+ ? 'Your hub is linked to your account. Local data stays on the hub.'
210
+ : 'You joined this team’s host. Your sessions here are private until you share them.',
211
+ );
207
212
  }
208
213
  } catch (error) {
209
214
  // A cancelled pairing has nothing to report about linking.