diff --git a/frontend/src/components/pilot/ResolutionNotePreview.tsx b/frontend/src/components/pilot/ResolutionNotePreview.tsx index 600d3143..3a6ec8c4 100644 --- a/frontend/src/components/pilot/ResolutionNotePreview.tsx +++ b/frontend/src/components/pilot/ResolutionNotePreview.tsx @@ -9,7 +9,7 @@ * Kind switches the labels, button colors, and confirm-CTA text — the * underlying mechanics (preview fetch + edit + post) are identical. */ -import { useState, useEffect } from 'react' +import { useRef, useState, useEffect } from 'react' import { Loader2, RefreshCw, X, FileText, Pencil, Check, ArrowUpRight } from 'lucide-react' import { MarkdownContent } from '@/components/ui/MarkdownContent' import { cn } from '@/lib/utils' @@ -43,6 +43,7 @@ export function ResolutionNotePreview({ const [refreshing, setRefreshing] = useState(false) const [editing, setEditing] = useState(false) const [draft, setDraft] = useState('') + const popoverRef = useRef(null) // Keep the draft textarea in sync whenever fresh markdown arrives and we // aren't in the middle of editing. Once the engineer edits, their changes @@ -53,6 +54,15 @@ export function ResolutionNotePreview({ } }, [preview?.markdown, editing]) + // The popover renders at the bottom of TaskLane's scrollable region, which + // can leave it below the fold on smaller viewports. Scroll it into view + // whenever it opens so the engineer sees their preview immediately. + useEffect(() => { + if (open && popoverRef.current) { + popoverRef.current.scrollIntoView({ behavior: 'smooth', block: 'nearest' }) + } + }, [open]) + if (!open) return null const label = kind === 'resolve' ? 'Resolution note' : 'Escalation handoff package' @@ -73,7 +83,7 @@ export function ResolutionNotePreview({ } return ( -
+