@agimon-ai/po-native 0.0.1-alpha.76 → 0.0.1-alpha.78

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.
@@ -14,6 +14,7 @@ import { PluginDetailScreen, type PluginDetailScreenProps } from './PluginDetail
14
14
  import type { PluginEntry, PluginScope, PresetSummary } from './pluginModel';
15
15
  import { type OnboardingSheetState, PluginOnboardingScreen } from './PluginOnboardingScreen';
16
16
  import { PresetsScreen, type PresetsScreenProps } from './PresetsScreen';
17
+ import { NavRow } from './SettingsScreen';
17
18
 
18
19
  export const meta = { title: 'Native/Design/Plugin marketplace', tags: ['style-system', 'mockup', 'native'] };
19
20
  export default meta;
@@ -313,6 +314,25 @@ export const DetailWorkspaceOverride = {
313
314
  render: () => <Detail plugin={{ ...IMAGE_MAKER, setup: 'ready' }} scope={WORKSPACE} presets={WORKSPACE_PRESETS} />,
314
315
  };
315
316
  export const DetailClaude = { render: () => <Detail plugin={PLUGINS[6]!} adds={['12 skills', '3 hooks']} /> };
317
+ // A local plugin: its settings pages open here; no install, setup, preset or publisher rows.
318
+ export const DetailLocalPlugin = {
319
+ render: () => (
320
+ <Detail
321
+ plugin={{
322
+ ...SCHEDULE,
323
+ id: 'local:notes',
324
+ localPluginId: 'notes',
325
+ name: 'Notes',
326
+ description: 'Keeps your private notes on Studio Mac.',
327
+ category: 'Local plugins',
328
+ publisher: '',
329
+ install: 'installed',
330
+ }}
331
+ settings={<NavRow title="Notes" value="Where your notes are kept" onPress={noop} last />}
332
+ adds={[]}
333
+ />
334
+ ),
335
+ };
316
336
  export const OnboardingNeedsSetup = { render: () => <Onboarding state="needs-setup" /> };
317
337
  export const OnboardingMustFinishFirst = { render: () => <Onboarding state="needs-setup" activation="after-setup" /> };
318
338
  export const OnboardingFinishOnWeb = { render: () => <Onboarding state="unavailable" /> };
