feat(HAI-001): auto-open browser on dashboard start with --no-open flag

This commit is contained in:
Dustin Byrne
2026-03-25 18:23:31 -04:00
parent ae00af9223
commit eb207d15d7
2 changed files with 23 additions and 2 deletions

View File

@@ -15,6 +15,7 @@ Usage:
Options:
--port, -p <port> Dashboard port (default: 4040)
--engine Enable AI engine (auto-specify + execute tasks)
--no-open Don't auto-open the browser
--help, -h Show this help
Columns: triage, todo, in-progress, in-review, done
@@ -41,7 +42,8 @@ async function main() {
const pi = portIdx !== -1 ? portIdx : portIdxShort;
const port = pi !== -1 ? parseInt(args[pi + 1], 10) : 4040;
const engine = args.includes("--engine");
await runDashboard(port, { engine });
const open = !args.includes("--no-open");
await runDashboard(port, { engine, open });
break;
}

View File

@@ -1,8 +1,23 @@
import { exec } from "child_process";
import { TaskStore } from "@hai/core";
import { createServer } from "@hai/dashboard";
import { TriageProcessor, TaskExecutor, Scheduler } from "@hai/engine";
export async function runDashboard(port: number, opts: { engine?: boolean } = {}) {
function openBrowser(url: string): void {
try {
const cmd =
process.platform === "darwin"
? `open "${url}"`
: process.platform === "win32"
? `start "" "${url}"`
: `xdg-open "${url}"`;
exec(cmd, () => {});
} catch {
// Silently ignore — e.g., headless environments
}
}
export async function runDashboard(port: number, opts: { engine?: boolean; open?: boolean } = {}) {
const cwd = process.cwd();
const store = new TaskStore(cwd);
await store.init();
@@ -56,5 +71,9 @@ export async function runDashboard(port: number, opts: { engine?: boolean } = {}
}
console.log(` Press Ctrl+C to stop`);
console.log();
if (opts.open !== false) {
openBrowser(`http://localhost:${port}`);
}
});
}