({
selectionLabel,
contextPreview,
anchorPoint = null,
onSubmit,
onClose,
}: {
selectionLabel: string;
contextPreview?: string;
anchorPoint?: AgentModalAnchorPoint | null;
onSubmit: (instruction: string) => void;
onClose: () => void;
})
| 25 | } |
| 26 | |
| 27 | export function AskAgentModal({ |
| 28 | selectionLabel, |
| 29 | contextPreview, |
| 30 | anchorPoint = null, |
| 31 | onSubmit, |
| 32 | onClose, |
| 33 | }: { |
| 34 | selectionLabel: string; |
| 35 | contextPreview?: string; |
| 36 | anchorPoint?: AgentModalAnchorPoint | null; |
| 37 | onSubmit: (instruction: string) => void; |
| 38 | onClose: () => void; |
| 39 | }) { |
| 40 | const [value, setValue] = useState(""); |
| 41 | const inputRef = useRef<HTMLTextAreaElement>(null); |
| 42 | const modalPositionStyle = getAgentModalPositionStyle(anchorPoint); |
| 43 | |
| 44 | useMountEffect(() => { |
| 45 | requestAnimationFrame(() => inputRef.current?.focus()); |
| 46 | }); |
| 47 | |
| 48 | const handleSubmit = () => { |
| 49 | if (!value.trim()) return; |
| 50 | onSubmit(value.trim()); |
| 51 | }; |
| 52 | |
| 53 | return ( |
| 54 | <div |
| 55 | className={ |
| 56 | anchorPoint |
| 57 | ? "fixed inset-0 z-[100] bg-black/60 backdrop-blur-sm" |
| 58 | : "fixed inset-0 z-[100] flex items-center justify-center bg-black/60 backdrop-blur-sm" |
| 59 | } |
| 60 | onClick={onClose} |
| 61 | > |
| 62 | <div |
| 63 | className={`w-[480px] rounded-2xl border border-neutral-800 bg-neutral-950 shadow-2xl ${ |
| 64 | anchorPoint ? "fixed" : "" |
| 65 | }`} |
| 66 | style={modalPositionStyle} |
| 67 | onClick={(e) => e.stopPropagation()} |
| 68 | > |
| 69 | <div className="flex items-center justify-between px-5 py-4 border-b border-neutral-800/60"> |
| 70 | <div> |
| 71 | <h3 className="text-sm font-medium text-neutral-200">Copy prompt to AI agent</h3> |
| 72 | <p className="text-xs text-neutral-500 mt-0.5"> |
| 73 | {selectionLabel.length > 50 ? `${selectionLabel.slice(0, 49)}…` : selectionLabel} |
| 74 | </p> |
| 75 | </div> |
| 76 | <button |
| 77 | className="p-1 rounded-md text-neutral-500 hover:text-neutral-300 hover:bg-neutral-800/50" |
| 78 | onClick={onClose} |
| 79 | > |
| 80 | <svg |
| 81 | width="14" |
| 82 | height="14" |
| 83 | viewBox="0 0 24 24" |
| 84 | fill="none" |
nothing calls this directly
no test coverage detected