@@ -0,0 +1,270 @@
1
+ import { settingsDirectoryFixture } from '@agimon-ai/po-core/webTesting';
2
+ import { Button, EmptyState, fontOf, InfoStrip, Input, SearchIcon } from '@agimon-ai/po-native-components';
3
+ import { useState } from 'react';
4
+ import { KeyboardAvoidingView, Platform, ScrollView, Text, View } from 'react-native';
5
+ import { StyleSheet } from 'react-native-unistyles';
6
+
7
+ import { PhoneFrame, type DesignScheme } from './designFrame';
8
+ import { Group, NavRow, Row } from './SettingsScreen';
9
+ import { WorkspaceDefaultsScreen } from './WorkspaceSettingsScreen';
10
+
11
+ type DirectoryItem = ReturnType<typeof settingsDirectoryFixture>[number]['items'][number];
12
+ type Context = 'online' | 'offline' | 'all' | 'cloud';
13
+ const noop = () => undefined;
14
+
15
+ /** Reuses the existing defaults interior, without enabling writes in this directory target. */
16
+ function DefaultsPreview() {
17
+ return (
18
+ <WorkspaceDefaultsScreen
19
+ settings={{
20
+ repository: { id: 'po-internal', name: 'po-internal', path: '/Users/dev/workspace/po-internal', active: true },
21
+ hash: 'directory-preview',
22
+ catalogs: {
23
+ presets: [{ name: 'copilot', description: 'Interactive development' }],
24
+ domains: [{ name: 'development', description: 'Coding tools' }],
25
+ profiles: [{ name: 'ponytail' }],
26
+ },
27
+ selection: {
28
+ preset: { effective: 'copilot', origin: 'host' },
29
+ domains: { effective: ['development'], origin: 'host' },
30
+ profile: { effective: 'ponytail', origin: 'default' },
31
+ },
32
+ }}
33
+ changes={{}}
34
+ busy
35
+ note=""
36
+ onChange={noop}
37
+ onSave={noop}
38
+ onDiscard={noop}
39
+ onRetry={noop}
40
+ />
41
+ );
42
+ }
43
+
44
+ function Directory({
45
+ scheme = 'light',
46
+ initialQuery = '',
47
+ context = 'online',
48
+ initialDestination,
49
+ }: {
50
+ scheme?: DesignScheme;
51
+ initialQuery?: string;
52
+ context?: Context;
53
+ initialDestination?: string;
54
+ }) {
55
+ const [query, setQuery] = useState(initialQuery);
56
+ const [stack, setStack] = useState<DirectoryItem[]>(() => {
57
+ const item = settingsDirectoryFixture('mobile', initialQuery, context)
58
+ .flatMap((group) => group.items)
59
+ .find((entry) => entry.id === initialDestination && !entry.disabled);
60
+ return item ? [item] : [];
61
+ });
62
+ const destination = stack.at(-1);
63
+ const searching = query.trim().length > 0;
64
+ const groups = settingsDirectoryFixture('mobile', query, context);
65
+ const results = groups.flatMap((group) => group.items);
66
+ const unavailable =
67
+ context === 'offline'
68
+ ? 'Studio Mac is offline. Reconnect to browse its settings. This phone and your account are still available.'
69
+ : context === 'all'
70
+ ? 'Choose a host in the host menu to see its settings. This phone and your account are still available.'
71
+ : undefined;
72
+
73
+ const renderItem = (groupId: string, item: DirectoryItem, index: number, count: number) => {
74
+ const blocked = item.disabled;
75
+ const detail = [
76
+ searching || destination ? item.detail : undefined,
77
+ searching && !destination ? item.path : undefined,
78
+ searching || !unavailable || (groupId !== 'host' && groupId !== 'workspace') ? item.reason : undefined,
79
+ ]
80
+ .filter(Boolean)
81
+ .join('\n');
82
+ if (blocked) {
83
+ return (
84
+ <View key={`${groupId}/${item.id}`} accessibilityState={{ disabled: true }}>
85
+ <Row title={item.label} description={detail || undefined} last={index === count - 1} />
86
+ </View>
87
+ );
88
+ }
89
+ return (
90
+ <NavRow
91
+ key={`${groupId}/${item.id}`}
92
+ title={item.label}
93
+ value={detail || undefined}
94
+ onPress={() => setStack((current) => [...current, item])}
95
+ last={index === count - 1}
96
+ />
97
+ );
98
+ };
99
+
100
+ return (
101
+ <PhoneFrame scheme={scheme}>
102
+ <KeyboardAvoidingView style={styles.shell} behavior={Platform.OS === 'ios' ? 'padding' : undefined}>
103
+ {/* Story-only stack shell. Production keeps its existing native stack header. */}
104
+ <View style={styles.header}>
105
+ <View style={styles.headerRow}>
106
+ {destination ? (
107
+ <Button
108
+ variant="ghost"
109
+ size="lg"
110
+ accessibilityLabel={
111
+ stack.length > 1 ? 'Back to Plugins' : searching ? 'Back to results' : 'Back to Settings'
112
+ }
113
+ onPress={() => setStack((current) => current.slice(0, -1))}
114
+ >
115
+ Back
116
+ </Button>
117
+ ) : null}
118
+ <Text accessibilityRole="header" style={styles.title}>
119
+ {destination?.label ?? 'Settings'}
120
+ </Text>
121
+ </View>
122
+ </View>
123
+ {destination ? (
124
+ <View style={styles.destination}>
125
+ <View style={styles.previewNotice}>
126
+ <Text style={styles.caption}>Illustrative preview only. No settings are changed.</Text>
127
+ <Text style={styles.caption}>{destination.path}</Text>
128
+ {destination.id === 'appearance' ? (
129
+ <Text style={styles.caption}>
130
+ Theme and language stay on this phone. Layout uses computer or workspace settings.
131
+ </Text>
132
+ ) : null}
133
+ {destination.reason ? <Text style={styles.caption}>{destination.reason}</Text> : null}
134
+ </View>
135
+ {destination.id === 'defaults' ? (
136
+ <DefaultsPreview />
137
+ ) : (
138
+ <ScrollView contentContainerStyle={styles.content} keyboardShouldPersistTaps="handled">
139
+ <Text style={styles.caption}>{destination.detail}</Text>
140
+ {destination.id === 'plugins'
141
+ ? settingsDirectoryFixture('mobile', 'plugins', context).map((group) => {
142
+ const plugins = group.items.filter(
143
+ (item) => item.id === 'image-gen' || item.id === 'agent-models',
144
+ );
145
+ return plugins.length ? (
146
+ <Group key={group.id} label="Installed plugins">
147
+ {plugins.map((item, index) => renderItem(group.id, item, index, plugins.length))}
148
+ </Group>
149
+ ) : null;
150
+ })
151
+ : null}
152
+ </ScrollView>
153
+ )}
154
+ </View>
155
+ ) : (
156
+ <View style={styles.destination}>
157
+ <View style={styles.search}>
158
+ <View style={styles.searchField}>
159
+ <Input
160
+ value={query}
161
+ onChangeText={setQuery}
162
+ placeholder="Search settings"
163
+ accessibilityLabel="Search settings"
164
+ returnKeyType="search"
165
+ autoCorrect={false}
166
+ autoCapitalize="none"
167
+ />
168
+ </View>
169
+ {searching && results.length > 0 ? (
170
+ <Button
171
+ variant="ghost"
172
+ size="lg"
173
+ accessibilityLabel="Clear settings search"
174
+ onPress={() => setQuery('')}
175
+ >
176
+ Clear
177
+ </Button>
178
+ ) : null}
179
+ </View>
180
+ <ScrollView
181
+ contentContainerStyle={styles.content}
182
+ keyboardShouldPersistTaps="handled"
183
+ keyboardDismissMode="on-drag"
184
+ >
185
+ {unavailable ? <InfoStrip message={unavailable} /> : null}
186
+ {searching ? (
187
+ <Text style={styles.caption} accessibilityLiveRegion="polite">
188
+ {results.length === 1 ? '1 result' : `${results.length} results`}
189
+ </Text>
190
+ ) : null}
191
+ {searching && results.length === 0 ? (
192
+ <EmptyState
193
+ icon={<SearchIcon size={20} />}
194
+ title="No settings match"
195
+ description={`Nothing matches “${query}”. Try a shorter word or clear your search.`}
196
+ secondaryAction={{ label: 'Clear search', onAction: () => setQuery('') }}
197
+ />
198
+ ) : searching ? (
199
+ <View style={styles.results}>
200
+ <Group label="Search results">
201
+ {groups
202
+ .flatMap((group) => group.items.map((item) => ({ groupId: group.id, item })))
203
+ .map(({ groupId, item }, index) => renderItem(groupId, item, index, results.length))}
204
+ </Group>
205
+ </View>
206
+ ) : (
207
+ groups
208
+ .filter((group) => group.items.length > 0)
209
+ .map((group) => (
210
+ <Group key={group.id} label={group.label}>
211
+ {group.items.map((item, index) => renderItem(group.id, item, index, group.items.length))}
212
+ </Group>
213
+ ))
214
+ )}
215
+ </ScrollView>
216
+ </View>
217
+ )}
218
+ </KeyboardAvoidingView>
219
+ </PhoneFrame>
220
+ );
221
+ }
222
+
223
+ const styles = StyleSheet.create((theme) => ({
224
+ shell: { flex: 1, backgroundColor: theme.colors.bg },
225
+ header: {
226
+ padding: theme.spacing(4),
227
+ gap: theme.spacing(2),
228
+ borderBottomWidth: StyleSheet.hairlineWidth,
229
+ borderBottomColor: theme.colors['border-soft'],
230
+ },
231
+ headerRow: { flexDirection: 'row', alignItems: 'center', gap: theme.spacing(2), minHeight: 44 },
232
+ title: {
233
+ flex: 1,
234
+ fontFamily: fontOf(theme.fontFamily.sans),
235
+ fontSize: theme.fontSize.lg,
236
+ lineHeight: theme.lineHeight.lg,
237
+ fontWeight: theme.fontWeight.medium,
238
+ color: theme.colors.hi,
239
+ },
240
+ caption: {
241
+ fontFamily: fontOf(theme.fontFamily.sans),
242
+ fontSize: theme.fontSize.sm,
243
+ lineHeight: theme.lineHeightRelaxed.sm,
244
+ color: theme.colors.dim,
245
+ },
246
+ content: { padding: theme.spacing(4), paddingBottom: theme.spacing(10), gap: theme.spacing(5) },
247
+ search: { flexDirection: 'row', alignItems: 'center', gap: theme.spacing(2), padding: theme.spacing(4) },
248
+ searchField: { flex: 1 },
249
+ results: { gap: theme.spacing(2) },
250
+ destination: { flex: 1 },
251
+ previewNotice: { padding: theme.spacing(4), gap: theme.spacing(2) },
252
+ }));
253
+
254
+ export const meta = {
255
+ title: 'Native/Design/Settings directory',
256
+ tags: ['style-system', 'mockup', 'native'],
257
+ };
258
+ export default meta;
259
+ export const Playground = { render: () => <Directory /> };
260
+ export const SearchDefaults = { render: () => <Directory initialQuery="new session defaults" /> };
261
+ export const SearchPlugin = { render: () => <Directory initialQuery="image" /> };
262
+ export const NoMatches = { render: () => <Directory initialQuery="unicorn wallpaper" /> };
263
+ export const Dark = { render: () => <Directory scheme="dark" /> };
264
+ export const Offline = { render: () => <Directory context="offline" /> };
265
+ export const AllComputers = { render: () => <Directory context="all" /> };
266
+ export const PoCloud = { render: () => <Directory context="cloud" /> };
267
+ export const OfflineSearch = { render: () => <Directory context="offline" initialQuery="api key" /> };
268
+ export const WorkspaceDestination = {
269
+ render: () => <Directory initialQuery="new session defaults" initialDestination="defaults" />,
270
+ };
@@ -12,6 +12,7 @@ import { StyleSheet, UnistylesRuntime } from 'react-native-unistyles';
12
12
 
