@agimon-ai/po-native 0.0.1-alpha.72 → 0.0.1-alpha.74

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.72",
3
+ "version": "0.0.1-alpha.74",
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.192",
33
- "@agimon-ai/po-expo-signing": "0.0.1-alpha.72",
34
- "@agimon-ai/po-identity": "0.0.2-alpha.139",
35
- "@agimon-ai/po-native-components": "0.0.0-alpha.192",
36
- "@agimon-ai/po-native-dashboard": "0.0.0-alpha.64",
37
- "@agimon-ai/po-template-advanced": "0.0.0-alpha.192",
38
- "@agimon-ai/po-template-elegant": "0.0.0-alpha.192",
39
- "@agimon-ai/po-voice": "0.0.0-alpha.192",
40
- "@agimon-ai/po-web-components": "0.0.0-alpha.192",
41
- "@agimon-ai/po-web-dashboard": "0.0.0-alpha.192",
42
- "@agimon-ai/po-web-security": "0.0.0-alpha.192",
32
+ "@agimon-ai/po-core": "0.0.0-alpha.194",
33
+ "@agimon-ai/po-expo-signing": "0.0.1-alpha.74",
34
+ "@agimon-ai/po-identity": "0.0.2-alpha.141",
35
+ "@agimon-ai/po-native-components": "0.0.0-alpha.194",
36
+ "@agimon-ai/po-native-dashboard": "0.0.0-alpha.66",
37
+ "@agimon-ai/po-template-advanced": "0.0.0-alpha.194",
38
+ "@agimon-ai/po-template-elegant": "0.0.0-alpha.194",
39
+ "@agimon-ai/po-voice": "0.0.0-alpha.194",
40
+ "@agimon-ai/po-web-components": "0.0.0-alpha.194",
41
+ "@agimon-ai/po-web-dashboard": "0.0.0-alpha.194",
42
+ "@agimon-ai/po-web-security": "0.0.0-alpha.194",
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.2",
package/src/app/App.tsx CHANGED
@@ -113,7 +113,11 @@ import {
113
113
  sessionSetupActionFor,
114
114
  } from '@agimon-ai/po-web-dashboard/core';
115
115
  import type { SettingsRepository } from '@agimon-ai/po-web-dashboard/types';
116
- import { type BottomTabBarProps, createBottomTabNavigator } from '@react-navigation/bottom-tabs';
116
+ import {
117
+ type BottomTabBarProps,
118
+ type BottomTabNavigationProp,
119
+ createBottomTabNavigator,
120
+ } from '@react-navigation/bottom-tabs';
117
121
  import { useHeaderHeight } from '@react-navigation/elements';
