repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by bugabinga

Keep exported tune dashboard server routes pointed at latest export files

e96903f66caf7677e9ba5f11d4be4d7b00bd705e

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Result: {"status":"keep","wall_time":500,"tests_passed":46,"failures":0}

Changed files (1)

extensions/tune/index.ts

Modified
2576 2576 let dashboardServer: Server | null = null;
2577 2577 let dashboardServerPort: number | null = null;
2578 + let dashboardIndexPath: string | null = null;
2579 + let dashboardJsonlPath: string | null = null;
2578 2580 const dashboardSseClients = new Set<ServerResponse>();
2580 2582 const TITLE_PLACEHOLDER = "__TUNE_TITLE__";
2626 2628 dashboardServer = null;
2627 2629 dashboardServerPort = null;
2630 + dashboardIndexPath = null;
2631 + dashboardJsonlPath = null;
2630 2634 function openInBrowser(url: string): void {
2657 2661 const exportDir = fs.mkdtempSync(path.join(tmpdir(), "pi-tune-dashboard-"));
2658 2662 const dest = path.join(exportDir, "index.html");
2659 2663 fs.writeFileSync(dest, html);
2664 + dashboardIndexPath = dest;
2665 + dashboardJsonlPath = jsonlPath;
2661 2667 if (!dashboardServer) {
2662 2668 const server = createServer((req, res) => {
2673 2679 return;
2675 2681 const filePath =
2676 - url.pathname === "/" ? dest : url.pathname === "/session.jsonl" ? jsonlPath : null;
2682 + url.pathname === "/"
2683 + ? dashboardIndexPath
2684 + : url.pathname === "/session.jsonl"
2685 + ? dashboardJsonlPath
2686 + : null;
2677 2687 if (!filePath) {
2678 2688 res.writeHead(404);
2679 2689 res.end();