Skip to content

Commit deee4bd

Browse files
committed
fix(client): 合并重复的 summarizeSub 声明 + 补面板产物解析闸
CodeRabbit review 抓到的真问题:rebase 到含 #316(summarizeReasoningEffort)的 main 时,我在 autoSummarize 子块新加的 `const summarizeSub` 与上游同名声明撞车—— `node --check lib/client.js` 报 "Identifier 'summarizeSub' has already been declared", 面板 bundle 一执行就抛 SyntaxError,整个设置页加载失败。而当时 CI 全绿。 - 把错峰时段输入**并入上游那个 summarizeSub**(保留思考强度下拉与其 hint), 而不是并列第二个声明。 - 补一道解析闸(test/client.test.js):该文件此前只把面板当**文本**读(断言全是 正则/字符串包含),仓库 CI 里没有任何一步解析 lib/client.js,而 lib/client.js 无 src 对应物、不参与 sync —— 于是这类语法错误能全绿进主干。新增用例用 `node --check` 解析产物;已实测「注入重复声明 → 该用例失败、还原后通过」。 - 全量 npm test:1399 条,失败集合仍与上游 main 逐条一致(9 条 runtime-verify 环境相关用例)。
1 parent 26b5619 commit deee4bd

2 files changed

Lines changed: 18 additions & 9 deletions

File tree

‎dsh-mneme/lib/client.js‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2227,13 +2227,6 @@ window.__ModuleLoader__.load({
22272227
eff.embedProvider === "ollama" && strRow("ollamaModel")
22282228
);
22292229

2230-
// Issue #239 第 4 项:蒸馏侧错峰时段串(空 = 关闭)。挂在 autoSummarize
2231-
// 下面——与巩固侧对称,两处错峰开关都能在面板上调。
2232-
const summarizeSub = eff.autoSummarize && h("div", { className: "mneme-featsub" },
2233-
strRow("summarizePeakHours"),
2234-
h("div", { className: "mneme-featsubhint" }, t("memory.features.summarizePeakHours.hint"))
2235-
);
2236-
22372230
// 巩固模型:autoDream 开着才展开,避免闲置配置占版面。/llm-providers
22382231
// 可用时用级联下拉 + 连通性测试;旧后端(端点 404)回退纯文本输入。
22392232
const dreamSub = eff.autoDream && h("div", { className: "mneme-featsub" },
@@ -2288,7 +2281,11 @@ window.__ModuleLoader__.load({
22882281
},
22892282
SUMMARIZE_REASONING.map((r) => h("option", { key: r, value: r }, t(`memory.features.summarizeReasoningEffort.${r}`))))
22902283
),
2291-
h("div", { className: "mneme-featsubhint" }, t("memory.features.summarizeReasoningEffort.hint"))
2284+
h("div", { className: "mneme-featsubhint" }, t("memory.features.summarizeReasoningEffort.hint")),
2285+
// Issue #239 第 4 项:蒸馏侧错峰时段串(空 = 关闭)。与思考强度同处一个
2286+
// autoSummarize 子块——两处错峰开关都能在面板上调(巩固侧见 dreamSub)。
2287+
strRow("summarizePeakHours"),
2288+
h("div", { className: "mneme-featsubhint" }, t("memory.features.summarizePeakHours.hint"))
22922289
);
22932290

22942291
if (error && !state) return h("section", { className: "mneme-set-card" },

‎dsh-mneme/test/client.test.js‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import assert from "node:assert/strict";
33
import { readFileSync, existsSync } from "node:fs";
44
import { fileURLToPath } from "node:url";
55
import { dirname, join } from "node:path";
6+
import { spawnSync } from "node:child_process";
67

78
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
89
const clientSource = readFileSync(join(root, "lib/client.js"), "utf8");
@@ -943,4 +944,15 @@ test("a11y+preview: inject preview card is wired on the status tab", () => {
943944
const occurrences = clientSource.split(`"${key}"`).length - 1;
944945
assert.ok(occurrences >= 2, `i18n key ${key} must exist in both zh and en (got ${occurrences})`);
945946
}
946-
});
947+
});
948+
// 面板 bundle 在本文件里只被当**文本**读(上面的断言全是正则/字符串包含),
949+
// 而仓库的 CI 里没有任何一步**解析**它:于是重复声明这类语法错误能一路绿灯进
950+
// 主干,后果却是整个面板加载失败(__ModuleLoader__ 拿到的模块一执行就抛
951+
// SyntaxError)。lib/client.js 无 src 对应物、不参与 sync,也就没有别的闸门
952+
// 覆盖它——这里补一道解析闸(PR #320 rebase 时真实踩到:与上游新增的
953+
// summarizeSub 撞名,node --check 报 "Identifier 'summarizeSub' has already
954+
// been declared",而当时 CI 全绿)。
955+
test("client bundle parses: 面板产物必须是合法 JS(无重复声明等语法错误)", () => {
956+
const result = spawnSync(process.execPath, ["--check", join(root, "lib/client.js")], { encoding: "utf8" });
957+
assert.equal(result.status, 0, `lib/client.js 解析失败:\n${result.stderr || result.stdout}`);
958+
});

0 commit comments

Comments
 (0)