13
13
  import type { Appearance } from '../app/appearance';
14
14
  import { AppearanceScreen } from './AppearanceScreen';
15
+ import { LanguageScreen } from './LanguageScreen';
15
16
  import { ProvidersScreen } from './ProvidersScreen';
16
17
  import { RemoteControlScreen } from './RemoteControlScreen';
17
18
  import { CardBody, GlobalSettingsView, Group, NavRow, SettingsScreen } from './SettingsScreen';
@@ -158,8 +159,6 @@ function AppearanceStory({ scheme, initial }: { scheme: 'light' | 'dark'; initia
158
159
  <AppearanceScreen
159
160
  theme={theme}
160
161
  onTheme={setTheme}
161
- locales={[{ name: 'zh-CN', nativeLabel: '简体中文' }]}
162
- onLocale={() => undefined}
163
162
  target="global"
164
163
  repositories={REPOSITORIES}
165
164
  templates={TEMPLATES}
@@ -182,11 +181,6 @@ const COMPUTERS = [
182
181
  { id: 'a', label: 'MacBook', online: true },
183
182
  { id: 'b', label: 'Studio', online: true },
184
183
  ];
185
- const PANEL_GROUPS = COMPUTERS.map((host) => ({
186
- hostId: host.id,
187
- label: host.label,
188
- panels: [{ id: 'tools', pluginId: 'po-tools', label: 'Tools', detail: 'Which tools Po can use' }],
189
- }));
190
184
  /** The Global group as a signed-in teammate sees it: the team, the editor and its saved notice. */
191
185
  const globalSection = (profile = false) => (
192
186
  <Group label="Global" hint="Your portable preferences across hosts.">
@@ -226,7 +220,6 @@ function AllHostsStory({
226
220
  hostAddress=""
227
221
  phoneOnly
228
222
  computers={COMPUTERS}
229
- panelGroups={PANEL_GROUPS}
230
223
  appearance="Match iPhone"
231
224
  {...(team ? { team } : {})}
232
225
  {...(global ? { globalSection: GLOBAL_SECTION } : {})}
@@ -274,6 +267,25 @@ export const GlobalProfileDark = { render: () => <GlobalProfileStory scheme="dar
274
267
  export const AppearanceLight = { render: () => <AppearanceStory scheme="light" initial="system" /> };
275
268
  export const AppearanceDark = { render: () => <AppearanceStory scheme="dark" initial="dark" /> };
276
269
 
270
+ /** Language packs a computer contributes, named in their own language. */
271
+ const LOCALES = [
272
+ { name: 'vi', nativeLabel: 'Tiếng Việt' },
273
+ { name: 'zh-CN', nativeLabel: '简体中文' },
274
+ ];
275
+
276
+ function LanguageStory({ scheme }: { scheme: 'light' | 'dark' }) {
277
+ const [locale, setLocale] = useState<string | undefined>(undefined);
278
+ return (
279
+ <Phone scheme={scheme}>
280
+ <LanguageScreen {...(locale === undefined ? {} : { locale })} locales={LOCALES} onLocale={setLocale} />
281
+ </Phone>
282
+ );
283
+ }
284
+
285
+ /** Its own screen under This phone: the language belongs to the phone, not to how Po looks. */
286
+ export const LanguageLight = { render: () => <LanguageStory scheme="light" /> };
287
+ export const LanguageDark = { render: () => <LanguageStory scheme="dark" /> };
288
+
277
289
  const REPOSITORIES: SettingsRepository[] = [
278
290
  { id: 'r1', name: 'po-internal', path: '/Users/dev/workspace/po-internal', active: true },
279
291
  { id: 'r2', name: 'notes', path: '/Users/dev/.po/workspace/notes', active: false },
@@ -10,6 +10,7 @@ import {
10
10
  fontOf,
11
11
  type IconProps,
12
12
  InfoStrip,
13
+ LanguagesIcon,
13
14
  LockIcon,
14
15
  MessageIcon,
15
16
  MonitorIcon,
@@ -151,6 +152,7 @@ export type SettingsSection =
151
152
  | 'SettingsPlugins'
152
153
  | 'SettingsMetrics'
153
154
  | 'SettingsAppearance'
155
+ | 'SettingsLanguage'
154
156
  | 'SettingsAccount'
155
157
  | 'SettingsTeam';
156
158
 
@@ -171,6 +173,8 @@ export interface SettingsScreenProps {
171
173
  remote?: RemoteAccessStateView;
172
174
  /** How the app looks on this phone, as the Appearance screen names it. */
173
175
  appearance?: string;
176
+ /** The language this phone uses, as the Language screen names it. */
177
+ language?: string;
174
178
  /** "Resize to 2000 px"; absent until read. */
175
179
  images?: string;
176
180
  /** "14 installed". */
@@ -180,10 +184,8 @@ export interface SettingsScreenProps {
180
184
  onOpenSection?: (id: string) => void;
181
185
  /** Pages packages draw themselves, in menu order; their group is left out when there are none. */
182
186
  panels?: readonly SettingsPanelEntry[];
183
- /** All paired hosts contribute their own pages, without merging same-named panels. */
184
- panelGroups?: readonly { hostId: string; label: string; panels: readonly SettingsPanelEntry[] }[];
185
187
  onOpen: (section: SettingsSection) => void;
186
- onOpenPanel?: (id: string, hostId?: string) => void;
188
+ onOpenPanel?: (id: string) => void;
187
189
  onForgetHost: () => void;
188
190
  error?: string;
189
191
  notices?: readonly { id: string; message: string }[];
@@ -193,7 +195,7 @@ export interface SettingsScreenProps {
193
195
  */
194
196
  computers?: readonly { id: string; label: string; online: boolean }[];
195
197
  computer?: string;
196
- /** All hosts is chosen: hide computer-specific built-in settings, but keep each host's plugin pages. */
198
+ /** All hosts is chosen: no host is selected, so only this phone and the account show. */
197
199
  phoneOnly?: boolean;
198
200
  globalSection?: ReactNode;
199
201
  /** The host's `account-region`: a person's package may decorate or replace the Account entry. */
@@ -236,12 +238,12 @@ export function SettingsScreen({
236
238
  mcpServers,
237
239
  remote,
238
240
  appearance,
241
+ language,
239
242
  images,
240
243
  plugins,
241
244
  sections = [],
242
245
  onOpenSection,
243
246
  panels = [],
244
- panelGroups = [],
245
247
  onOpen,
246
248
  onOpenPanel,
247
249
  onForgetHost,
@@ -263,9 +265,7 @@ export function SettingsScreen({
263
265
  <ScrollView contentContainerStyle={styles.content}>
264
266
  <Text style={styles.lede}>
265
267
  {phoneOnly
266
- ? panelGroups.length > 0
267
- ? t('native.settings.lede.computers', 'How Po works on your computers, and on this phone.')
268
- : t('native.settings.lede.phone', 'How Po works on this phone.')
268
+ ? t('native.settings.lede.phone', 'How Po works on this phone.')
269
269
  : t('native.settings.lede.computer', 'How Po works on {name}, and on this phone.', { name })}
270
270
  </Text>
271
271
  <ErrorLine>{error}</ErrorLine>
@@ -391,21 +391,6 @@ export function SettingsScreen({
391
391
  ) : null}
392
392
  </>
393
393
  )}
394
- {panelGroups.map((group) =>
395
- group.panels.length > 0 ? (
396
- <Group key={group.hostId} label={group.label} hint={t('native.settings.features', 'Features')}>
397
- {group.panels.map((panel, index) => (
398
- <NavRow
399
- key={`${group.hostId}/${panel.pluginId ?? ''}/${panel.id}`}
400
- title={panel.label}
401
- value={sentenceCase(panel.detail)}
402
- onPress={() => onOpenPanel?.(panel.id, group.hostId)}
403
- last={index === group.panels.length - 1}
404
- />
405
- ))}
406
- </Group>
407
- ) : null,
408
- )}
409
394
  {globalSection}
410
395
  <Group label={t('native.settings.thisPhone', 'This phone')}>
411
396
  {accountRegion(
@@ -434,6 +419,12 @@ export function SettingsScreen({
434
419
  title={t('native.settings.appearance', 'Appearance')}
435
420
  value={appearance}
436
421
  onPress={() => onOpen('SettingsAppearance')}
422
+ />
423
+ <NavRow
424
+ Icon={LanguagesIcon}
425
+ title={t('native.settings.language', 'Language')}
426
+ value={language}
427
+ onPress={() => onOpen('SettingsLanguage')}
437
428
  last
438
429
  />
439
430
  </Group>
@@ -254,7 +254,8 @@ export function homeOverview(
254
254
  }
255
255
  const working = [...bySource.values()];
256
256
  const runningSessions = sessions.filter((session) => !session.dormant && session.phase !== 'idle').length;
257
- if (runningSessions > 0) working.unshift({ label: 'Sessions', running: runningSessions, queued: 0 });
257
+ if (runningSessions > 0)
258
+ working.unshift({ label: t('native.home.workingSessions', 'Sessions'), running: runningSessions, queued: 0 });
258
259
  const remoteTotal = statuses.reduce(
259
260
  (total, status) =>
260
261
  total +
@@ -0,0 +1,46 @@
1
+ import { localPluginEntries, localPluginPageId } from '@agimon-ai/po-web-dashboard/core';
2
+ import type { CatalogLayer, PluginEntry } from '@agimon-ai/po-web-dashboard/types';
3
+
4
+ /*
5
+ * A settings page that names its plugin with `pluginPage` is reachable from that plugin's Plugins screen:
6
+ * its installed curated layer's screen, or else a local plugin's own. One computer's registry feeds all of
7
+ * it, so a page is only ever opened on the computer that owns it.
8
+ */
9
+
10
+ interface LocalPanel {
11
+ id: string;
12
+ label: string;
13
+ pluginId: string;
14
+ pluginPage?: string;
15
+ detail: string;
16
+ }
17
+
18
+ /** What one computer's registry reports: its settings pages and the plugins installed there. */
19
+ export interface LocalPluginSources {
20
+ panels: readonly LocalPanel[];
21
+ installed: readonly { id: string; packageName?: string }[];
22
+ }
23
+
24
+ export const NO_LOCAL_PLUGINS: LocalPluginSources = { panels: [], installed: [] };
25
+
26
+ /** Waits for the catalog: only it tells a local plugin from a curated one. */
27
+ export function localEntries(sources: LocalPluginSources, layers: readonly CatalogLayer[] | undefined): PluginEntry[] {
28
+ return layers === undefined ? [] : localPluginEntries(sources.panels, sources.installed, layers);
29
+ }
30
+
31
+ /**
32
+ * The Plugins screen an opted-in page opens on, once the catalog says which: its installed curated layer
33
+ * or the local plugin's. Undefined for a page that has not opted in.
34
+ */
35
+ export function pluginPageOf(
36
+ panel: LocalPanel,
37
+ installed: LocalPluginSources['installed'],
38
+ layers: readonly CatalogLayer[] | undefined,
39
+ ): string | undefined {
40
+ const plugin = installed.find(({ id }) => id === panel.pluginId);
41
+ if (layers === undefined || !panel.pluginPage?.trim() || plugin === undefined) return undefined;
42
+ const layer = layers.find(
43
+ (candidate) => candidate.installed && candidate.packages.includes(plugin.packageName ?? ''),
44
+ );
45
+ return layer?.id ?? localPluginPageId(panel.pluginId);
46
+ }
@@ -24,6 +24,7 @@ import {
24
24
  readPresets,
25
25
  startInstall,
26
26
  } from '../services/settingsApi';
27
+ import { localEntries, type LocalPluginSources, NO_LOCAL_PLUGINS } from './localPlugins';
27
28
 
28
29
  /*
29
30
  * The phone's Plugins screens, on the computer Settings chose: its curated catalog, its presets and
@@ -36,7 +37,11 @@ const SETTLED: ReadonlySet<InstallOperation['state']> = new Set(['succeeded', 'f
36
37
 
37
38
  type Edit = { ok: true } | { ok: false; error: string };
38
39
 
39
- export function usePluginMarketplace(hostId?: string, hostLabel = 'your computer') {
40
+ export function usePluginMarketplace(
41
+ hostId?: string,
42
+ hostLabel = 'your computer',
43
+ local: LocalPluginSources = NO_LOCAL_PLUGINS,
44
+ ) {
40
45
  const [layers, setLayers] = useState<CatalogLayer[]>();
41
46
  const [presets, setPresets] = useState<SettingsPresetsView>();
42
47
  const [external, setExternal] = useState<ExternalPluginsView>();
@@ -107,9 +112,12 @@ export function usePluginMarketplace(hostId?: string, hostLabel = 'your computer
107
112
  [layers, presets, external, installs],
108
113
  );
109
114
 
115
+ // Private plugins stay out of `entries`: presets and installs only ever see the curated catalog.
116
+ const privateEntries = useMemo(() => localEntries(local, layers), [local, layers]);
117
+
110
118
  /** Installs when needed and joins `preset` ('' is the default), all on the computer. */
111
119
  const join = async (entry: PluginEntry, preset: string) => {
112
- if (presets === undefined) return;
120
+ if (presets === undefined || entry.localPluginId !== undefined) return;
113
121
  setStartErrors(({ [entry.id]: _cleared, ...rest }) => rest);
114
122
  const started = await startInstall(
115
123
  {
@@ -150,6 +158,7 @@ export function usePluginMarketplace(hostId?: string, hostLabel = 'your computer
150
158
 
151
159
  /** Removes the plugin from presets one at a time, each write carrying the token the last returned. */
152
160
  const leave = async (layer: string, names: readonly string[]) => {
161
+ if (privateEntries.some((entry) => entry.id === layer)) return;
153
162
  let view = presets;
154
163
  for (const name of names) {
155
164
  if (view === undefined) return;
@@ -170,6 +179,8 @@ export function usePluginMarketplace(hostId?: string, hostLabel = 'your computer
170
179
  layers === undefined ? (error === undefined ? ('loading' as const) : ('error' as const)) : ('ready' as const),
171
180
  error,
172
181
  entries,
182
+ /** Plugins this computer's registry lists for the phone; they have no install or preset actions. */
183
+ localEntries: privateEntries,
173
184
  layers: layers ?? [],
174
185
  presets,
175
186
  summaries: presetSummaries(presets),
@@ -191,31 +202,40 @@ export function usePluginMarketplace(hostId?: string, hostLabel = 'your computer
191
202
  export type PluginMarketplace = ReturnType<typeof usePluginMarketplace>;
192
203
 
193
204
  /*
194
- * Settings on the phone keeps only pages that are not a curated plugin's: those live on the plugin's
195
- * own screen. One catalog read per computer per app run; until it answers, nothing moves.
205
+ * Settings on the phone keeps only pages that are not a plugin's own screen: those live on the plugin's
206
+ * screen. One catalog read per computer per app run; until it answers, nothing moves.
196
207
  */
197
- const curatedPackages = new Map<string, Promise<ReadonlySet<string>>>();
208
+ const catalogReads = new Map<string, Promise<readonly CatalogLayer[] | undefined>>();
198
209
 
199
- export function useCuratedPackages(hostId?: string): ReadonlySet<string> | undefined {
200
- const [packages, setPackages] = useState<ReadonlySet<string>>();
210
+ /** The computer's catalog for Settings; undefined until it answers, and after a read that failed. */
211
+ export function useCatalogLayers(hostId?: string): readonly CatalogLayer[] | undefined {
212
+ const [catalog, setCatalog] = useState<{ hostId?: string; layers?: readonly CatalogLayer[] }>();
201
213
  useEffect(() => {
202
214
  const key = hostId ?? '';
203
- let load = curatedPackages.get(key);
215
+ let load = catalogReads.get(key);
204
216
  if (load === undefined) {
205
- load = readCatalog(hostId).then(
206
- (read) => new Set('layers' in read ? read.layers.flatMap((layer) => layer.packages) : []),
207
- );
208
- curatedPackages.set(key, load);
217
+ const read = readCatalog(hostId).then((answer) => ('layers' in answer ? answer.layers : undefined));
218
+ // A failed read is not kept, so the next screen asks again.
219
+ void read.then((found) => {
220
+ if (found === undefined && catalogReads.get(key) === read) catalogReads.delete(key);
221
+ });
222
+ catalogReads.set(key, read);
223
+ load = read;
209
224
  }
210
225
  let current = true;
211
226
  void load.then((found) => {
212
- if (current) setPackages(found);
227
+ if (current) setCatalog({ hostId, layers: found });
213
228
  });
214
229
  return () => {
215
230
  current = false;
216
231
  };
217
232
  }, [hostId]);
218
- return packages;
233
+ return catalog?.hostId === hostId ? catalog?.layers : undefined;
234
+ }
235
+
236
+ export function useCuratedPackages(hostId?: string): ReadonlySet<string> | undefined {
237
+ const layers = useCatalogLayers(hostId);
238
+ return useMemo(() => layers && new Set(layers.flatMap((layer) => layer.packages)), [layers]);
219
239
  }
220
240
 
221
241
  /** Whether a contribution's package belongs to a curated layer on this computer. */
@@ -11,7 +11,7 @@ import {
11
11
  sessionApiPath,
12
12
  } from '@agimon-ai/po-core/web';
13
13
  import { parseProfileCatalog } from '@agimon-ai/po-web-components/text';
14
- import { qualifyHostId, splitHostId, type StarterPo } from '@agimon-ai/po-web-dashboard/core';
14
+ import { cacheParticipantAvatar, qualifyHostId, splitHostId, type StarterPo } from '@agimon-ai/po-web-dashboard/core';
15
15
  import {
16
16
  DIRECTORIES_API_ROUTE,
17
17
  DIRECTORY_CHILDREN_API_ROUTE,
@@ -222,13 +222,18 @@ export async function loadSessionAvatar(sessionId: string, iconVersion: string):
222
222
  );
223
223
  }
224
224
 
225
- /** A recorded participant's avatar on the session's owning host; missing pictures keep the initials. */
226
- export async function loadParticipantAvatar(sessionId: string, profileId: string): Promise<string | undefined> {
227
- const response = await nativeApiTransport(
228
- `${sessionApiPath(sessionId)}/plugins/profile/person/${encodeURIComponent(profileId)}/avatar`,
229
- );
230
- if (response.status === 404) return undefined;
231
- return imageDataUri(response, 'participant avatar', true);
225
+ /**
226
+ * A recorded participant's avatar on the session's owning host; missing pictures keep the initials. Rows share one
227
+ * load per host-qualified session and person.
228
+ */
229
+ export function loadParticipantAvatar(sessionId: string, profileId: string): Promise<string | undefined> {
230
+ return cacheParticipantAvatar(sessionId, profileId, async () => {
231
+ const response = await nativeApiTransport(
232
+ `${sessionApiPath(sessionId)}/plugins/profile/person/${encodeURIComponent(profileId)}/avatar`,
233
+ );
234
+ if (response.status === 404) return undefined;
235
+ return imageDataUri(response, 'participant avatar', true);
236
+ });
232
237
  }
233
238
 
234
239
  /** Stores one picked file on the host, as the web composer does, so a tool can be handed its path. */