feat: 发布热更 1.5.94,修复中转历史会话并支持一键清空

This commit is contained in:
mac
2026-09-11 09:06:41 +08:00
parent 0446d09b3b
commit a74576c3e1
28 changed files with 3217 additions and 155 deletions
+8
View File
@@ -16,6 +16,7 @@ const path = require("path");
function dlog(...a) { try { console.log("[voice]", ...a); } catch {} }
const router = require("./router");
const codexDesktop = require("./codex_desktop");
const globalDictation = require("./global_dictation");
const { INJECT_SCRIPT } = require("./voice_inject");
const { TOKEN_INJECT_SCRIPT } = require("./token_inject");
const tokenUsage = require("./token_usage");
@@ -1014,6 +1015,10 @@ function closeNetworkSessions() {
// —— 连接到已带端口的 Codex ——
async function connectToTarget(port) {
const targets = await listTargets(port);
// listTargets() keeps its legacy [] fallback for the voice state machine.
// Let the cleanup module probe the endpoint itself so a failed connection
// cannot be mistaken for an available endpoint with no targets.
await globalDictation.closeGlobalDictationTargets(port);
const tgt = pickTarget(targets);
if (!tgt) return false;
closeNetworkSessions();
@@ -1120,6 +1125,7 @@ function onSessionDelete(cb) {
async function connect(cb, opts = {}) {
if (cb) onStatusCb = cb;
const port = opts.port || DEFAULT_PORT;
globalDictation.disableKeepVisible();
state.port = port;
setPhase("checking", { lastError: "", launchWarning: "", portDiagnostic: "" });
const exe = scanCodexExecutable();
@@ -1184,6 +1190,7 @@ async function connect(cb, opts = {}) {
async function disconnect() {
stopTokenSync();
closeNetworkSessions();
globalDictation.disableKeepVisible();
if (session) {
const ownedSession = session;
// 先让页面停止录音并删除已挂载按钮,再关闭 CDP;关闭后无法清理前台 DOM。
@@ -1205,6 +1212,7 @@ async function disconnect() {
} catch {}
}
setPhase("disconnected");
await globalDictation.closeGlobalDictationTargets(state.port);
return snapshot();
}