From 4a2ff0dcde5f7eab66502008da87e919dfd2b1c8 Mon Sep 17 00:00:00 2001 From: Willie Date: Sun, 4 Oct 2026 22:50:10 +0800 Subject: [PATCH] fix(ui): keep Skillshare-installed Pi plugins out of Pi packages A plugin Skillshare installs from a Git source and binds only to Pi landed in the "Pi packages" list, which is meant for packages Pi installs itself (npm:/git: identifiers with no recorded source). The list now also requires that neither the package nor any binding has a source, so such plugins stay under "Managed by Skillshare". The Pi target's Extensions tab titled those same plugins by their local state path (local:.../skillshare-/content), which does not say which plugin it is. The server already returns the plugin name as managedBy; use it as the card title, keeping the path in the tooltip and details. --- ui/src/components/targets/TargetPiExtensions.test.tsx | 5 +++++ ui/src/components/targets/TargetPiExtensions.tsx | 3 ++- ui/src/pages/PluginsPage.test.tsx | 9 ++++++++- ui/src/pages/PluginsPage.tsx | 8 +++++--- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/ui/src/components/targets/TargetPiExtensions.test.tsx b/ui/src/components/targets/TargetPiExtensions.test.tsx index d0886535e..72bcc7a93 100644 --- a/ui/src/components/targets/TargetPiExtensions.test.tsx +++ b/ui/src/components/targets/TargetPiExtensions.test.tsx @@ -105,6 +105,11 @@ describe('Pi target Extensions tab', () => { expect(screen.queryByText('Package default')).not.toBeInTheDocument(); }); + it('names a package Skillshare installs by its plugin, not its state path', async () => { + show(global({ packages: [{ ...global().packages[0], managedBy: 'superpowers' }] })); + expect(await screen.findByRole('region', { name: 'superpowers' })).toBeInTheDocument(); + }); + it('collapses a package to its header', async () => { const user = userEvent.setup(); show(global()); diff --git a/ui/src/components/targets/TargetPiExtensions.tsx b/ui/src/components/targets/TargetPiExtensions.tsx index a62fc43af..f18bf93dc 100644 --- a/ui/src/components/targets/TargetPiExtensions.tsx +++ b/ui/src/components/targets/TargetPiExtensions.tsx @@ -149,7 +149,8 @@ const isOn = (row: PiExtensionRow, action?: PiExtensionAction) => function PackageCard({ pkg, name, ownsRules, pending, set, t }: { pkg: PiExtensionPackage; name: string; ownsRules: boolean; pending: Record; set: SetAction; t: T }) { const [open, setOpen] = useState(true); const [details, setDetails] = useState(false); - const title = pkg.identity || pkg.source; + // A plugin Skillshare installs is a local path into its state directory: its name says which one. + const title = pkg.managedBy || pkg.identity || pkg.source; const actionOf = (r: PiExtensionRow) => pending[keyOf(pkg.scope, pkg.index, r.path)]; const on = pkg.rows.filter((r) => isOn(r, actionOf(r))).length; const locked = Boolean(pkg.readOnly) || (pkg.rows.length > 0 && pkg.rows.every((r) => !r.editable)); diff --git a/ui/src/pages/PluginsPage.test.tsx b/ui/src/pages/PluginsPage.test.tsx index 009936786..96a5b7f44 100644 --- a/ui/src/pages/PluginsPage.test.tsx +++ b/ui/src/pages/PluginsPage.test.tsx @@ -200,15 +200,22 @@ describe('PluginsPage', () => { { target: 'omo', label: 'omo', project: false, operations: ['add', 'sync'], npm: true }, { target: 'codex', label: 'Codex', project: false, operations: ['add', 'sync'] }, ], - packages: { demo: { bindings: { codex: { id: 'demo@market' } } }, driver: { bindings: { omo: { id: 'npm:@scope/driver' } } } }, + packages: { + demo: { bindings: { codex: { id: 'demo@market' } } }, + driver: { bindings: { omo: { id: 'npm:@scope/driver' } } }, + // Skillshare installs this one from its source, even though only a Pi target has it. + powers: { source: 'owner/powers', bindings: { omo: { id: 'local:/state/powers/content', source: 'owner/powers' } } }, + }, hosts: [], }); mount(); const pi = (await screen.findByRole('heading', { name: 'plugins.piTitle' })).closest('section')!; const managed = screen.getByRole('heading', { name: 'plugins.managedTitle' }).closest('section')!; expect(pi).toHaveTextContent('driver'); + expect(pi).not.toHaveTextContent('powers'); expect(managed).not.toHaveTextContent('driver'); expect(managed).toHaveTextContent('demo'); + expect(managed).toHaveTextContent('powers'); }); it('offers an imported npm package to the other Pi targets, installing it from its identifier', async () => { vi.mocked(pluginsApi.list).mockResolvedValue({ diff --git a/ui/src/pages/PluginsPage.tsx b/ui/src/pages/PluginsPage.tsx index c3df91fbf..6ac82cc42 100644 --- a/ui/src/pages/PluginsPage.tsx +++ b/ui/src/pages/PluginsPage.tsx @@ -135,12 +135,14 @@ export default function PluginsPage() { ], }); }; - // A package bound only to Pi targets is a Pi package: it gets its own list, in the same rows. + // A package Pi installs itself (no source Skillshare copies from) and bound only to Pi targets + // is a Pi package: it gets its own list, in the same rows. A plugin Skillshare installs stays above. const piTargets = new Set((data?.targetDefinitions ?? []).filter((d) => d.npm).map((d) => d.target)); const names = Object.keys(data?.packages ?? {}); const isPi = (name: string) => { - const bound = Object.keys(data!.packages[name].bindings); - return bound.length > 0 && bound.every((target) => piTargets.has(target)); + const pack = data!.packages[name]; + const bound = Object.entries(pack.bindings); + return !pack.source && bound.length > 0 && bound.every(([target, b]) => piTargets.has(target) && !b?.source); }; const piPackages = names.filter(isPi); const plugins = names.filter((name) => !isPi(name));