From a4e6516ae4ff8c6f48f4ea982c84dcae158d27b3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 21 Feb 2026 18:08:24 +0000 Subject: [PATCH 1/2] Initial plan From ba5fb5b57ae35e405ce6ddcff9848e563bc8b9d0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 21 Feb 2026 18:10:51 +0000 Subject: [PATCH 2/2] Fix module-level state and silent failure in caret plugin Co-authored-by: usamaasfar <42825498+usamaasfar@users.noreply.github.com> --- apps/desktop/src/editor/plugins/caret.ts | 25 ++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/apps/desktop/src/editor/plugins/caret.ts b/apps/desktop/src/editor/plugins/caret.ts index ca82e79..25d114f 100644 --- a/apps/desktop/src/editor/plugins/caret.ts +++ b/apps/desktop/src/editor/plugins/caret.ts @@ -4,12 +4,15 @@ import type { EditorView } from "prosemirror-view"; export type CaretStyle = "line" | "underline"; let caretStyle: CaretStyle = (localStorage.getItem("cursor") as CaretStyle) ?? "line"; -let activeView: EditorView | null = null; -let activeEl: HTMLElement | null = null; + +// Track all active caret instances so setCaretStyle updates every editor. +const activeInstances = new Map(); export function setCaretStyle(style: CaretStyle) { caretStyle = style; - if (activeView && activeEl) updateCaret(activeView, activeEl); + for (const [view, el] of activeInstances) { + updateCaret(view, el); + } } function getCursorRect(view: EditorView) { @@ -48,12 +51,19 @@ function updateCaret(view: EditorView, el: HTMLElement) { export const caretPlugin = new Plugin({ view(view) { + const parent = view.dom.parentElement; + if (!parent) { + throw new Error( + "caretPlugin: editor DOM node has no parent element – ensure the editor is mounted in the DOM before initializing the caret plugin", + ); + } + const el = document.createElement("div"); el.className = "pm-caret"; el.setAttribute("data-style", caretStyle); - view.dom.parentElement?.appendChild(el); - activeView = view; - activeEl = el; + parent.appendChild(el); + + activeInstances.set(view, el); updateCaret(view, el); return { @@ -62,8 +72,7 @@ export const caretPlugin = new Plugin({ }, destroy() { el.remove(); - activeView = null; - activeEl = null; + activeInstances.delete(view); }, }; },