Add daemon restart, preview diagnostics, browse caching, and rate-limit pauses

This commit is contained in:
Fisto
2026-09-17 07:33:35 +02:00
parent cba7ae8143
commit dea1724eb3
13 changed files with 367 additions and 56 deletions
+33 -4
View File
@@ -9,6 +9,7 @@
* VESKSLOP_SOCKET=/path/to/vesktop-puppet.sock MCP_PORT=8788 pnpm control:bridge
*/
import { spawn } from "node:child_process";
import { config as loadEnv } from "dotenv";
import { createMcpExpressApp } from "@modelcontextprotocol/sdk/server/express.js";
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
@@ -286,6 +287,7 @@ const webui = startWebUi({
transcripts,
preferences,
media,
restartDaemon,
connectAudioDevices: () => autoConnectAudio(requireCore())
});
@@ -1004,11 +1006,38 @@ app.listen(PORT, HOST, (error?: Error) => {
if (stale) console.warn(`[daemon] ${stale}`);
});
function shutdown() {
function shutdown(keepCore = false) {
stopSpeakingPoll();
core?.close();
void Promise.allSettled([coreProcess.dispose(4000), audio.dispose()]).finally(() => process.exit(0));
const tasks: Array<Promise<unknown>> = [audio.dispose()];
if (!keepCore) tasks.push(coreProcess.dispose(4000));
void Promise.allSettled(tasks).finally(() => process.exit(0));
}
process.on("SIGINT", shutdown);
process.on("SIGTERM", shutdown);
/** Replace this daemon with a fresh copy, leaving the client running. */
let restartingDaemon = false;
function restartDaemon(): void {
if (restartingDaemon) return;
restartingDaemon = true;
const quote = (value: string) => `'${value.replace(/'/g, `'\\''`)}'`;
const args = [...process.execArgv, ...process.argv.slice(1)];
const command = `${quote(process.execPath)} ${args.map(quote).join(" ")}`;
console.log("[daemon] restart requested: spawning a replacement");
const child = spawn("sh", ["-c", `sleep 2; exec ${command}`], {
detached: true,
stdio: "ignore",
cwd: process.cwd(),
env: { ...process.env, VESKSLOP_DAEMON_RESTART: "1" }
});
child.unref();
setTimeout(() => shutdown(true), 300);
}
process.on("SIGINT", () => shutdown());
process.on("SIGTERM", () => shutdown());