@agimon-ai/po-native 0.0.1-alpha.29 → 0.0.1-alpha.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +12 -12
- package/src/app/App.tsx +194 -20
- package/src/screens/ContributedSettingsScreen.tsx +2 -4
- package/src/screens/PluginCatalogScreen.tsx +241 -0
- package/src/screens/PluginDetailScreen.tsx +270 -0
- package/src/screens/PluginMarketplaceDesign.stories.tsx +344 -0
- package/src/screens/PluginOnboardingScreen.tsx +181 -0
- package/src/screens/PresetsScreen.tsx +212 -0
- package/src/screens/pluginModel.tsx +78 -0
- package/src/screens/usePluginMarketplace.ts +222 -0
- package/src/services/settingsApi/index.ts +93 -0
- package/src/screens/PluginsScreen.tsx +0 -97
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agimon-ai/po-native",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.30",
|
|
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.
|
|
33
|
-
"@agimon-ai/po-expo-signing": "0.0.1-alpha.
|
|
34
|
-
"@agimon-ai/po-identity": "0.0.2-alpha.
|
|
35
|
-
"@agimon-ai/po-native-components": "0.0.0-alpha.
|
|
36
|
-
"@agimon-ai/po-native-dashboard": "0.0.0-alpha.
|
|
37
|
-
"@agimon-ai/po-template-advanced": "0.0.0-alpha.
|
|
38
|
-
"@agimon-ai/po-template-elegant": "0.0.0-alpha.
|
|
39
|
-
"@agimon-ai/po-voice": "0.0.0-alpha.
|
|
40
|
-
"@agimon-ai/po-web-components": "0.0.0-alpha.
|
|
41
|
-
"@agimon-ai/po-web-dashboard": "0.0.0-alpha.
|
|
42
|
-
"@agimon-ai/po-web-security": "0.0.0-alpha.
|
|
32
|
+
"@agimon-ai/po-core": "0.0.0-alpha.150",
|
|
33
|
+
"@agimon-ai/po-expo-signing": "0.0.1-alpha.30",
|
|
34
|
+
"@agimon-ai/po-identity": "0.0.2-alpha.97",
|
|
35
|
+
"@agimon-ai/po-native-components": "0.0.0-alpha.150",
|
|
36
|
+
"@agimon-ai/po-native-dashboard": "0.0.0-alpha.22",
|
|
37
|
+
"@agimon-ai/po-template-advanced": "0.0.0-alpha.150",
|
|
38
|
+
"@agimon-ai/po-template-elegant": "0.0.0-alpha.150",
|
|
39
|
+
"@agimon-ai/po-voice": "0.0.0-alpha.150",
|
|
40
|
+
"@agimon-ai/po-web-components": "0.0.0-alpha.150",
|
|
41
|
+
"@agimon-ai/po-web-dashboard": "0.0.0-alpha.150",
|
|
42
|
+
"@agimon-ai/po-web-security": "0.0.0-alpha.150",
|
|
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
|
@@ -81,10 +81,12 @@ import {
|
|
|
81
81
|
sessionToolRenderer,
|
|
82
82
|
submitMessage,
|
|
83
83
|
fileTabForPath,
|
|
84
|
+
fileLinkMentions,
|
|
84
85
|
useFileLinks,
|
|
85
86
|
UPDATE_REQUIRED_REASON,
|
|
86
87
|
qualifyHostId,
|
|
87
88
|
splitHostId,
|
|
89
|
+
webPluginDiagnostics,
|
|
88
90
|
webPluginRegistryForHost,
|
|
89
91
|
parseDashboardTileData,
|
|
90
92
|
HOST_SLOTS,
|
|
@@ -96,10 +98,10 @@ import {
|
|
|
96
98
|
useRenderTrace,
|
|
97
99
|
ToolRendererBoundary,
|
|
98
100
|
installedWebPlugins,
|
|
99
|
-
webPluginDiagnostics,
|
|
100
101
|
nativeTemplateCatalog,
|
|
101
102
|
settingsKeyOf,
|
|
102
103
|
homeActivity,
|
|
104
|
+
filterEntries,
|
|
103
105
|
} from '@agimon-ai/po-web-dashboard/core';
|
|
104
106
|
import { NATIVE_PAIRING_LINK_PREFIX, type SettingsRepository } from '@agimon-ai/po-web-dashboard/types';
|
|
105
107
|
import { type BottomTabBarProps, createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
|
@@ -177,11 +179,23 @@ import { HostDrawer, HostMenuButton } from '../screens/HostDrawer';
|
|
|
177
179
|
import { ImagesScreen, imagesSummary, useImageSettings } from '../screens/ImagesScreen';
|
|
178
180
|
import { McpServersScreen, mcpServersSummary, useMcpServers } from '../screens/McpServersScreen';
|
|
179
181
|
import { MetricsScreen, useMetrics } from '../screens/MetricsScreen';
|
|
180
|
-
import {
|
|
182
|
+
import { ALL_CATEGORIES, EXTERNAL_CATEGORY, PluginCatalogScreen } from '../screens/PluginCatalogScreen';
|
|
183
|
+
import { PluginDetailScreen } from '../screens/PluginDetailScreen';
|
|
184
|
+
import { PluginOnboardingScreen } from '../screens/PluginOnboardingScreen';
|
|
185
|
+
import { PresetsScreen } from '../screens/PresetsScreen';
|
|
181
186
|
import { providersSummary, ProvidersScreen, useProviders } from '../screens/ProvidersScreen';
|
|
182
187
|
import { type McpSession, RemoteControlScreen, useRemoteControl } from '../screens/RemoteControlScreen';
|
|
183
188
|
import { type SessionSummary, SessionListScreen } from '../screens/SessionListScreen';
|
|
184
|
-
import {
|
|
189
|
+
import { StateRow } from '../screens/SettingsFields';
|
|
190
|
+
import {
|
|
191
|
+
Group,
|
|
192
|
+
SectionPage,
|
|
193
|
+
type SettingsSection,
|
|
194
|
+
SettingsPanelPage,
|
|
195
|
+
SettingsScreen,
|
|
196
|
+
sentenceCase,
|
|
197
|
+
} from '../screens/SettingsScreen';
|
|
198
|
+
import { isCuratedPlugin, useCuratedPackages, usePluginMarketplace } from '../screens/usePluginMarketplace';
|
|
185
199
|
import { workspacePageState } from '../screens/workspaceModel';
|
|
186
200
|
import type { ProviderCandidate } from '../screens/WorkspaceProviders';
|
|
187
201
|
import { WorkspaceProvidersSection } from '../screens/WorkspaceProvidersSection';
|
|
@@ -283,6 +297,9 @@ type Routes = {
|
|
|
283
297
|
SettingsWorkspaceMcp: WorkspaceParams;
|
|
284
298
|
SettingsImages: { hostId?: string } | undefined;
|
|
285
299
|
SettingsPlugins: { hostId?: string } | undefined;
|
|
300
|
+
/** One curated or Codex/Claude plugin, on the computer the catalog was read from. */
|
|
301
|
+
SettingsPlugin: { id: string; title: string; hostId?: string };
|
|
302
|
+
SettingsPresets: { hostId?: string } | undefined;
|
|
286
303
|
SettingsMetrics: { hostId?: string } | undefined;
|
|
287
304
|
SettingsAppearance: undefined;
|
|
288
305
|
SettingsAccount: undefined;
|
|
@@ -984,6 +1001,7 @@ function SessionRoute({
|
|
|
984
1001
|
live: true,
|
|
985
1002
|
searchFiles: (query: string) => searchFiles(sessionId, query),
|
|
986
1003
|
mentionSessions: () => mentionSessionsOn(sessionId),
|
|
1004
|
+
references: (query: string) => fileLinkMentions(sessionId, query),
|
|
987
1005
|
uploadAttachment: uploadSessionAttachment,
|
|
988
1006
|
onAbort: () => whenConnected(sessionId, () => abortRun(sessionId)),
|
|
989
1007
|
onOpenOptions: () => setOptionsOpen(true),
|
|
@@ -1149,13 +1167,16 @@ function SettingsRoute(
|
|
|
1149
1167
|
// A named computer replaces the implicit current session; a computer offline answers nothing.
|
|
1150
1168
|
const allowed = settingsHost !== undefined ? chosen?.online !== false : props.allowGlobalActions;
|
|
1151
1169
|
const refused = chosen && !chosen.online ? `${chosen.label} is offline.` : HOST_OWNERSHIP_PENDING;
|
|
1152
|
-
const
|
|
1170
|
+
const installedPlugins =
|
|
1171
|
+
settingsHost === undefined ? installedWebPlugins() : webPluginRegistryForHost(settingsHost).installedWebPlugins();
|
|
1172
|
+
// A curated plugin's pages live on its own Plugins screen, so Settings leaves them out.
|
|
1173
|
+
const curated = useCuratedPackages(settingsHost);
|
|
1174
|
+
const listed = (pluginId: string) => !isCuratedPlugin(pluginId, installedPlugins, curated);
|
|
1175
|
+
const panels = useSettingsPanels(settingsHost).filter((panel) => listed(panel.pluginId));
|
|
1153
1176
|
const panelGroups = useSettingsPanelGroups(props.phoneOnly ? props.computers : undefined);
|
|
1154
|
-
const sections = useSettingsSections('host', settingsHost);
|
|
1177
|
+
const sections = useSettingsSections('host', settingsHost).filter((section) => listed(section.pluginId));
|
|
1155
1178
|
const sectionKeys = sections.flatMap((section) => section.fields.map(settingsKeyOf)).join('\n');
|
|
1156
|
-
const plugins =
|
|
1157
|
-
settingsHost === undefined ? installedWebPlugins() : webPluginRegistryForHost(settingsHost).installedWebPlugins()
|
|
1158
|
-
).length;
|
|
1179
|
+
const plugins = installedPlugins.length;
|
|
1159
1180
|
// Each computer keeps its own last answer, shown at once and refreshed on focus, never blanked.
|
|
1160
1181
|
const scopeKey = allowed ? `settings:${settingsHost ?? ''}` : undefined;
|
|
1161
1182
|
const summary = useCachedRequest(scopeKey && `${scopeKey}:summary`, async () => {
|
|
@@ -1383,19 +1404,157 @@ function MetricsRoute({ route }: NativeStackScreenProps<Routes, 'SettingsMetrics
|
|
|
1383
1404
|
return <MetricsScreen {...useMetrics(route.params?.hostId)} />;
|
|
1384
1405
|
}
|
|
1385
1406
|
|
|
1386
|
-
function PluginsRoute({ route }: NativeStackScreenProps<Routes, 'SettingsPlugins'>) {
|
|
1407
|
+
function PluginsRoute({ navigation, route }: NativeStackScreenProps<Routes, 'SettingsPlugins'>) {
|
|
1387
1408
|
const hostId = route.params?.hostId;
|
|
1388
|
-
|
|
1389
|
-
const
|
|
1390
|
-
const
|
|
1409
|
+
const market = usePluginMarketplace(hostId);
|
|
1410
|
+
const [query, setQuery] = useState('');
|
|
1411
|
+
const [category, setCategory] = useState(ALL_CATEGORIES);
|
|
1412
|
+
useFocusEffect(
|
|
1413
|
+
useCallback(() => {
|
|
1414
|
+
void market.reload();
|
|
1415
|
+
// Read again whenever the screen comes back into view, as other screens change presets.
|
|
1416
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- market.reload is stable per host.
|
|
1417
|
+
}, [hostId]),
|
|
1418
|
+
);
|
|
1391
1419
|
return (
|
|
1392
|
-
<
|
|
1393
|
-
plugins={
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
}
|
|
1398
|
-
|
|
1420
|
+
<PluginCatalogScreen
|
|
1421
|
+
plugins={filterEntries(market.entries, query, category, ALL_CATEGORIES, EXTERNAL_CATEGORY)}
|
|
1422
|
+
categories={[...new Set(market.entries.filter((entry) => entry.source === 'po').map((entry) => entry.category))]}
|
|
1423
|
+
category={category}
|
|
1424
|
+
onCategoryChange={setCategory}
|
|
1425
|
+
query={query}
|
|
1426
|
+
onQueryChange={setQuery}
|
|
1427
|
+
scope={market.scope}
|
|
1428
|
+
scopes={[market.scope]}
|
|
1429
|
+
onScopeChange={() => undefined}
|
|
1430
|
+
destination={market.destination}
|
|
1431
|
+
status={market.status}
|
|
1432
|
+
{...(market.error === undefined ? {} : { error: market.error })}
|
|
1433
|
+
onRetry={() => void market.reload()}
|
|
1434
|
+
{...(market.justTurnedOn === undefined ? {} : { justTurnedOn: market.justTurnedOn })}
|
|
1435
|
+
onUndo={() => {
|
|
1436
|
+
if (market.justTurnedOn !== undefined && market.presets !== undefined)
|
|
1437
|
+
void market.leave(market.justTurnedOn.id, [market.presets.defaultPreset]);
|
|
1438
|
+
market.clearJustTurnedOn();
|
|
1439
|
+
}}
|
|
1440
|
+
onOpen={(plugin) => navigation.navigate('SettingsPlugin', { id: plugin.id, title: plugin.name, hostId })}
|
|
1441
|
+
onInstall={(plugin) => void market.join(plugin, '')}
|
|
1442
|
+
onTurnOn={(plugin) => void market.join(plugin, '')}
|
|
1443
|
+
diagnostics={
|
|
1444
|
+
hostId === undefined ? webPluginDiagnostics() : webPluginRegistryForHost(hostId).webPluginDiagnostics()
|
|
1445
|
+
}
|
|
1446
|
+
/>
|
|
1447
|
+
);
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
function PluginRoute({ navigation, route }: NativeStackScreenProps<Routes, 'SettingsPlugin'>) {
|
|
1451
|
+
const { id, hostId } = route.params;
|
|
1452
|
+
const market = usePluginMarketplace(hostId);
|
|
1453
|
+
const [setupOpen, setSetupOpen] = useState(false);
|
|
1454
|
+
const plugin = market.entries.find((entry) => entry.id === id);
|
|
1455
|
+
if (plugin === undefined) {
|
|
1456
|
+
return (
|
|
1457
|
+
<SectionPage>
|
|
1458
|
+
<Group label="Plugin">
|
|
1459
|
+
<StateRow
|
|
1460
|
+
title={market.status === 'loading' ? 'Reading the catalog' : "This plugin isn't here"}
|
|
1461
|
+
description={market.error ?? 'It is not in the catalog on this computer.'}
|
|
1462
|
+
onRetry={() => void market.reload()}
|
|
1463
|
+
/>
|
|
1464
|
+
</Group>
|
|
1465
|
+
</SectionPage>
|
|
1466
|
+
);
|
|
1467
|
+
}
|
|
1468
|
+
const layer = market.layers.find((entry) => entry.id === id);
|
|
1469
|
+
const operation = market.installs[id];
|
|
1470
|
+
const installError = market.startErrors[id] ?? (operation?.state === 'failed' ? operation.error : undefined);
|
|
1471
|
+
const openPresets = () => navigation.navigate('SettingsPresets', { hostId });
|
|
1472
|
+
return (
|
|
1473
|
+
<>
|
|
1474
|
+
<PluginDetailScreen
|
|
1475
|
+
plugin={plugin}
|
|
1476
|
+
scope={market.scope}
|
|
1477
|
+
destination={market.destination}
|
|
1478
|
+
presets={market.summaries}
|
|
1479
|
+
{...(layer?.version === undefined ? {} : { version: layer.version })}
|
|
1480
|
+
adds={[]}
|
|
1481
|
+
{...(installError === undefined ? {} : { installError })}
|
|
1482
|
+
{...(operation?.clash === undefined ? {} : { clash: operation.clash })}
|
|
1483
|
+
onInstall={() => void market.join(plugin, '')}
|
|
1484
|
+
onTurnOn={() => void market.join(plugin, '')}
|
|
1485
|
+
onTurnOff={() => void market.leave(id, plugin.inPresets)}
|
|
1486
|
+
onChangeDestination={openPresets}
|
|
1487
|
+
onSetUp={() => setSetupOpen(true)}
|
|
1488
|
+
onRetrySetup={() => setSetupOpen(true)}
|
|
1489
|
+
onTogglePreset={(preset, on) => void (on ? market.join(plugin, preset) : market.leave(id, [preset]))}
|
|
1490
|
+
onOpenPreset={openPresets}
|
|
1491
|
+
onManageDomains={() =>
|
|
1492
|
+
navigation.navigate('SettingsPanel', { id: 'plugins', title: 'Codex and Claude plugins', hostId })
|
|
1493
|
+
}
|
|
1494
|
+
/>
|
|
1495
|
+
{/* ponytail: no plugin ships a `.native` onboarding yet, so the sheet always says to finish on the web.
|
|
1496
|
+
Mount the plugin's native body here once one exists. */}
|
|
1497
|
+
<PluginOnboardingScreen
|
|
1498
|
+
open={setupOpen}
|
|
1499
|
+
plugin={plugin}
|
|
1500
|
+
state="unavailable"
|
|
1501
|
+
activation="before-setup"
|
|
1502
|
+
destination={market.destination}
|
|
1503
|
+
onChangeDestination={() => {
|
|
1504
|
+
setSetupOpen(false);
|
|
1505
|
+
openPresets();
|
|
1506
|
+
}}
|
|
1507
|
+
onRetry={() => undefined}
|
|
1508
|
+
onClose={() => setSetupOpen(false)}
|
|
1509
|
+
/>
|
|
1510
|
+
</>
|
|
1511
|
+
);
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
function PresetsRoute({ route }: NativeStackScreenProps<Routes, 'SettingsPresets'>) {
|
|
1515
|
+
const market = usePluginMarketplace(route.params?.hostId);
|
|
1516
|
+
const [draft, setDraft] = useState<{ name: string; error?: string }>();
|
|
1517
|
+
const [blocked, setBlocked] = useState<{ action: 'rename' | 'delete'; preset: string; references: string[] }>();
|
|
1518
|
+
return (
|
|
1519
|
+
<PresetsScreen
|
|
1520
|
+
scope={market.scope}
|
|
1521
|
+
scopes={[market.scope]}
|
|
1522
|
+
onScopeChange={() => undefined}
|
|
1523
|
+
presets={market.summaries}
|
|
1524
|
+
plugins={market.entries}
|
|
1525
|
+
status={market.presets === undefined ? market.status : 'ready'}
|
|
1526
|
+
{...(market.error === undefined ? {} : { error: market.error })}
|
|
1527
|
+
onRetry={() => void market.reload()}
|
|
1528
|
+
{...(draft === undefined ? {} : { draft })}
|
|
1529
|
+
onDraftChange={(name) => setDraft({ name })}
|
|
1530
|
+
onStartCreate={() => setDraft({ name: '' })}
|
|
1531
|
+
onCreate={() => {
|
|
1532
|
+
const name = draft?.name.trim() ?? '';
|
|
1533
|
+
if (name === '') return setDraft({ name: '', error: 'Give it a name.' });
|
|
1534
|
+
void market.create(name).then((result) => setDraft(result.ok ? undefined : { name, error: result.error }));
|
|
1535
|
+
}}
|
|
1536
|
+
onCancelCreate={() => setDraft(undefined)}
|
|
1537
|
+
onOpenPreset={(preset) =>
|
|
1538
|
+
Alert.alert(preset.name, preset.description || undefined, [
|
|
1539
|
+
...(preset.isDefault ? [] : [{ text: 'Make default', onPress: () => void market.makeDefault(preset.name) }]),
|
|
1540
|
+
...(preset.inherited
|
|
1541
|
+
? []
|
|
1542
|
+
: [
|
|
1543
|
+
{
|
|
1544
|
+
text: 'Delete',
|
|
1545
|
+
style: 'destructive' as const,
|
|
1546
|
+
onPress: () =>
|
|
1547
|
+
void market.remove(preset.name).then((result) => {
|
|
1548
|
+
if (!result.ok) setBlocked({ action: 'delete', preset: preset.name, references: [result.error] });
|
|
1549
|
+
}),
|
|
1550
|
+
},
|
|
1551
|
+
]),
|
|
1552
|
+
{ text: 'Cancel', style: 'cancel' as const },
|
|
1553
|
+
])
|
|
1554
|
+
}
|
|
1555
|
+
{...(blocked === undefined ? {} : { blocked })}
|
|
1556
|
+
onDismissBlocked={() => setBlocked(undefined)}
|
|
1557
|
+
conflict={market.conflict}
|
|
1399
1558
|
/>
|
|
1400
1559
|
);
|
|
1401
1560
|
}
|
|
@@ -2406,9 +2565,10 @@ function PluginPageRoute({
|
|
|
2406
2565
|
const pageHostId = owner?.hostId ?? (fill ? splitHostId(fill.pluginId)?.hostId : undefined);
|
|
2407
2566
|
const calendarHost = useCalendarHostProps(hostStates, pageHostId);
|
|
2408
2567
|
const openWorkspace = useOpenWorkspace(pageHostId);
|
|
2568
|
+
const richRenderers = useMemo(createRichActivityRenderers, []);
|
|
2409
2569
|
if (!Page) return <EmptyState title="This page is not installed" description="Go back to Home." />;
|
|
2410
2570
|
const props = {
|
|
2411
|
-
...nativeSlotProps('', {}, () => undefined),
|
|
2571
|
+
...nativeSlotProps('', {}, () => undefined, undefined, { ...richRenderers, nativeSaveFile }),
|
|
2412
2572
|
sessionId: null,
|
|
2413
2573
|
workspaceId,
|
|
2414
2574
|
...calendarHost,
|
|
@@ -3282,6 +3442,20 @@ export function App({ nativeHost }: { nativeHost?: (sessionId: string) => Native
|
|
|
3282
3442
|
component={PluginsRoute}
|
|
3283
3443
|
options={{ title: 'Plugins', headerBackTitle: 'Settings', headerBackButtonDisplayMode: 'default' }}
|
|
3284
3444
|
/>
|
|
3445
|
+
<Stack.Screen
|
|
3446
|
+
name="SettingsPlugin"
|
|
3447
|
+
component={PluginRoute}
|
|
3448
|
+
options={({ route }) => ({
|
|
3449
|
+
title: route.params.title,
|
|
3450
|
+
headerBackTitle: 'Plugins',
|
|
3451
|
+
headerBackButtonDisplayMode: 'default',
|
|
3452
|
+
})}
|
|
3453
|
+
/>
|
|
3454
|
+
<Stack.Screen
|
|
3455
|
+
name="SettingsPresets"
|
|
3456
|
+
component={PresetsRoute}
|
|
3457
|
+
options={{ title: 'Presets', headerBackTitle: 'Back', headerBackButtonDisplayMode: 'default' }}
|
|
3458
|
+
/>
|
|
3285
3459
|
<Stack.Screen
|
|
3286
3460
|
name="SettingsMetrics"
|
|
3287
3461
|
component={MetricsRoute}
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
settingsLockedReason,
|
|
13
13
|
subscribeWebPluginRegistry,
|
|
14
14
|
webPluginRegistryForHost,
|
|
15
|
+
type InstalledSettingsSection,
|
|
15
16
|
} from '@agimon-ai/po-web-dashboard/core';
|
|
16
17
|
import type {
|
|
17
18
|
ProviderAuthSummary,
|
|
@@ -315,10 +316,7 @@ export function ContributedSettingsScreen(props: ContributedSettingsScreenProps)
|
|
|
315
316
|
}
|
|
316
317
|
|
|
317
318
|
/** The sections plugins contribute at one scope, from the named computer's registry; re-read on install. */
|
|
318
|
-
export function useSettingsSections(
|
|
319
|
-
scope: 'host' | 'workspace',
|
|
320
|
-
hostId?: string,
|
|
321
|
-
): readonly SettingsSectionContribution[] {
|
|
319
|
+
export function useSettingsSections(scope: 'host' | 'workspace', hostId?: string): readonly InstalledSettingsSection[] {
|
|
322
320
|
const [, setVersion] = useState(0);
|
|
323
321
|
useEffect(() => subscribeWebPluginRegistry(() => setVersion((value) => value + 1)), []);
|
|
324
322
|
return hostId === undefined
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Button,
|
|
3
|
+
CheckIcon,
|
|
4
|
+
EmptyState,
|
|
5
|
+
fontOf,
|
|
6
|
+
InfoStrip,
|
|
7
|
+
Input,
|
|
8
|
+
Panel,
|
|
9
|
+
SegmentedControl,
|
|
10
|
+
Spinner,
|
|
11
|
+
StatusBadge,
|
|
12
|
+
} from '@agimon-ai/po-native-components';
|
|
13
|
+
import type { InstallDiagnostic } from '@agimon-ai/po-web-dashboard/core';
|
|
14
|
+
import { Pressable, ScrollView, Text, View } from 'react-native';
|
|
15
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
16
|
+
|
|
17
|
+
import { domainLabel, type PluginEntry, type PluginScope, PluginTile } from './pluginModel';
|
|
18
|
+
import { StateRow } from './SettingsFields';
|
|
19
|
+
import { Group, Row, SectionPage } from './SettingsScreen';
|
|
20
|
+
|
|
21
|
+
export const ALL_CATEGORIES = 'All';
|
|
22
|
+
export const EXTERNAL_CATEGORY = 'From Codex and Claude';
|
|
23
|
+
|
|
24
|
+
export interface PluginCatalogScreenProps {
|
|
25
|
+
plugins: readonly PluginEntry[];
|
|
26
|
+
categories: readonly string[];
|
|
27
|
+
category: string;
|
|
28
|
+
onCategoryChange: (category: string) => void;
|
|
29
|
+
query: string;
|
|
30
|
+
onQueryChange: (query: string) => void;
|
|
31
|
+
scope: PluginScope;
|
|
32
|
+
scopes: readonly PluginScope[];
|
|
33
|
+
onScopeChange: (scope: PluginScope) => void;
|
|
34
|
+
destination: string;
|
|
35
|
+
status: 'loading' | 'ready' | 'error';
|
|
36
|
+
error?: string;
|
|
37
|
+
onRetry?: () => void;
|
|
38
|
+
offline?: boolean;
|
|
39
|
+
justTurnedOn?: PluginEntry;
|
|
40
|
+
onUndo?: () => void;
|
|
41
|
+
onOpen: (plugin: PluginEntry) => void;
|
|
42
|
+
onInstall: (plugin: PluginEntry) => void;
|
|
43
|
+
onTurnOn: (plugin: PluginEntry) => void;
|
|
44
|
+
/** Plugins installed on this computer that could not load cleanly, such as two asking for one name. */
|
|
45
|
+
diagnostics?: readonly InstallDiagnostic[];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const scopeKey = (scope: PluginScope) => `${scope.kind}:${scope.label}`;
|
|
49
|
+
|
|
50
|
+
/** The plugin catalog on the phone. Installs run on the selected computer, never on the phone. */
|
|
51
|
+
export function PluginCatalogScreen(props: PluginCatalogScreenProps) {
|
|
52
|
+
const { plugins, status, scope } = props;
|
|
53
|
+
return (
|
|
54
|
+
<SectionPage lede="Plugins give Po new things to do. Switch one on and new sessions start with it.">
|
|
55
|
+
<View style={styles.controls}>
|
|
56
|
+
{props.scopes.length > 1 ? (
|
|
57
|
+
<SegmentedControl
|
|
58
|
+
accessibilityLabel="Where changes apply"
|
|
59
|
+
options={props.scopes.map((option) => ({
|
|
60
|
+
value: scopeKey(option),
|
|
61
|
+
label: option.kind === 'host' ? `All of ${option.label}` : `Only ${option.label}`,
|
|
62
|
+
}))}
|
|
63
|
+
value={scopeKey(scope)}
|
|
64
|
+
onValueChange={(value) => {
|
|
65
|
+
const next = props.scopes.find((option) => scopeKey(option) === value);
|
|
66
|
+
if (next) props.onScopeChange(next);
|
|
67
|
+
}}
|
|
68
|
+
/>
|
|
69
|
+
) : null}
|
|
70
|
+
<Text style={styles.hint}>New plugins: {props.destination}</Text>
|
|
71
|
+
<Input
|
|
72
|
+
value={props.query}
|
|
73
|
+
onChangeText={props.onQueryChange}
|
|
74
|
+
placeholder="Search plugins"
|
|
75
|
+
accessibilityLabel="Search plugins"
|
|
76
|
+
returnKeyType="search"
|
|
77
|
+
/>
|
|
78
|
+
<ScrollView horizontal showsHorizontalScrollIndicator={false} contentContainerStyle={styles.chips}>
|
|
79
|
+
{[ALL_CATEGORIES, ...props.categories, EXTERNAL_CATEGORY].map((name) => (
|
|
80
|
+
<Button
|
|
81
|
+
key={name}
|
|
82
|
+
size="sm"
|
|
83
|
+
variant={name === props.category ? 'subtle' : 'ghost'}
|
|
84
|
+
accessibilityState={{ selected: name === props.category }}
|
|
85
|
+
onPress={() => props.onCategoryChange(name)}
|
|
86
|
+
>
|
|
87
|
+
{name}
|
|
88
|
+
</Button>
|
|
89
|
+
))}
|
|
90
|
+
</ScrollView>
|
|
91
|
+
</View>
|
|
92
|
+
|
|
93
|
+
{props.offline ? (
|
|
94
|
+
<InfoStrip message={`${scope.host} isn't answering. You can look around; changes wait until it's back.`} />
|
|
95
|
+
) : null}
|
|
96
|
+
{props.justTurnedOn ? (
|
|
97
|
+
<Panel style={styles.done}>
|
|
98
|
+
<CheckIcon size={16} color="green" />
|
|
99
|
+
<Text style={styles.doneText}>{props.justTurnedOn.name} is on. New sessions start with it.</Text>
|
|
100
|
+
<Button variant="ghost" size="sm" onPress={props.onUndo}>
|
|
101
|
+
Undo
|
|
102
|
+
</Button>
|
|
103
|
+
</Panel>
|
|
104
|
+
) : null}
|
|
105
|
+
|
|
106
|
+
{status === 'loading' ? (
|
|
107
|
+
<Group label="Plugins">
|
|
108
|
+
<StateRow title="Loading plugins" description={`Asking ${scope.host} what it has.`} />
|
|
109
|
+
</Group>
|
|
110
|
+
) : status === 'error' ? (
|
|
111
|
+
<Group label="Plugins">
|
|
112
|
+
<StateRow
|
|
113
|
+
title="The plugin list didn't load"
|
|
114
|
+
description={props.error ?? 'Po could not reach the computer.'}
|
|
115
|
+
onRetry={props.onRetry}
|
|
116
|
+
/>
|
|
117
|
+
</Group>
|
|
118
|
+
) : 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
|
+
/>
|
|
123
|
+
) : (
|
|
124
|
+
<Group label="Plugins" hint={`${String(plugins.length)} shown`}>
|
|
125
|
+
{plugins.map((plugin, index) => (
|
|
126
|
+
<Pressable
|
|
127
|
+
key={plugin.id}
|
|
128
|
+
accessibilityRole="button"
|
|
129
|
+
accessibilityLabel={`${plugin.name}. ${plugin.description}`}
|
|
130
|
+
onPress={() => props.onOpen(plugin)}
|
|
131
|
+
style={({ pressed }) => [
|
|
132
|
+
styles.row,
|
|
133
|
+
index < plugins.length - 1 && styles.divider,
|
|
134
|
+
pressed && styles.pressed,
|
|
135
|
+
]}
|
|
136
|
+
>
|
|
137
|
+
<PluginTile icon={plugin.icon} />
|
|
138
|
+
<View style={styles.rowText}>
|
|
139
|
+
<Text style={styles.rowTitle}>{plugin.name}</Text>
|
|
140
|
+
<Text style={styles.rowValue} numberOfLines={2}>
|
|
141
|
+
{plugin.description}
|
|
142
|
+
</Text>
|
|
143
|
+
</View>
|
|
144
|
+
<RowState plugin={plugin} offline={props.offline} onInstall={props.onInstall} onTurnOn={props.onTurnOn} />
|
|
145
|
+
</Pressable>
|
|
146
|
+
))}
|
|
147
|
+
</Group>
|
|
148
|
+
)}
|
|
149
|
+
{props.diagnostics?.length ? (
|
|
150
|
+
<Group label="Needs attention">
|
|
151
|
+
{props.diagnostics.map((diagnostic, index, all) => (
|
|
152
|
+
<Row
|
|
153
|
+
key={`${diagnostic.pluginId}:${diagnostic.kind}:${String(index)}`}
|
|
154
|
+
title={`${diagnostic.pluginId} · ${diagnostic.kind}`}
|
|
155
|
+
description={diagnostic.message}
|
|
156
|
+
last={index === all.length - 1}
|
|
157
|
+
/>
|
|
158
|
+
))}
|
|
159
|
+
</Group>
|
|
160
|
+
) : null}
|
|
161
|
+
</SectionPage>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function RowState({
|
|
166
|
+
plugin,
|
|
167
|
+
offline,
|
|
168
|
+
onInstall,
|
|
169
|
+
onTurnOn,
|
|
170
|
+
}: { plugin: PluginEntry; offline?: boolean } & Pick<PluginCatalogScreenProps, 'onInstall' | 'onTurnOn'>) {
|
|
171
|
+
if (plugin.source !== 'po') {
|
|
172
|
+
const label = domainLabel(plugin);
|
|
173
|
+
return <StatusBadge tone={label === 'Off' ? 'neutral' : 'ok'}>{label}</StatusBadge>;
|
|
174
|
+
}
|
|
175
|
+
if (plugin.install === 'installing') return <Spinner label={`Installing ${plugin.name}`} />;
|
|
176
|
+
if (plugin.install === 'failed') return <StatusBadge tone="error">Couldn't install</StatusBadge>;
|
|
177
|
+
if (plugin.install === 'available') {
|
|
178
|
+
return (
|
|
179
|
+
<Button size="sm" disabled={offline} onPress={() => onInstall(plugin)}>
|
|
180
|
+
Install
|
|
181
|
+
</Button>
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
if (plugin.inPresets.length === 0) {
|
|
185
|
+
return (
|
|
186
|
+
<Button size="sm" disabled={offline} onPress={() => onTurnOn(plugin)}>
|
|
187
|
+
Turn on
|
|
188
|
+
</Button>
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
if (plugin.setup === 'needs-setup') return <StatusBadge tone="accent">Finish setup</StatusBadge>;
|
|
192
|
+
return <StatusBadge tone="ok">On</StatusBadge>;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const styles = StyleSheet.create((theme) => {
|
|
196
|
+
const sans = fontOf(theme.fontFamily.sans);
|
|
197
|
+
return {
|
|
198
|
+
controls: { gap: theme.spacing(3) },
|
|
199
|
+
hint: {
|
|
200
|
+
fontFamily: sans,
|
|
201
|
+
fontSize: theme.fontSize.sm,
|
|
202
|
+
lineHeight: theme.lineHeight.sm,
|
|
203
|
+
color: theme.colors.dim,
|
|
204
|
+
paddingHorizontal: theme.spacing(1),
|
|
205
|
+
},
|
|
206
|
+
chips: { gap: theme.spacing(1) },
|
|
207
|
+
done: {
|
|
208
|
+
flexDirection: 'row',
|
|
209
|
+
alignItems: 'center',
|
|
210
|
+
gap: theme.spacing(2),
|
|
211
|
+
padding: theme.spacing(3),
|
|
212
|
+
backgroundColor: theme.colors['tint-green'],
|
|
213
|
+
borderColor: theme.colors['edge-green'],
|
|
214
|
+
},
|
|
215
|
+
doneText: { flex: 1, fontFamily: sans, fontSize: theme.fontSize.base, color: theme.colors.hi },
|
|
216
|
+
row: {
|
|
217
|
+
flexDirection: 'row',
|
|
218
|
+
alignItems: 'center',
|
|
219
|
+
gap: theme.spacing(3),
|
|
220
|
+
paddingHorizontal: theme.spacing(4),
|
|
221
|
+
paddingVertical: theme.spacing(3),
|
|
222
|
+
minHeight: 44,
|
|
223
|
+
},
|
|
224
|
+
divider: { borderBottomWidth: StyleSheet.hairlineWidth, borderBottomColor: theme.colors['border-soft'] },
|
|
225
|
+
pressed: { backgroundColor: theme.colors['border-soft'] },
|
|
226
|
+
rowText: { flex: 1, minWidth: 0, gap: 2 },
|
|
227
|
+
rowTitle: {
|
|
228
|
+
fontFamily: sans,
|
|
229
|
+
fontSize: theme.fontSize.base,
|
|
230
|
+
lineHeight: theme.lineHeight.base,
|
|
231
|
+
fontWeight: theme.fontWeight.medium,
|
|
232
|
+
color: theme.colors.hi,
|
|
233
|
+
},
|
|
234
|
+
rowValue: {
|
|
235
|
+
fontFamily: sans,
|
|
236
|
+
fontSize: theme.fontSize.sm,
|
|
237
|
+
lineHeight: theme.lineHeightRelaxed.sm,
|
|
238
|
+
color: theme.colors.dim,
|
|
239
|
+
},
|
|
240
|
+
};
|
|
241
|
+
});
|