diff --git a/src/components/dashboard/messenger.tsx b/src/components/dashboard/messenger.tsx index 5d84fe9..345bd7a 100644 --- a/src/components/dashboard/messenger.tsx +++ b/src/components/dashboard/messenger.tsx @@ -139,7 +139,10 @@ function ThreadView({ conv, nameOf, onError }: { conv: UiConversation; nameOf: ( const [draft, setDraft] = useState(""); const [sending, setSending] = useState(false); const [replyTo, setReplyTo] = useState(null); + const [flashId, setFlashId] = useState(null); const endRef = useRef(null); + const inputRef = useRef(null); + const msgRefs = useRef>(new Map()); const typingSentAt = useRef(0); useEffect(() => { endRef.current?.scrollIntoView({ behavior: "smooth" }); }, [t.messages.length]); @@ -147,6 +150,20 @@ function ThreadView({ conv, nameOf, onError }: { conv: UiConversation; nameOf: ( const byId = useMemo(() => Object.fromEntries(t.messages.map((m) => [m.id, m])), [t.messages]); const lastMineId = useMemo(() => [...t.messages].reverse().find((m) => m.mine)?.id ?? null, [t.messages]); + // Reply → focus the composer (bug: it didn't focus, forcing a manual click). + function startReply(msg: UiMessage) { + setReplyTo(msg); + requestAnimationFrame(() => inputRef.current?.focus()); + } + // Click a quoted message → scroll to the original and flash it. + function jumpTo(id: string) { + const el = msgRefs.current.get(id); + if (!el) return; + el.scrollIntoView({ behavior: "smooth", block: "center" }); + setFlashId(id); + setTimeout(() => setFlashId((f) => (f === id ? null : f)), 1200); + } + function onDraftChange(v: string) { setDraft(v); const now = Date.now(); @@ -188,8 +205,11 @@ function ThreadView({ conv, nameOf, onError }: { conv: UiConversation; nameOf: ( parent={msg.parentInteractionId ? byId[msg.parentInteractionId] : undefined} seen={msg.id === lastMineId && t.seenIds.has(msg.id)} showStatus={msg.id === lastMineId} + flash={flashId === msg.id} + registerRef={(el) => { if (el) msgRefs.current.set(msg.id, el); else msgRefs.current.delete(msg.id); }} onReact={(emoji) => t.react(msg.id, emoji)} - onReply={() => setReplyTo(msg)} + onReply={() => startReply(msg)} + onQuoteClick={jumpTo} /> ))}
@@ -209,6 +229,7 @@ function ThreadView({ conv, nameOf, onError }: { conv: UiConversation; nameOf: (