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
{/* biome-ignore lint/a11y/useKeyWithClickEvents: stop-propagation only; no real interaction */} {/* biome-ignore lint/a11y/noStaticElementInteractions: stop-propagation only; no real interaction */}
e.stopPropagation()} style={{ background: "#2f2f2f", border: "1px solid #444", borderRadius: "12px", padding: "24px", maxWidth: "640px", width: "90vw", maxHeight: "60vh", display: "flex", flexDirection: "column", gap: "16px", boxShadow: "0 8px 32px rgba(0,0,0,0.5)", }} > {/* Header */}
/btw {question}
{/* Response area */}
{loading && !response && ( Thinking… )} {response && {response}}
{/* Footer hint */} {!loading && (
Press Escape, Enter, or Space to dismiss
)}
); }