fix: open chat for annotation edits
This commit is contained in:
parent
5648ad12be
commit
c033e75ba1
@ -3598,8 +3598,14 @@ export function CanvasChatPanel({
|
||||
nodeId?: string;
|
||||
label?: string;
|
||||
};
|
||||
type PendingCanvasAgentAnnotationEditRequest = {
|
||||
nodeId?: string;
|
||||
title?: string;
|
||||
annotationCount?: number;
|
||||
};
|
||||
const targetWindow = window as Window & {
|
||||
__canvasAgentPendingSlotFillRequest?: PendingCanvasAgentSlotFillRequest;
|
||||
__canvasAgentPendingAnnotationEditRequest?: PendingCanvasAgentAnnotationEditRequest;
|
||||
};
|
||||
|
||||
const focusComposerWithPrompt = (prompt: string) => {
|
||||
@ -3645,6 +3651,10 @@ export function CanvasChatPanel({
|
||||
annotationCount?: number;
|
||||
}>
|
||||
).detail;
|
||||
const pending = targetWindow.__canvasAgentPendingAnnotationEditRequest;
|
||||
if (!pending?.nodeId || pending.nodeId === detail?.nodeId) {
|
||||
delete targetWindow.__canvasAgentPendingAnnotationEditRequest;
|
||||
}
|
||||
const nodeId = String(detail?.nodeId || "").trim();
|
||||
if (nodeId) {
|
||||
pendingCanvasAgentAnnotationEditTargetRef.current = {
|
||||
@ -3679,6 +3689,15 @@ export function CanvasChatPanel({
|
||||
})
|
||||
);
|
||||
}
|
||||
const pendingAnnotationEditRequest =
|
||||
targetWindow.__canvasAgentPendingAnnotationEditRequest;
|
||||
if (pendingAnnotationEditRequest) {
|
||||
handleAgentAnnotationEditRequest(
|
||||
new CustomEvent("canvas-agent-annotation-edit-request", {
|
||||
detail: pendingAnnotationEditRequest,
|
||||
})
|
||||
);
|
||||
}
|
||||
return () => {
|
||||
window.removeEventListener(
|
||||
"canvas-agent-slot-fill-request",
|
||||
|
||||
@ -6680,16 +6680,30 @@ export function ImageNode({
|
||||
return;
|
||||
}
|
||||
|
||||
const detail = {
|
||||
nodeId: node.id,
|
||||
title: displayTitle,
|
||||
annotationCount: canvasAgentAnnotations.length,
|
||||
};
|
||||
const targetWindow = window as Window & {
|
||||
__canvasAgentPendingAnnotationEditRequest?: typeof detail;
|
||||
};
|
||||
|
||||
selectNode(node.id, false);
|
||||
window.dispatchEvent(
|
||||
new CustomEvent("canvas-agent-annotation-edit-request", {
|
||||
targetWindow.__canvasAgentPendingAnnotationEditRequest = detail;
|
||||
targetWindow.dispatchEvent(
|
||||
new CustomEvent("canvas-open-chat-panel-request", {
|
||||
detail: {
|
||||
nodeId: node.id,
|
||||
title: displayTitle,
|
||||
annotationCount: canvasAgentAnnotations.length,
|
||||
reason: "agent-annotation-edit",
|
||||
nodeId: detail.nodeId,
|
||||
},
|
||||
})
|
||||
);
|
||||
targetWindow.dispatchEvent(
|
||||
new CustomEvent("canvas-agent-annotation-edit-request", {
|
||||
detail,
|
||||
})
|
||||
);
|
||||
}, [
|
||||
canvasAgentAnnotations.length,
|
||||
displayTitle,
|
||||
|
||||
@ -1388,6 +1388,7 @@ metadata: {
|
||||
2. 将 annotations 放入 `CanvasAgentContext`。
|
||||
3. 自动在输入框插入一句:“按这张图上的批注修改”。
|
||||
4. 用户可直接发送,也可补充文字。
|
||||
5. 若右侧对话面板关闭或 lazy 未挂载,需要先展开对话框,并缓存一次 pending annotation edit request,确保 prompt 与目标图不丢。
|
||||
|
||||
### 10.3 Agent 规则
|
||||
|
||||
@ -1621,6 +1622,7 @@ lib/ai/runtime/middlewares/canvas-agent-clarification-gate.ts
|
||||
- 图片节点 metadata 支持 annotations
|
||||
- 图片节点 UI 支持添加文本批注/框选批注
|
||||
- `CanvasAgentContext` 输出 annotations
|
||||
- “按批注修改”会展开对话框并在面板未挂载时保留 pending request
|
||||
- Agent prompt 加入标注编辑规则
|
||||
- 编辑结果使用 `append_revision`
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user