Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: multi-touch pointer isolation + reset state on mediaKey change (#2036)

Adam Eivy2fe42a754619
diff --git a/client/src/components/media/AnnotationCanvas.jsx b/client/src/components/media/AnnotationCanvas.jsx
index f0f0b29f02..cf1232b1a1 100644
--- a/client/src/components/media/AnnotationCanvas.jsx
+++ b/client/src/components/media/AnnotationCanvas.jsx
@@ -16,6 +16,7 @@ const AnnotationCanvas = forwardRef(function AnnotationCanvas(
const canvasRef = useRef(null);
const imgRef = useRef(null);
const drawingRef = useRef(null); // in-progress (uncommitted) stroke
+ const activePointerIdRef = useRef(null); // the single pointer we're tracking
const [dims, setDims] = useState(null); // { w, h } in natural pixels
const [inProgress, setInProgress] = useState(null);
@@ -54,8 +55,11 @@ const AnnotationCanvas = forwardRef(function AnnotationCanvas(
}, []);
const handlePointerDown = useCallback((e) => {
- if (!dims) return;
+ // Track exactly one pointer — a second finger/palm mid-draw is ignored so
+ // it can't hijack or garble the in-progress stroke on touch devices.
+ if (!dims || activePointerIdRef.current !== null) return;
e.preventDefault();
+ activePointerIdRef.current = e.pointerId;
// Capture so strokes continue smoothly even when the pointer leaves the
// canvas bounds mid-draw. Auto-releases on pointerup/cancel.
canvasRef.current?.setPointerCapture?.(e.pointerId);
@@ -66,7 +70,7 @@ const AnnotationCanvas = forwardRef(function AnnotationCanvas(
}, [dims, tool, toNatural]);
const handlePointerMove = useCallback((e) => {
- if (!drawingRef.current) return;
+ if (e.pointerId !== activePointerIdRef.current || !drawingRef.current) return;
e.preventDefault();
const { x, y } = toNatural(e);
const next = appendPoint(drawingRef.current, x, y);
@@ -74,7 +78,9 @@ const AnnotationCanvas = forwardRef(function AnnotationCanvas(
setInProgress(next);
}, [toNatural]);
- const finishStroke = useCallback(() => {
+ const finishStroke = useCallback((e) => {
+ if (e && e.pointerId !== activePointerIdRef.current) return;
+ activePointerIdRef.current = null;
const stroke = drawingRef.current;
if (!stroke) return;
drawingRef.current = null;
diff --git a/client/src/pages/MediaAnnotate.jsx b/client/src/pages/MediaAnnotate.jsx
index f8e02e4b29..91df711586 100644
--- a/client/src/pages/MediaAnnotate.jsx
+++ b/client/src/pages/MediaAnnotate.jsx
@@ -38,10 +38,16 @@ export default function MediaAnnotate() {
const [loading, setLoading] = useState(true);
const [imageError, setImageError] = useState(false);
- // Load any previously-saved strokes for this media key.
+ // Load any previously-saved strokes for this media key. React Router reuses
+ // this component instance across :mediaKey changes (no remount), so reset all
+ // transient view state synchronously before fetching — otherwise the previous
+ // key's strokes / imageError / dims leak onto the new image.
useEffect(() => {
if (!isImage) { setLoading(false); return; }
let active = true;
+ setStrokes([]);
+ setDims(null);
+ setImageError(false);
setLoading(true);
getMediaSketch(mediaKey, { silent: true })
.then((res) => {