From b54ad4b36c958f7fd0c58074b4d9d1cef98d8381 Mon Sep 17 00:00:00 2001 From: Jeff Emmett Date: Wed, 1 Apr 2026 12:32:01 -0700 Subject: [PATCH] Fix multi-user cursor positions: use page-relative coordinates Remote cursors were broadcast as viewport-relative (clientX/Y), causing them to appear at wrong positions when users had different scroll offsets. Now sends page-relative coords and converts back on the receiver side. Co-Authored-By: Claude Opus 4.6 --- shared/components/rstack-collab-overlay.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/shared/components/rstack-collab-overlay.ts b/shared/components/rstack-collab-overlay.ts index b187eb6..6c4bff4 100644 --- a/shared/components/rstack-collab-overlay.ts +++ b/shared/components/rstack-collab-overlay.ts @@ -5,7 +5,7 @@ * - "N online" badge (top-right pill with colored dots) * - People panel dropdown (click badge to open) * - Online/Offline mode toggle in panel - * - Remote cursors (SVG arrows with username labels, viewport-relative) + * - Remote cursors (SVG arrows with username labels, page-relative) * - Focus highlighting (colored outline rings on data-collab-id elements) * - Auto-discovery via rspace-doc-subscribe events from runtime * - Bridge API for canvas (external peer management via CommunitySync) @@ -395,7 +395,7 @@ export class RStackCollabOverlay extends HTMLElement { // ── Pointer tracking (15Hz throttle) — covers mouse, touch, and pen ── #pointerHandler = (e: PointerEvent) => { - this.#lastCursor = { x: e.clientX, y: e.clientY }; + this.#lastCursor = { x: e.clientX + window.scrollX, y: e.clientY + window.scrollY }; }; #startMouseTracking() { @@ -747,8 +747,10 @@ export class RStackCollabOverlay extends HTMLElement { const age = now - peer.lastSeen; const opacity = age > 5000 ? 0.3 : 1; + const sx = peer.cursor.x - window.scrollX; + const sy = peer.cursor.y - window.scrollY; fragments.push(` -
+