import { useEffect, useRef, useState } from "react";
import { Tooltip } from "react-tooltip";
import { At } from "@phosphor-icons/react";
import { useIsAgentSessionActive } from "@/utils/chat/agent";
export default function AvailableAgentsButton({ showing, setShowAgents }) {
const agentSessionActive = useIsAgentSessionActive();
if (agentSessionActive) return null;
return (
setShowAgents(!showing)}
className={`flex justify-center items-center cursor-pointer ${
showing ? "!opacity-100" : ""
}`}
>
);
}
function AbilityTag({ text }) {
return (
);
}
export function AvailableAgents({
showing,
setShowing,
sendCommand,
promptRef,
}) {
const formRef = useRef(null);
const agentSessionActive = useIsAgentSessionActive();
useEffect(() => {
function listenForOutsideClick() {
if (!showing || !formRef.current) return false;
document.addEventListener("click", closeIfOutside);
}
listenForOutsideClick();
}, [showing, formRef.current]);
const closeIfOutside = ({ target }) => {
if (target.id === "agent-list-btn") return;
const isOutside = !formRef?.current?.contains(target);
if (!isOutside) return;
setShowing(false);
};
if (agentSessionActive) return null;
return (
<>
>
);
}
export function useAvailableAgents() {
const [showAgents, setShowAgents] = useState(false);
return { showAgents, setShowAgents };
}