From 37ae8ce525a2a270fe01cf0caa3c18cec88af263 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Mon, 6 Apr 2026 22:45:00 -0700 Subject: [PATCH] feat: add Star on GitHub button to landing page (#360) Co-authored-by: Claude Opus 4.6 --- src/main/github/client.ts | 41 ++++++++++++++++ src/main/ipc/github.ts | 8 ++- src/preload/index.d.ts | 2 + src/preload/index.ts | 5 +- src/renderer/src/components/Landing.tsx | 65 ++++++++++++++++++++++++- 5 files changed, 118 insertions(+), 3 deletions(-) diff --git a/src/main/github/client.ts b/src/main/github/client.ts index baff4c49c..62cbef92a 100644 --- a/src/main/github/client.ts +++ b/src/main/github/client.ts @@ -12,6 +12,47 @@ import { deriveCheckStatus } from './mappers' +const ORCA_REPO = 'stablyai/orca' + +/** + * Check if the authenticated user has starred the Orca repo. + * Returns true if starred, false if not, null if unable to determine (gh unavailable). + */ +export async function checkOrcaStarred(): Promise { + await acquire() + try { + await execFileAsync('gh', ['api', `user/starred/${ORCA_REPO}`], { encoding: 'utf-8' }) + return true + } catch (err) { + const message = err instanceof Error ? err.message : String(err) + // 404 means the user hasn't starred — the only expected "no" answer + if (message.includes('HTTP 404')) { + return false + } + // Anything else (gh not installed, not authenticated, network issue) + return null + } finally { + release() + } +} + +/** + * Star the Orca repo for the authenticated user. + */ +export async function starOrca(): Promise { + await acquire() + try { + await execFileAsync('gh', ['api', '-X', 'PUT', `user/starred/${ORCA_REPO}`], { + encoding: 'utf-8' + }) + return true + } catch { + return false + } finally { + release() + } +} + /** * Get PR info for a given branch using gh CLI. * Returns null if gh is not installed, or no PR exists for the branch. diff --git a/src/main/ipc/github.ts b/src/main/ipc/github.ts index ed650f75f..59e9cd2d4 100644 --- a/src/main/ipc/github.ts +++ b/src/main/ipc/github.ts @@ -7,7 +7,9 @@ import { listIssues, getPRChecks, updatePRTitle, - mergePR + mergePR, + checkOrcaStarred, + starOrca } from '../github/client' function assertRegisteredRepoPath(repoPath: string, store: Store): string { @@ -71,4 +73,8 @@ export function registerGitHubHandlers(store: Store): void { return mergePR(repoPath, args.prNumber, args.method) } ) + + // Star operations target the Orca repo itself — no repoPath validation needed + ipcMain.handle('gh:checkOrcaStarred', () => checkOrcaStarred()) + ipcMain.handle('gh:starOrca', () => starOrca()) } diff --git a/src/preload/index.d.ts b/src/preload/index.d.ts index 7f1217f14..e309d4ec0 100644 --- a/src/preload/index.d.ts +++ b/src/preload/index.d.ts @@ -81,6 +81,8 @@ type GhApi = { prNumber: number method?: 'merge' | 'squash' | 'rebase' }) => Promise<{ ok: true } | { ok: false; error: string }> + checkOrcaStarred: () => Promise + starOrca: () => Promise } type SettingsApi = { diff --git a/src/preload/index.ts b/src/preload/index.ts index 34cdf5092..a11b20e63 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -220,7 +220,10 @@ const api = { prNumber: number method?: 'merge' | 'squash' | 'rebase' }): Promise<{ ok: true } | { ok: false; error: string }> => - ipcRenderer.invoke('gh:mergePR', args) + ipcRenderer.invoke('gh:mergePR', args), + + checkOrcaStarred: (): Promise => ipcRenderer.invoke('gh:checkOrcaStarred'), + starOrca: (): Promise => ipcRenderer.invoke('gh:starOrca') }, settings: { diff --git a/src/renderer/src/components/Landing.tsx b/src/renderer/src/components/Landing.tsx index 335eeea1d..f927737f7 100644 --- a/src/renderer/src/components/Landing.tsx +++ b/src/renderer/src/components/Landing.tsx @@ -1,5 +1,6 @@ import { useEffect, useMemo, useState } from 'react' -import { AlertTriangle, ExternalLink, FolderPlus, GitBranchPlus } from 'lucide-react' +import { AlertTriangle, ExternalLink, FolderPlus, GitBranchPlus, Star } from 'lucide-react' +import { cn } from '../lib/utils' import { useAppStore } from '../store' import logo from '../../../../resources/logo.svg' @@ -25,6 +26,66 @@ function KeyCap({ label }: { label: string }): React.JSX.Element { ) } +type StarState = 'loading' | 'starred' | 'not-starred' | 'hidden' + +function GitHubStarButton(): React.JSX.Element | null { + const [state, setState] = useState('loading') + + useEffect(() => { + let cancelled = false + void window.api.gh.checkOrcaStarred().then((result) => { + if (cancelled) { + return + } + if (result === null) { + setState('hidden') + } else { + setState(result ? 'starred' : 'not-starred') + } + }) + return () => { + cancelled = true + } + }, []) + + const handleClick = async (): Promise => { + if (state !== 'not-starred') { + return + } + setState('starred') // optimistic + const ok = await window.api.gh.starOrca() + if (!ok) { + setState('not-starred') + } + } + + if (state === 'hidden') { + return null + } + + return ( + + ) +} + function PreflightBanner({ issues }: { issues: PreflightIssue[] }): React.JSX.Element { return (
@@ -129,6 +190,8 @@ export default function Landing(): React.JSX.Element {

ORCA

+ + {preflightIssues.length > 0 && }