diff --git a/src/renderer/src/components/editor/RichMarkdownEditor.tsx b/src/renderer/src/components/editor/RichMarkdownEditor.tsx index 0338e2942..9794b3311 100644 --- a/src/renderer/src/components/editor/RichMarkdownEditor.tsx +++ b/src/renderer/src/components/editor/RichMarkdownEditor.tsx @@ -737,6 +737,29 @@ export default function RichMarkdownEditor({ return registerPendingEditorFlush(fileId, flushPendingSerialization) }, [fileId, flushPendingSerialization]) + const clearAttentionTimers = useCallback(() => { + if (attentionReviewCommentTimeoutRef.current !== null) { + window.clearTimeout(attentionReviewCommentTimeoutRef.current) + attentionReviewCommentTimeoutRef.current = null + } + if (sourceAttentionTimeoutRef.current !== null) { + window.clearTimeout(sourceAttentionTimeoutRef.current) + sourceAttentionTimeoutRef.current = null + } + }, []) + + const setRootElement = useCallback( + (node: HTMLDivElement | null) => { + // Why: review-note pulses are tied to this editor root; ref cleanup + // keeps the existing unmount boundary without a passive Effect. + if (node === null) { + clearAttentionTimers() + } + rootRef.current = node + }, + [clearAttentionTimers] + ) + const syncAnnotationTarget = useCallback((nextEditor: Editor): void => { if (annotationTargetFrameRef.current !== null) { window.cancelAnimationFrame(annotationTargetFrameRef.current) @@ -764,17 +787,6 @@ export default function RichMarkdownEditor({ }) }, []) - useEffect(() => { - return () => { - if (attentionReviewCommentTimeoutRef.current !== null) { - window.clearTimeout(attentionReviewCommentTimeoutRef.current) - } - if (sourceAttentionTimeoutRef.current !== null) { - window.clearTimeout(sourceAttentionTimeoutRef.current) - } - } - }, []) - const pulseRichMarkdownReviewNote = useCallback((commentId: string): void => { if (attentionReviewCommentTimeoutRef.current !== null) { window.clearTimeout(attentionReviewCommentTimeoutRef.current) @@ -1689,7 +1701,7 @@ export default function RichMarkdownEditor({ return (