fix: distinguish annotation edits from annotation notes

This commit is contained in:
134 2026-06-23 18:33:35 +08:00
parent e0dc5a3d77
commit d3c921a489
2 changed files with 25 additions and 2 deletions

View File

@ -11,8 +11,20 @@ function uniqueStrings(values: Array<string | undefined | null>) {
}
export function hasCanvasAgentAnnotationEditIntent(userText: string) {
return /按.*(?:批注|标注|箭头|框选|备注)|(?:批注|标注|箭头|框选|圈选|annotation|note)/i.test(
userText
const text = trimText(userText, 1000);
if (!text) return false;
const annotationKeyword = "(?:批注|标注|箭头|框选|圈选|备注|annotation|note)";
if (new RegExp(`(?:添加|新增|创建|加|写).{0,8}${annotationKeyword}`, "i").test(text)) {
return false;
}
return (
new RegExp(`(?:按|按照|根据|依据|依照|参考|基于).{0,18}${annotationKeyword}`, "i").test(
text
) ||
new RegExp(
`${annotationKeyword}.{0,24}(?:修改|编辑|修图|改图|处理|调整|去掉|移除|换|生成|出图|执行)`,
"i"
).test(text)
);
}

View File

@ -3050,7 +3050,11 @@ test.describe("canvas chat pure helpers", () => {
};
expect(hasCanvasAgentAnnotationEditIntent("按批注修改这张图")).toBe(true);
expect(hasCanvasAgentAnnotationEditIntent("批注里的水印去掉")).toBe(true);
expect(hasCanvasAgentAnnotationEditIntent("把背景换成白色")).toBe(false);
expect(hasCanvasAgentAnnotationEditIntent("给选中图片加批注:这里保留")).toBe(
false
);
const prompt = buildCanvasAgentAnnotationEditPrompt({
context,
@ -3069,6 +3073,13 @@ test.describe("canvas chat pure helpers", () => {
userText: "把背景换成白色",
})
).toBe("");
expect(
buildCanvasAgentAnnotationEditPrompt({
context,
targetNodeIds: ["image-1"],
userText: "给选中图片加批注:这里保留",
})
).toBe("");
});
test("labels image note action as an agent annotation entry", () => {