fix: scope pending canvas view retry to project

This commit is contained in:
134 2026-06-22 22:45:03 +08:00
parent dfb8971bcb
commit 183f07be25
3 changed files with 24 additions and 2 deletions

View File

@ -4257,7 +4257,7 @@ export function CanvasChatPanel({
const payload: CanvasViewOperationStreamPayload =
typeof dataPart.data === "string" ? JSON.parse(dataPart.data) : dataPart.data;
const applied = applyCanvasViewOperation(payload);
if (!applied && shouldRetryCanvasViewOperationAfterRefresh(payload)) {
if (!applied && shouldRetryCanvasViewOperationAfterRefresh(payload, canvasId)) {
pendingCanvasViewOperationRef.current = payload;
}
} catch (e) {

View File

@ -65,10 +65,20 @@ export function shouldSkipCanvasMediaPayloadForHandledItems(params: {
}
export function shouldRetryCanvasViewOperationAfterRefresh(
payload: CanvasViewOperationStreamPayload
payload: CanvasViewOperationStreamPayload,
currentProjectId?: string
) {
const operation = String(payload?.operation || "").trim();
if (!operation) return false;
const targetProjectId = String(payload?.projectId || "").trim();
const normalizedCurrentProjectId = String(currentProjectId || "").trim();
if (
targetProjectId &&
normalizedCurrentProjectId &&
targetProjectId !== normalizedCurrentProjectId
) {
return false;
}
if (normalizeCanvasStreamIdList(payload.nodeIds).length > 0) return true;
if (String(payload.anchorNodeId || "").trim()) return true;
return (

View File

@ -1241,6 +1241,18 @@ test.describe("canvas chat pure helpers", () => {
operation: "zoom_in",
})
).toBe(false);
expect(
shouldRetryCanvasViewOperationAfterRefresh(
{
version: 1,
viewOperationId: "view-other-project",
operation: "focus_latest_result",
projectId: "project-other",
nodeIds: ["new-image-1"],
},
"project-current"
)
).toBe(false);
});
test("builds transient view operations for agent writeback results", () => {