From fd91f4ea22ca649f9e28b3b3b03247c24d6ea73f Mon Sep 17 00:00:00 2001 From: Gagan Date: Tue, 7 Jul 2026 20:59:02 +0530 Subject: [PATCH] feat(apps): star-ranked catalog, star from Rowboat, delete local apps - catalog is ranked by GitHub star count (per-repo lookup with a 10-min cache; unauthenticated works, the publish token is used when present) - star button on each catalog card stars/unstars the app's repo as the signed-in user (public_repo scope covers it), optimistic with revert and a sign-in hint when signed out - the info panel now offers Delete for local apps (apps:delete already existed and cleans up app-owned agents; only installed apps had a removal button before) --- apps/x/apps/main/src/ipc.ts | 13 +++ .../src/components/apps/app-detail.tsx | 16 +++- .../renderer/src/components/apps/catalog.tsx | 46 ++++++++++- apps/x/packages/core/src/apps/stars.ts | 81 +++++++++++++++++++ apps/x/packages/shared/src/ipc.ts | 12 +++ 5 files changed, 165 insertions(+), 3 deletions(-) create mode 100644 apps/x/packages/core/src/apps/stars.ts diff --git a/apps/x/apps/main/src/ipc.ts b/apps/x/apps/main/src/ipc.ts index 6c60ea63..febe3e91 100644 --- a/apps/x/apps/main/src/ipc.ts +++ b/apps/x/apps/main/src/ipc.ts @@ -67,6 +67,7 @@ import * as appsServer from '@x/core/dist/apps/server.js'; import * as appsAgents from '@x/core/dist/apps/agents.js'; import { capture } from '@x/core/dist/analytics/posthog.js'; import * as githubAuth from '@x/core/dist/apps/github-auth.js'; +import * as appsStars from '@x/core/dist/apps/stars.js'; import * as appsInstaller from '@x/core/dist/apps/installer.js'; import { registryClient } from '@x/core/dist/apps/registry.js'; import * as appsPublisher from '@x/core/dist/apps/publisher.js'; @@ -1616,6 +1617,18 @@ export function setupIpcHandlers() { 'apps:catalogSearch': async (_event, args) => { return { records: await registryClient.search(args.query) }; }, + 'apps:catalogStars': async (_event, args) => { + const [stars, starred] = await Promise.all([ + appsStars.repoStars(args.repos), + appsStars.starredStatus(args.repos), + ]); + return { stars, starred }; + }, + 'apps:star': async (_event, args) => { + const result = await appsStars.setStar(args.repo, args.star); + capture('app_starred', { repo: args.repo, star: args.star }); + return result; + }, 'apps:catalogDetail': async (_event, args) => { const record = await registryClient.resolve(args.name); if (!record) throw new Error(`no such app in the catalog: ${args.name}`); diff --git a/apps/x/apps/renderer/src/components/apps/app-detail.tsx b/apps/x/apps/renderer/src/components/apps/app-detail.tsx index 6e8aa554..5304c81d 100644 --- a/apps/x/apps/renderer/src/components/apps/app-detail.tsx +++ b/apps/x/apps/renderer/src/components/apps/app-detail.tsx @@ -81,6 +81,15 @@ export function AppDetail({ folder, onClose }: { folder: string; onClose: () => onClose() }) + // Local apps aren't "installed", so they get delete instead of uninstall. + const doDelete = () => runAction('delete', async () => { + const agentNote = agents.length ? `\n\nThis also deletes its background agents: ${agents.map((a) => a.name).join(', ')}.` : '' + const publishNote = app?.publish ? '\n\nThe published copy (GitHub repo + catalog listing) is not touched.' : '' + if (!window.confirm(`Delete this app? The whole folder, including data/, is removed from this machine.${publishNote}${agentNote}`)) return + await window.ipc.invoke('apps:delete', { folder }) + onClose() + }) + useEffect(() => { let cancelled = false ;(async () => { @@ -217,11 +226,16 @@ export function AppDetail({ folder, onClose }: { folder: string; onClose: () => {app.publish ? 'Publish update' : 'Publish'} )} - {app.kind === 'installed' && ( + {app.kind === 'installed' ? ( + ) : ( + )} diff --git a/apps/x/apps/renderer/src/components/apps/catalog.tsx b/apps/x/apps/renderer/src/components/apps/catalog.tsx index 99bdda2c..3741f56a 100644 --- a/apps/x/apps/renderer/src/components/apps/catalog.tsx +++ b/apps/x/apps/renderer/src/components/apps/catalog.tsx @@ -1,5 +1,5 @@ import { useEffect, useState } from 'react' -import { BadgeCheck, Bot, Download, Link2, RefreshCw, Search, ShieldAlert } from 'lucide-react' +import { BadgeCheck, Bot, Download, Link2, RefreshCw, Search, ShieldAlert, Star } from 'lucide-react' import type { rowboatApp } from '@x/shared' // Catalog tab (spec §14): search the registry, install with the D18 capability @@ -162,6 +162,35 @@ export function CatalogTab({ onInstalled }: { onInstalled: (folder: string) => v const [enabling, setEnabling] = useState(false) // Registry name → local folder, for apps already installed from the catalog. const [installedByName, setInstalledByName] = useState>(new Map()) + // GitHub star counts rank the list; `starred` is the signed-in user's set. + const [stars, setStars] = useState>({}) + const [starred, setStarred] = useState>({}) + + const loadStars = async (recs: rowboatApp.RegistryRecord[]) => { + if (recs.length === 0) return + try { + const r = await window.ipc.invoke('apps:catalogStars', { repos: recs.map((x) => x.repo) }) + setStars((prev) => ({ ...prev, ...r.stars })) + setStarred((prev) => ({ ...prev, ...r.starred })) + } catch { /* unranked list is fine */ } + } + + const toggleStar = async (repo: string) => { + const next = !starred[repo] + // Optimistic; revert on failure. + setStarred((prev) => ({ ...prev, [repo]: next })) + setStars((prev) => ({ ...prev, [repo]: Math.max(0, (prev[repo] ?? 0) + (next ? 1 : -1)) })) + try { + await window.ipc.invoke('apps:star', { repo, star: next }) + } catch (e) { + setStarred((prev) => ({ ...prev, [repo]: !next })) + setStars((prev) => ({ ...prev, [repo]: Math.max(0, (prev[repo] ?? 0) + (next ? -1 : 1)) })) + const msg = e instanceof Error ? e.message : String(e) + setError(msg.includes('not_signed_in') + ? 'Starring uses your GitHub account — sign in once via any app’s Publish flow, then try again.' + : msg) + } + } const loadInstalled = async () => { try { @@ -179,6 +208,7 @@ export function CatalogTab({ onInstalled }: { onInstalled: (folder: string) => v const r = await window.ipc.invoke('apps:catalogIndex', { force }) setRecords(r.records) setStale(r.stale) + void loadStars(r.records) } catch (e) { setError(e instanceof Error ? e.message : String(e)) } @@ -192,9 +222,14 @@ export function CatalogTab({ onInstalled }: { onInstalled: (folder: string) => v ? await window.ipc.invoke('apps:catalogSearch', { query: q }) : await window.ipc.invoke('apps:catalogIndex', {}) setRecords(r.records) + void loadStars(r.records) } catch { /* keep current list */ } } + // Rank by stars (unknown counts sink), name as the stable tiebreak. + const ranked = [...records].sort((a, b) => + ((stars[b.repo] ?? -1) - (stars[a.repo] ?? -1)) || a.name.localeCompare(b.name)) + const startInstall = async (name: string) => { setError(null) try { @@ -304,7 +339,7 @@ export function CatalogTab({ onInstalled }: { onInstalled: (folder: string) => v ) : (
- {records.map((r) => ( + {ranked.map((r) => (
@@ -313,6 +348,13 @@ export function CatalogTab({ onInstalled }: { onInstalled: (folder: string) => v

{r.description || 'No description.'}

+ {installedByName.has(r.name) ? (