Pause
This commit is contained in:
@@ -2,7 +2,7 @@ import { appendFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import {
|
||||
MODELS,
|
||||
Model,
|
||||
type Model,
|
||||
shuffle,
|
||||
withRetry,
|
||||
callGeneratePrompt,
|
||||
@@ -141,7 +141,7 @@ async function worker() {
|
||||
} else {
|
||||
completedRounds++;
|
||||
if (result.winner) {
|
||||
scores[result.winner.name]++;
|
||||
scores[result.winner.name] = (scores[result.winner.name] ?? 0) + 1;
|
||||
}
|
||||
|
||||
let roundLog = `\n=== ROUND ${roundNum} ===\n`;
|
||||
|
||||
@@ -415,7 +415,7 @@ function App() {
|
||||
}
|
||||
|
||||
if (!state.active && !state.done && state.completed.length > 0) {
|
||||
return <Arena round={lastCompleted} total={totalRounds} />;
|
||||
return <Arena round={lastCompleted!} total={totalRounds} />;
|
||||
}
|
||||
|
||||
if (!state.active && !state.done && state.completed.length === 0) {
|
||||
|
||||
5
game.ts
5
game.ts
@@ -71,6 +71,7 @@ export type GameState = {
|
||||
active: RoundState | null;
|
||||
scores: Record<string, number>;
|
||||
done: boolean;
|
||||
isPaused: boolean;
|
||||
};
|
||||
|
||||
// ── OpenRouter ──────────────────────────────────────────────────────────────
|
||||
@@ -261,6 +262,10 @@ export async function runGame(
|
||||
rerender: () => void,
|
||||
) {
|
||||
for (let r = 1; r <= runs; r++) {
|
||||
while (state.isPaused) {
|
||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||
}
|
||||
|
||||
const shuffled = shuffle([...MODELS]);
|
||||
const prompter = shuffled[0]!;
|
||||
const contA = shuffled[1]!;
|
||||
|
||||
9
quipslop-logo-black.svg
Normal file
9
quipslop-logo-black.svg
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="1200pt" height="1200pt" version="1.1" viewBox="0 0 1200 1200" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="m900 1200h-600c-110.3 0-200-89.699-200-200v-600c0-110.3 89.699-200 200-200h600c110.3 0 200 89.699 200 200v600c0 110.3-89.699 200-200 200zm-600-950c-82.699 0-150 67.301-150 150v600c0 82.699 67.301 150 150 150h600c82.699 0 150-67.301 150-150v-600c0-82.699-67.301-150-150-150z"/>
|
||||
<path d="m925 1050h-650c-13.801 0-25-11.25-25-25v-225c0-13.75 11.199-25 25-25s25 11.25 25 25v200h600v-200c0-13.75 11.25-25 25-25s25 11.25 25 25v225c0 13.75-11.25 25-25 25z"/>
|
||||
<path d="m525 650h-150c-13.801 0-25-11.25-25-25v-150c0-13.801 11.199-25 25-25h150c13.801 0 25 11.199 25 25v150c0 13.75-11.199 25-25 25zm-125-50h100v-100h-100z"/>
|
||||
<path d="m825 650h-150c-13.75 0-25-11.25-25-25v-150c0-13.801 11.25-25 25-25h150c13.75 0 25 11.199 25 25v150c0 13.75-11.25 25-25 25zm-125-50h100v-100h-100z"/>
|
||||
<path d="m475 150h-100c-13.801 0-25-11.199-25-25v-100c0-13.801 11.199-25 25-25h100c13.801 0 25 11.199 25 25v100c0 13.801-11.199 25-25 25zm-75-50h50v-50h-50z"/>
|
||||
<path d="m650 225c-13.75 0-25-11.199-25-25 0-68.898-56.102-125-125-125-13.801 0-25-11.199-25-25s11.199-25 25-25c96.5 0 175 78.5 175 175 0 13.801-11.25 25-25 25z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
@@ -223,6 +223,7 @@ function Game({ runs }: { runs: number }) {
|
||||
active: null,
|
||||
scores: Object.fromEntries(MODELS.map((m) => [m.name, 0])),
|
||||
done: false,
|
||||
isPaused: false,
|
||||
});
|
||||
const [, setTick] = useState(0);
|
||||
const rerender = useCallback(() => setTick((t) => t + 1), []);
|
||||
|
||||
19
server.ts
19
server.ts
@@ -26,6 +26,7 @@ const gameState: GameState = {
|
||||
active: null,
|
||||
scores: Object.fromEntries(MODELS.map((m) => [m.name, 0])),
|
||||
done: false,
|
||||
isPaused: false,
|
||||
};
|
||||
|
||||
// ── WebSocket clients ───────────────────────────────────────────────────────
|
||||
@@ -56,6 +57,24 @@ const server = Bun.serve({
|
||||
const file = Bun.file(path);
|
||||
return new Response(file);
|
||||
}
|
||||
if (url.pathname === "/api/pause") {
|
||||
const secret = url.searchParams.get("secret");
|
||||
if (process.env.ADMIN_SECRET && secret === process.env.ADMIN_SECRET) {
|
||||
gameState.isPaused = true;
|
||||
broadcast();
|
||||
return new Response("Paused", { status: 200 });
|
||||
}
|
||||
return new Response("Unauthorized", { status: 401 });
|
||||
}
|
||||
if (url.pathname === "/api/resume") {
|
||||
const secret = url.searchParams.get("secret");
|
||||
if (process.env.ADMIN_SECRET && secret === process.env.ADMIN_SECRET) {
|
||||
gameState.isPaused = false;
|
||||
broadcast();
|
||||
return new Response("Resumed", { status: 200 });
|
||||
}
|
||||
return new Response("Unauthorized", { status: 401 });
|
||||
}
|
||||
if (url.pathname === "/api/history") {
|
||||
const page = parseInt(url.searchParams.get("page") || "1", 10);
|
||||
return new Response(JSON.stringify(getRounds(page)), {
|
||||
|
||||
Reference in New Issue
Block a user