diff --git a/pkgs/id/web/src/cursor-utils.ts b/pkgs/id/web/src/cursor-utils.ts index 671288ca3c..1a0a2d1868 100644 --- a/pkgs/id/web/src/cursor-utils.ts +++ b/pkgs/id/web/src/cursor-utils.ts @@ -114,8 +114,7 @@ export const CURSOR_COLORS = [ * Uses a hash function to map client IDs to colors. */ export function getColorForClient(clientID: string | number): string { - // A plain loop: no intermediate array of characters per call. - const str = String(clientID); + const str = typeof clientID === "string" ? clientID : String(clientID); let hash = 0; for (let i = 0; i < str.length; i++) { hash = ((hash << 5) - hash + str.charCodeAt(i)) | 0; diff --git a/pkgs/id/web/src/cursors.ts b/pkgs/id/web/src/cursors.ts index 2cafe3d04d..0506c7212c 100644 --- a/pkgs/id/web/src/cursors.ts +++ b/pkgs/id/web/src/cursors.ts @@ -603,22 +603,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) => { - const left = getLeftCoord ? getLeftCoord(g.position) : "no-view"; - 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)); @@ -811,7 +795,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(); @@ -923,14 +906,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); }, },