YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix(app): add actions to recent Pi packages (#5337)
Louis Beaumontedc5c75b8176
diff --git a/apps/screenpipe-app-tauri/components/settings/__tests__/pi-extensions-card.test.tsx b/apps/screenpipe-app-tauri/components/settings/__tests__/pi-extensions-card.test.tsxindex 30cfbbc61..771ca4dc9 100644--- a/apps/screenpipe-app-tauri/components/settings/__tests__/pi-extensions-card.test.tsx+++ b/apps/screenpipe-app-tauri/components/settings/__tests__/pi-extensions-card.test.tsx@@ -157,6 +157,43 @@ describe("PiExtensionsCard", () => {);});+ it("installs a recently published package directly from its compact card", async () => {+ commandMocks.piInstallExtensionPackage.mockResolvedValueOnce({+ status: "ok",+ data: packageList("npm:pi-subagents", "npm:@example/pi-recent-tool"),+ });+ vi.mocked(fetch).mockResolvedValueOnce({+ ok: true,+ json: async () => ({+ total: 1,+ objects: [+ {+ package: {+ name: "@example/pi-recent-tool",+ description: "A newly published Pi package.",+ date: new Date().toISOString(),+ keywords: ["pi-package"],+ links: {+ npm: "https://www.npmjs.com/package/@example/pi-recent-tool",+ },+ },+ },+ ],+ }),+ } as Response);+ render(<PiExtensionsCard />);++ expect(await screen.findByText("Recently published")).toBeInTheDocument();+ fireEvent.click(screen.getByRole("button", { name: "Add Recent Tool" }));++ await waitFor(() =>+ expect(commandMocks.piInstallExtensionPackage).toHaveBeenCalledWith(+ "npm:@example/pi-recent-tool",+ ),+ );+ expect(await screen.findByRole("button", { name: "Remove Recent Tool" })).toBeInTheDocument();+ });+it("locks other extension toggles while a package change is in flight", async () => {let resolveInstall: (value: {status: "ok";diff --git a/apps/screenpipe-app-tauri/components/settings/pi-extensions-card.tsx b/apps/screenpipe-app-tauri/components/settings/pi-extensions-card.tsxindex 517ccae2a..91ee70443 100644--- a/apps/screenpipe-app-tauri/components/settings/pi-extensions-card.tsx+++ b/apps/screenpipe-app-tauri/components/settings/pi-extensions-card.tsx@@ -155,31 +155,66 @@ function PiExtensionRow({);}-function PiExtensionRecentCard({ item }: { item: PiExtensionCatalogItem }) {+function PiExtensionRecentCard({+ item,+ enabled,+ stale,+ busy,+ disabled,+ onToggle,+}: {+ item: PiExtensionCatalogItem;+ enabled: boolean;+ stale: boolean;+ busy: boolean;+ disabled: boolean;+ onToggle: (checked: boolean) => void;+}) {const published = relativeDate(item.publishedAt);+ const packageName = item.source.replace(/^npm:/, "");+ const action = stale ? "repair" : enabled ? "remove" : "add";return (- <button- type="button"- onClick={() => openUrl(item.npmUrl)}- className="min-w-0 border border-border bg-card p-3 text-left transition-colors hover:border-foreground/30 hover:bg-muted/30"- >+ <article className="flex min-h-[132px] min-w-0 flex-col border border-border bg-card p-3 transition-colors hover:border-foreground/30"><div className="flex items-start justify-between gap-2"><span className="min-w-0 truncate font-mono text-xs font-medium text-foreground">- {item.source.replace(/^npm:/, "")}+ {packageName}</span>- <ExternalLink className="h-3 w-3 shrink-0 text-muted-foreground" />+ <button+ type="button"+ onClick={() => openUrl(item.npmUrl)}+ aria-label={`Open ${item.name} on npm`}+ className="shrink-0 text-muted-foreground transition-colors hover:text-foreground"+ >+ <ExternalLink className="h-3 w-3" />+ </button></div><p className="mt-1 line-clamp-2 text-[11px] leading-relaxed text-muted-foreground">{item.summary}</p>- {published && (- <span className="mt-2 inline-flex items-center gap-1 text-[10px] text-muted-foreground">- <Clock3 className="h-3 w-3" />- {published}- </span>- )}- </button>+ <div className="mt-auto flex items-end justify-between gap-2 pt-2">+ {published ? (+ <span className="inline-flex items-center gap-1 text-[10px] text-muted-foreground">+ <Clock3 className="h-3 w-3" />+ {published}+ </span>+ ) : (+ <span />+ )}+ <Button+ type="button"+ variant={enabled && !stale ? "ghost" : "outline"}+ size="sm"+ disabled={disabled || busy}+ onClick={() => onToggle(stale || !enabled)}+ aria-label={`${action.charAt(0).toUpperCase()}${action.slice(1)} ${item.name}`}+ className="h-6 px-2 text-[10px] uppercase tracking-[0.12em]"+ >+ {busy && <Loader2 className="h-3 w-3 animate-spin" />}+ {action}+ </Button>+ </div>+ </article>);}@@ -467,9 +502,20 @@ export function PiExtensionsCard({ onChanged }: { onChanged?: () => void }) {</span></div><div className="grid grid-cols-1 gap-2 md:grid-cols-2 xl:grid-cols-4">- {recentRegistryItems.map((item) => (- <PiExtensionRecentCard key={`recent-${item.id}`} item={item} />- ))}+ {recentRegistryItems.map((item) => {+ const normalized = normalizePiPackageSource(item.source);+ return (+ <PiExtensionRecentCard+ key={`recent-${item.id}`}+ item={item}+ enabled={configuredSources.has(normalized)}+ stale={missingSources.has(normalized)}+ busy={busySource === item.source}+ disabled={changingPackage && busySource !== item.source}+ onToggle={(checked) => togglePackage(item, checked)}+ />+ );+ })}</div></div>)}