Skip to content

Commit e6f0d7f

Browse files
committed
feat(client): 连通性测试结果附模型实际回复(reply)与失败时的 modelId+报错
云端 test-model 已按契约对齐(fix/dream-effort-trap 分支):成功 200 附 reply(模型真实回答,后端截 100 字符)/ 失败 502 {ok:false,error, durationMs,modelId} / 400 missing-provider-or-model|no-route。结果行升级: - 成功:modelId · 「回复原文」——面板能确认模型真的答了,而非只报通 - 失败:modelId · 报错原因(后端耗时优先),不再只给客户端计时
1 parent dc6af8f commit e6f0d7f

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

‎dsh-mneme/lib/client.js‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,7 +1698,8 @@ window.__ModuleLoader__.load({
16981698
const modelValue = (m) => (typeof m === "string" ? m : String((m && m.id) ?? ""));
16991699

17001700
// 连通性测试:POST /test-model,空 provider/model = 按巩固路由解析
1701-
// (agent 默认)。durationMs 优先取后端值,缺失时客户端兜底计时。
1701+
// (agent 默认)。durationMs 优先后端值,缺失时客户端兜底计时;成功行
1702+
// 附模型的实际回复(reply,后端截 100 字符)——「真的答了 ok」而非只报通。
17021703
const runModelTest = async (provider, model) => {
17031704
setTestState({ running: true });
17041705
const started = Date.now();
@@ -1709,11 +1710,19 @@ window.__ModuleLoader__.load({
17091710
body: JSON.stringify({ provider, model })
17101711
});
17111712
const j = await res.json().catch(() => ({}));
1712-
if (!res.ok || j.ok === false) throw new Error(j.error || "HTTP " + res.status);
1713+
const ms = typeof j.durationMs === "number" ? j.durationMs : Date.now() - started;
1714+
if (!res.ok || j.ok === false) {
1715+
setTestState({
1716+
ok: false,
1717+
ms,
1718+
detail: [j.modelId, j.error || "HTTP " + res.status].filter(Boolean).join(" · ")
1719+
});
1720+
return;
1721+
}
17131722
setTestState({
17141723
ok: true,
1715-
ms: typeof j.durationMs === "number" ? j.durationMs : Date.now() - started,
1716-
detail: j.modelId || ""
1724+
ms,
1725+
detail: [j.modelId, j.reply ? "「" + j.reply + "」" : ""].filter(Boolean).join(" · ")
17171726
});
17181727
} catch (err) {
17191728
setTestState({ ok: false, ms: Date.now() - started, detail: String((err && err.message) ?? err) });

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,14 @@ test("consolidation/sleep model routing: provider dropdowns from /llm-providers,
506506
/typeof j\.durationMs === "number" \? j\.durationMs : Date\.now\(\) - started/.test(clientSource),
507507
"the result duration must prefer the backend's durationMs and fall back to client timing"
508508
);
509+
assert.ok(
510+
/detail: \[j\.modelId, j\.reply \? "「" \+ j\.reply \+ "」" : ""\]\.filter\(Boolean\)\.join\(" · "\)/.test(clientSource),
511+
"the success line must surface the model's actual reply (backend caps it at 100 chars)"
512+
);
513+
assert.ok(
514+
/detail: \[j\.modelId, j\.error \|\| "HTTP " \+ res\.status\]\.filter\(Boolean\)\.join\(" · "\)/.test(clientSource),
515+
"the failure line must carry the tested modelId plus the backend error (502/400 bodies)"
516+
);
509517
assert.ok(
510518
clientSource.includes("memory.features.modelTestOk") && clientSource.includes("memory.features.modelTestFail"),
511519
"the result line must render success/failure with the localized labels"

0 commit comments

Comments
 (0)