fix false spatial targeting in canvas follow-up edits
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled

This commit is contained in:
Your Name 2026-03-10 12:11:18 +08:00
parent 6de541c1fb
commit 3347bb0d87
2 changed files with 6 additions and 6 deletions

View File

@ -3002,7 +3002,7 @@ export async function POST(request: Request) {
/用户已选中\s*\d+\s*张图片/.test(autoContextText);
const hasExplicitTargetHint =
requestTargetResolution.resolutionMode === "text_reference" ||
/第[一二三四五六七八九十\d]+张|左|右|上|下|中间|选中/.test(requestTextContent);
/第[一二三四五六七八九十\d]+张|左边|左侧|左上|左下|右边|右侧|右上|右下|上面|上方|下面|下方|中间|居中|中央|选中/.test(requestTextContent);
const hasActionableEditIntent = /改|调整|优化|换|替换|去掉|抠|重绘|增强|修|处理|按照|按|保留|统一|色差|背景|清晰|风格/.test(
requestTextContent
);

View File

@ -103,11 +103,11 @@ function pickBySpatialHint(text: string, refs: ResolvedImageRef[]): ResolvedImag
if (!refs.length) return [];
const normalizedText = text.replace(/\s+/g, "");
const hasLeft = normalizedText.includes("左");
const hasRight = normalizedText.includes("右");
const hasTop = normalizedText.includes("上");
const hasBottom = normalizedText.includes("下");
const hasCenter = normalizedText.includes("中间") || normalizedText.includes("中");
const hasLeft = /左边|左侧|左面|左上|左下|靠左/.test(normalizedText);
const hasRight = /右边|右侧|右面|右上|右下|靠右/.test(normalizedText);
const hasTop = /上面|上方|上边|上侧|顶部|靠上|最上/.test(normalizedText);
const hasBottom = /下面|下方|下边|下侧|底部|靠下|最下/.test(normalizedText);
const hasCenter = /中间|居中|正中|中央/.test(normalizedText);
if (!(hasLeft || hasRight || hasTop || hasBottom || hasCenter)) return [];