118
122
  import {
119
123
  DarkTheme,
@@ -131,6 +135,7 @@ import {
131
135
  } from '@react-navigation/native-stack';
132
136
  import { shallow, useStore } from '@tanstack/react-store';
133
137
  import { Store } from '@tanstack/store';
138
+ import { addNetworkStateListener } from 'expo-network';
134
139
  import {
135
140
  cloneElement,
136
141
  memo,
@@ -1356,7 +1361,16 @@ function SessionRoute({
1356
1361
  const tab =
1357
1362
  transientTabs.find((candidate) => candidate.id === detail.params.tabId) ??
1358
1363
  webTabs(ownerSessionId).find((candidate) => candidate.id === detail.params.tabId);
1359
- if (!tab) return <EmptyState title="This activity is no longer available." />;
1364
+ if (!tab)
1365
+ return (
1366
+ <EmptyState
1367
+ size="page"
1368
+ tone="error"
1369
+ title="This activity is no longer available"
1370
+ description="It closed or finished. The conversation keeps everything it produced."
1371
+ action={{ label: 'Go back', onAction: () => child.goBack() }}
1372
+ />
1373
+ );
1360
1374
  let setTabHeader = tabHeaders.current.get(tab.id);
1361
1375
  if (!setTabHeader) {
1362
1376
  const label = tab.label;
@@ -1609,7 +1623,16 @@ function SettingsPanelRoute({ route }: NativeStackScreenProps<Routes, 'SettingsP
1609
1623
  const { hostId } = route.params;
1610
1624
  const panel = useSettingsPanels(hostId).find((candidate) => candidate.id === route.params.id);
1611
1625
  const request = useMemo(() => (hostId === undefined ? requestWithStepUp : apiTransportForHost(hostId)), [hostId]);
1612
- if (!panel) return <EmptyState title="This page is not installed" description="Go back to Settings." />;
1626
+ if (!panel)
1627
+ return (
1628
+ <EmptyState
1629
+ size="page"
1630
+ tone="error"
1631
+ title="This page is not installed"
1632
+ description="The plugin that adds it is off or not on this computer."
1633
+ action={{ label: 'Go back', onAction: () => navigation.goBack() }}
1634
+ />
1635
+ );
1613
1636
  const Panel = panel.component;
1614
1637
  return (
1615
1638
  <SettingsPanelPage {...(panel.detail ? { detail: panel.detail } : {})}>
@@ -1870,12 +1893,21 @@ function PresetsRoute({ route }: NativeStackScreenProps<Routes, 'SettingsPresets
1870
1893
  );
1871
1894
  }
1872
1895
 
1873
- function ContributedSectionRoute({ route }: NativeStackScreenProps<Routes, 'SettingsSection'>) {
1896
+ function ContributedSectionRoute({ route, navigation }: NativeStackScreenProps<Routes, 'SettingsSection'>) {
1874
1897
  const { id, hostId, workspace } = route.params;
1875
1898
  const section = useSettingsSections(workspace ? 'workspace' : 'host', hostId).find(
1876
1899
  (candidate) => candidate.id === id,
1877
1900
  );
1878
- if (!section) return <EmptyState title="This page is not installed" description="Go back to Settings." />;
1901
+ if (!section)
1902
+ return (
1903
+ <EmptyState
1904
+ size="page"
1905
+ tone="error"
1906
+ title="This page is not installed"
1907
+ description="The plugin that adds it is off or not on this computer."
1908
+ action={{ label: 'Go back', onAction: () => navigation.goBack() }}
1909
+ />
1910
+ );
1879
1911
  return <ContributedSection section={section} workspace={workspace} hostId={hostId} />;
1880
1912
  }
1881
1913
 
@@ -2846,7 +2878,16 @@ function useCalendarHostProps(hostStates: readonly HostRuntimeState[], hostId: s
2846
2878
  }
2847
2879
 
2848
2880
  /** Workspace compositions mount eagerly in liveRuntime, independently of session focus. */
2849
- function WorkspaceRoute({ workspaceId, hostStates }: { workspaceId: string; hostStates: readonly HostRuntimeState[] }) {
2881
+ function WorkspaceRoute({
2882
+ workspaceId,
2883
+ hostStates,
2884
+ onReconnect,
2885
+ }: {
2886
+ workspaceId: string;
2887
+ hostStates: readonly HostRuntimeState[];
2888
+ /** Reconnects one computer, as Settings' Retry does; the Workspace page offers it when that computer is offline or failed. */
2889
+ onReconnect: (host: HostRuntimeState['host']) => void;
2890
+ }) {
2850
2891
  const navigation = useNavigation<NativeStackNavigationProp<Routes>>();
2851
2892
  useSyncExternalStore(subscribeWebPluginRegistry, webPluginRegistryRevision);
2852
2893
  const workspace = useStore(workspacesStore, (state) => state.byId[workspaceId]);
@@ -2861,7 +2902,14 @@ function WorkspaceRoute({ workspaceId, hostStates }: { workspaceId: string; host
2861
2902
  const openWorkspace = useOpenWorkspace(owner?.hostId);
2862
2903
  const { loading, error } = useActivityLoad(owner?.hostId, ['catalog', 'host', `workspace:${workspaceId}`]);
2863
2904
  const state = workspacePageState({ hostStatus: host?.status, workspace, loading, error });
2864
- if (!owner || state !== 'ready') return <WorkspaceScreen state={owner ? state : 'missing'} error={error} />;
2905
+ if (!owner || state !== 'ready')
2906
+ return (
2907
+ <WorkspaceScreen
2908
+ state={owner ? state : 'missing'}
2909
+ error={error}
2910
+ {...(host ? { onRetry: () => onReconnect(host.host) } : {})}
2911
+ />
2912
+ );
2865
2913
  const registry = webPluginRegistryForHost(owner.hostId);
2866
2914
  const fills = (slot: string) =>
2867
2915
  [
@@ -2982,7 +3030,16 @@ function PluginPageRoute({
2982
3030
  const calendarHost = useCalendarHostProps(hostStates, pageHostId);
2983
3031
  const openWorkspace = useOpenWorkspace(pageHostId);
2984
3032
  const richRenderers = useMemo(createRichActivityRenderers, []);
2985
- if (!Page) return <EmptyState title="This page is not installed" description="Go back to Home." />;
3033
+ if (!Page)
3034
+ return (
3035
+ <EmptyState
3036
+ size="page"
3037
+ tone="error"
3038
+ title="This page is not installed"
3039
+ description="The plugin that adds it is off or not on this computer."
3040
+ action={{ label: 'Go back', onAction: () => navigation.goBack() }}
3041
+ />
3042
+ );
2986
3043
  const props = {
2987
3044
  ...nativeSlotProps('', {}, () => undefined, undefined, { ...richRenderers, nativeSaveFile }),
2988
3045
  sessionId: null,
@@ -3181,24 +3238,27 @@ function HomeAttentionRoute({
3181
3238
 
3182
3239
  /** Until the phone is connected, the other tabs point back to Home, or offer Restore when it is already paired. */
3183
3240
  function ConnectFirst({ restore }: { restore?: { onRestore: () => void; busy: boolean } }) {
3241
+ // Only the Sessions and Settings tabs draw this, so the nearest navigator is the tab bar.
3242
+ const tabs = useNavigation<BottomTabNavigationProp<TabRoutes>>();
3184
3243
  if (!restore) {
3185
- return <EmptyState title="Not connected yet." description="Connect this phone to Po from Home." />;
3244
+ return (
3245
+ <EmptyState
3246
+ size="page"
3247
+ icon={<HomeIcon size={24} />}
3248
+ title="Not connected yet"
3249
+ description="Connect this phone to Po from Home."
3250
+ action={{ label: 'Go to Home', onAction: () => tabs.navigate('Home') }}
3251
+ />
3252
+ );
3186
3253
  }
3187
3254
  return (
3188
3255
  <EmptyState
3189
- title="Not connected right now."
3256
+ size="page"
3257
+ tone="error"
3258
+ title="Not connected right now"
3190
3259
  description="This phone is paired, but Po on your computer is not reachable."
3191
- >
3192
- <Button
3193
- variant="primary"
3194
- size="md"
3195
- loading={restore.busy}
3196
- loadingLabel="Restoring the connection"
3197
- onPress={restore.onRestore}
3198
- >
3199
- Restore connection
3200
- </Button>
3201
- </EmptyState>
3260
+ action={{ label: 'Restore connection', onAction: restore.onRestore, loading: restore.busy }}
3261
+ />
3202
3262
  );
3203
3263
  }
3204
3264
 
@@ -3326,10 +3386,17 @@ export function App({ nativeHost }: { nativeHost?: (sessionId: string) => Native
3326
3386
  renew();
3327
3387
  const subscription = AppState.addEventListener('change', (state) => {
3328
3388
  if (state !== 'active') return;
3389
+ hosts.current?.retryDisconnectedComputers();
3329
3390
  renew();
3330
3391
  followAccountRemovals(hosts.current);
3331
3392
  });
3332
- return () => subscription.remove();
3393
+ const network = addNetworkStateListener(({ isConnected }) => {
3394
+ if (isConnected && AppState.currentState === 'active') hosts.current?.retryDisconnectedComputers();
3395
+ });
3396
+ return () => {
3397
+ subscription.remove();
3398
+ network.remove();
3399
+ };
3333
3400
  }, []);
3334
3401
 
3335
3402
  useEffect(() => {
@@ -3799,7 +3866,13 @@ export function App({ nativeHost }: { nativeHost?: (sessionId: string) => Native
3799
3866
  getId={({ params }) => params.workspaceId}
3800
3867
  options={({ route }) => ({ title: route.params.title })}
3801
3868
  >
3802
- {({ route }) => <WorkspaceRoute workspaceId={route.params.workspaceId} hostStates={hostStates} />}
3869
+ {({ route }) => (
3870
+ <WorkspaceRoute
3871
+ workspaceId={route.params.workspaceId}
3872
+ hostStates={hostStates}
3873
+ onReconnect={(saved) => void hosts.current?.connect(saved).catch(() => undefined)}
3874
+ />
3875
+ )}
3803
3876
  </Stack.Screen>
3804
3877
  <Stack.Screen name="CalendarDetail" options={{ title: 'Event details' }}>
3805
3878
  {({ route }) => (
@@ -1,7 +1,7 @@
1
1
  import { encodeBase64 } from '@agimon-ai/po-core/native';
2
2
  import {
3
3
  createStarterProfile,
4
- runCommand,
4
+ invokeModeAction,
5
5
  saveStarterAboutYou,
6
6
  STARTER_POS,
7
7
  type StarterPo,
@@ -18,8 +18,6 @@ import { openFirstSession } from '../services/hostActions';
18
18
  import { listProviders } from '../services/settingsApi';
19
19
  import { rememberFirstSessionWelcome } from './firstSteps';
20
20
 
21
- /** The mode's own activate action, as the mode menu sends it: a mode already on stays on. */
22
- const HELP_COMMAND = 'mode help activate';
23
21
  const NOT_LISTED = 'Your Po is ready, but its conversation has not shown up yet. Pull to refresh Home.';
24
22
 
25
23
  /** The panda as a PNG data URL for the profile; undefined if it cannot be read, so the Po starts without one. */
@@ -100,7 +98,10 @@ export function OnboardingRoute({
100
98
  const { sessionId } = opened;
101
99
  rememberFirstSessionWelcome({ sessionId, poId: chosen.id, name: name.trim(), interests: interests.trim() });
102
100
  if (!(await waitForSession(sessionId))) return fail(NOT_LISTED);
103
- void whenSessionReady(sessionId, () => runCommand(HELP_COMMAND, sessionId));
101
+ // The mode's own activate action over the modes API, as the mode menu sends it: a mode already on stays on.
102
+ void whenSessionReady(sessionId, () =>
103
+ invokeModeAction('help', 'activate', sessionId, apiTransportForHost(hostId)),
104
+ );
104
105
  onOpenSession(sessionId);
105
106
  };
106
107
 
@@ -579,6 +579,13 @@ export function createHostRuntimes(
579
579
  return {
580
580
  connect,
581
581
  snapshot,
582
+ retryDisconnectedComputers() {
583
+ for (const { host, status } of entries.values()) {
584
+ if (!isCloudHost(host) && status === 'disconnected') {
585
+ void connect(host).catch(() => undefined);
586
+ }
587
+ }
588
+ },
582
589
  async rescan(scanned: string, signal?: AbortSignal): Promise<TrustedSession> {
583
590
  if (closed) throw new Error('The host runtimes are closed.');
584
591
  if (scan) throw new Error('A pairing scan is already running.');
@@ -83,6 +83,7 @@ import { createHomeReader, type HomeReader } from './homeState';
83
83
  import { setNativeTemplateChoice } from './nativeTemplate';
84
84
  /** `client=native` tells the host a phone needs its native build, which it otherwise defers. */
85
85
  const COMPOSITIONS_ROUTE = '/api/compositions?client=native';
86
+ const BUNDLE_REQUEST_TIMEOUT_MS = 8_000;
86
87
  const BUNDLED_IDS: ReadonlySet<string> = new Set(bundledPlugins.map((plugin) => plugin.id));
87
88
 
88
89
  /**
@@ -102,6 +103,7 @@ let stopFileLinkModes: (() => void) | undefined;
102
103
  /** What the current connection lends the host's plugins; absent between a drop and its replacement. */
103
104
  interface HostPluginLink {
104
105
  request: Connection['request'];
106
+ requestBundle: (target: string) => Promise<Response>;
105
107
  onActivityLoad: (owner: string, state: ActivityLoadState) => void;
106
108
  onCompatibility: (issues: readonly PluginCompatibility[]) => void;
107
109
  onError: (error: unknown) => void;
@@ -147,15 +149,13 @@ function createHostPlugins(host: HostRecord): HostPlugins {
147
149
  hostId: host.id,
148
150
  signerPublicKey: host.signer.publicKey,
149
151
  async fetchComposition(descriptor, entryPath) {
150
- const { request } = linked(kept);
151
- const manifest = await request({ method: 'GET', target: descriptor.manifestUrl });
152
+ const { requestBundle } = linked(kept);
153
+ const manifest = await requestBundle(descriptor.manifestUrl);
152
154
  if (!manifest.ok) throw new Error(`Composition ${descriptor.id} manifest is unavailable.`);
153
- const asset = await request({
154
- method: 'GET',
155
- target: `${descriptor.rawAssetBaseUrl.replace(/\/+$/u, '')}${entryPath}`,
156
- });
155
+ const signed: unknown = await manifest.json();
156
+ const asset = await requestBundle(`${descriptor.rawAssetBaseUrl.replace(/\/+$/u, '')}${entryPath}`);
157
157
  if (!asset.ok) throw new Error(`Composition ${descriptor.id} module ${entryPath} is unavailable.`);
158
- return { signed: await manifest.json(), source: new Uint8Array(await asset.arrayBuffer()) };
158
+ return { signed, source: new Uint8Array(await asset.arrayBuffer()) };
159
159
  },
160
160
  onError(error) {
161
161
  kept.link?.onActivityLoad('catalog', {
@@ -194,13 +194,14 @@ function createHostPlugins(host: HostRecord): HostPlugins {
194
194
  async fetchComposition(descriptor, entryPath) {
195
195
  const composition = compositions.get(descriptor.id);
196
196
  if (!composition) throw new Error(`Composition ${descriptor.id} is not advertised by the host.`);
197
- const { request } = linked(kept);
198
- const manifest = await request({ method: 'GET', target: composition.manifestUrl });
197
+ const { requestBundle } = linked(kept);
198
+ const manifest = await requestBundle(composition.manifestUrl);
199
199
  if (!manifest.ok) throw new Error(`Composition ${descriptor.id} manifest is unavailable.`);
200
+ const signed: unknown = await manifest.json();
200
201
  const base = composition.rawAssetBaseUrl.replace(/\/+$/u, '');
201
- const asset = await request({ method: 'GET', target: `${base}${entryPath}` });
202
+ const asset = await requestBundle(`${base}${entryPath}`);
202
203
  if (!asset.ok) throw new Error(`Composition ${descriptor.id} module ${entryPath} is unavailable.`);
203
- return { signed: await manifest.json(), source: new Uint8Array(await asset.arrayBuffer()) };
204
+ return { signed, source: new Uint8Array(await asset.arrayBuffer()) };
204
205
  },
205
206
  });
206
207
  return Object.assign(kept, {
@@ -463,7 +464,7 @@ export function startLiveRuntime(
463
464
  onChannel: (frame) => plugins.dispatch(frame),
464
465
  // A republished global or workspace composition swaps in place; the app itself is not reloaded.
465
466
  onCompositions() {
466
- if (!closed) void loadCompositions();
467
+ void loadCompositions('changed');
467
468
  },
468
469
  onReconnectNeeded() {
469
470
  ready = false;
@@ -509,8 +510,16 @@ export function startLiveRuntime(
509
510
  (target, body) => request({ method: 'POST', target, headers: [['content-type', 'application/json']], body }),
510
511
  host.id,
511
512
  );
513
+ const bundleLifetime = new AbortController();
514
+ const requestBundle = (target: string) =>
515
+ request({
516
+ method: 'GET',
517
+ target,
518
+ signal: AbortSignal.any([bundleLifetime.signal, AbortSignal.timeout(BUNDLE_REQUEST_TIMEOUT_MS)]),
519
+ });
512
520
  kept.link = {
513
521
  request,
522
+ requestBundle,
514
523
  onActivityLoad,
515
524
  onError: reportMountFailure,
516
525
  onCompatibility(issues) {
@@ -533,50 +542,54 @@ export function startLiveRuntime(
533
542
  : target.scope === 'workspace'
534
543
  ? `workspace:${target.workspaceId}`
535
544
  : 'host';
536
- if (target.scope === 'session') {
537
- const previous = selectedSessions.get(target.sessionId);
538
- if (previous) composition = previous;
539
- else {
540
- const candidate = descriptorOf(composition);
541
- if (!candidate) return;
542
- const selected = await updates.selectSession(candidate);
543
- if (!selected || closed || sessionMounts.get(target.sessionId) !== target) return;
544
- composition = { ...(composition as SessionNativeComposition), ...selected };
545
- selectedSessions.set(target.sessionId, composition);
545
+ const epoch = (loadEpochs.get(owner) ?? 0) + 1;
546
+ loadEpochs.set(owner, epoch);
547
+ const current = () =>
548
+ !closed &&
549
+ loadEpochs.get(owner) === epoch &&
550
+ (target.scope !== 'session' || sessionMounts.get(target.sessionId) === target);
551
+ try {
552
+ if (target.scope === 'session') {
553
+ const previous = selectedSessions.get(target.sessionId);
554
+ if (previous) composition = previous;
555
+ else {
556
+ onActivityLoad(owner, { loading: true });
557
+ const candidate = descriptorOf(composition);
558
+ if (!candidate) throw new Error('The session has an invalid Activity composition.');
559
+ const selected = await updates.selectSession(candidate);
560
+ if (!current()) return;
561
+ if (!selected) throw new Error('The installed Activity bundle does not cover this session.');
562
+ composition = { ...(composition as SessionNativeComposition), ...selected };
563
+ selectedSessions.set(target.sessionId, composition);
564
+ }
546
565
  }
547
- }
548
- const descriptor = descriptorOf(composition);
549
- if (!descriptor) {
550
- plugins.unmount(target);
551
- if (loadEpochs.has(owner)) {
552
- loadEpochs.set(owner, loadEpochs.get(owner)! + 1);
553
- if (target.scope !== 'session') {
566
+ const descriptor = descriptorOf(composition);
567
+ if (!descriptor) {
568
+ plugins.unmount(target);
569
+ if (epoch > 1) {
554
570
  home.clear();
555
571
  attentionHome.clear();
556
572
  }
573
+ onActivityLoad(owner, { loading: false });
574
+ return;
557
575
  }
558
- return;
559
- }
560
- compositions.set(descriptor.id, composition as SessionNativeComposition);
561
- const epoch = (loadEpochs.get(owner) ?? 0) + 1;
562
- loadEpochs.set(owner, epoch);
563
- // Session upserts re-run focus often; an unchanged composition must not blank the sheet with a spinner.
564
- if (!plugins.mounted(target, descriptor)) {
565
- if (target.scope !== 'session') {
566
- home.clear();
567
- attentionHome.clear();
576
+ compositions.set(descriptor.id, composition as SessionNativeComposition);
577
+ // An unchanged composition must not replace usable cards with a spinner.
578
+ if (!plugins.mounted(target, descriptor)) {
579
+ if (target.scope !== 'session') {
580
+ home.clear();
581
+ attentionHome.clear();
582
+ }
583
+ onActivityLoad(owner, { loading: true });
568
584
  }
569
- onActivityLoad(owner, { loading: true });
570
- }
571
- try {
572
585
  await plugins.mount(target, descriptor);
573
- if (!closed && loadEpochs.get(owner) === epoch) onActivityLoad(owner, { loading: false });
586
+ if (current()) onActivityLoad(owner, { loading: false });
574
587
  } catch (error) {
575
- if (!closed && loadEpochs.get(owner) === epoch)
576
- onActivityLoad(owner, {
577
- loading: false,
578
- error: error instanceof Error ? error.message : 'Activity failed to load.',
579
- });
588
+ if (!current()) return;
589
+ onActivityLoad(owner, {
590
+ loading: false,
591
+ error: error instanceof Error ? error.message : 'Activity failed to load.',
592
+ });
580
593
  reportMountFailure(error);
581
594
  }
582
595
  };
@@ -623,10 +636,13 @@ export function startLiveRuntime(
623
636
  await mount({ scope: 'workspace', workspaceId }, workspace.nativeComposition);
624
637
  }
625
638
  };
639
+ let installed = false;
626
640
  const startup = updates
627
641
  .startup()
628
642
  .then(async (catalog) => {
629
643
  if (catalog && !closed) {
644
+ installed = true;
645
+ onActivityLoad('catalog', { loading: false });
630
646
  await applyCatalog(catalog);
631
647
  if (!closed) applyFocus();
632
648
  }
@@ -634,22 +650,21 @@ export function startLiveRuntime(
634
650
  .catch((error: unknown) => {
635
651
  if (!closed) reportMountFailure(error);
636
652
  });
637
- const loadCompositions = async () => {
638
- const epoch = (loadEpochs.get('catalog') ?? 0) + 1;
639
- loadEpochs.set('catalog', epoch);
640
- const current = () => !closed && loadEpochs.get('catalog') === epoch;
641
- onActivityLoad('catalog', { loading: true });
653
+ const checkCompositions = async (reoffer: boolean) => {
654
+ const current = () => !closed;
642
655
  try {
643
656
  await startup;
644
657
  if (!current()) return;
645
- const response = await request({ method: 'GET', target: COMPOSITIONS_ROUTE });
658
+ if (!installed) onActivityLoad('catalog', { loading: true });
659
+ const response = await requestBundle(COMPOSITIONS_ROUTE);
646
660
  const body: unknown = await response.json();
647
661
  if (!current()) return;
648
662
  if (!response.ok || !isRecord(body)) throw new Error('Activity extensions are unavailable.');
649
663
  options.observeCompositions?.(body, request);
650
- const result = await updates.check(body);
664
+ const result = await updates.check(body, { signal: bundleLifetime.signal, reoffer });
651
665
  if (!current()) return;
652
666
  if (result.catalog) {
667
+ installed = true;
653
668
  setNativeTemplateChoice(body.nativeTemplate, host.id);
654
669
  await applyCatalog(result.catalog);
655
670
  if (current()) applyFocus();
@@ -669,7 +684,7 @@ export function startLiveRuntime(
669
684
  }
670
685
  }
671
686
  } catch (error) {
672
- if (current())
687
+ if (current() && !installed)
673
688
  onActivityLoad('catalog', {
674
689
  loading: false,
675
690
  error: error instanceof Error ? error.message : 'Activity update failed.',
@@ -691,7 +706,8 @@ export function startLiveRuntime(
691
706
  }
692
707
  if (current()) onActivityLoad('catalog', { loading: false });
693
708
  } catch (error) {
694
- if (current())
709
+ if (!current()) return;
710
+ if (!installed)
695
711
  onActivityLoad('catalog', {
696
712
  loading: false,
697
713
  error: error instanceof Error ? error.message : 'Activity failed to load.',
@@ -699,6 +715,25 @@ export function startLiveRuntime(
699
715
  reportMountFailure(error);
700
716
  }
701
717
  };
718
+ let checking: Promise<void> | undefined;
719
+ let trailing: 'changed' | 'retry' | undefined;
720
+ const loadCompositions = (reason?: 'changed' | 'retry'): Promise<void> | undefined => {
721
+ if (closed) return;
722
+ if (checking) {
723
+ if (reason === 'retry' || (reason === 'changed' && !trailing)) trailing = reason;
724
+ return checking;
725
+ }
726
+ checking = checkCompositions(reason === 'retry').finally(() => {
727
+ checking = undefined;
728
+ const next = trailing;
729
+ trailing = undefined;
730
+ if (next) void loadCompositions(next);
731
+ });
732
+ return checking;
733
+ };
734
+ const foreground = AppState.addEventListener('change', (state) => {
735
+ if (state === 'active') void loadCompositions();
736
+ });
702
737
  void loadCompositions();
703
738
 
704
739
  /** A stopped session has no runtime to attach to: its history is read from disk, as the cockpit does. */
@@ -811,7 +846,7 @@ export function startLiveRuntime(
811
846
  open: openSession,
812
847
  retryActivity(sessionId) {
813
848
  if (closed || sessionId !== focused) return;
814
- void loadCompositions();
849
+ void loadCompositions('retry');
815
850
  applyFocus();
816
851
  },
817
852
  async wake(sessionId, options) {
@@ -849,6 +884,8 @@ export function startLiveRuntime(
849
884
  close({ preserveHost = false } = {}) {
850
885
  if (closed) return;
851
886
  closed = true;
887
+ foreground.remove();
888
+ bundleLifetime.abort();
852
889
  // A reconnect keeps the computer's plugins mounted for the next connection; anything else stops them.
853
890
  const keep = preserveHost && host.id !== undefined && keptPlugins.get(host.id) === kept;
854
891
  if (kept.link?.request === request) kept.link = undefined;
@@ -1,8 +1,10 @@
1
1
  import type { WebPluginSlotProps } from '@agimon-ai/po-core/web';
2
2
  import {
3
3
  Badge,
4
+ BoxIcon,
4
5
  ChevronDownIcon,
5
6
  ChevronRightIcon,
7
+ EmptyState,
6
8
  fontOf,
7
9
  Input,
8
10
  SearchIcon,
@@ -219,14 +221,22 @@ export function ContextFaceView({
219
221
  </View>
220
222
  {children}
221
223
  {rows.length === 0 ? (
222
- <View style={styles.empty}>
223
- <Text style={styles.emptyTitle}>{groups.length === 0 ? 'No composition yet' : 'No matches'}</Text>
224
- <Text style={styles.meta}>
225
- {groups.length === 0
226
- ? 'The session reports its preset, modes and domains once it has started.'
227
- : 'Try a mode, package, tool or skill name.'}
228
- </Text>
229
- </View>
224
+ groups.length === 0 ? (
225
+ <EmptyState
226
+ size="compact"
227
+ icon={<BoxIcon size={16} />}
228
+ title="No composition yet"
229
+ description="The session reports its preset, modes and domains once it has started."
230
+ />
231
+ ) : (
232
+ <EmptyState
233
+ size="compact"
234
+ icon={<SearchIcon size={16} />}
235
+ title="No matches"
236
+ description="Try a mode, package, tool or skill name."
237
+ secondaryAction={{ label: 'Clear search', onAction: () => setSearch('') }}
238
+ />
239
+ )
230
240
  ) : (
231
241
  <View style={[styles.listHead, styles.frame, styles.frameTop]}>
232
242
  <Text style={styles.meta}>Loaded context</Text>
@@ -350,16 +360,6 @@ const styles = StyleSheet.create((theme) => {
350
360
  search: { justifyContent: 'center' },
351
361
  searchInput: { paddingLeft: theme.spacing(9) },
352
362
  searchIcon: { position: 'absolute', left: theme.spacing(3) },
353
- empty: {
354
- gap: theme.spacing(1),
355
- paddingHorizontal: theme.spacing(4),
356
- paddingVertical: theme.spacing(5),
357
- borderRadius: theme.borderRadius.lg,
358
- borderWidth: 1,
359
- borderStyle: 'dashed',
360
- borderColor: theme.colors.border,
361
- },
362
- emptyTitle: { ...text('base', theme.colors.hi), fontWeight: theme.fontWeight.semibold },
363
363
  listHead: {
364
364
  flexDirection: 'row',
365
365
  justifyContent: 'space-between',
@@ -16,6 +16,7 @@ import {
16
16
  sessionStoreFor,
17
17
  useBotWake,
18
18
  setPendingMenu,
19
+ toggleMode,
19
20
  } from '@agimon-ai/po-web-dashboard/core';
20
21
  import { useStore } from '@tanstack/react-store';
21
22
  import { type ComponentProps, type ReactElement, useCallback, useEffect, useMemo, useRef, useState } from 'react';
@@ -208,7 +209,7 @@ function OpenSessionOptionsSheet({ sessionId, open, onOpenChange }: SessionOptio
208
209
  disabled: mode.availability === 'unavailable',
209
210
  hint: mode.availability === 'unavailable' ? mode.unavailableReason || 'Unavailable in this session' : mode.detail,
210
211
  }));
211
- onPick = (id) => whenConnected(sessionId, () => runCommand(`/mode ${id}`, sessionId));
212
+ onPick = (id) => whenConnected(sessionId, () => void toggleMode(id, sessionId, nativeApiTransport));
212
213
  } else if (page === 'model') {
213
214
  body = (
214
215
  <Input
@@ -10,6 +10,7 @@ import {
10
10
  DropdownMenuTrigger,
11
11
  DropdownMenuContent,
12
12
  DropdownMenuItem,
13
+ EmptyState,
13
14
  fontOf,
14
15
  } from '@agimon-ai/po-native-components';
15
16
  import { Text, View } from 'react-native';
@@ -65,8 +66,15 @@ export function ClientDevicesView(p: ClientDevicesViewProps) {
65
66
  </View>
66
67
  </Group>
67
68
  <Group label={`Devices on ${p.hostLabel}`} hint="Names are labels, not access permissions.">
68
- {p.status === 'loading' || !p.devices.length ? (
69
- <Row title={p.status === 'loading' ? 'Loading devices…' : 'No devices recorded yet'} last />
69
+ {p.status === 'loading' ? (
70
+ <Row title="Loading devices…" last />
71
+ ) : !p.devices.length ? (
72
+ <EmptyState
73
+ size="compact"
74
+ surface="plain"
75
+ title="No devices recorded yet"
76
+ description="Phones and computers that sign in to this computer show here."
77
+ />
70
78
  ) : (
71
79
  p.devices.map((device, index) => (
72
80
  <Row
@@ -7,6 +7,7 @@ import {
7
7
  DropdownMenuContent,
8
8
  DropdownMenuItem,
9
9
  DropdownMenuTrigger,
10
+ EmptyState,
10
11
  fontOf,
11
12
  Input,
12
13
  Label,
@@ -76,7 +77,12 @@ export function AccountHostsView({
76
77
  </View>
77
78
  ))
78
79
  ) : (
79
- <Row title="No hosts in this account" last />
80
+ <EmptyState
81
+ size="compact"
82
+ surface="plain"
83
+ title="No hosts in this account"
84
+ description="Computers you add to this account show here."
85
+ />
80
86
  )}
81
87
  </Group>
82
88
  );
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  Button,
3
+ EmptyState,
3
4
  fontOf,
4
5
  Input,
5
6
  Label,
@@ -340,7 +341,12 @@ export function McpServersScreen({
340
341
  {servers ? (
341
342
  <Group label="Servers">
342
343
  {servers.length === 0 ? (
343
- <Row title="No servers yet" description="Servers you add here are available in every repository." last />
344
+ <EmptyState
345
+ size="compact"
346
+ surface="plain"
347
+ title="No servers yet"
348
+ description="Servers you add here are available in every repository."
349
+ />
344
350
  ) : (
345
351
  servers.map((server, index) => (
346
352
  <Row
@@ -1,4 +1,5 @@
1
1
  import {
2
+ BoxIcon,
2
3
  Button,
3
4
  CheckIcon,
4
5
  EmptyState,
@@ -6,6 +7,7 @@ import {
6
7
  InfoStrip,
7
8
  Input,
8
9
  Panel,
10
+ SearchIcon,
9
11
  SegmentedControl,
10
12
  Spinner,
11
13
  StatusBadge,
@@ -116,10 +118,27 @@ export function PluginCatalogScreen(props: PluginCatalogScreenProps) {
116
118
  />
117
119
  </Group>
118
120
  ) : plugins.length === 0 ? (
119
- <EmptyState
120
- title="No plugins match"
121
- description={props.query ? `Nothing matches "${props.query}". Try a shorter word.` : 'Nothing here yet.'}
122
- />
121
+ props.query ? (
122
+ <EmptyState
123
+ icon={<SearchIcon size={20} />}
124
+ title="No plugins match"
125
+ description={`Nothing matches "${props.query}". Try a shorter word.`}
126
+ secondaryAction={{ label: 'Clear search', onAction: () => props.onQueryChange('') }}
127
+ />
128
+ ) : props.category !== ALL_CATEGORIES ? (
129
+ <EmptyState
130
+ icon={<BoxIcon size={20} />}
131
+ title="No plugins in this category"
132
+ description={`Nothing in this category on ${scope.host} yet.`}
133
+ secondaryAction={{ label: 'Show all', onAction: () => props.onCategoryChange(ALL_CATEGORIES) }}
134
+ />
135
+ ) : (
136
+ <EmptyState
137
+ icon={<BoxIcon size={20} />}
138
+ title="No plugins yet"
139
+ description={`${scope.host} has no plugins to offer right now.`}
140
+ />
141
+ )
123
142
  ) : (
124
143
  <Group label="Plugins" hint={`${String(plugins.length)} shown`}>
125
144
  {plugins.map((plugin, index) => (
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  Button,
3
+ EmptyState,
3
4
  fontOf,
4
5
  Input,
5
6
  SegmentedControl,
@@ -87,7 +88,9 @@ export function PresetsScreen(props: PresetsScreenProps) {
87
88
  ) : (
88
89
  <Group label="Presets">
89
90
  {presets.length === 0 ? (
90
- <StateRow
91
+ <EmptyState
92
+ size="compact"
93
+ surface="plain"
91
94
  title="No presets here yet"
92
95
  description={`${scope.label} uses the presets on ${scope.host}. Make one to give it its own.`}
93
96
  />
@@ -2,6 +2,7 @@ import { hostRevisionTopic, hubRevision, subscribeHubRevision } from '@agimon-ai
2
2
  import {
3
3
  Button,
4
4
  Dot,
5
+ EmptyState,
5
6
  fontOf,
6
7
  Input,
7
8
  Sheet,
@@ -368,7 +369,12 @@ export function ProvidersScreen({
368
369
  <Group label="Connected">{rows(connected)}</Group>
369
370
  ) : (
370
371
  <Group label="Connected">
371
- <Row title="Nothing connected yet" description="Pick a provider below. Po takes it from there." last />
372
+ <EmptyState
373
+ size="compact"
374
+ surface="plain"
375
+ title="Nothing connected yet"
376
+ description="Pick a provider below. Po takes it from there."
377
+ />
372
378
  </Group>
373
379
  )
374
380
  ) : null}
@@ -1,5 +1,5 @@
1
1
  import type { RemoteAccessStateView, TunnelConfig } from '@agimon-ai/po-core/remoteContract';
2
- import { Badge, Button, Dot, fontOf, Spinner } from '@agimon-ai/po-native-components';
2
+ import { Badge, Button, Dot, EmptyState, fontOf, Spinner } from '@agimon-ai/po-native-components';
3
3
  import { useCallback, useEffect, useState } from 'react';
4
4
  import { Alert, ScrollView, Text } from 'react-native';
5
5
  import { StyleSheet } from 'react-native-unistyles';
@@ -108,7 +108,14 @@ export function RemoteControlScreen({ remote, error, busy, turnOff, revokeDevice
108
108
  <OnComputer>Tunnel settings and pairing codes change on your computer only.</OnComputer>
109
109
 
110
110
  <Group label="Trusted devices">
111
- {remote.trustedDevices.length === 0 ? <Row title="No trusted devices." last /> : null}
111
+ {remote.trustedDevices.length === 0 ? (
112
+ <EmptyState
113
+ size="compact"
114
+ surface="plain"
115
+ title="No trusted devices"
116
+ description="Devices you pair for remote control show here."
117
+ />
118
+ ) : null}
112
119
  {remote.trustedDevices.map((device, index) => (
113
120
  <Row
114
121
  key={device.id}
@@ -1,4 +1,13 @@
1
- import { EmptyState, fontOf, HostTag, InfoStrip, List, ListRow, LiveDuration } from '@agimon-ai/po-native-components';
1
+ import {
2
+ EmptyState,
3
+ fontOf,
4
+ HostTag,
5
+ InfoStrip,
6
+ List,
7
+ ListRow,
8
+ LiveDuration,
9
+ MessageIcon,
10
+ } from '@agimon-ai/po-native-components';
2
11
  import { Text, View } from 'react-native';
3
12
  import { StyleSheet } from 'react-native-unistyles';
4
13
 
@@ -91,7 +100,14 @@ export function SessionListScreen({ sessions, onOpen, hosts, connections, embedd
91
100
  keyExtractor={(item) => item.id}
92
101
  renderItem={row}
93
102
  header={notes}
94
- empty={<EmptyState title="No sessions yet." description="Start one in Po on your computer." />}
103
+ empty={
104
+ <EmptyState
105
+ size="page"
106
+ icon={<MessageIcon size={24} />}
107
+ title="No sessions yet"
108
+ description="Sessions you start on this phone or on your computer show here."
109
+ />
110
+ }
95
111
  />
96
112
  </View>
97
113
  );
@@ -1,7 +1,9 @@
1
- import { PoNativeProvider } from '@agimon-ai/po-native-components';
1
+ import { ActivityIcon, Button, ChevronRightIcon, fontOf, PoNativeProvider } from '@agimon-ai/po-native-components';
2
2
  import { type TimelineEntry, SessionScreen } from '@agimon-ai/po-native-dashboard';
3
- import { View } from 'react-native';
4
- import { UnistylesRuntime } from 'react-native-unistyles';
3
+ import { Text, View } from 'react-native';
4
+ import { StyleSheet, UnistylesRuntime } from 'react-native-unistyles';
5
+
6
+ import { type DesignScheme, PhoneFrame } from './designFrame';
5
7
 
6
8
  const noop = () => {};
7
9
  const ENTRIES: TimelineEntry[] = [
@@ -26,6 +28,95 @@ export const meta = {
26
28
  };
27
29
 
28
30
  export default meta;
31
+
32
+ function WorkspaceHeaderPreview({ scheme }: { scheme: DesignScheme }) {
33
+ return (
34
+ <PhoneFrame scheme={scheme} width={320} height={180}>
35
+ {['Design', 'Platform reliability and release operations', undefined].map((workspace) => (
36
+ <View key={workspace ?? 'standalone'} style={previewStyles.header}>
37
+ <Button variant="ghost" size="icon" accessibilityLabel="Back" onPress={noop}>
38
+ <View style={previewStyles.back}>
39
+ <ChevronRightIcon color="hi" />
40
+ </View>
41
+ </Button>
42
+ <View style={previewStyles.center}>
43
+ <View style={previewStyles.row}>
44
+ <View style={previewStyles.avatar}>
45
+ <Text style={previewStyles.initial}>P</Text>
46
+ </View>
47
+ <Text style={previewStyles.title} numberOfLines={1}>
48
+ Session
49
+ </Text>
50
+ {workspace ? (
51
+ <Text accessibilityLabel={`Workspace: ${workspace}`} style={previewStyles.workspace} numberOfLines={1}>
52
+ {`· ${workspace}`}
53
+ </Text>
54
+ ) : null}
55
+ </View>
56
+ <View style={previewStyles.row}>
57
+ <Text style={previewStyles.agent} numberOfLines={1}>
58
+ Ponytail ·
59
+ </Text>
60
+ <Text style={previewStyles.meta} numberOfLines={1}>
61
+ ready when you are
62
+ </Text>
63
+ </View>
64
+ </View>
65
+ <Button variant="ghost" size="icon" accessibilityLabel="Activity" onPress={noop}>
66
+ <ActivityIcon color="hi" />
67
+ </Button>
68
+ </View>
69
+ ))}
70
+ </PhoneFrame>
71
+ );
72
+ }
73
+
74
+ export const WorkspaceHeaderDark = { render: () => <WorkspaceHeaderPreview scheme="dark" /> };
75
+ export const WorkspaceHeaderLight = { render: () => <WorkspaceHeaderPreview scheme="light" /> };
76
+
77
+ const previewStyles = StyleSheet.create((theme) => {
78
+ const meta = {
79
+ fontFamily: fontOf(theme.fontFamily.sans),
80
+ fontSize: theme.fontSize.sm,
81
+ lineHeight: theme.lineHeight.sm,
82
+ color: theme.colors.dim,
83
+ flexShrink: 1,
84
+ };
85
+ return {
86
+ header: {
87
+ minHeight: 60,
88
+ flexDirection: 'row',
89
+ alignItems: 'center',
90
+ paddingHorizontal: theme.spacing(4),
91
+ gap: theme.spacing(2),
92
+ backgroundColor: theme.colors.rail,
93
+ borderBottomWidth: StyleSheet.hairlineWidth,
94
+ borderBottomColor: theme.colors['border-soft'],
95
+ },
96
+ center: { flex: 1, minWidth: 0, alignItems: 'center' },
97
+ row: { flexDirection: 'row', alignItems: 'center', maxWidth: '100%', gap: theme.spacing(1.5) },
98
+ back: { transform: [{ rotate: '180deg' }] },
99
+ avatar: {
100
+ width: 20,
101
+ height: 20,
102
+ alignItems: 'center',
103
+ justifyContent: 'center',
104
+ borderRadius: theme.borderRadius.full,
105
+ backgroundColor: theme.colors['tint-green'],
106
+ },
107
+ initial: { ...meta, fontSize: theme.fontSize['2xs'], color: theme.colors.green },
108
+ title: {
109
+ ...meta,
110
+ fontSize: theme.fontSize.lg,
111
+ lineHeight: theme.lineHeight.lg,
112
+ fontWeight: theme.fontWeight.semibold,
113
+ color: theme.colors.hi,
114
+ },
115
+ agent: { ...meta, color: theme.colors.hi },
116
+ workspace: { ...meta, maxWidth: '60%' },
117
+ meta,
118
+ };
119
+ });
29
120
  export const Playground = {
30
121
  render: () => (
31
122
  <PoNativeProvider>
@@ -1,4 +1,4 @@
1
- import { EmptyState, Spinner } from '@agimon-ai/po-native-components';
1
+ import { EmptyState, FolderIcon, MonitorIcon, Spinner } from '@agimon-ai/po-native-components';
2
2
  import { ScrollView, View } from 'react-native';
3
3
  import { StyleSheet } from 'react-native-unistyles';
4
4
 
@@ -6,9 +6,21 @@ import { DashboardTiles, type NativeDashboardTile } from '../components/Dashboar
6
6
  import type { WorkspacePageState } from './workspaceModel';
7
7
 
8
8
  const messages = {
9
- missing: { title: 'Workspace not found', description: 'This workspace or its computer is no longer available.' },
10
- offline: { title: 'This computer is offline', description: 'Reconnect to see this workspace’s tiles.' },
11
- unavailable: { title: 'Workspace unavailable', description: 'Open Po on its computer to check this workspace.' },
9
+ missing: {
10
+ icon: <FolderIcon size={24} />,
11
+ title: 'Workspace not found',
12
+ description: 'This workspace or its computer is no longer available.',
13
+ },
14
+ offline: {
15
+ icon: <MonitorIcon size={24} />,
16
+ title: 'This computer is offline',
17
+ description: 'Reconnect to see this workspace’s tiles.',
18
+ },
19
+ unavailable: {
20
+ icon: <FolderIcon size={24} />,
21
+ title: 'Workspace unavailable',
22
+ description: 'Open Po on its computer to check this workspace.',
23
+ },
12
24
  error: { title: 'Workspace tiles could not load', description: 'Try reconnecting to this computer.' },
13
25
  };
14
26
 
@@ -17,10 +29,13 @@ export function WorkspaceScreen({
17
29
  state,
18
30
  tiles = [],
19
31
  error,
32
+ onRetry,
20
33
  }: {
21
34
  state: WorkspacePageState;
22
35
  tiles?: readonly NativeDashboardTile[];
23
36
  error?: string;
37
+ /** Reconnects to the workspace's computer; absent leaves the offline and failed cards without a button. */
38
+ onRetry?: () => void;
24
39
  }) {
25
40
  return (
26
41
  <ScrollView style={styles.screen} contentContainerStyle={styles.content} contentInsetAdjustmentBehavior="automatic">
@@ -29,9 +44,21 @@ export function WorkspaceScreen({
29
44
  <Spinner label="Loading workspace" />
30
45
  </View>
31
46
  ) : state !== 'ready' ? (
32
- <EmptyState {...messages[state]} {...(state === 'error' && error ? { description: error } : {})} />
47
+ <EmptyState
48
+ size="page"
49
+ {...messages[state]}
50
+ {...(state === 'error' ? { tone: 'error' as const, ...(error ? { description: error } : {}) } : {})}
51
+ {...((state === 'error' || state === 'offline') && onRetry
52
+ ? { action: { label: 'Retry', onAction: onRetry } }
53
+ : {})}
54
+ />
33
55
  ) : tiles.length === 0 ? (
34
- <EmptyState title="No workspace tiles yet" description="Apps that support this workspace appear here." />
56
+ <EmptyState
57
+ size="page"
58
+ icon={<FolderIcon size={24} />}
59
+ title="No workspace tiles yet"
60
+ description="Apps that support this workspace appear here."
61
+ />
35
62
  ) : (
36
63
  <DashboardTiles tiles={tiles} />
37
64
  )}
@@ -3,6 +3,7 @@ import {
3
3
  Button,
4
4
  CheckIcon,
5
5
  Dot,
6
+ EmptyState,
6
7
  fontOf,
7
8
  BranchIcon,
8
9
  FolderIcon,
@@ -335,7 +336,12 @@ export function McpCatalogScreen({ catalog, busy, error, onDiscover, onRetry }:
335
336
  <ErrorLine>{error}</ErrorLine>
336
337
  <Group label="Servers">
337
338
  {catalog.servers.length === 0 ? (
338
- <Row title="No servers yet" description="Add one in Po on your computer, then discover it here." last />
339
+ <EmptyState
340
+ size="compact"
341
+ surface="plain"
342
+ title="No servers yet"
343
+ description="Add one in Po on your computer, then discover it here."
344
+ />
339
345
  ) : (
340
346
  catalog.servers.map((server, index) => {
341
347
  const line = serverLine(server);
@@ -390,17 +390,28 @@ export function createNativeBundleUpdates(options: {
390
390
  assertActive();
391
391
  return state.generation?.catalog;
392
392
  },
393
- async check(body: unknown): Promise<{ catalog?: NativeBundleCatalog; update?: NativeBundleUpdateChoice }> {
393
+ async check(
394
+ body: unknown,
395
+ { signal, reoffer = false }: { signal?: AbortSignal; reoffer?: boolean } = {},
396
+ ): Promise<{ catalog?: NativeBundleCatalog; update?: NativeBundleUpdateChoice }> {
394
397
  const state = await selection;
398
+ signal?.throwIfAborted();
395
399
  const localEpoch = ++epoch;
396
400
  const admitted = (state.checkEpoch ?? 0) + 1;
397
401
  state.checkEpoch = admitted;
398
402
  const current = () => {
399
403
  assertActive();
404
+ signal?.throwIfAborted();
400
405
  if (epoch !== localEpoch || state.checkEpoch !== admitted)
401
406
  throw new Error('Native catalog check was replaced.');
402
407
  };
403
408
  const candidate: Generation = { catalog: catalogOf(body), modules: [] };
409
+ // A matching catalog cannot change which verified bytes the current process is using.
410
+ if (state.generation && JSON.stringify(state.generation.catalog) === JSON.stringify(candidate.catalog)) {
411
+ current();
412
+ state.offeredIdentity = state.identity;
413
+ return {};
414
+ }
404
415
  for (const descriptor of descriptors(candidate.catalog))
405
416
  for (const path of paths(descriptor)) {
406
417
  current();
@@ -459,7 +470,7 @@ export function createNativeBundleUpdates(options: {
459
470
  state.generation = refreshed;
460
471
  return { catalog: refreshed.catalog };
461
472
  }
462
- if (state.pendingIdentity === nextIdentity || alreadyOffered) return {};
473
+ if (!reoffer && (state.pendingIdentity === nextIdentity || alreadyOffered)) return {};
463
474
  state.offeredBy = owner;
464
475
  let decision: Promise<void> | undefined;
465
476
  const commit = async (defer: boolean) => {
@@ -507,7 +518,9 @@ export function createNativeBundleUpdates(options: {
507
518
  if (!state.generation) return undefined;
508
519
  // A new scope may use only modules already selected by this generation. In particular,
509
520
  // a pending UI entry must never be fetched or evaluated through the session path.
510
- if (descriptor.uiEntry !== state.generation.catalog.nativeHost?.uiEntry) return undefined;
521
+ // The pinned hub session contract omits uiEntry. Only the host mount selects the UI in that case.
522
+ if (descriptor.uiEntry !== undefined && descriptor.uiEntry !== state.generation.catalog.nativeHost?.uiEntry)
523
+ return undefined;
511
524
  const admitted = paths(descriptor);
512
525
  for (const module of state.generation.modules) {
513
526
  const loaded = await verify(module);
@@ -521,7 +521,8 @@ export async function reconnect(
521
521
  );
522
522
  options.signal?.addEventListener('abort', cancel, { once: true });
523
523
  });
524
- const signal = AbortSignal.any([AbortSignal.timeout(8_000), ...(options.signal ? [options.signal] : [])]);
524
+ const deadline = AbortSignal.timeout(8_000);
525
+ const signal = AbortSignal.any([deadline, ...(options.signal ? [options.signal] : [])]);
525
526
  let signingIn = true;
526
527
  const boundedFetch: typeof fetch = (input, init) => fetcher(input, signingIn ? { ...init, signal } : init);
527
528
  try {
@@ -534,11 +535,13 @@ export async function reconnect(
534
535
  isLanTlsTrustError(error) ||
535
536
  isRelayTrustError(error) ||
536
537
  error instanceof DeviceSignInError ||
537
- options.signal?.aborted ||
538
- options.giveUp?.() === true ||
539
- attempt === attemptsAt.length - 1
538
+ options.signal?.aborted
540
539
  )
541
540
  throw error;
541
+ if (options.giveUp?.() === true || attempt === attemptsAt.length - 1) {
542
+ if (deadline.aborted) throw new Error('Reconnecting to this computer timed out. Try again.', { cause: error });
543
+ throw error;
544
+ }
542
545
  }
543
546
  }
544
547
  throw new Error('Could not reconnect.');
@@ -26,7 +26,6 @@ import {
26
26
  // Binds nativeApiTransport to the sealed, step-up aware shell transport.
27
27
  import { apiTransportForHost } from '../apiTransport';
28
28
  import '../byteCodec';
29
- import { readSettingsConfig, writeSettingsValues } from '../settingsApi';
30
29
 
31
30
  /**
32
31
  * The cockpit rail's session and workspace requests, over the phone's sealed channel. The same
@@ -288,38 +287,21 @@ export async function addCoordinator(
288
287
  return { sessionId: body.sessionId, created: body.created };
289
288
  }
290
289
 
291
- const PRESET_KEY = 'selection.preset';
292
-
293
290
  /**
294
- * First run on the chosen computer: the Po's mode, then the home coordinator as that Po, or the one it
295
- * already has. A mode the catalog lacks fails every later session too, so a coordinator that cannot
296
- * open puts the previous mode back. As the web's finishOnboarding, without its layout: the phone has
297
- * its own. Answers the qualified session id.
291
+ * First run on the chosen computer: the home coordinator as the chosen Po, or the one it already has.
292
+ * As the web's finishOnboarding, without its layout: the phone has its own. Answers the qualified
293
+ * session id.
298
294
  */
299
295
  export async function openFirstSession(
300
296
  hostId: string,
301
- po: Pick<StarterPo, 'alias' | 'name' | 'preset'>,
297
+ po: Pick<StarterPo, 'alias' | 'name'>,
302
298
  ): Promise<{ sessionId: string } | { error: string }> {
303
- const before = await readSettingsConfig([PRESET_KEY], undefined, hostId);
304
- if ('error' in before) return before;
305
- const previous = before.config.values[PRESET_KEY];
306
- const write = (value: string | null, expectedHash: string) =>
307
- writeSettingsValues(
308
- { repoRoot: '', scope: 'host', edits: [{ keyPath: PRESET_KEY.split('.'), value }], expectedHash },
309
- undefined,
310
- hostId,
311
- );
312
- const selected = await write(po.preset, before.config.hashes.host);
313
- if ('error' in selected) return selected;
314
299
  const { ok, body, status } = await rootRequest(
315
300
  '/api/coordinators/home',
316
301
  { method: 'POST', headers: JSON_BODY, body: JSON.stringify({ profile: po.alias, name: po.name }) },
317
302
  hostId,
318
303
  );
319
- if (!ok || !isRecord(body) || typeof body.sessionId !== 'string' || !body.sessionId) {
320
- await write(previous?.origin === 'host' ? (previous.value ?? null) : null, selected.config.hashes.host);
321
- return errorOf(body, status);
322
- }
304
+ if (!ok || !isRecord(body) || typeof body.sessionId !== 'string' || !body.sessionId) return errorOf(body, status);
323
305
  return { sessionId: qualifyHostId(hostId, body.sessionId) };
324
306
  }
325
307