Skip to content

Commit 9f23b63

Browse files
committed
More progress
1 parent e4d5ea9 commit 9f23b63

File tree

22 files changed

+735
-119
lines changed

22 files changed

+735
-119
lines changed

benchmark/apps/cli/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
"dependencies": {
1212
"@benchmark/db": "workspace:^",
1313
"@vscode/test-electron": "^2.4.0",
14-
"gluegun": "^5.1.2",
15-
"uuid": "^11.1.0"
14+
"gluegun": "^5.1.2"
1615
},
1716
"devDependencies": {
1817
"@benchmark/eslint-config": "workspace:^",

benchmark/apps/cli/src/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as fs from "fs"
22
import * as path from "path"
33
import * as os from "os"
44

5-
import { v4 as uuidv4 } from "uuid"
65
import { build, filesystem, GluegunPrompt, GluegunToolbox } from "gluegun"
76
import { runTests } from "@vscode/test-electron"
87

@@ -152,7 +151,11 @@ const askExercise = async (prompt: GluegunPrompt, language: Language) => {
152151
const findOrCreateRun = async ({ id, model = "anthropic/claude-3.7-sonnet" }: { id?: number; model?: string }) =>
153152
id
154153
? findRun(id)
155-
: createRun({ model, pid: process.pid, socketPath: path.resolve(os.tmpdir(), `benchmark-${uuidv4()}.sock`) })
154+
: createRun({
155+
model,
156+
pid: process.pid,
157+
socketPath: path.resolve(os.tmpdir(), `benchmark-${crypto.randomUUID()}.sock`),
158+
})
156159

157160
const findOrCreatePendingTask = async ({
158161
runId,

benchmark/apps/web/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"@benchmark/ipc": "workspace:^",
1515
"@hookform/resolvers": "^4.1.3",
1616
"@radix-ui/react-label": "^2.1.2",
17+
"@radix-ui/react-scroll-area": "^1.2.3",
1718
"@radix-ui/react-select": "^2.1.6",
1819
"@radix-ui/react-slot": "^1.1.2",
1920
"@tanstack/react-query": "^5.69.0",
@@ -25,9 +26,9 @@
2526
"react": "^19.0.0",
2627
"react-dom": "^19.0.0",
2728
"react-hook-form": "^7.54.2",
29+
"react-use": "^17.6.0",
2830
"tailwind-merge": "^3.0.2",
2931
"tailwindcss-animate": "^1.0.7",
30-
"uuid": "^11.1.0",
3132
"zod": "^3.24.2"
3233
},
3334
"devDependencies": {

benchmark/apps/web/src/app/api/runs/[id]/stream/route.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { NextRequest } from "next/server"
2-
import { v4 as uuidv4 } from "uuid"
32

43
import { findRun } from "@benchmark/db"
54
import { IpcClient } from "@benchmark/ipc"
@@ -10,7 +9,7 @@ export const dynamic = "force-dynamic"
109

1110
export async function GET(request: NextRequest, { params }: { params: Promise<{ id: string }> }) {
1211
const { id } = await params
13-
const requestId = uuidv4()
12+
const requestId = crypto.randomUUID()
1413
const stream = new SSEStream()
1514
const run = await findRun(Number(id))
1615
const client = new IpcClient(run.socketPath, () => {})
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import type { NextRequest } from "next/server"
2+
3+
import { findRun } from "@benchmark/db"
4+
import { IpcClient } from "@benchmark/ipc"
5+
6+
import { SSEStream } from "@/lib/server/sse-stream"
7+
8+
export const dynamic = "force-dynamic"
9+
10+
export async function GET(request: NextRequest, { params }: { params: Promise<{ id: string }> }) {
11+
const { id } = await params
12+
const requestId = crypto.randomUUID()
13+
const stream = new SSEStream()
14+
const run = await findRun(Number(id))
15+
const client = new IpcClient(run.socketPath, () => {})
16+
17+
const write = async (data: string | object) => {
18+
const success = await stream.write(data)
19+
20+
if (!success) {
21+
client.disconnect()
22+
}
23+
}
24+
25+
console.log(`[stream#${requestId}] connect`)
26+
client.on("connect", () => write("connect"))
27+
client.on("disconnect", () => write("disconnect"))
28+
client.on("message", write)
29+
30+
request.signal.addEventListener("abort", () => {
31+
console.log(`[stream#${requestId}] abort`)
32+
client.disconnect()
33+
stream.close().catch(() => {})
34+
})
35+
36+
return stream.getResponse()
37+
}

benchmark/apps/web/src/app/globals.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,20 @@
109109
--radius-md: calc(var(--radius) - 2px);
110110
--radius-lg: var(--radius);
111111
--radius-xl: calc(var(--radius) + 4px);
112+
113+
--animate-hop: hop 0.8s ease-in-out infinite;
114+
115+
@keyframes hop {
116+
0%,
117+
100% {
118+
transform: none;
119+
animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
120+
}
121+
50% {
122+
transform: translateY(-8px);
123+
animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
124+
}
125+
}
112126
}
113127

114128
@layer base {

benchmark/apps/web/src/app/home.tsx

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { Rocket } from "lucide-react"
55

66
import { getRuns } from "@benchmark/db"
77

8-
import { Button, Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui"
98
import { formatCurrency, formatDuration } from "@/lib"
9+
import { Button, Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui"
1010

1111
type Run = Awaited<ReturnType<typeof getRuns>>[number]
1212

@@ -15,39 +15,37 @@ export function Home({ runs }: { runs: Run[] }) {
1515

1616
return (
1717
<>
18-
<div className="max-w-4xl px-12 mx-auto py-24">
19-
<Table className="border">
20-
<TableHeader>
21-
<TableRow>
22-
<TableHead>ID</TableHead>
23-
<TableHead>Model</TableHead>
24-
<TableHead>Timestamp</TableHead>
25-
<TableHead>Passed</TableHead>
26-
<TableHead>Failed</TableHead>
27-
<TableHead>% Correct</TableHead>
28-
<TableHead>Cost</TableHead>
29-
<TableHead>Duration</TableHead>
18+
<Table className="border">
19+
<TableHeader>
20+
<TableRow>
21+
<TableHead>ID</TableHead>
22+
<TableHead>Model</TableHead>
23+
<TableHead>Timestamp</TableHead>
24+
<TableHead>Passed</TableHead>
25+
<TableHead>Failed</TableHead>
26+
<TableHead>% Correct</TableHead>
27+
<TableHead>Cost</TableHead>
28+
<TableHead>Duration</TableHead>
29+
</TableRow>
30+
</TableHeader>
31+
<TableBody>
32+
{runs.map((run) => (
33+
<TableRow key={run.id}>
34+
<TableCell>{run.id}</TableCell>
35+
<TableCell>{run.model}</TableCell>
36+
<TableCell>{new Date(run.createdAt).toLocaleString()}</TableCell>
37+
<TableCell>{run.passed}</TableCell>
38+
<TableCell>{run.failed}</TableCell>
39+
<TableCell>{(run.rate * 100).toFixed(1)}%</TableCell>
40+
<TableCell>{formatCurrency(run.cost)}</TableCell>
41+
<TableCell>{formatDuration(run.duration)}</TableCell>
3042
</TableRow>
31-
</TableHeader>
32-
<TableBody>
33-
{runs.map((run) => (
34-
<TableRow key={run.id}>
35-
<TableCell>{run.id}</TableCell>
36-
<TableCell>{run.model}</TableCell>
37-
<TableCell>{new Date(run.createdAt).toLocaleString()}</TableCell>
38-
<TableCell>{run.passed}</TableCell>
39-
<TableCell>{run.failed}</TableCell>
40-
<TableCell>{(run.rate * 100).toFixed(1)}%</TableCell>
41-
<TableCell>{formatCurrency(run.cost)}</TableCell>
42-
<TableCell>{formatDuration(run.duration)}</TableCell>
43-
</TableRow>
44-
))}
45-
</TableBody>
46-
</Table>
47-
</div>
43+
))}
44+
</TableBody>
45+
</Table>
4846
<Button
4947
variant="default"
50-
className="absolute top-5 right-5 size-12 rounded-full"
48+
className="absolute top-4 right-12 size-12 rounded-full"
5149
onClick={() => router.push("/runs/new")}>
5250
<Rocket className="size-6" />
5351
</Button>

benchmark/apps/web/src/app/layout.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { Metadata } from "next"
22
import { Geist, Geist_Mono } from "next/font/google"
33

44
import { ThemeProvider, ReactQueryProvider } from "@/components/providers"
5+
import { Header } from "@/components/layout/header"
56

67
import "./globals.css"
78

@@ -21,7 +22,10 @@ export default function RootLayout({
2122
<html lang="en">
2223
<body className={`${fontSans.variable} ${fontMono.variable} font-sans antialiased`}>
2324
<ThemeProvider attribute="class" defaultTheme="system" enableSystem disableTransitionOnChange>
24-
<ReactQueryProvider>{children}</ReactQueryProvider>
25+
<ReactQueryProvider>
26+
<Header />
27+
<div className="max-w-3xl mx-auto">{children}</div>
28+
</ReactQueryProvider>
2529
</ThemeProvider>
2630
</body>
2731
</html>
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
import { findRun } from "@benchmark/db"
1+
import { findRun, getTasks, getPendingTasks } from "@benchmark/db"
22

33
import { ShowRun } from "./show-run"
44

55
export default async function Page({ params }: { params: Promise<{ id: string }> }) {
66
const { id } = await params
77
const run = await findRun(Number(id))
8+
const tasks = await getTasks(run.id)
9+
const pendingTasks = await getPendingTasks(run.id)
810

911
if (!run) {
1012
return <div>Run not found</div>
1113
}
1214

13-
return <ShowRun run={run} />
15+
return <ShowRun run={{ ...run, tasks, pendingTasks }} />
1416
}

0 commit comments

Comments
 (0)