From 8aef69ba93621d9f79b1f94206dc73ea2ba168e7 Mon Sep 17 00:00:00 2001 From: Muse Sweep Date: Mon, 26 Oct 2026 13:37:49 -0500 Subject: [PATCH] perf(id-web): remove hot-path [cursor-debug] logging from cursor decorations Ports PR #930's cursors.ts deletions onto current main (post-#922): the guarded [cursor-debug] clustering block in createCursorDecorations, the apply() UPDATE log, and the decorations() cursor-count log. 33 deletions, one file. Decision recorded on #956: delete (per #930) rather than guard-and-keep (per #922). #922 merged first and its guard was a stopgap; the #831 getLeftCoord throw contract lives in the helper itself and is unaffected. #930's unrelated cursor-utils getColorForClient typeof hunk is dropped as behavior-neutral churn. Verified: vitest cursor-utils 78/78, tsc --noEmit clean. Queue task 1105. --- pkgs/id/web/src/cursors.ts | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/pkgs/id/web/src/cursors.ts b/pkgs/id/web/src/cursors.ts index 380ce2941f..179bc980b2 100644 --- a/pkgs/id/web/src/cursors.ts +++ b/pkgs/id/web/src/cursors.ts @@ -643,30 +643,6 @@ function createCursorDecorations( // Cluster overlapping groups - only merge those that actually overlap const clusters = clusterOverlappingGroups(positionGroups, getLeftCoord); - // DEBUG: Log clustering results - if (positionGroups.length > 1) { - console.log("[cursor-debug] positionGroups:", positionGroups.length, "clusters:", clusters.length); - positionGroups.forEach((g, i) => { - // Debug logging must never throw on a failed coord lookup (#831). - let left: number | string = "no-view"; - if (getLeftCoord) { - try { - left = getLeftCoord(g.position); - } catch { - left = "unavailable"; - } - } - console.log( - ` group[${i}]: pos=${g.position}, left=${left}, cursors=${g.cursors.map((c) => c.clientID).join(",")}`, - ); - }); - clusters.forEach((c, i) => { - console.log( - ` cluster[${i}]: groups=${c.groups.length}, cursors=${c.groups.flatMap((g) => g.cursors.map((cur) => cur.clientID)).join(",")}`, - ); - }); - } - clusters.forEach((cluster) => { // Check if own cursor is in this cluster const clusterHasOwnCursor = cluster.groups.some((g) => g.cursors.some((c) => c.isOwnCursor)); @@ -855,7 +831,6 @@ export function createCursorPlugin(myClientID: string | number | null, sendCurso if (cursorUpdate) { switch (cursorUpdate.type) { case "update": { - console.log("[cursor-debug] apply() UPDATE for", cursorUpdate.clientID, "at", cursorUpdate.head); const newCursors = new Map(pluginState.cursors); // If idleSecs is provided (initial load), backdate lastUpdate const lastUpdate = cursorUpdate.idleSecs ? Date.now() - cursorUpdate.idleSecs * 1000 : Date.now(); @@ -967,14 +942,6 @@ export function createCursorPlugin(myClientID: string | number | null, sendCurso const pluginState = cursorPluginKey.getState(state); if (!pluginState) return DecorationSet.empty; - // DEBUG: Log cursor count - console.log( - "[cursor-debug] decorations() called, cursor count:", - pluginState.cursors.size, - "cursors:", - Array.from(pluginState.cursors.keys()).join(","), - ); - return createCursorDecorations(state, pluginState, myClientID, currentView); }, },