import {
IconBrandDiscord,
IconBrandGithub,
IconBrandNotion,
IconBrandSlack,
IconBrandYoutube,
IconLayoutKanban,
IconLinkPlus,
IconTicket,
} from "@tabler/icons-react";
import {
ChevronDown,
File,
FileText,
Globe,
Link,
MessageCircle,
Microscope,
Plus,
Search,
Sparkles,
Telescope,
Webhook,
} from "lucide-react";
import type React from "react";
import { Button } from "@/components/ui/button";
import type { Connector, ResearchMode } from "./types";
// Helper function to get connector icon
export const getConnectorIcon = (connectorType: string) => {
const iconProps = { className: "h-4 w-4" };
switch (connectorType) {
case "LINKUP_API":
return ;
case "LINEAR_CONNECTOR":
return ;
case "GITHUB_CONNECTOR":
return ;
case "YOUTUBE_VIDEO":
return ;
case "CRAWLED_URL":
return ;
case "FILE":
return ;
case "EXTENSION":
return ;
case "SERPER_API":
case "TAVILY_API":
return ;
case "SLACK_CONNECTOR":
return ;
case "NOTION_CONNECTOR":
return ;
case "DISCORD_CONNECTOR":
return ;
case "JIRA_CONNECTOR":
return ;
case "DEEP":
return ;
case "DEEPER":
return ;
case "DEEPEST":
return ;
default:
return ;
}
};
export const researcherOptions: {
value: ResearchMode;
label: string;
icon: React.ReactNode;
}[] = [
{
value: "QNA",
label: "Q/A",
icon: getConnectorIcon("GENERAL"),
},
{
value: "REPORT_GENERAL",
label: "General",
icon: getConnectorIcon("GENERAL"),
},
{
value: "REPORT_DEEP",
label: "Deep",
icon: getConnectorIcon("DEEP"),
},
{
value: "REPORT_DEEPER",
label: "Deeper",
icon: getConnectorIcon("DEEPER"),
},
];
/**
* Displays a small icon for a connector type
*/
export const ConnectorIcon = ({ type, index = 0 }: { type: string; index?: number }) => (
{getConnectorIcon(type)}
);
/**
* Displays a count indicator for additional connectors
*/
export const ConnectorCountBadge = ({ count }: { count: number }) => (
+{count}
);
type ConnectorButtonProps = {
selectedConnectors: string[];
onClick: () => void;
connectorSources: Connector[];
};
/**
* Button that displays selected connectors and opens connector selection dialog
*/
export const ConnectorButton = ({
selectedConnectors,
onClick,
connectorSources,
}: ConnectorButtonProps) => {
const totalConnectors = connectorSources.length;
const selectedCount = selectedConnectors.length;
const progressPercentage = (selectedCount / totalConnectors) * 100;
// Get the name of a single selected connector
const getSingleConnectorName = () => {
const connector = connectorSources.find((c) => c.type === selectedConnectors[0]);
return connector?.name || "";
};
// Get display text based on selection count
const getDisplayText = () => {
if (selectedCount === totalConnectors) return "All Connectors";
if (selectedCount === 1) return getSingleConnectorName();
return `${selectedCount} Connectors`;
};
// Render the empty state (no connectors selected)
const renderEmptyState = () => (
<>
Select Connectors
>
);
// Render the selected connectors preview
const renderSelectedConnectors = () => (
<>
{/* Show up to 3 connector icons */}
{selectedConnectors.slice(0, 3).map((type, index) => (
))}
{/* Show count indicator if more than 3 connectors are selected */}
{selectedCount > 3 && }
{/* Display text */}
{getDisplayText()}
>
);
return (
);
};
// New component for Research Mode Control with Q/A and Report toggle
type ResearchModeControlProps = {
value: ResearchMode;
onChange: (value: ResearchMode) => void;
};
export const ResearchModeControl = ({ value, onChange }: ResearchModeControlProps) => {
// Determine if we're in Q/A mode or Report mode
const isQnaMode = value === "QNA";
const isReportMode = value.startsWith("REPORT_");
// Get the current report sub-mode
const getCurrentReportMode = () => {
if (!isReportMode) return "GENERAL";
return value.replace("REPORT_", "") as "GENERAL" | "DEEP" | "DEEPER";
};
const reportSubOptions = [
{ value: "GENERAL", label: "General", icon: getConnectorIcon("GENERAL") },
{ value: "DEEP", label: "Deep", icon: getConnectorIcon("DEEP") },
{ value: "DEEPER", label: "Deeper", icon: getConnectorIcon("DEEPER") },
];
const handleModeToggle = (mode: "QNA" | "REPORT") => {
if (mode === "QNA") {
onChange("QNA");
} else {
// Default to GENERAL for Report mode
onChange("REPORT_GENERAL");
}
};
const handleReportSubModeChange = (subMode: string) => {
onChange(`REPORT_${subMode}` as ResearchMode);
};
return (
{/* Main Q/A vs Report Toggle */}
{/* Report Sub-options (only show when in Report mode) */}
{isReportMode && (