fix: harden conversational mode draft revisions
This commit is contained in:
@@ -323,6 +323,86 @@ test("a follow-up turn carries only the active authoritative draft reference", a
|
||||
assert.equal(Object.hasOwn(request.mode_profile_draft_context, "actions"), false);
|
||||
});
|
||||
|
||||
test("the change-into predicate carries only a same-name opaque draft reference", async () => {
|
||||
const events = modeDraftEvents("req-draft-change-into", 24);
|
||||
const harness = createHarness(events);
|
||||
harness.input.value = "构建一个午休模式";
|
||||
await harness.sandbox.CognitiveAgentAssistant.submit();
|
||||
|
||||
events.splice(0, events.length,
|
||||
{ type: "message.accepted", route: "agent", engine: "codex-app-server" },
|
||||
{ type: "answer.completed", route: "agent", answer: "已处理" },
|
||||
);
|
||||
harness.input.value = "把午休模式的空调温度变成25度";
|
||||
await harness.sandbox.CognitiveAgentAssistant.submit();
|
||||
harness.input.value = "午休模式的空调温度变成25度了吗?";
|
||||
await harness.sandbox.CognitiveAgentAssistant.submit();
|
||||
harness.input.value = "把露营模式的空调温度变成25度";
|
||||
await harness.sandbox.CognitiveAgentAssistant.submit();
|
||||
|
||||
const sameMode = JSON.parse(harness.requestCalls[1].options.body);
|
||||
const question = JSON.parse(harness.requestCalls[2].options.body);
|
||||
const anotherMode = JSON.parse(harness.requestCalls[3].options.body);
|
||||
assert.deepEqual(
|
||||
Object.keys(sameMode.mode_profile_draft_context).sort(),
|
||||
["name", "source_request_id", "vehicle_id"],
|
||||
);
|
||||
assert.equal(sameMode.mode_profile_draft_context.name, "午休模式");
|
||||
assert.equal(sameMode.mode_profile_draft_context.source_request_id, "req-draft-change-into");
|
||||
assert.equal(sameMode.mode_profile_draft_context.vehicle_id, "demo-vehicle");
|
||||
assert.equal(Object.hasOwn(question, "mode_profile_draft_context"), false);
|
||||
assert.equal(Object.hasOwn(anotherMode, "mode_profile_draft_context"), false);
|
||||
});
|
||||
|
||||
test("shade position rows explain the target opening at semantic boundaries", async () => {
|
||||
const positions = [0, 30, 50, 100];
|
||||
const events = [
|
||||
{ type: "message.accepted", route: "vehicle_control", engine: "n7web-mode-builder" },
|
||||
{
|
||||
type: "action.completed",
|
||||
success: true,
|
||||
payload: {
|
||||
status: "succeeded",
|
||||
execution_mode: "dry_run",
|
||||
orchestration_route: "mode_profile_create_preview",
|
||||
mode_profile_draft: {
|
||||
name: "遮阳测试模式",
|
||||
instruction: "遮阳帘目标开度测试",
|
||||
operation_count: positions.length,
|
||||
source_request_id: "req-draft-shade-positions",
|
||||
vehicle_id: "demo-vehicle",
|
||||
},
|
||||
actions: positions.map((position) => ({
|
||||
domain: "roof",
|
||||
capability: "roof.set_shade_position",
|
||||
target: { zone: "vehicle" },
|
||||
parameters: { position_pct: position },
|
||||
})),
|
||||
},
|
||||
},
|
||||
{ type: "answer.completed", route: "vehicle_control", answer: "模式草稿已生成" },
|
||||
];
|
||||
const harness = createHarness(events);
|
||||
harness.input.value = "构建一个遮阳测试模式";
|
||||
|
||||
await harness.sandbox.CognitiveAgentAssistant.submit();
|
||||
|
||||
const rows = harness.messages.querySelectorAll(".assistant-mode-draft-row");
|
||||
assert.equal(rows.length, 4);
|
||||
assert.deepEqual(
|
||||
rows.map((row) => ({
|
||||
label: row.children[1].textContent,
|
||||
value: row.children[2].textContent,
|
||||
})),
|
||||
[
|
||||
{ label: "遮阳帘", value: "完全关闭(目标开度 0%)" },
|
||||
{ label: "遮阳帘", value: "目标开度 30%" },
|
||||
{ label: "遮阳帘", value: "半开(目标开度 50%)" },
|
||||
{ label: "遮阳帘", value: "完全打开(目标开度 100%)" },
|
||||
],
|
||||
);
|
||||
});
|
||||
|
||||
test("ordinary questions and updates for another mode do not carry the draft reference", async () => {
|
||||
const events = modeDraftEvents("req-draft-scoped", 24);
|
||||
const harness = createHarness(events);
|
||||
|
||||
Reference in New Issue
Block a user