graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
Add Reviews pane, claim chips, and open Appearance from the sidebar
Racha293369384ed
diff --git a/apps/native/app/api/claims/route.ts b/apps/native/app/api/claims/route.tsnew file mode 100644index 00000000..3f1100b0--- /dev/null+++ b/apps/native/app/api/claims/route.ts@@ -0,0 +1,29 @@+import { readFile } from "node:fs/promises";+import path from "node:path";+import { NextRequest } from "next/server";+import { resolveRoot } from "@/lib/server-root";++export const runtime = "nodejs";+export const dynamic = "force-dynamic";++export type ClaimRow = { kind: string; key: string; session: string; pid: number };++export async function GET(req: NextRequest) {+ const resolved = resolveRoot(req.nextUrl.searchParams.get("root"));+ if ("error" in resolved) return Response.json({ error: resolved.error }, { status: resolved.status });+ try {+ const text = await readFile(path.join(resolved.root, ".graff", "artifact-claims.json"), "utf8");+ const parsed = JSON.parse(text) as unknown;+ const claims: ClaimRow[] = Array.isArray(parsed) ? parsed.flatMap((item) => {+ if (!item || typeof item !== "object") return [];+ const rec = item as { kind?: unknown; key?: unknown; session?: unknown; pid?: unknown };+ if (typeof rec.kind !== "string" || typeof rec.key !== "string" || typeof rec.session !== "string") return [];+ return [{ kind: rec.kind, key: rec.key, session: rec.session, pid: typeof rec.pid === "number" ? rec.pid : 0 }];+ }) : [];+ return Response.json({ ok: true, claims });+ } catch (error) {+ const code = error && typeof error === "object" && "code" in error ? (error as { code?: string }).code : "";+ if (code === "ENOENT") return Response.json({ ok: true, claims: [] });+ return Response.json({ error: error instanceof Error ? error.message : String(error) }, { status: 500 });+ }+}diff --git a/apps/native/app/api/reviews/route.ts b/apps/native/app/api/reviews/route.tsnew file mode 100644index 00000000..d37f1c18--- /dev/null+++ b/apps/native/app/api/reviews/route.ts@@ -0,0 +1,53 @@+import { execFile } from "node:child_process";+import { promisify } from "node:util";+import { NextRequest } from "next/server";+import { parsePrList } from "@/lib/github-reviews";+import { resolveRoot } from "@/lib/server-root";++export const runtime = "nodejs";+export const dynamic = "force-dynamic";+const run = promisify(execFile);++async function gh(root: string, args: string[]) {+ return run("gh", args, { cwd: root, timeout: 20000, encoding: "utf8" });+}++export async function GET(req: NextRequest) {+ const resolved = resolveRoot(req.nextUrl.searchParams.get("root"));+ if ("error" in resolved) return Response.json({ error: resolved.error }, { status: resolved.status });+ try {+ await gh(resolved.root, ["auth", "status"]);+ } catch {+ return Response.json({ ok: false, needAuth: true, prs: [] });+ }+ const number = req.nextUrl.searchParams.get("number");+ try {+ if (number) {+ const { stdout } = await gh(resolved.root, ["pr", "view", number, "--json", "number,title,author,url,isDraft,reviewDecision,headRefName,statusCheckRollup,body,reviews,comments"]);+ return Response.json({ ok: true, pr: JSON.parse(stdout) });+ }+ const { stdout } = await gh(resolved.root, ["pr", "list", "--json", "number,title,author,url,isDraft,reviewDecision,headRefName,statusCheckRollup"]);+ return Response.json({ ok: true, needAuth: false, prs: parsePrList(JSON.parse(stdout)) });+ } catch (error) {+ return Response.json({ error: error instanceof Error ? error.message : String(error) }, { status: 500 });+ }+}++export async function POST(req: Request) {+ const body = await req.json().catch(() => null);+ if (!body || typeof body !== "object") return Response.json({ error: "expected JSON" }, { status: 400 });+ const resolved = resolveRoot(typeof body.root === "string" ? body.root : null);+ if ("error" in resolved) return Response.json({ error: resolved.error }, { status: resolved.status });+ const number = String(body.number ?? "");+ const event = body.event === "APPROVE" ? "approve" : body.event === "REQUEST_CHANGES" ? "request-changes" : "comment";+ const text = typeof body.body === "string" ? body.body : "";+ if (!/^\d+$/.test(number)) return Response.json({ error: "invalid pull request" }, { status: 400 });+ try {+ const args = ["pr", "review", number, `--${event}`];+ if (text) args.push("--body", text);+ await gh(resolved.root, args);+ return Response.json({ ok: true });+ } catch (error) {+ return Response.json({ error: error instanceof Error ? error.message : String(error) }, { status: 500 });+ }+}diff --git a/apps/native/components/site/AppSettings.tsx b/apps/native/components/site/AppSettings.tsxindex 709f88f9..89cc08ef 100644--- a/apps/native/components/site/AppSettings.tsx+++ b/apps/native/components/site/AppSettings.tsx@@ -3,8 +3,8 @@ import { ThemeToggle } from "./ThemeToggle";import McpServers from "./McpServers";export default function AppSettings({ sidebar = false }: { sidebar?: boolean }) {- return <span className={sidebar ? "mx-2 flex shrink-0 items-center justify-end gap-1 border-t border-line pt-2" : "flex shrink-0 items-center"}>- <ThemeToggle />- <McpServers />+ return <span className={sidebar ? "mx-2 flex shrink-0 flex-col gap-0.5 border-t border-line pt-2" : "flex shrink-0 items-center"}>+ <ThemeToggle labeled={sidebar} />+ <McpServers labeled={sidebar} /></span>;}diff --git a/apps/native/components/site/ChatSplitLayout.tsx b/apps/native/components/site/ChatSplitLayout.tsxindex 22fb27ff..1bfdab07 100644--- a/apps/native/components/site/ChatSplitLayout.tsx+++ b/apps/native/components/site/ChatSplitLayout.tsx@@ -6,11 +6,12 @@ import { createComposerDraft, type ComposerDraftStore } from "@/lib/composer-draimport SplitDivider from "./SplitDivider";import paneStyles from "./chat-pane.module.css";import {flatSplit,pruneSplit,splitGeometry,paneStyle,type SplitTree} from "@/lib/split-tree";-export default function ChatSplitLayout({ threads, liveChatIds, activeId, direction, layout, onLayoutChange, onFocus, onClose, folder, body, split }: {+export default function ChatSplitLayout({ threads, liveChatIds, activeId, direction, layout, onLayoutChange, onFocus, onClose, folder, body, split, claims = [] }: {threads: Chat[]; activeId: number; direction: "row" | "column"; layout?: SplitTree;liveChatIds?: number[];onLayoutChange(tree:SplitTree):void; onFocus(id: number): void; onClose(id: number): void;folder(thread: Chat): { name: string; path?: string }; body(thread: Chat): ReactNode; split: boolean;+ claims?: { kind: string; key: string; session: string }[];}) {const drafts = useRef(new Map<number, ComposerDraftStore>());const liveKey = liveChatIds?.join(",");@@ -43,10 +44,14 @@ export default function ChatSplitLayout({ threads, liveChatIds, activeId, directonFocusCapture={()=>{if(thread.id!==activeId)onFocus(thread.id);}}style={{...paneStyle(geometry.panes.find(p=>p.id===thread.id)!.box),minHeight:0,borderColor:split&&thread.id===activeId?'var(--accent)':undefined}}className={`${paneStyles.pane} absolute flex min-w-0 flex-col overflow-hidden border border-line bg-page ${split ? "rounded-[6px]" : "rounded-[14px]"}`}>- {split&&<header className="flex h-9 shrink-0 items-center gap-2 border-b border-line px-3">- <button type="button" aria-pressed={thread.id===activeId} onClick={()=>onFocus(thread.id)} title="Focus this chat" className="min-w-0 flex-1 truncate text-left text-xs font-medium">{thread.title??`Chat ${thread.id}`}</button>- <span title={folder(thread).path} className="flex min-w-0 max-w-[40%] items-center gap-1 text-[11px] text-ink-3"><IconFolder size={13}/><span className="truncate">{folder(thread).name}</span></span>- <button type="button" aria-label="Close this split" title="Close this chat (⌘W)" onClick={()=>onClose(thread.id)} className="flex size-6 shrink-0 items-center justify-center rounded text-ink-3 hover:bg-hover hover:text-ink">×</button>+ {(split || claims.some(claim => claim.session === thread.session)) && <header className="flex h-9 shrink-0 items-center gap-2 border-b border-line px-3">+ {split && <button type="button" aria-pressed={thread.id===activeId} onClick={()=>onFocus(thread.id)} title="Focus this chat" className="min-w-0 flex-1 truncate text-left text-xs font-medium">{thread.title??`Chat ${thread.id}`}</button>}+ {!split && <span className="min-w-0 flex-1" />}+ {claims.filter(claim => claim.session === thread.session).slice(0, 1).map(claim =>+ <span key={`${claim.kind}:${claim.key}`} title={`${claim.kind} ${claim.key}`} className="max-w-[45%] truncate rounded-full bg-inset px-2 py-0.5 text-[10px] text-ink-3">{claim.kind === "pull_request" ? `PR ${claim.key}` : claim.kind === "issue" ? `#${claim.key}` : claim.key}</span>+ )}+ {split && <span title={folder(thread).path} className="flex min-w-0 max-w-[40%] items-center gap-1 text-[11px] text-ink-3"><IconFolder size={13}/><span className="truncate">{folder(thread).name}</span></span>}+ {split && <button type="button" aria-label="Close this split" title="Close this chat (⌘W)" onClick={()=>onClose(thread.id)} className="flex size-6 shrink-0 items-center justify-center rounded text-ink-3 hover:bg-hover hover:text-ink">×</button>}</header>}<ComposerDraftContext.Provider value={draftFor(thread.id)}>{body(thread)}</ComposerDraftContext.Provider></section>diff --git a/apps/native/components/site/GraffHarness.tsx b/apps/native/components/site/GraffHarness.tsxindex 83ba871e..ea39f17f 100644--- a/apps/native/components/site/GraffHarness.tsx+++ b/apps/native/components/site/GraffHarness.tsx@@ -22,6 +22,7 @@ import { sidebarRecents } from "./harness-sidebar";import AgentsPane from "./AgentsPane";import { newPageToken, newSessionName, type Chat, type Msg } from "./harness-types";import ChangesPane from "./ChangesPane";+import ReviewsPane from "./ReviewsPane";import { useBrowserVisibility } from "./useBrowserVisibility";import { useCallback, useEffect, useMemo, useRef, useState } from "react";import { type PromptModel } from "@/components/primitives/PromptBar";@@ -88,6 +89,8 @@ export default function GraffHarness() {const [workingAgents, setWorkingAgents] = useState(0);const [tasksOpen, setTasksOpen] = useTasksVisibility();const [filesOpen, setFilesOpen] = useState(false);+ const [reviewsOpen, setReviewsOpen] = useState(false);+ const [claims, setClaims] = useState<{ kind: string; key: string; session: string }[]>([]);const [fileRequest, setFileRequest] = useState<{ path: string; n: number; changes?: boolean } | null>(null);const fileReqRef = useRef(0);// Shell-style prompt recall (ArrowUp in the composer), kept per browser so@@ -407,6 +410,19 @@ export default function GraffHarness() {return findWorkspace(workspaces, dir)?.name ?? (dir ? basename(dir) : "workspace");};const chatCwd = cwdOf(chatThread);+ useEffect(() => {+ let alive = true;+ const tick = () => {+ const params = new URLSearchParams();+ if (chatCwd) params.set("root", chatCwd);+ void fetch(`/api/claims?${params}`, { cache: "no-store" }).then((response) => response.json()).then((body: { claims?: { kind: string; key: string; session: string }[] }) => {+ if (alive && Array.isArray(body.claims)) setClaims(body.claims);+ }).catch(() => {});+ };+ tick();+ const id = setInterval(tick, 5000);+ return () => { alive = false; clearInterval(id); };+ }, [chatCwd]);const chatWorkspace = findWorkspace(workspaces, chatCwd);const workspaceName = chatWorkspace?.name ?? (chatCwd ? basename(chatCwd) : "workspace");const pinCount = (pinsByChat[chatThread.id] ?? []).length;@@ -426,7 +442,7 @@ export default function GraffHarness() {});const columnBody = (thread: Chat) => <ChatColumn key={thread.id} thread={thread}- compact={columnIds.length > 1 || navigation.focusedMode || filesOpen || browserOpen || agentsOpen} following={tailing[thread.id] ?? true} register={paneRef(thread.id)}+ compact={columnIds.length > 1 || navigation.focusedMode || filesOpen || browserOpen || agentsOpen || reviewsOpen || !!(fileRequest?.changes)} following={tailing[thread.id] ?? true} register={paneRef(thread.id)}onOpenPath={openPath} onReview={openChanges}onRefresh={loaded => {const messages: Msg[] = loaded.messages.map(m => ({ id: ++msgIdRef.current, ...m }));@@ -530,6 +546,7 @@ export default function GraffHarness() {conversationsOpen={conversationsOpen} openConversations={openConversations} split={panes.length > 0} toggleSplit={toggleSplit}filesOpen={filesOpen} onFiles={() => { setAgentsOpen(false); setFileRequest(null); setProjectsOpen(false); setBrowserOpen(false); setConversationsOpen(false); setFilesOpen(fileRequest?.changes ? true : !filesOpen); }}chatCwd={chatCwd} workspaceName={workspaceName} onFolder={() => setDialog({ mode: "new" })} openChanges={toggleChanges} changesOpen={!!(filesOpen && fileRequest?.changes)}+ reviewsOpen={reviewsOpen} onReviews={() => { setAgentsOpen(false); setProjectsOpen(false); setBrowserOpen(false); setConversationsOpen(false); setFilesOpen(false); setReviewsOpen(open => !open); }}browserOpen={browserOpen} onBrowser={() => { setAgentsOpen(false); setProjectsOpen(false); setConversationsOpen(false); setFilesOpen(false); setBrowserOpen(open => !open); }} pinCount={pinCount}terminalVisible={terminalVisible} toggleTerminal={toggleTerminal} agentsOpen={agentsOpen}workingAgents={workingAgents}@@ -559,11 +576,12 @@ export default function GraffHarness() {<div className="min-h-0 min-w-0 flex-1" style={{ display: projectsOpen || conversationsOpen || agentsOpen ? "none" : "flex" }}><ChatSplitLayout threads={columns} liveChatIds={chats.map(chat => chat.id)} activeId={activeId} direction={splitDirection} layout={groups.tree} onLayoutChange={groups.setTree}onFocus={id => focusChat(id, false)} onClose={closeChat} folder={thread => ({name: workspaceNameOf(thread), path: cwdOf(thread)})}- body={columnBody} split={columnIds.length > 1} />+ body={columnBody} split={columnIds.length > 1} claims={claims} /></div>{agentsOpen && !projectsOpen && !filesOpen && !browserOpen && !conversationsOpen && <AgentsPane key={chatCwd} root={chatCwd} fullWidth onOccupancy={setWorkingAgents} onClose={() => setAgentsOpen(false)} />}- {filesOpen && !projectsOpen && !conversationsOpen && (fileRequest?.changes ? <ChangesPane root={chatThread.cwd} onClose={() => setFilesOpen(false)} /> : <FilesPane root={chatThread.cwd} requested={fileRequest} onClose={() => setFilesOpen(false)} />)}+ {filesOpen && !projectsOpen && !conversationsOpen && !reviewsOpen && (fileRequest?.changes ? <ChangesPane root={chatThread.cwd} onClose={() => setFilesOpen(false)} /> : <FilesPane root={chatThread.cwd} requested={fileRequest} onClose={() => setFilesOpen(false)} />)}+ {reviewsOpen && !projectsOpen && !conversationsOpen && <ReviewsPane root={chatThread.cwd} onClose={() => setReviewsOpen(false)} />}{browserOpen && !projectsOpen && !conversationsOpen && (<BrowserPanediff --git a/apps/native/components/site/HarnessChrome.tsx b/apps/native/components/site/HarnessChrome.tsxindex 092c0fe5..2d4041d3 100644--- a/apps/native/components/site/HarnessChrome.tsx+++ b/apps/native/components/site/HarnessChrome.tsx@@ -14,7 +14,7 @@ type Props = {focusChat(id: number): void; closeChat(id: number): void; newChat(): void;conversationsOpen: boolean; openConversations(): void; split: boolean; toggleSplit(): void;filesOpen: boolean; onFiles(): void; chatCwd?: string; workspaceName: string; onFolder(): void;- openChanges(): void; changesOpen?: boolean; browserOpen: boolean; onBrowser(): void; pinCount: number;+ openChanges(): void; changesOpen?: boolean; reviewsOpen?: boolean; onReviews?: () => void; browserOpen: boolean; onBrowser(): void; pinCount: number;terminalVisible: boolean; toggleTerminal(): void; agentsOpen: boolean; onAgents(): void; workingAgents?: number;tasksOpen?: boolean; taskCount?: number; onTasks?: () => void; splitNotice?: string | null;};@@ -23,14 +23,15 @@ function paneBtn(pressed: boolean) {return `h-7 shrink-0 rounded-[7px] px-2.5 text-[12.5px] font-medium ${pressed ? "bg-hover-2 text-ink" : "text-ink-2 hover:bg-hover"}`;}-function PaneGroup({ filesOpen, changesOpen, browserOpen, terminalVisible, pinCount, onFiles, openChanges, onBrowser, toggleTerminal, taskCount, tasksOpen, onTasks }: {- filesOpen: boolean; changesOpen: boolean; browserOpen: boolean; terminalVisible: boolean; pinCount: number;- onFiles(): void; openChanges(): void; onBrowser(): void; toggleTerminal(): void;+function PaneGroup({ filesOpen, changesOpen, reviewsOpen, browserOpen, terminalVisible, pinCount, onFiles, openChanges, onReviews, onBrowser, toggleTerminal, taskCount, tasksOpen, onTasks }: {+ filesOpen: boolean; changesOpen: boolean; reviewsOpen: boolean; browserOpen: boolean; terminalVisible: boolean; pinCount: number;+ onFiles(): void; openChanges(): void; onReviews(): void; onBrowser(): void; toggleTerminal(): void;taskCount: number; tasksOpen: boolean; onTasks?: () => void;}) {return <><button type="button" aria-label="Files" aria-pressed={filesOpen && !changesOpen} onClick={onFiles} className={paneBtn(filesOpen && !changesOpen)}>Files</button><button type="button" aria-label="Review workspace changes" aria-pressed={changesOpen} onClick={openChanges} className={paneBtn(changesOpen)}>Changes</button>+ <button type="button" aria-label="GitHub reviews" aria-pressed={reviewsOpen} onClick={onReviews} className={paneBtn(reviewsOpen)}>Reviews</button><button type="button" aria-label="Browser" aria-pressed={browserOpen} onClick={onBrowser} className={paneBtn(browserOpen)}>Browser{pinCount > 0 ? ` (${pinCount})` : ""}</button><button type="button" aria-label="Toggle terminal" aria-pressed={terminalVisible} onClick={toggleTerminal} className={paneBtn(terminalVisible)}>Terminal</button>{(taskCount > 0 || tasksOpen) && onTasks && <button type="button" aria-label="Show tasks" aria-pressed={tasksOpen} onClick={onTasks} className={paneBtn(tasksOpen)}>Tasks{taskCount ? ` (${taskCount})` : ""}</button>}@@ -39,9 +40,9 @@ function PaneGroup({ filesOpen, changesOpen, browserOpen, terminalVisible, pinCoexport default function HarnessChrome({navigationToggle, sidebarVisible = false, unreadIds, chats, activeId, busyIds, focusChat, closeChat, newChat,conversationsOpen, openConversations, split, toggleSplit, filesOpen, onFiles, chatCwd,- workspaceName, onFolder, openChanges, changesOpen = false, browserOpen, onBrowser, pinCount, terminalVisible,+ workspaceName, onFolder, openChanges, changesOpen = false, reviewsOpen = false, onReviews, browserOpen, onBrowser, pinCount, terminalVisible,toggleTerminal, agentsOpen, onAgents, workingAgents = 0, tasksOpen = false, taskCount = 0, onTasks, splitNotice, onTabPointerDown, onTabClickCapture}: Props) {- const panes = <PaneGroup filesOpen={filesOpen} changesOpen={changesOpen} browserOpen={browserOpen} terminalVisible={terminalVisible} pinCount={pinCount} onFiles={onFiles} openChanges={openChanges} onBrowser={onBrowser} toggleTerminal={toggleTerminal} taskCount={taskCount} tasksOpen={tasksOpen} onTasks={onTasks} />;+ const panes = <PaneGroup filesOpen={filesOpen} changesOpen={changesOpen} reviewsOpen={reviewsOpen} browserOpen={browserOpen} terminalVisible={terminalVisible} pinCount={pinCount} onFiles={onFiles} openChanges={openChanges} onReviews={onReviews ?? (() => {})} onBrowser={onBrowser} toggleTerminal={toggleTerminal} taskCount={taskCount} tasksOpen={tasksOpen} onTasks={onTasks} />;const more = <ActionMenu label="Chat actions" text="More" className="shrink-0">{!sidebarVisible && <button type="button" onClick={newChat}>New chat <span className="ml-auto text-ink-3">⌘T</span></button>}<button type="button" aria-pressed={split} onClick={toggleSplit}>{split ? "Close splits" : "Split view"} <span className="ml-auto text-ink-3">⌘\</span></button>diff --git a/apps/native/components/site/ReviewsPane.tsx b/apps/native/components/site/ReviewsPane.tsxnew file mode 100644index 00000000..c87ab848--- /dev/null+++ b/apps/native/components/site/ReviewsPane.tsx@@ -0,0 +1,91 @@+"use client";+import { useEffect, useState } from "react";+import ResizableReviewPane from "./ResizableReviewPane";+import type { ReviewPr } from "@/lib/github-reviews";++export default function ReviewsPane({ root, onClose }: { root?: string; onClose(): void }) {+ const [prs, setPrs] = useState<ReviewPr[]>([]);+ const [needAuth, setNeedAuth] = useState(false);+ const [error, setError] = useState("");+ const [selected, setSelected] = useState<number | null>(null);+ const [comment, setComment] = useState("");+ const [busy, setBusy] = useState(false);++ const load = async () => {+ setError("");+ const params = new URLSearchParams();+ if (root) params.set("root", root);+ const response = await fetch(`/api/reviews?${params}`, { cache: "no-store" });+ const body = await response.json() as { ok?: boolean; needAuth?: boolean; prs?: ReviewPr[]; error?: string };+ if (!response.ok) throw new Error(body.error ?? "Could not load reviews.");+ setNeedAuth(body.needAuth === true);+ setPrs(body.prs ?? []);+ };++ useEffect(() => {+ let alive = true;+ void load().catch((err: unknown) => { if (alive) setError(err instanceof Error ? err.message : "Could not load reviews."); });+ return () => { alive = false; };+ }, [root]);++ const review = async (event: "APPROVE" | "COMMENT" | "REQUEST_CHANGES") => {+ if (selected == null) return;+ setBusy(true); setError("");+ try {+ const response = await fetch("/api/reviews", {+ method: "POST",+ headers: { "content-type": "application/json" },+ body: JSON.stringify({ root, number: selected, event, body: comment }),+ });+ const body = await response.json() as { error?: string };+ if (!response.ok) throw new Error(body.error ?? "Could not submit review.");+ setComment("");+ await load();+ } catch (err) {+ setError(err instanceof Error ? err.message : "Could not submit review.");+ } finally { setBusy(false); }+ };++ const current = prs.find((pr) => pr.number === selected);+ return <ResizableReviewPane label="reviews">+ <section aria-label="Reviews" className="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden rounded-[14px] border border-line bg-page">+ <header className="flex h-10 shrink-0 items-center gap-2 border-b border-line px-3">+ <strong className="min-w-0 flex-1 truncate text-[13px] font-medium">Reviews</strong>+ <button type="button" aria-label="Close reviews" onClick={onClose} className="flex size-7 items-center justify-center rounded-md text-ink-3 hover:bg-hover">×</button>+ </header>+ {needAuth ? (+ <div className="flex flex-1 flex-col gap-2 p-4 text-[13px] text-ink-2">+ <p>Sign in with GitHub to see this project's review inbox.</p>+ <p className="text-[12px] text-ink-3">In a terminal: <span className="font-mono text-ink">gh auth login</span></p>+ </div>+ ) : (+ <div className="flex min-h-0 flex-1">+ <ul className="w-44 shrink-0 overflow-y-auto border-r border-line p-2">+ {prs.length === 0 && <li className="px-2 py-3 text-[12px] text-ink-3">No open pull requests.</li>}+ {prs.map((pr) => (+ <li key={pr.number}>+ <button type="button" onClick={() => setSelected(pr.number)} className={`mb-1 w-full rounded-[8px] px-2 py-1.5 text-left ${selected === pr.number ? "bg-hover-2 text-ink" : "text-ink-2 hover:bg-hover"}`}>+ <span className="block truncate text-[12.5px] font-medium">#{pr.number} {pr.title}</span>+ <span className="block truncate text-[11px] text-ink-3">{pr.author} · {pr.checks}{pr.isDraft ? " · draft" : ""}</span>+ </button>+ </li>+ ))}+ </ul>+ <div className="min-w-0 flex-1 overflow-y-auto p-3 text-[13px]">+ {!current ? <p className="text-ink-3">Select a pull request.</p> : <>+ <a href={current.url} className="font-medium text-ink hover:underline" target="_blank" rel="noreferrer">#{current.number} {current.title}</a>+ <p className="mt-1 text-[12px] text-ink-3">{current.headRefName} · {current.reviewDecision ?? "awaiting review"}</p>+ <textarea value={comment} onChange={(event) => setComment(event.target.value)} placeholder="Review comment" className="mt-3 h-24 w-full rounded-[8px] bg-inset p-2 font-sans text-[12.5px] shadow-hairline" />+ <div className="mt-2 flex flex-wrap gap-1">+ <button type="button" disabled={busy} onClick={() => void review("COMMENT")} className="h-7 rounded-full px-2.5 text-[12px] text-ink-2 hover:bg-hover">Comment</button>+ <button type="button" disabled={busy} onClick={() => void review("APPROVE")} className="h-7 rounded-full px-2.5 text-[12px] text-ink-2 hover:bg-hover">Approve</button>+ <button type="button" disabled={busy} onClick={() => void review("REQUEST_CHANGES")} className="h-7 rounded-full px-2.5 text-[12px] text-ink-2 hover:bg-hover">Request changes</button>+ </div>+ </>}+ </div>+ </div>+ )}+ {error && <p role="alert" className="border-t border-line px-3 py-2 text-[12px] text-red">{error}</p>}+ </section>+ </ResizableReviewPane>;+}diff --git a/apps/native/lib/github-reviews.test.ts b/apps/native/lib/github-reviews.test.tsnew file mode 100644index 00000000..e699abe0--- /dev/null+++ b/apps/native/lib/github-reviews.test.ts@@ -0,0 +1,22 @@+import { expect, test } from "bun:test";+import { parsePrList, summarizeChecks } from "./github-reviews";++test("parsePrList keeps review inbox fields", () => {+ const rows = parsePrList([{+ number: 12, title: "Fix chrome", url: "https://github.com/org/repo/pull/12",+ isDraft: false, reviewDecision: "REVIEW_REQUIRED", headRefName: "fix/chrome",+ author: { login: "yxlyx" },+ statusCheckRollup: [{ conclusion: "SUCCESS" }],+ }]);+ expect(rows).toEqual([{+ number: 12, title: "Fix chrome", author: "yxlyx",+ url: "https://github.com/org/repo/pull/12", isDraft: false,+ reviewDecision: "REVIEW_REQUIRED", headRefName: "fix/chrome", checks: "passing",+ }]);+});++test("summarizeChecks maps rollup states", () => {+ expect(summarizeChecks([{ conclusion: "FAILURE" }])).toBe("failing");+ expect(summarizeChecks([{ status: "PENDING" }])).toBe("pending");+ expect(summarizeChecks([])).toBe("no checks");+});diff --git a/apps/native/lib/github-reviews.ts b/apps/native/lib/github-reviews.tsnew file mode 100644index 00000000..48fc8258--- /dev/null+++ b/apps/native/lib/github-reviews.ts@@ -0,0 +1,46 @@+export type ReviewPr = {+ number: number;+ title: string;+ author: string;+ url: string;+ isDraft: boolean;+ reviewDecision: string | null;+ headRefName: string;+ checks: string;+};++export function summarizeChecks(rollup: unknown): string {+ if (!Array.isArray(rollup) || rollup.length === 0) return "no checks";+ const states = rollup.map((item) => {+ if (!item || typeof item !== "object") return "";+ const rec = item as { state?: string; conclusion?: string; status?: string };+ return (rec.conclusion || rec.state || rec.status || "").toUpperCase();+ });+ if (states.some((s) => s === "FAILURE" || s === "FAILED" || s === "ERROR")) return "failing";+ if (states.some((s) => s === "PENDING" || s === "IN_PROGRESS" || s === "QUEUED")) return "pending";+ if (states.every((s) => s === "SUCCESS" || s === "SKIPPED" || s === "NEUTRAL")) return "passing";+ return "mixed";+}++export function parsePrList(raw: unknown): ReviewPr[] {+ if (!Array.isArray(raw)) return [];+ return raw.flatMap((item) => {+ if (!item || typeof item !== "object") return [];+ const rec = item as {+ number?: unknown; title?: unknown; url?: unknown; isDraft?: unknown;+ reviewDecision?: unknown; headRefName?: unknown; author?: { login?: unknown };+ statusCheckRollup?: unknown;+ };+ if (typeof rec.number !== "number" || typeof rec.title !== "string") return [];+ return [{+ number: rec.number,+ title: rec.title,+ author: typeof rec.author?.login === "string" ? rec.author.login : "unknown",+ url: typeof rec.url === "string" ? rec.url : "",+ isDraft: rec.isDraft === true,+ reviewDecision: typeof rec.reviewDecision === "string" ? rec.reviewDecision : null,+ headRefName: typeof rec.headRefName === "string" ? rec.headRefName : "",+ checks: summarizeChecks(rec.statusCheckRollup),+ }];+ });+}