Skip to content

Commit 31e0ace

Browse files
committed
feat(client): 路由旧值显式标记 + 行级提示与测试说明(#191)
巩固/睡眠/实体抽取的级联下拉刻意保留不在列表里的旧值(不静默丢配置), 但此前与正常选项无差别展示——切 Provider 后残留的旧 model id 照常保存, 分不清「改错了」还是「还没生效」。 - 旧值在下拉收起时即带「(不在可用列表)」标记,路由行给 ⚠ 提示: 改选,或点「测试连通性」当场验证;改动保存后重启 DSH 生效 - 标记只在适配器列表非空时判定(空列表无从比对,防误报);provider 未选或未注册时不校验 model,归属由后端按默认路由解析 - 旧值保留保持无条件:只有标记带门,列表为空不静默丢已存值 - 「测试连通性」接上 modelTestHint(定义后一直未接线)作说明行, 与结果行同一槽位二选一,不堆叠
1 parent 66bb4d2 commit 31e0ace

2 files changed

Lines changed: 71 additions & 10 deletions

File tree

‎dsh-mneme/lib/client.js‎

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,8 @@ window.__ModuleLoader__.load({
383383
"memory.features.modelTestOk": "连通正常",
384384
"memory.features.modelTestFail": "测试失败",
385385
"memory.features.modelTestHint": "真实发起一次最小巩固调用,验证 Provider/模型连通与 effort 支持",
386+
"memory.features.routeStaleMark": "(不在可用列表)",
387+
"memory.features.routeStaleHint": "不在当前可用列表,多为切换 Provider 后的旧值:请改选,或点「测试连通性」当场验证;改动保存后重启 DSH 生效。",
386388
"memory.explorer.viewCards": "卡片",
387389
"memory.explorer.viewTimeline": "时间线",
388390
"memory.explorer.viewAria": "视图切换",
@@ -734,6 +736,8 @@ window.__ModuleLoader__.load({
734736
"memory.features.modelTestOk": "Connected",
735737
"memory.features.modelTestFail": "Test failed",
736738
"memory.features.modelTestHint": "Fires one minimal consolidation call to verify provider/model connectivity and effort support",
739+
"memory.features.routeStaleMark": " (not in list)",
740+
"memory.features.routeStaleHint": "Not in the current provider's model list, often a leftover from a provider switch: reselect, or run a connectivity test to verify now; changes take effect after restarting DSH.",
737741
"memory.explorer.viewCards": "Cards",
738742
"memory.explorer.viewTimeline": "Timeline",
739743
"memory.explorer.viewAria": "Switch view",
@@ -1903,14 +1907,21 @@ window.__ModuleLoader__.load({
19031907
// 巩固/睡眠路由行:provider/model 级联下拉(数据来自宿主侧已注册的
19041908
// 适配器,用户不会选到不存在的模型)+ 连通性测试。空值 = 跟随默认
19051909
// 路由;改动即提交(与 embedProvider 下拉一致)。当前值不在枚举里时
1906-
// 保留为额外选项,避免静默改值。
1910+
// 保留为额外选项避免静默改值,并显式标记 + 行级提示(issue #191)。
19071911
const routeSelects = (providerKey, modelKey, testState, setTestState) => {
19081912
const curP = strs[providerKey] ?? "";
19091913
const curM = strs[modelKey] ?? "";
19101914
const entries = Array.isArray(routes) ? routes : [];
19111915
const entry = entries.find((p) => p && p.provider === curP);
19121916
const models = (entry && Array.isArray(entry.models)) ? entry.models : [];
19131917
const mVals = models.map(modelValue);
1918+
// issue #191:旧值保留是刻意不丢配置,但必须看得见。适配器列表为空
1919+
// (端点刚起 / 宿主零适配器)时无从比对,不标记防误报;provider 未
1920+
// 选或本身不在列表时,模型归属由后端按默认路由解析,前端不校验
1921+
// model——只在 provider 已注册时查配套。
1922+
const hasProviders = entries.length > 0;
1923+
const pStale = hasProviders && !!curP && !entry;
1924+
const mStale = hasProviders && !!entry && !!curM && !mVals.includes(curM);
19141925
const pList = entries.map((p) => p.provider).concat(
19151926
curP && !entries.some((p) => p.provider === curP) ? [curP] : []);
19161927
const putKey = (key) => (e) => {
@@ -1926,7 +1937,8 @@ window.__ModuleLoader__.load({
19261937
"aria-label": t(`memory.features.${providerKey}`), onChange: putKey(providerKey)
19271938
},
19281939
h("option", { value: "" }, t("memory.features.routeFollowDefault")),
1929-
pList.map((p) => h("option", { key: p, value: p }, p)))),
1940+
pList.map((p) => h("option", { key: p, value: p },
1941+
pStale && p === curP ? p + t("memory.features.routeStaleMark") : p)))),
19301942
h("div", { className: "mneme-featnum" },
19311943
h("span", { className: "mneme-featnumlabel" }, t(`memory.features.${modelKey}`)),
19321944
h("select", {
@@ -1935,17 +1947,23 @@ window.__ModuleLoader__.load({
19351947
},
19361948
h("option", { value: "" }, t("memory.features.routeFollowDefault")),
19371949
models.map((m, i) => h("option", { key: modelValue(m) + "|" + i, value: modelValue(m) }, modelLabel(m))),
1938-
curM && !mVals.includes(curM) ? h("option", { key: "current", value: curM }, curM) : null)),
1950+
curM && !mVals.includes(curM) ? h("option", { key: "current", value: curM },
1951+
mStale ? curM + t("memory.features.routeStaleMark") : curM) : null)),
1952+
(pStale || mStale) && h("div", { className: "mneme-featsubhint" },
1953+
"⚠ " + t("memory.features.routeStaleHint")),
19391954
h("div", { className: "mneme-featnum" },
19401955
h("button", {
19411956
type: "button", className: "mneme-btn",
19421957
disabled: busy || (testState && testState.running),
19431958
onClick: () => runModelTest(curP, curM, setTestState)
19441959
}, t((testState && testState.running) ? "memory.features.modelTesting" : "memory.features.modelTest")),
1945-
testState && !testState.running && h("div", { className: "mneme-featsubhint" },
1946-
(testState.ok ? "✓ " + t("memory.features.modelTestOk") : "✗ " + t("memory.features.modelTestFail"))
1947-
+ (typeof testState.ms === "number" ? " · " + (testState.ms / 1000).toFixed(1) + "s" : "")
1948-
+ (testState.detail ? " · " + testState.detail : "")))
1960+
// 结果与说明共用同一行槽位二选一:出结果后说明自动让位,不堆叠。
1961+
(testState && !testState.running
1962+
? h("div", { className: "mneme-featsubhint" },
1963+
(testState.ok ? "✓ " + t("memory.features.modelTestOk") : "✗ " + t("memory.features.modelTestFail"))
1964+
+ (typeof testState.ms === "number" ? " · " + (testState.ms / 1000).toFixed(1) + "s" : "")
1965+
+ (testState.detail ? " · " + testState.detail : ""))
1966+
: h("div", { className: "mneme-featsubhint" }, t("memory.features.modelTestHint"))))
19491967
);
19501968
};
19511969

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

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -573,11 +573,11 @@ test("consolidation/sleep model routing: provider dropdowns from /llm-providers,
573573
"select changes must commit through the features PUT like the embed provider select"
574574
);
575575
assert.ok(
576-
/curM && !mVals\.includes\(curM\) \? h\("option", \{ key: "current", value: curM \}, curM\) : null/.test(clientSource),
577-
"a configured value missing from the provider's model list must survive as an extra option"
576+
/curM && !mVals\.includes\(curM\) \? h\("option", \{ key: "current", value: curM \},\s*\n\s*mStale \? curM \+ t\("memory\.features\.routeStaleMark"\) : curM\) : null/.test(clientSource),
577+
"a configured value missing from the provider's model list must survive as an extra option, marked when stale (issue #191)"
578578
);
579579
// 5. 双语 i18n 与样式
580-
for (const key of ["routeFollowDefault", "modelTest", "modelTesting", "modelTestOk", "modelTestFail", "sleepModelHint"]) {
580+
for (const key of ["routeFollowDefault", "modelTest", "modelTesting", "modelTestOk", "modelTestFail", "modelTestHint", "routeStaleMark", "routeStaleHint", "sleepModelHint"]) {
581581
const occurrences = clientSource.split(`"memory.features.${key}"`).length - 1;
582582
assert.ok(occurrences >= 2, `i18n key memory.features.${key} must exist in both zh and en (got ${occurrences})`);
583583
}
@@ -587,6 +587,49 @@ test("consolidation/sleep model routing: provider dropdowns from /llm-providers,
587587
);
588588
});
589589

590+
// issue #191:级联下拉刻意保留不在列表里的旧值(不丢配置),但此前与正常
591+
// 选项无差别展示——切 Provider 后残留的中继风格 model id 照常保存,用户分
592+
// 不清「改错了」还是「还没生效」。旧值必须显式标记 + 行级提示(改选或点连
593+
// 通性测试当场验证 + 重启生效);适配器列表为空或 provider 未注册时前端无
594+
// 从校验 model,一律不标记防误报。
595+
test("stale route values are marked and explained at the row level (issue #191)", () => {
596+
// 1. 旧值判定:仅在适配器列表非空时比对;model 只在 provider 已注册时校验
597+
assert.ok(
598+
/const hasProviders = entries\.length > 0;/.test(clientSource),
599+
"stale checks must be gated on a non-empty provider registry (no false alarms)"
600+
);
601+
assert.ok(
602+
/const pStale = hasProviders && !!curP && !entry;/.test(clientSource),
603+
"a saved provider missing from /llm-providers must be flagged"
604+
);
605+
assert.ok(
606+
/const mStale = hasProviders && !!entry && !!curM && !mVals\.includes\(curM\);/.test(clientSource),
607+
"a saved model outside the selected provider's list must be flagged only when that provider is registered"
608+
);
609+
// 2. 标记落在选项文本上:下拉收起时也能看出旧值不在列表
610+
assert.ok(
611+
/pStale && p === curP \? p \+ t\("memory\.features\.routeStaleMark"\) : p/.test(clientSource),
612+
"the preserved provider option must carry the stale mark"
613+
);
614+
// 3. 行级提示:⚠ 警示 + 改选/测试引导 + 重启生效,一条提示说完
615+
assert.ok(
616+
/\(pStale \|\| mStale\) && h\("div", \{ className: "mneme-featsubhint" \},\s*\n\s*"⚠ " \+ t\("memory\.features\.routeStaleHint"\)/.test(clientSource),
617+
"the stale warning hint must render at the route row with the warning prefix"
618+
);
619+
// 3b. 旧值保留必须无条件:列表为空(端点刚起 / 零适配器)时也不得把已存
620+
// provider 静默显示成「跟随默认路由」——只有标记带门,保留不带门。
621+
assert.ok(
622+
/curP && !entries\.some\(\(p\) => p\.provider === curP\) \? \[curP\] : \[\]/.test(clientSource),
623+
"the preserved provider option must stay unconditional (empty list must not hide the saved value)"
624+
);
625+
// 4. 连通性测试按钮的说明与结果互斥(同一行槽位二选一,不堆叠)
626+
assert.ok(
627+
/\(testState && !testState\.running\s*\n\s*\? h\("div", \{ className: "mneme-featsubhint" \},/.test(clientSource)
628+
&& clientSource.includes('t("memory.features.modelTestHint")'),
629+
"the test row must show either the result or the standing explanation, never both"
630+
);
631+
});
632+
590633
// 帮助与反馈入口(v0.8):设置页底部三个反馈链接——GitHub 新建 issue 预填
591634
// (环境信息)、邮件反馈、浏览已知问题。纯前端链接零后端成本;插件版本从
592635
// /info 拉取(version 只读,不铺任何 token/凭据)。公开链接不得带个人邮箱。

0 commit comments

Comments
 (0)