@agimon-ai/po-native 0.0.1-alpha.25 → 0.0.1-alpha.27

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/README.md CHANGED
@@ -9,7 +9,7 @@ The app pairs with one Po host over its remote-access tunnel, lists that host's
9
9
  - **Pairing.** Scan the host's pairing QR with the camera, or paste the URL. The host approves the request on its own screen. The app then registers device keys (see the trust model) and keeps the host record.
10
10
  - **Connection.** Remote HTTP with the device cookie, three sealed channels (session, protocol, HTTP), the Pi `Client` over the protocol socket, and the hub socket. A dropped hub signs in again with the device key and rebuilds the connection.
11
11
  - **Session state.** `@agimon-ai/po-web-dashboard/core` supplies the session, transcript, and plugin registry stores, the same ones the browser cockpit uses, without any DOM dependency.
12
- - **Plugins.** The host advertises native compositions through `nativeGlobal` and `workspaces[].nativeComposition` on `/api/compositions` and `nativeComposition` on a session summary. For each mount the app loads the composition through its verified cache, evaluates it, keeps only the plugin ids the descriptor admits, installs them in the plugin registry, and starts them. Channel frames reach plugins through `dispatchChannelFrame`. A newer load for a mount makes older ones stale.
12
+ - **Plugins.** The host advertises native compositions through `nativeHost` and `workspaces[].nativeComposition` on `/api/compositions` and `nativeComposition` on a session summary. For each mount the app loads the composition through its verified cache, evaluates it, keeps only the plugin ids the descriptor admits, installs them in the plugin registry, and starts them. Channel frames reach plugins through `dispatchChannelFrame`. A newer load for a mount makes older ones stale.
13
13
  - **Navigation.** `App` registers screens by phase (reconnecting, pairing, ready) in a React Navigation native stack, inside `SafeAreaProvider > PoNativeProvider > KeyboardProvider > NavigationContainer`. Native headers own back navigation and swipe back; Sessions has a large title and a Settings action. A session opens in the live runtime on focus and closes on blur; Settings reloads trusted devices on focus.
14
14
  - **Lists and content.** Sessions and transcripts use the component library's FlashList-backed `List`; the transcript uses `startAtBottom`. Assistant text uses `Markdown`; tool entries use the plugin `sessionToolRenderer`, falling back to `MessageItem` and `CodeBlock`.
15
15
  - **Sheets.** `PoNativeProvider` supplies the shared gesture root and bottom sheet host for plugin detail sheets and action menus. The composer's decision prompts stay inline as gentle rose panels, not modal sheets. `SettingsScreen` lists trusted devices, revokes one through biometric step-up, and forgets the host.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agimon-ai/po-native",
