From 5b69790e4c0c223250a57e5d85a0e78a80c6bd1f Mon Sep 17 00:00:00 2001 From: Mao Nakamoto Date: Sun, 30 Aug 2026 04:18:01 +0000 Subject: [PATCH] fix(compose): surface failed figure saves instead of discarding them silently MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dragging, resizing, or reordering a figure calls updateFigure.mutate with no onError handler, while every other mutation in the app (upload, surface save, figure edit) toasts on failure. A failed PATCH here left Konva's local node position out of sync with the DB with zero indication anything went wrong — the user only discovered the loss on a later reload, by which point the change felt real. Wire the same toast.error(err.message) pattern already used elsewhere in this file family. --- app/src/components/compose/CanvasToolbar.tsx | 5 ++++- app/src/components/compose/CompositionCanvas.tsx | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/src/components/compose/CanvasToolbar.tsx b/app/src/components/compose/CanvasToolbar.tsx index 53a9684..03f24b6 100644 --- a/app/src/components/compose/CanvasToolbar.tsx +++ b/app/src/components/compose/CanvasToolbar.tsx @@ -50,7 +50,10 @@ export function CanvasToolbar({ if (!selectedFigure) return; const newDepth = direction === 'up' ? selectedFigure.z_depth + 1 : Math.max(0, selectedFigure.z_depth - 1); - updateFigure.mutate({ id: selectedFigure.id, data: { z_depth: newDepth } }); + updateFigure.mutate( + { id: selectedFigure.id, data: { z_depth: newDepth } }, + { onError: (err) => toast.error(err.message) }, + ); } function downloadPanel(file: PanelFile, panelCount: number, dpi: number) { diff --git a/app/src/components/compose/CompositionCanvas.tsx b/app/src/components/compose/CompositionCanvas.tsx index 9724e16..8807c22 100644 --- a/app/src/components/compose/CompositionCanvas.tsx +++ b/app/src/components/compose/CompositionCanvas.tsx @@ -104,14 +104,20 @@ export function CompositionCanvas({ projectId, figures, surface }: CompositionCa const handleDragEnd = useCallback( (figureId: string, normX: number, normY: number) => { - updateFigure.mutate({ id: figureId, data: { position_x: normX, position_y: normY } }); + updateFigure.mutate( + { id: figureId, data: { position_x: normX, position_y: normY } }, + { onError: (err) => toast.error(err.message) }, + ); }, [updateFigure], ); const handleScaleChange = useCallback( (figureId: string, scale: number) => { - updateFigure.mutate({ id: figureId, data: { scale } }); + updateFigure.mutate( + { id: figureId, data: { scale } }, + { onError: (err) => toast.error(err.message) }, + ); }, [updateFigure], );