From cc091d06ab842fdd5eeca88df94af382422c00cb Mon Sep 17 00:00:00 2001 From: Alex Hernandez Date: Mon, 2 Mar 2026 09:35:49 +1000 Subject: [PATCH] :bug: hover analysis should update the sidebar feedback --- .../components/Editor/MarkdownEditor.tsx | 2 ++ .../components/Feedback/FeedbackPanel.tsx | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/renderer/components/Editor/MarkdownEditor.tsx b/src/renderer/components/Editor/MarkdownEditor.tsx index 9c6cbaf..483f887 100644 --- a/src/renderer/components/Editor/MarkdownEditor.tsx +++ b/src/renderer/components/Editor/MarkdownEditor.tsx @@ -130,6 +130,7 @@ export function analyseAnnotation( const text = accumulated || ann.message const suggestion = extractBlockquote(text) ?? ann.suggestion ?? null tooltipAnalysisCache.set(ann.id, { text, suggestion }) + window.dispatchEvent(new CustomEvent('annotation-cached', { detail: { id: ann.id } })) onUpdate(text, false, suggestion) }).catch(() => { if (!cancelled) onUpdate(ann.message, false, ann.suggestion ?? null) @@ -137,6 +138,7 @@ export function analyseAnnotation( } else { const suggestion = ann.suggestion ?? null tooltipAnalysisCache.set(ann.id, { text: ann.message, suggestion }) + window.dispatchEvent(new CustomEvent('annotation-cached', { detail: { id: ann.id } })) onUpdate(ann.message, false, suggestion) } diff --git a/src/renderer/components/Feedback/FeedbackPanel.tsx b/src/renderer/components/Feedback/FeedbackPanel.tsx index 6d4fafa..fb05e4b 100644 --- a/src/renderer/components/Feedback/FeedbackPanel.tsx +++ b/src/renderer/components/Feedback/FeedbackPanel.tsx @@ -79,6 +79,24 @@ function FeedbackCard({ ann, autoAnalyse, onDismiss }: FeedbackCardProps): JSX.E return () => { cleanupRef.current?.() } }, []) + // When a hover tooltip completes analysis for this annotation, hydrate the card + // from the cache so the sidebar reflects the result without requiring a manual click. + useEffect(() => { + const handler = (e: Event): void => { + const { id } = (e as CustomEvent<{ id: string }>).detail + if (id !== ann.id) return + const cached = tooltipAnalysisCache.get(ann.id) + if (!cached) return + setState(prev => + prev.status === 'idle' + ? { status: 'done', text: cached.text, suggestion: cached.suggestion } + : prev + ) + } + window.addEventListener('annotation-cached', handler) + return () => window.removeEventListener('annotation-cached', handler) + }, [ann.id]) + const typeName = ann.type.replace(/_/g, ' ') const isSpinning = state.status === 'streaming' && state.text === '' const hasText = (state.status === 'streaming' || state.status === 'done') && state.text !== ''