fix: route clear canvas requests through confirmation
This commit is contained in:
parent
0bb134d3b8
commit
50aa93d5f3
@ -136,7 +136,13 @@ function getDecisionNodeIds(params: {
|
|||||||
|
|
||||||
function inferHighRiskOperation(userText: string) {
|
function inferHighRiskOperation(userText: string) {
|
||||||
const text = userText.toLowerCase();
|
const text = userText.toLowerCase();
|
||||||
if (/删除|删掉|移除/.test(text)) return "delete_nodes";
|
if (
|
||||||
|
/删除|删掉|删了|删去|移除/.test(text) ||
|
||||||
|
/清空(?:画布|选中|当前|节点|对象|元素|这些|全部)/.test(text) ||
|
||||||
|
/清除(?:选中|当前|节点|对象|元素|这些|全部)/.test(text)
|
||||||
|
) {
|
||||||
|
return "delete_nodes";
|
||||||
|
}
|
||||||
if (/覆盖|替换当前|替换原图|直接替换|覆盖原图/.test(text)) {
|
if (/覆盖|替换当前|替换原图|直接替换|覆盖原图/.test(text)) {
|
||||||
return "replace_node_media";
|
return "replace_node_media";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -266,6 +266,12 @@ test.describe("canvas chat pure helpers", () => {
|
|||||||
context: plannerContext,
|
context: plannerContext,
|
||||||
})
|
})
|
||||||
).toBe(true);
|
).toBe(true);
|
||||||
|
expect(
|
||||||
|
shouldConsiderCanvasAgentModelPlanner({
|
||||||
|
userText: "清空选中的节点",
|
||||||
|
context: plannerContext,
|
||||||
|
})
|
||||||
|
).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("treats selected agent slots as canvas routing context", () => {
|
test("treats selected agent slots as canvas routing context", () => {
|
||||||
@ -656,6 +662,23 @@ test.describe("canvas chat pure helpers", () => {
|
|||||||
riskOperation: "delete_nodes",
|
riskOperation: "delete_nodes",
|
||||||
targetNodeIds: ["image-1", "text-1"],
|
targetNodeIds: ["image-1", "text-1"],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const clearOutcome = normalizeCanvasAgentModelPlannerDecision({
|
||||||
|
decision: {
|
||||||
|
action: "none",
|
||||||
|
},
|
||||||
|
context: plannerContext,
|
||||||
|
projectId: plannerContext.projectId || "",
|
||||||
|
messageId: "message-1",
|
||||||
|
chatId: "chat-1",
|
||||||
|
userText: "清除选中的对象",
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(clearOutcome).toMatchObject({
|
||||||
|
kind: "confirmation_required",
|
||||||
|
riskOperation: "delete_nodes",
|
||||||
|
targetNodeIds: ["image-1", "text-1"],
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("builds pending move-node operation from model-planned high-risk layout", () => {
|
test("builds pending move-node operation from model-planned high-risk layout", () => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user