From 2329645df4b0facadea9cd95a2c23e35c290e639 Mon Sep 17 00:00:00 2001 From: duffyduck Date: Fri, 10 Apr 2026 01:24:55 +0200 Subject: [PATCH] fix: XTTS voices list + upload use fresh RVS connection with response wait Co-Authored-By: Claude Opus 4.6 (1M context) --- diagnostic/server.js | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/diagnostic/server.js b/diagnostic/server.js index 077921c..1592266 100644 --- a/diagnostic/server.js +++ b/diagnostic/server.js @@ -560,6 +560,31 @@ function connectRVS(forcePlain) { }); } +function sendToRVS_withResponse(sendType, sendPayload, expectType, clientWs) { + if (!RVS_HOST || !RVS_TOKEN) return; + const proto = RVS_TLS === "true" ? "wss" : "ws"; + const url = `${proto}://${RVS_HOST}:${RVS_PORT}?token=${RVS_TOKEN}`; + const freshWs = new WebSocket(url); + const timeout = setTimeout(() => { + try { freshWs.close(); } catch (_) {} + clientWs.send(JSON.stringify({ type: expectType, payload: { voices: [], error: "Timeout" }, timestamp: Date.now() })); + }, 15000); + freshWs.on("open", () => { + freshWs.send(JSON.stringify({ type: sendType, payload: sendPayload, timestamp: Date.now() })); + }); + freshWs.on("message", (raw) => { + try { + const resp = JSON.parse(raw.toString()); + if (resp.type === expectType) { + clearTimeout(timeout); + clientWs.send(JSON.stringify(resp)); + setTimeout(() => { try { freshWs.close(); } catch (_) {} }, 1000); + } + } catch {} + }); + freshWs.on("error", () => {}); +} + function sendToRVS_raw(msgObj) { if (!RVS_HOST || !RVS_TOKEN) return; const proto = RVS_TLS === "true" ? "wss" : "ws"; @@ -1166,11 +1191,12 @@ wss.on("connection", (ws) => { broadcast({ type: "agent_activity", activity: "idle" }); dockerExec("aria-core", "openclaw doctor --fix 2>/dev/null || true").catch(() => {}); } else if (msg.action === "voice_upload") { - // Voice-Samples an XTTS-Bridge via RVS weiterleiten - sendToRVS_raw({ type: "voice_upload", payload: { name: msg.name, samples: msg.samples }, timestamp: Date.now() }); - log("info", "server", `Voice-Upload '${msg.name}' (${(msg.samples || []).length} Samples) an RVS gesendet`); + // Voice-Samples an XTTS-Bridge via RVS weiterleiten, auf Bestätigung warten + log("info", "server", `Voice-Upload '${msg.name}' (${(msg.samples || []).length} Samples) sende an RVS...`); + sendToRVS_withResponse("voice_upload", { name: msg.name, samples: msg.samples }, "xtts_voice_saved", ws); } else if (msg.action === "xtts_list_voices") { - sendToRVS_raw({ type: "xtts_list_voices", payload: {}, timestamp: Date.now() }); + // Frische Verbindung die auf Antwort wartet + sendToRVS_withResponse("xtts_list_voices", {}, "xtts_voices_list", ws); } else if (msg.action === "get_voice_config") { handleGetVoiceConfig(ws); } else if (msg.action === "send_voice_config") {