3
- "version": "0.0.1-alpha.25",
3
+ "version": "0.0.1-alpha.27",
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.145",
33
- "@agimon-ai/po-expo-signing": "0.0.1-alpha.25",
34
- "@agimon-ai/po-identity": "0.0.2-alpha.92",
35
- "@agimon-ai/po-native-components": "0.0.0-alpha.145",
36
- "@agimon-ai/po-native-dashboard": "0.0.0-alpha.17",
37
- "@agimon-ai/po-template-advanced": "0.0.0-alpha.145",
38
- "@agimon-ai/po-template-elegant": "0.0.0-alpha.145",
39
- "@agimon-ai/po-voice": "0.0.0-alpha.145",
40
- "@agimon-ai/po-web-components": "0.0.0-alpha.145",
41
- "@agimon-ai/po-web-dashboard": "0.0.0-alpha.145",
42
- "@agimon-ai/po-web-security": "0.0.0-alpha.145",
32
+ "@agimon-ai/po-core": "0.0.0-alpha.147",
33
+ "@agimon-ai/po-expo-signing": "0.0.1-alpha.27",
34
+ "@agimon-ai/po-identity": "0.0.2-alpha.94",
35
+ "@agimon-ai/po-native-components": "0.0.0-alpha.147",
36
+ "@agimon-ai/po-native-dashboard": "0.0.0-alpha.19",
37
+ "@agimon-ai/po-template-advanced": "0.0.0-alpha.147",
38
+ "@agimon-ai/po-template-elegant": "0.0.0-alpha.147",
39
+ "@agimon-ai/po-voice": "0.0.0-alpha.147",
40
+ "@agimon-ai/po-web-components": "0.0.0-alpha.147",
41
+ "@agimon-ai/po-web-dashboard": "0.0.0-alpha.147",
42
+ "@agimon-ai/po-web-security": "0.0.0-alpha.147",
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
@@ -88,9 +88,9 @@ import {
88
88
  webPluginRegistryForHost,
89
89
  parseDashboardTileData,
90
90
  HOST_SLOTS,
91
- globalSlotFills,
91
+ hostSlotFills,
92
92
  webPluginRegistryRevision,
93
- globalPluginProviders,
93
+ hostPluginProviders,
94
94
  setUiTraceSink,
95
95
  traceStore,
96
96
  useRenderTrace,
@@ -169,6 +169,7 @@ import {
169
169
  useSettingsSections,
170
170
  } from '../screens/ContributedSettingsScreen';
171
171
  import { GitRemoteScreen, useGitRemote } from '../screens/GitRemoteScreen';
172
+ import { GlobalSettings } from '../screens/GlobalSettings';
172
173
  import { keepEqual, type HomeAttentionRow } from '../screens/homeModel';
173
174
  import { HomeAppsSection, HomeAttentionScreen, HomeScreen, type HomeView } from '../screens/HomeScreen';
174
175
  import { HostDrawer, HostMenuButton } from '../screens/HostDrawer';
@@ -1198,6 +1199,7 @@ function SettingsRoute(
1198
1199
  const appearance = useStore(appearanceStore, (state) => state);
1199
1200
  return (
1200
1201
  <SettingsScreen
1202
+ globalSection={<GlobalSettings />}
1201
1203
  {...props}
1202
1204
  {...(providers ? { providers } : {})}
1203
1205
  {...(mcpServers ? { mcpServers } : {})}
@@ -2181,7 +2183,7 @@ const HomeAttentionFills = memo(function HomeAttentionFills({
2181
2183
  const seen = new Set<string>();
2182
2184
  const fills = hostStates.flatMap(({ host }) =>
2183
2185
  webPluginRegistryForHost(host.id)
2184
- .globalSlotFills(HOST_SLOTS.homeAttention)
2186
+ .hostSlotFills(HOST_SLOTS.homeAttention)
2185
2187
  .filter((fill) => {
2186
2188
  const key = JSON.stringify([splitHostId(fill.pluginId)?.localId ?? fill.pluginId, fill.id]);
2187
2189
  if (fill.component === undefined || seen.has(key)) return false;
@@ -2293,7 +2295,7 @@ function WorkspaceRoute({ workspaceId, hostStates }: { workspaceId: string; host
2293
2295
  const fills = (slot: string) =>
2294
2296
  [
2295
2297
  ...new Map(
2296
- [...registry.globalSlotFills(slot), ...registry.workspaceSlotFills(workspaceId, slot)].map((fill) => [
2298
+ [...registry.hostSlotFills(slot), ...registry.workspaceSlotFills(workspaceId, slot)].map((fill) => [
2297
2299
  JSON.stringify([fill.pluginId, fill.id]),
2298
2300
  fill,
2299
2301
  ]),
@@ -2392,7 +2394,7 @@ function PluginPageRoute({
2392
2394
  const fill = scopeMatches
2393
2395
  ? [
2394
2396
  ...(registry && workspaceId ? registry.workspaceSlotFills(workspaceId, HOST_SLOTS.page) : []),
2395
- ...(registry?.globalSlotFills(HOST_SLOTS.page) ?? globalSlotFills(HOST_SLOTS.page)),
2397
+ ...(registry?.hostSlotFills(HOST_SLOTS.page) ?? hostSlotFills(HOST_SLOTS.page)),
2396
2398
  ].find((fill) => fill.id === (owner?.localId ?? pageId))
2397
2399
  : undefined;
2398
2400
  const Page = fill?.component;
@@ -2488,7 +2490,7 @@ function useHomeApps(
2488
2490
  const target = data.open;
2489
2491
  const canOpen =
2490
2492
  target?.kind === 'page'
2491
- ? registry.globalSlotFills(HOST_SLOTS.page).some((candidate) => candidate.id === target.id)
2493
+ ? registry.hostSlotFills(HOST_SLOTS.page).some((candidate) => candidate.id === target.id)
2492
2494
  : target?.kind === 'settings' &&
2493
2495
  (['providers', 'mcp', 'workspaces'].includes(target.id) ||
2494
2496
  registry.pluginSettingsPanels().some((candidate) => candidate.id === target.id));
@@ -2587,11 +2589,11 @@ function ConnectFirst({ restore }: { restore?: { onRestore: () => void; busy: bo
2587
2589
  );
2588
2590
  }
2589
2591
 
2590
- type GlobalProviders = ReturnType<typeof globalPluginProviders>;
2591
- let providerList: GlobalProviders = [];
2592
+ type HostProviders = ReturnType<typeof hostPluginProviders>;
2593
+ let providerList: HostProviders = [];
2592
2594
  /** The same list until a provider really changes, so unrelated registry changes never re-render the app root. */
2593
- function currentGlobalProviders(): GlobalProviders {
2594
- const next = globalPluginProviders();
2595
+ function currentHostProviders(): HostProviders {
2596
+ const next = hostPluginProviders();
2595
2597
  const same =
2596
2598
  next.length === providerList.length &&
2597
2599
  next.every(
@@ -2606,8 +2608,8 @@ function currentGlobalProviders(): GlobalProviders {
2606
2608
  * Plugin providers sit above the sheet host so sheet content sees them, and below the navigation and keyboard
2607
2609
  * containers so a provider arriving re-mounts the navigators without losing navigation state or keyboard tracking.
2608
2610
  */
2609
- function GlobalPluginProviders({ children }: { children: ReactNode }) {
2610
- const providers = useSyncExternalStore(subscribeWebPluginRegistry, currentGlobalProviders);
2611
+ function HostPluginProviders({ children }: { children: ReactNode }) {
2612
+ const providers = useSyncExternalStore(subscribeWebPluginRegistry, currentHostProviders);
2611
2613
  return providers.reduceRight<ReactNode>(
2612
2614
  (content, { pluginId, provider: Provider }) => <Provider key={pluginId}>{content}</Provider>,
2613
2615
  <PoNativeProvider>{children}</PoNativeProvider>,
@@ -2980,7 +2982,7 @@ export function App({ nativeHost }: { nativeHost?: (sessionId: string) => Native
2980
2982
  // A pushed or switched screen has no field for the keyboard left open on the one behind.
2981
2983
  onStateChange={() => Keyboard.dismiss()}
2982
2984
  >
2983
- <GlobalPluginProviders>
2985
+ <HostPluginProviders>
2984
2986
  <Stack.Navigator screenOptions={stackOptions}>
2985
2987
  <Stack.Screen name="Tabs" options={{ headerShown: false }}>
2986
2988
  {() => (
@@ -3327,7 +3329,7 @@ export function App({ nativeHost }: { nativeHost?: (sessionId: string) => Native
3327
3329
  onAdd={() => navigation.navigate('AddHost')}
3328
3330
  onManage={() => navigation.navigate('Hosts')}
3329
3331
  />
3330
- </GlobalPluginProviders>
3332
+ </HostPluginProviders>
3331
3333
  </NavigationContainer>
3332
3334
  </KeyboardProvider>
3333
3335
  ) : null}
@@ -12,7 +12,7 @@ import { StyleSheet, View } from 'react-native';
12
12
 
13
13
  import type { HostRuntimeState } from './hostRuntimes';
14
14
 
15
- type BackdropFill = ReturnType<ReturnType<typeof webPluginRegistryForHost>['globalSlotFills']>[number];
15
+ type BackdropFill = ReturnType<ReturnType<typeof webPluginRegistryForHost>['hostSlotFills']>[number];
16
16
 
17
17
  /**
18
18
  * The `backdrop` fills of the person's computers, once per plugin fill: the same plugin on two
@@ -23,7 +23,7 @@ export function useBackdropFills(hostStates: readonly HostRuntimeState[]): reado
23
23
  const seen = new Set<string>();
24
24
  return hostStates.flatMap(({ host }) =>
25
25
  webPluginRegistryForHost(host.id)
26
- .globalSlotFills(HOST_SLOTS.backdrop)
26
+ .hostSlotFills(HOST_SLOTS.backdrop)
27
27
  .filter((fill) => {
28
28
  const key = JSON.stringify([splitHostId(fill.pluginId)?.localId ?? fill.pluginId, fill.id]);
29
29
  if (fill.component === undefined || seen.has(key)) return false;
@@ -7,6 +7,7 @@ import { StyleSheet } from 'react-native-unistyles';
7
7
  import * as deviceKey from '../../modules/po-device-key';
8
8
  import { ConnectCard, type ConnectCardProps } from '../components/ConnectCard';
9
9
  import {
10
+ AccountHostsView,
10
11
  ComputerDetailView,
11
12
  ComputerRemovalView,
12
13
  AddHostView,
@@ -20,6 +21,10 @@ import {
20
21
  consumeAccountEvictions,
21
22
  discoverAccountComputer,
22
23
  readAccountRosters,
24
+ readVisibleAccountHosts,
25
+ pairedAccountHost,
26
+ setAccountHostVisibility,
27
+ type AccountHost,
23
28
  removeAccountHub,
24
29
  } from '../services/accountRoster';
25
30
  import { createHostLinkBroker, HostLinkConfirmationNeeded, type HostLinks } from '../services/hostLinkBroker';
@@ -120,11 +125,24 @@ export function HostsRoute({
120
125
  phase: 'confirm' | 'forgotten';
121
126
  pendingQuorum?: boolean;
122
127
  }>();
123
- const [account, setAccount] = useState<{ issuer: string; subject: string }>();
128
+ const [account, setAccount] = useState<Awaited<ReturnType<typeof loadLocalAccount>>>();
129
+ const [accountHosts, setAccountHosts] = useState<AccountHost[]>([]);
124
130
  const [busy, setBusy] = useState(false);
125
131
  const [renameError, setRenameError] = useState<string>();
132
+ const accountRead = useRef(0);
126
133
  const refreshAccount = useCallback(async () => {
127
- setAccount(await loadLocalAccount(await selectedIdentityIssuer()));
134
+ const revision = ++accountRead.current;
135
+ const issuer = await selectedIdentityIssuer();
136
+ const record = await loadLocalAccount(issuer);
137
+ let visible: AccountHost[] = [];
138
+ if (record) {
139
+ const auth = await createAccountClient(issuer);
140
+ if ((await auth.session())?.id === record.subject)
141
+ visible = await readVisibleAccountHosts((path) => auth.request(path), record.subject);
142
+ }
143
+ if (revision !== accountRead.current) return;
144
+ setAccount(record);
145
+ setAccountHosts(visible);
128
146
  await applyAccountEvictions(manager());
129
147
  }, [manager]);
130
148
  useFocusEffect(
@@ -136,7 +154,10 @@ export function HostsRoute({
136
154
  const subscription = AppState.addEventListener('change', (state) => {
137
155
  if (state === 'active') refresh();
138
156
  });
139
- return () => subscription.remove();
157
+ return () => {
158
+ accountRead.current++;
159
+ subscription.remove();
160
+ };
140
161
  }, [refreshAccount]),
141
162
  );
142
163
  const remove = () => {
@@ -284,6 +305,66 @@ export function HostsRoute({
284
305
  {error}
285
306
  </Text>
286
307
  ) : null}
308
+ {account ? (
309
+ <AccountHostsView
310
+ hosts={accountHosts.map((host) => {
311
+ const pairedId = pairedAccountHost(
312
+ host,
313
+ states.flatMap(({ host }) => ('signer' in host ? [host] : [])),
314
+ );
315
+ const paired = states.find(({ host }) => host.id === pairedId)?.host;
316
+ return {
317
+ ...host,
318
+ label: paired?.displayName ?? host.label,
319
+ pairedId,
320
+ canShare:
321
+ host.canShare &&
322
+ !!paired &&
323
+ 'signer' in paired &&
324
+ paired.person?.issuer === account.issuer &&
325
+ paired.person.subject === account.subject &&
326
+ paired.accountDeviceKeyId === account.deviceId,
327
+ };
328
+ })}
329
+ busy={busy}
330
+ onConnect={onAdd}
331
+ onDetail={onComputerDetail ?? setDetail}
332
+ onShare={(networkId, hostId, shared) => {
333
+ if (busy) return;
334
+ const host = accountHosts.find((host) => host.networkId === networkId && host.hostId === hostId);
335
+ const pairedId =
336
+ host &&
337
+ pairedAccountHost(
338
+ host,
339
+ states.flatMap(({ host }) => ('signer' in host ? [host] : [])),
340
+ );
341
+ const paired = states.find(({ host }) => host.id === pairedId)?.host;
342
+ if (!host || !paired || !('signer' in paired)) return;
343
+ setBusy(true);
344
+ setError(undefined);
345
+ void (async () => {
346
+ const auth = await createAccountClient(await selectedIdentityIssuer());
347
+ if (auth.issuer !== account.issuer || (await auth.session())?.id !== account.subject)
348
+ throw new Error('Sign in again before changing sharing.');
349
+ await setAccountHostVisibility(
350
+ {
351
+ keys: deviceKey,
352
+ put: (path, body) => auth.put(path, body),
353
+ now,
354
+ nonce: () => crypto.randomUUID(),
355
+ },
356
+ account,
357
+ host,
358
+ paired,
359
+ shared ? 'org' : 'member',
360
+ );
361
+ await refreshAccount();
362
+ })()
363
+ .catch((error: unknown) => setError(message(error)))
364
+ .finally(() => setBusy(false));
365
+ }}
366
+ />
367
+ ) : null}
287
368
  <HostsView
288
369
  hosts={hosts}
289
370
  onDetail={onComputerDetail ?? setDetail}
@@ -137,7 +137,7 @@ export function createHostRuntimes(
137
137
  reported = next;
138
138
  options.changed?.(next);
139
139
  };
140
- const stopEntry = (entry: HostRuntimeEntry, preserveGlobal = false) => {
140
+ const stopEntry = (entry: HostRuntimeEntry, preserveHost = false) => {
141
141
  entry.controller.abort();
142
142
  for (const [key, operation] of repairs)
143
143
  if (operation.left === entry || operation.right === entry) {
@@ -145,7 +145,7 @@ export function createHostRuntimes(
145
145
  repairs.delete(key);
146
146
  }
147
147
  entry.push?.stop();
148
- entry.runtime?.close({ preserveGlobal });
148
+ entry.runtime?.close({ preserveHost });
149
149
  };
150
150
 
151
151
  /** Cloud hosts poll and focus over cookie admission, and enroll push with the person's account. */
@@ -228,7 +228,7 @@ export interface LiveRuntime {
228
228
  searchFiles(sessionId: string, query: string): Promise<string[]>;
229
229
  retryActivity(sessionId: string): void;
230
230
  readonly hasVoiceSession: boolean;
231
- close(options?: { preserveGlobal?: boolean }): void;
231
+ close(options?: { preserveHost?: boolean }): void;
232
232
  }
233
233
 
234
234
  function isRecord(value: unknown): value is Record<string, unknown> {
@@ -572,7 +572,7 @@ export function startLiveRuntime(
572
572
 
573
573
  const applyCatalog = async (catalog: NativeBundleCatalog) => {
574
574
  if (closed) return;
575
- await mount({ scope: 'host' }, catalog.nativeGlobal);
575
+ await mount({ scope: 'host' }, catalog.nativeHost);
576
576
  if (closed) return;
577
577
  const present = new Set(
578
578
  catalog.workspaces.map((w) => (host.id === undefined ? w.id : qualifyHostId(host.id, w.id))),
@@ -813,11 +813,11 @@ export function startLiveRuntime(
813
813
  return []; // Completion is a convenience; a failed lookup just shows nothing, as in the cockpit.
814
814
  }
815
815
  },
816
- close({ preserveGlobal = false } = {}) {
816
+ close({ preserveHost = false } = {}) {
817
817
  if (closed) return;
818
818
  closed = true;
819
819
  // A reconnect keeps the computer's plugins mounted for the next connection; anything else stops them.
820
- const keep = preserveGlobal && host.id !== undefined && keptPlugins.get(host.id) === kept;
820
+ const keep = preserveHost && host.id !== undefined && keptPlugins.get(host.id) === kept;
821
821
  if (kept.link?.request === request) kept.link = undefined;
822
822
  clearVoiceReconnect();
823
823
  stopHeldChannels.unsubscribe();
@@ -26,7 +26,7 @@ interface NativeTemplateChoice {
26
26
  mount: WebPluginMount;
27
27
  }
28
28
 
29
- const GLOBAL: NativeTemplateChoice = { mount: { scope: 'host' } };
29
+ const HOST_DEFAULT: NativeTemplateChoice = { mount: { scope: 'host' } };
30
30
 
31
31
  const workspaceOf = (mount: WebPluginMount) => (mount.scope === 'workspace' ? mount.workspaceId : undefined);
32
32
  const sameChoice = (left: NativeTemplateChoice, right: NativeTemplateChoice) =>
@@ -52,14 +52,14 @@ function isRecord(value: unknown): value is Record<string, unknown> {
52
52
 
53
53
  function mountOf(value: unknown): WebPluginMount | undefined {
54
54
  if (!isRecord(value)) return undefined;
55
- // The po.hub@1 wire spells the host mount 'global'; 'host' is accepted for hosts that already send it.
56
- if (value.scope === 'global' || value.scope === 'host') return { scope: 'host' };
55
+ if (value.scope === 'global') throw new Error("The 'global' scope was renamed to 'host'. Update this client.");
56
+ if (value.scope === 'host') return { scope: 'host' };
57
57
  if (value.scope === 'workspace' && typeof value.workspaceId === 'string')
58
58
  return { scope: 'workspace', workspaceId: value.workspaceId };
59
59
  return undefined;
60
60
  }
61
61
 
62
- /** Reads `nativeTemplate` from `/api/compositions`; anything malformed keeps the global default. */
62
+ /** Reads `nativeTemplate` from `/api/compositions`; anything malformed keeps the host default. */
63
63
  export function setNativeTemplateChoice(value: unknown, hostId?: string): void {
64
64
  const parsed = isRecord(value) ? mountOf(value.mount) : undefined;
65
65
  const mount =
@@ -67,7 +67,7 @@ export function setNativeTemplateChoice(value: unknown, hostId?: string): void {
67
67
  ? { ...parsed, workspaceId: qualifyHostId(hostId, parsed.workspaceId) }
68
68
  : parsed;
69
69
  const id = isRecord(value) && typeof value.id === 'string' ? value.id : undefined;
70
- const choice = mount === undefined ? GLOBAL : { ...(id === undefined ? {} : { id }), mount };
70
+ const choice = mount === undefined ? HOST_DEFAULT : { ...(id === undefined ? {} : { id }), mount };
71
71
  // A compositions reload repeats the choice; an unchanged one must not re-render every template screen.
72
72
  choiceStore.setState((state) => {
73
73
  const previous = state.choices[hostId ?? ''];
@@ -114,12 +114,12 @@ export function useNativeTemplateScreen<Name extends keyof NativeTemplateScreens
114
114
  choiceStore,
115
115
  (value) => {
116
116
  const host = scopedHostId ?? value.hostId;
117
- return { managed: value.managed, hostId: host, choice: value.choices[host ?? ''] ?? GLOBAL };
117
+ return { managed: value.managed, hostId: host, choice: value.choices[host ?? ''] ?? HOST_DEFAULT };
118
118
  },
119
119
  (left, right) => left.managed === right.managed && left.hostId === right.hostId && left.choice === right.choice,
120
120
  );
121
121
  const snapshot = useCallback(() => {
122
- // The global list belongs to the phone, never to a downloaded host template or registry.
122
+ // The host list belongs to the phone, never to a downloaded host template or registry.
123
123
  if (bundled || (name === 'sessions' && managed && hostId === undefined)) {
124
124
  return bundledNativeTemplateScreen(name);
125
125
  }
@@ -1,4 +1,4 @@
1
- import { globalRevisionTopic, subscribeHubRevision, type HomeRequest } from '@agimon-ai/po-core/native';
1
+ import { hostRevisionTopic, subscribeHubRevision, type HomeRequest } from '@agimon-ai/po-core/native';
2
2
  import {
3
3
  pluginHomeContributions,
4
4
  qualifyHostId,
@@ -28,7 +28,7 @@ export function useHome(
28
28
  hostId?: string,
29
29
  attention = false,
30
30
  ) {
31
- const revisionTopic = globalRevisionTopic('home', hostId);
31
+ const revisionTopic = hostRevisionTopic('home', hostId);
32
32
  const reader = attention ? (runtime?.attentionHome ?? runtime?.home) : runtime?.home;
33
33
  const current = useStore(reader?.store ?? disconnected, (value) => value);
34
34
  const matches = current.query === JSON.stringify([filter.source, filter.workspaceId]);
@@ -164,7 +164,7 @@ export function useHomes(
164
164
  };
165
165
  update();
166
166
  const offs = readers.map(({ hostId, reader }) =>
167
- subscribeHubRevision(globalRevisionTopic('home', hostId), () => {
167
+ subscribeHubRevision(hostRevisionTopic('home', hostId), () => {
168
168
  if (AppState.currentState === 'active') void reader?.refresh({ limit: 50 });
169
169
  }),
170
170
  );
@@ -1,4 +1,4 @@
1
- import { qualifyHostId, splitHostId } from '@agimon-ai/po-web-dashboard/core';
1
+ export { homeAppEntries, homePageRoute } from '@agimon-ai/po-web-dashboard/core';
2
2
 
3
3
  export type HomeTileSize = 'small' | 'wide' | 'tall' | 'large';
4
4
 
@@ -30,61 +30,3 @@ export function placeTiles(sizes: readonly HomeTileSize[], columns: number) {
30
30
  return { column: start % columns, row: Math.floor(start / columns), columnSpan, rowSpan };
31
31
  });
32
32
  }
33
-
34
- interface HomeHost {
35
- id: string;
36
- person?: { issuer: string; subject: string };
37
- connected?: boolean;
38
- }
39
-
40
- type FillScope = { combinesComputers?: unknown; dataScope?: unknown } | undefined;
41
-
42
- /**
43
- * One card per computer, except for a plugin whose page joins every computer (its fill sets
44
- * `data.combinesComputers`, as the calendar does): that one shows once per person. Unlinked
45
- * computers join the phone's one account, or share a card of their own when it holds several.
46
- * A fill with `data.dataScope: 'global'` reads a shared backend, so it also shows once per person,
47
- * from that person's first connected computer, and is marked `global` so it reads only that one.
48
- */
49
- export function homeAppEntries<T extends { pluginId: string; id: string; data?: unknown }>(
50
- hosts: readonly HomeHost[],
51
- read: (hostId: string) => readonly T[],
52
- ) {
53
- const people = new Set(hosts.flatMap((host) => (host.person ? [JSON.stringify(host.person)] : [])));
54
- const unlinked = people.size === 1 ? [...people][0]! : 'unlinked';
55
- const fills = hosts.map((host) => ({ host, fills: read(host.id) }));
56
- const keyOf = (host: HomeHost, fill: T) => {
57
- const scope = fill.data as FillScope;
58
- const perPerson = scope?.combinesComputers === true || scope?.dataScope === 'global';
59
- const owner = perPerson ? (host.person ? JSON.stringify(host.person) : unlinked) : host.id;
60
- return JSON.stringify([owner, splitHostId(fill.pluginId)?.localId ?? fill.pluginId, fill.id]);
61
- };
62
- // A global fill is served by the first connected computer that has it, else the first one.
63
- const globalHost = new Map<string, string>();
64
- for (const connectedPass of [true, false])
65
- for (const { host, fills: hostFills } of fills)
66
- if ((host.connected !== false) === connectedPass)
67
- for (const fill of hostFills)
68
- if ((fill.data as FillScope)?.dataScope === 'global') {
69
- const key = keyOf(host, fill);
70
- if (!globalHost.has(key)) globalHost.set(key, host.id);
71
- }
72
- const seen = new Set<string>();
73
- return fills.flatMap(({ host, fills: hostFills }) =>
74
- hostFills.flatMap((fill) => {
75
- const key = keyOf(host, fill);
76
- const chosen = globalHost.get(key);
77
- if (seen.has(key) || (chosen !== undefined && chosen !== host.id)) return [];
78
- seen.add(key);
79
- return [{ hostId: host.id, fill, key, global: chosen !== undefined }];
80
- }),
81
- );
82
- }
83
-
84
- /** Page ids retain the supplying host, independent of focus and connection order. */
85
- export function homePageRoute(hostId: string, pageId: string) {
86
- return {
87
- pageId: qualifyHostId(hostId, pageId),
88
- title: pageId.charAt(0).toUpperCase() + pageId.slice(1).replace(/-/g, ' '),
89
- };
90
- }
@@ -0,0 +1,51 @@
1
+ import { View } from 'react-native';
2
+
3
+ import { PhoneFrame } from './designFrame';
4
+ import { AccountHostsView } from './HostsView';
5
+
6
+ const noop = () => undefined;
7
+ function Target({
8
+ scheme = 'light',
9
+ shared = false,
10
+ manager = true,
11
+ empty = false,
12
+ }: {
13
+ scheme?: 'light' | 'dark';
14
+ shared?: boolean;
15
+ manager?: boolean;
16
+ empty?: boolean;
17
+ }) {
18
+ return (
19
+ <PhoneFrame scheme={scheme}>
20
+ <View style={{ padding: 16, gap: 16 }}>
21
+ <AccountHostsView
22
+ hosts={
23
+ empty
24
+ ? []
25
+ : [
26
+ {
27
+ networkId: 'personal',
28
+ hostId: 'studio',
29
+ label: 'Studio Mac',
30
+ pairedId: 'studio',
31
+ visibility: shared ? 'org' : 'member',
32
+ canShare: manager,
33
+ },
34
+ { networkId: 'team', hostId: 'office', label: 'Office Mac', visibility: 'org', canShare: false },
35
+ ]
36
+ }
37
+ onConnect={noop}
38
+ onDetail={noop}
39
+ onShare={noop}
40
+ />
41
+ </View>
42
+ </PhoneFrame>
43
+ );
44
+ }
45
+ export const Playground = { render: () => <Target /> };
46
+ export const Dark = { render: () => <Target scheme="dark" /> };
47
+ export const Shared = { render: () => <Target shared /> };
48
+ export const Member = { render: () => <Target manager={false} /> };
49
+ export const Empty = { render: () => <Target empty /> };
50
+ const meta = { title: 'Native/Design/Hosts in your account', tags: ['style-system', 'mockup', 'native'] };
51
+ export default meta;
@@ -18,7 +18,7 @@ import { ErrorLine, Group, SectionPage } from './SettingsScreen';
18
18
  */
19
19
 
20
20
  const TEMPLATE_KEY = 'native.template';
21
- const GLOBAL = 'global';
21
+ const HOST = 'host';
22
22
 
23
23
  /** Follow the phone, then each shipped theme under the scheme the app registers it as. */
24
24
  const THEMES: readonly { id: Appearance; title: string; detail?: string }[] = [
@@ -45,7 +45,7 @@ export interface AppearanceTemplate {
45
45
  export interface AppearanceScreenProps {
46
46
  theme: Appearance;
47
47
  onTheme: (theme: Appearance) => void;
48
- /** `global`, or the workspace id whose layout this page edits. */
48
+ /** `host`, or the workspace id whose layout this page edits. */
49
49
  target: string;
50
50
  repositories: readonly SettingsRepository[];
51
51
  templates: readonly AppearanceTemplate[];
@@ -89,7 +89,7 @@ function PluginThemes({ theme, onTheme }: Pick<AppearanceScreenProps, 'theme' |
89
89
  export function AppearanceScreen(props: AppearanceScreenProps) {
90
90
  const { theme, target, templates, choice, busy, loaded } = props;
91
91
  const targets: SelectOption[] = [
92
- { value: GLOBAL, label: 'Global default' },
92
+ { value: HOST, label: 'Host default' },
93
93
  ...props.repositories.map((repository) => ({
94
94
  value: repository.id,
95
95
  label: repository.name,
@@ -160,7 +160,7 @@ export function AppearanceScreen(props: AppearanceScreenProps) {
160
160
  Set as default
161
161
  </Button>
162
162
  <Button variant="ghost" size="sm" disabled={busy || !loaded} onPress={props.onFallback}>
163
- {target === GLOBAL ? 'Use automatic fallback' : 'Inherit global default'}
163
+ {target === HOST ? 'Use automatic fallback' : 'Inherit host default'}
164
164
  </Button>
165
165
  </View>
166
166
  <Note>
@@ -182,11 +182,11 @@ export function useAppearance(
182
182
  onSaved: () => void,
183
183
  hostId?: string,
184
184
  ): Model {
185
- const [target, setTarget] = useState(GLOBAL);
185
+ const [target, setTarget] = useState(HOST);
186
186
  const [draft, setDraft] = useState<string>();
187
187
  const [busy, setBusy] = useState(false);
188
188
  const [saveError, setSaveError] = useState<string>();
189
- const workspaceId = target === GLOBAL ? undefined : target;
189
+ const workspaceId = target === HOST ? undefined : target;
190
190
  const repoRoot = repositories.find((repository) => repository.id === workspaceId)?.path ?? '';
191
191
  // Without a host the calls take their two-argument form, which the phone-wide transport answers.
192
192
  const host = hostId === undefined ? ([] as const) : ([hostId] as const);
@@ -0,0 +1,36 @@
1
+ import { View } from 'react-native';
2
+
3
+ import { PhoneFrame } from './designFrame';
4
+ import { GlobalSettingsView, Group, Row } from './SettingsScreen';
5
+
6
+ const noop = () => undefined;
7
+ function Target({ scheme = 'light', notice, error }: { scheme?: 'light' | 'dark'; notice?: string; error?: string }) {
8
+ return (
9
+ <PhoneFrame scheme={scheme}>
10
+ <View style={{ padding: 16, gap: 16 }}>
11
+ <Group label="Studio Mac">
12
+ <Row title="Host settings" description="Settings on this computer override Global." last />
13
+ </Group>
14
+ <Group label="Global" hint="Your portable preferences across hosts in Personal.">
15
+ <GlobalSettingsView
16
+ yaml={'native:\n theme: dark\nvoice:\n language: en\n'}
17
+ onChange={noop}
18
+ onSave={noop}
19
+ notice={notice}
20
+ error={error}
21
+ />
22
+ </Group>
23
+ </View>
24
+ </PhoneFrame>
25
+ );
26
+ }
27
+ export const Playground = { render: () => <Target /> };
28
+ export const Dark = { render: () => <Target scheme="dark" /> };
29
+ export const DeliveryDeferred = {
30
+ render: () => (
31
+ <Target notice="Global settings are saved. Permission could not reach every host yet. Work here can continue." />
32
+ ),
33
+ };
34
+ export const Conflict = { render: () => <Target error="Settings changed. Reload before saving again." /> };
35
+ const meta = { title: 'Native/Design/Settings: by host + Global', tags: ['style-system', 'mockup', 'native'] };
36
+ export default meta;