import * as React from "react"; import Markdown from "react-markdown"; const { useEffect, useRef } = React; interface SideQuestionOverlayProps { question: string; /** Streaming response text. Empty while loading. */ response: string; loading: boolean; onDismiss: () => void; } /** * Dismissible overlay that shows a /btw side question and its streamed response. * The question and response are NOT part of the main conversation history. * Dismiss with Escape, Enter, or Space. */ export function SideQuestionOverlay({ question, response, loading, onDismiss, }: SideQuestionOverlayProps) { const dismissRef = useRef(onDismiss); dismissRef.current = onDismiss; useEffect(() => { const handler = (e: KeyboardEvent) => { if (e.key === "Escape" || e.key === "Enter" || e.key === " ") { e.preventDefault(); dismissRef.current(); } }; window.addEventListener("keydown", handler); return () => window.removeEventListener("keydown", handler); }, []); return ( // biome-ignore lint/a11y/noStaticElementInteractions: backdrop dismiss is supplementary; keyboard handled via window keydown // biome-ignore lint/a11y/useKeyWithClickEvents: keyboard dismiss handled via window keydown listener