From 7dd9cd23e0f3d1c1fdbd1cd1c094a221bd5db7ad Mon Sep 17 00:00:00 2001 From: Mark Date: Mon, 3 Nov 2025 20:14:29 -0800 Subject: [PATCH] x --- docker-compose.yml | 2 +- webui/src/app/api/get-script/route.ts | 4 ++-- webui/src/app/api/list-scripts/route.ts | 6 +++++- webui/src/components/Playground.tsx | 27 +------------------------ 4 files changed, 9 insertions(+), 30 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 9b1bf73..bc31188 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ services: webui: image: minimax ports: - - "3000:3000" + - "4000:3000" volumes: - ./data:/app/data env_file: diff --git a/webui/src/app/api/get-script/route.ts b/webui/src/app/api/get-script/route.ts index a494a46..5488c0a 100644 --- a/webui/src/app/api/get-script/route.ts +++ b/webui/src/app/api/get-script/route.ts @@ -28,7 +28,8 @@ export async function GET(request: NextRequest) { const filename = `${name}.rhai`; const filepath = join(saveDir, filename); - // Check if file exists + console.log(saveDir); + if (!existsSync(filepath)) { return NextResponse.json( { error: `Script "${name}" not found` }, @@ -36,7 +37,6 @@ export async function GET(request: NextRequest) { ); } - // Read and return file content const content = await readFile(filepath, "utf8"); return NextResponse.json({ diff --git a/webui/src/app/api/list-scripts/route.ts b/webui/src/app/api/list-scripts/route.ts index 97f3274..e896bee 100644 --- a/webui/src/app/api/list-scripts/route.ts +++ b/webui/src/app/api/list-scripts/route.ts @@ -1,6 +1,5 @@ import { NextResponse } from "next/server"; import { readdir } from "fs/promises"; -import { join } from "path"; import { existsSync } from "fs"; import { SAVE_CONFIG } from "@/lib/saveConfig"; @@ -8,6 +7,8 @@ export async function GET() { try { const saveDir = SAVE_CONFIG.SAVE_DIRECTORY; + console.log(saveDir); + // If save directory doesn't exist, return empty array if (!existsSync(saveDir)) { return NextResponse.json({ scripts: [] }); @@ -15,6 +16,9 @@ export async function GET() { // Read directory and filter for .rhai files const files = await readdir(saveDir); + + console.log(files); + const scripts = files .filter((file) => file.endsWith(".rhai")) .map((file) => file.replace(".rhai", "")) diff --git a/webui/src/components/Playground.tsx b/webui/src/components/Playground.tsx index c7f550b..d21abba 100644 --- a/webui/src/components/Playground.tsx +++ b/webui/src/components/Playground.tsx @@ -42,28 +42,6 @@ fn step_max(board) { const AGENTS = { // special-cased below Self: undefined, - - Random: `fn random_action(board) { - let symb = rand_symb(); - let pos = rand_int(0, 10); - let action = Action(symb, pos); - - while !board.can_play(action) { - let symb = rand_symb(); - let pos = rand_int(0, 10); - action = Action(symb, pos); - } - - return action; -} - -fn step_min(board) { - return random_action(board); -} - -fn step_max(board) { - return random_action(board); -}`, }; export default function Playground() { @@ -126,10 +104,7 @@ export default function Playground() { // Combine hardcoded agents with saved scripts, ensuring Self and Random are first const combinedAgents = [ "Self", - "Random", - ...Object.keys(AGENTS).filter( - (key) => key !== "Self" && key !== "Random" - ), + ...Object.keys(AGENTS).filter((key) => key !== "Self"), ...scripts, ];