chore: ran frontend linting

This commit is contained in:
Anish Sarkar 2026-01-19 21:23:22 +05:30
parent 5f672a07f2
commit f0997b0a30
11 changed files with 199 additions and 193 deletions

View file

@ -101,7 +101,8 @@ export const ConnectorIndicator: FC = () => {
// Fallback to API if Electric is not available or fails // Fallback to API if Electric is not available or fails
// Use Electric data if: 1) we have data, or 2) still loading without error // Use Electric data if: 1) we have data, or 2) still loading without error
// Use API data if: Electric failed (has error) or finished loading with no data // Use API data if: Electric failed (has error) or finished loading with no data
const useElectricData = connectorsFromElectric.length > 0 || (connectorsLoading && !connectorsError); const useElectricData =
connectorsFromElectric.length > 0 || (connectorsLoading && !connectorsError);
const connectors = useElectricData ? connectorsFromElectric : allConnectors || []; const connectors = useElectricData ? connectorsFromElectric : allConnectors || [];
// Manual refresh function that works with both Electric and API // Manual refresh function that works with both Electric and API
@ -226,7 +227,6 @@ export const ConnectorIndicator: FC = () => {
isDisconnecting={isDisconnecting} isDisconnecting={isDisconnecting}
isIndexing={indexingConnectorIds.has(editingConnector.id)} isIndexing={indexingConnectorIds.has(editingConnector.id)}
searchSpaceId={searchSpaceId?.toString()} searchSpaceId={searchSpaceId?.toString()}
onStartDateChange={setStartDate} onStartDateChange={setStartDate}
onEndDateChange={setEndDate} onEndDateChange={setEndDate}
onPeriodicEnabledChange={setPeriodicEnabled} onPeriodicEnabledChange={setPeriodicEnabled}

View file

@ -123,7 +123,8 @@ export const MCPConnectForm: FC<ConnectFormProps> = ({ onSubmit, isSubmitting })
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<Server className="h-4 w-4 shrink-0" /> <Server className="h-4 w-4 shrink-0" />
<AlertDescription className="text-[10px] sm:text-xs"> <AlertDescription className="text-[10px] sm:text-xs">
Connect to an MCP (Model Context Protocol) server. Each MCP server is added as a separate connector. Connect to an MCP (Model Context Protocol) server. Each MCP server is added as a
separate connector.
</AlertDescription> </AlertDescription>
</div> </div>
</Alert> </Alert>
@ -140,11 +141,10 @@ export const MCPConnectForm: FC<ConnectFormProps> = ({ onSubmit, isSubmitting })
rows={16} rows={16}
className={`font-mono text-xs ${jsonError ? "border-red-500" : ""}`} className={`font-mono text-xs ${jsonError ? "border-red-500" : ""}`}
/> />
{jsonError && ( {jsonError && <p className="text-xs text-red-500">{jsonError}</p>}
<p className="text-xs text-red-500">{jsonError}</p>
)}
<p className="text-[10px] sm:text-xs text-muted-foreground"> <p className="text-[10px] sm:text-xs text-muted-foreground">
Paste a single MCP server configuration. Must include: name, command, args (optional), env (optional), transport (optional). Paste a single MCP server configuration. Must include: name, command, args (optional),
env (optional), transport (optional).
</p> </p>
</div> </div>
@ -178,7 +178,9 @@ export const MCPConnectForm: FC<ConnectFormProps> = ({ onSubmit, isSubmitting })
<div className="flex-1"> <div className="flex-1">
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 sm:gap-0"> <div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 sm:gap-0">
<AlertTitle className="text-xs sm:text-sm"> <AlertTitle className="text-xs sm:text-sm">
{testResult.status === "success" ? "Connection Successful" : "Connection Failed"} {testResult.status === "success"
? "Connection Successful"
: "Connection Failed"}
</AlertTitle> </AlertTitle>
{testResult.tools.length > 0 && ( {testResult.tools.length > 0 && (
<Button <Button
@ -212,9 +214,7 @@ export const MCPConnectForm: FC<ConnectFormProps> = ({ onSubmit, isSubmitting })
{testResult.message} {testResult.message}
{showDetails && testResult.tools.length > 0 && ( {showDetails && testResult.tools.length > 0 && (
<div className="mt-3 pt-3 border-t border-green-500/20"> <div className="mt-3 pt-3 border-t border-green-500/20">
<p className="font-semibold mb-2 text-[10px] sm:text-xs"> <p className="font-semibold mb-2 text-[10px] sm:text-xs">Available tools:</p>
Available tools:
</p>
<ul className="list-disc list-inside text-[10px] sm:text-xs space-y-0.5"> <ul className="list-disc list-inside text-[10px] sm:text-xs space-y-0.5">
{testResult.tools.map((tool) => ( {testResult.tools.map((tool) => (
<li key={tool.name}>{tool.name}</li> <li key={tool.name}>{tool.name}</li>

View file

@ -50,17 +50,12 @@ export const MCPConfig: FC<MCPConfigProps> = ({ connector, onConfigChange, onNam
// Validate that this is an MCP connector (after hooks) // Validate that this is an MCP connector (after hooks)
if (connector.connector_type !== EnumConnectorName.MCP_CONNECTOR) { if (connector.connector_type !== EnumConnectorName.MCP_CONNECTOR) {
console.error( console.error("MCPConfig received non-MCP connector:", connector.connector_type);
"MCPConfig received non-MCP connector:",
connector.connector_type
);
return ( return (
<Alert className="border-red-500/50 bg-red-500/10"> <Alert className="border-red-500/50 bg-red-500/10">
<XCircle className="h-4 w-4 text-red-600" /> <XCircle className="h-4 w-4 text-red-600" />
<AlertTitle>Invalid Connector Type</AlertTitle> <AlertTitle>Invalid Connector Type</AlertTitle>
<AlertDescription> <AlertDescription>This component can only be used with MCP connectors.</AlertDescription>
This component can only be used with MCP connectors.
</AlertDescription>
</Alert> </Alert>
); );
} }
@ -127,7 +122,9 @@ export const MCPConfig: FC<MCPConfigProps> = ({ connector, onConfigChange, onNam
{/* Server Name */} {/* Server Name */}
<div className="rounded-xl border border-border bg-slate-400/5 dark:bg-white/5 p-3 sm:p-6 space-y-3 sm:space-y-4"> <div className="rounded-xl border border-border bg-slate-400/5 dark:bg-white/5 p-3 sm:p-6 space-y-3 sm:space-y-4">
<div className="space-y-2"> <div className="space-y-2">
<Label htmlFor="name" className="text-xs sm:text-sm">Server Name</Label> <Label htmlFor="name" className="text-xs sm:text-sm">
Server Name
</Label>
<Input <Input
id="name" id="name"
value={name} value={name}
@ -159,11 +156,10 @@ export const MCPConfig: FC<MCPConfigProps> = ({ connector, onConfigChange, onNam
rows={16} rows={16}
className={`font-mono text-xs ${jsonError ? "border-red-500" : ""}`} className={`font-mono text-xs ${jsonError ? "border-red-500" : ""}`}
/> />
{jsonError && ( {jsonError && <p className="text-xs text-red-500">JSON Error: {jsonError}</p>}
<p className="text-xs text-red-500">JSON Error: {jsonError}</p>
)}
<p className="text-[10px] sm:text-xs text-muted-foreground"> <p className="text-[10px] sm:text-xs text-muted-foreground">
Edit your MCP server configuration. Must include: name, command, args (optional), env (optional), transport (optional). Edit your MCP server configuration. Must include: name, command, args (optional), env
(optional), transport (optional).
</p> </p>
</div> </div>
@ -197,7 +193,9 @@ export const MCPConfig: FC<MCPConfigProps> = ({ connector, onConfigChange, onNam
<div className="flex-1"> <div className="flex-1">
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 sm:gap-0"> <div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 sm:gap-0">
<AlertTitle className="text-sm"> <AlertTitle className="text-sm">
{testResult.status === "success" ? "Connection Successful" : "Connection Failed"} {testResult.status === "success"
? "Connection Successful"
: "Connection Failed"}
</AlertTitle> </AlertTitle>
{testResult.tools.length > 0 && ( {testResult.tools.length > 0 && (
<Button <Button
@ -231,9 +229,7 @@ export const MCPConfig: FC<MCPConfigProps> = ({ connector, onConfigChange, onNam
{testResult.message} {testResult.message}
{showDetails && testResult.tools.length > 0 && ( {showDetails && testResult.tools.length > 0 && (
<div className="mt-3 pt-3 border-t border-green-500/20"> <div className="mt-3 pt-3 border-t border-green-500/20">
<p className="font-semibold mb-2"> <p className="font-semibold mb-2">Available tools:</p>
Available tools:
</p>
<ul className="list-disc list-inside text-xs space-y-0.5"> <ul className="list-disc list-inside text-xs space-y-0.5">
{testResult.tools.map((tool) => ( {testResult.tools.map((tool) => (
<li key={tool.name}>{tool.name}</li> <li key={tool.name}>{tool.name}</li>

View file

@ -99,7 +99,10 @@ export const ConnectorConnectView: FC<ConnectorConnectViewProps> = ({
</div> </div>
<div> <div>
<h2 className="text-xl sm:text-2xl font-semibold tracking-tight"> <h2 className="text-xl sm:text-2xl font-semibold tracking-tight">
Connect {connectorType === "MCP_CONNECTOR" ? "MCP Server" : getConnectorTypeDisplay(connectorType)} Connect{" "}
{connectorType === "MCP_CONNECTOR"
? "MCP Server"
: getConnectorTypeDisplay(connectorType)}
</h2> </h2>
<p className="text-xs sm:text-base text-muted-foreground mt-1"> <p className="text-xs sm:text-base text-muted-foreground mt-1">
Enter your connection details Enter your connection details
@ -139,7 +142,11 @@ export const ConnectorConnectView: FC<ConnectorConnectViewProps> = ({
Connecting Connecting
</> </>
) : ( ) : (
<>{connectorType === "MCP_CONNECTOR" ? "Connect" : `Connect ${getConnectorTypeDisplay(connectorType)}`}</> <>
{connectorType === "MCP_CONNECTOR"
? "Connect"
: `Connect ${getConnectorTypeDisplay(connectorType)}`}
</>
)} )}
</Button> </Button>
</div> </div>

View file

@ -200,7 +200,6 @@ export const ConnectorEditView: FC<ConnectorEditViewProps> = ({
onConfigChange={onConfigChange} onConfigChange={onConfigChange}
onNameChange={onNameChange} onNameChange={onNameChange}
searchSpaceId={searchSpaceId} searchSpaceId={searchSpaceId}
/> />
)} )}

View file

@ -644,7 +644,8 @@ export const useConnectorDialog = () => {
}, },
}); });
const successMessage = currentConnectorType === "MCP_CONNECTOR" const successMessage =
currentConnectorType === "MCP_CONNECTOR"
? `${connector.name} added successfully` ? `${connector.name} added successfully`
: `${connectorTitle} connected and indexing started!`; : `${connectorTitle} connected and indexing started!`;
toast.success(successMessage, { toast.success(successMessage, {
@ -708,7 +709,8 @@ export const useConnectorDialog = () => {
await refetchAllConnectors(); await refetchAllConnectors();
} else { } else {
// Other non-indexable connectors - just show success message and close // Other non-indexable connectors - just show success message and close
const successMessage = currentConnectorType === "MCP_CONNECTOR" const successMessage =
currentConnectorType === "MCP_CONNECTOR"
? `${connector.name} added successfully` ? `${connector.name} added successfully`
: `${connectorTitle} connected successfully!`; : `${connectorTitle} connected successfully!`;
toast.success(successMessage); toast.success(successMessage);

View file

@ -96,9 +96,7 @@ export const ActiveConnectorsTab: FC<ActiveConnectorsTabProps> = ({
// Separate OAuth and non-OAuth connectors // Separate OAuth and non-OAuth connectors
const oauthConnectors = connectors.filter((c) => oauthConnectorTypes.has(c.connector_type)); const oauthConnectors = connectors.filter((c) => oauthConnectorTypes.has(c.connector_type));
const nonOauthConnectors = connectors.filter( const nonOauthConnectors = connectors.filter((c) => !oauthConnectorTypes.has(c.connector_type));
(c) => !oauthConnectorTypes.has(c.connector_type)
);
// Group OAuth connectors by type // Group OAuth connectors by type
const oauthConnectorsByType = oauthConnectors.reduce( const oauthConnectorsByType = oauthConnectors.reduce(
@ -150,8 +148,7 @@ export const ActiveConnectorsTab: FC<ActiveConnectorsTabProps> = ({
}); });
const hasActiveConnectors = const hasActiveConnectors =
filteredOAuthConnectorTypes.length > 0 || filteredOAuthConnectorTypes.length > 0 || filteredNonOAuthConnectors.length > 0;
filteredNonOAuthConnectors.length > 0;
return ( return (
<TabsContent value="active" className="m-0"> <TabsContent value="active" className="m-0">

View file

@ -123,7 +123,6 @@ export const AllConnectorsTab: FC<AllConnectorsTabProps> = ({
isConnecting={isConnecting} isConnecting={isConnecting}
documentCount={documentCount} documentCount={documentCount}
accountCount={accountCount} accountCount={accountCount}
isIndexing={isIndexing} isIndexing={isIndexing}
onConnect={() => onConnectOAuth(connector)} onConnect={() => onConnectOAuth(connector)}
onManage={ onManage={
@ -165,8 +164,12 @@ export const AllConnectorsTab: FC<AllConnectorsTabProps> = ({
// For MCP connectors, count total MCP connectors instead of document count // For MCP connectors, count total MCP connectors instead of document count
const isMCP = connector.connectorType === EnumConnectorName.MCP_CONNECTOR; const isMCP = connector.connectorType === EnumConnectorName.MCP_CONNECTOR;
const mcpConnectorCount = isMCP && allConnectors const mcpConnectorCount =
? allConnectors.filter((c: SearchSourceConnector) => c.connector_type === EnumConnectorName.MCP_CONNECTOR).length isMCP && allConnectors
? allConnectors.filter(
(c: SearchSourceConnector) =>
c.connector_type === EnumConnectorName.MCP_CONNECTOR
).length
: undefined; : undefined;
const handleConnect = onConnectNonOAuth const handleConnect = onConnectNonOAuth

View file

@ -95,11 +95,11 @@ export const parseMCPConfig = (configJson: string): MCPConfigValidationResult =>
// Check cache first // Check cache first
const cached = configCache.get(configJson); const cached = configCache.get(configJson);
if (cached && Date.now() - cached.timestamp < CACHE_TTL) { if (cached && Date.now() - cached.timestamp < CACHE_TTL) {
console.log('[MCP Validator] ✅ Using cached config'); console.log("[MCP Validator] ✅ Using cached config");
return { config: cached.config, error: null }; return { config: cached.config, error: null };
} }
console.log('[MCP Validator] 🔍 Parsing new config...'); console.log("[MCP Validator] 🔍 Parsing new config...");
// Clean up expired cache entries periodically // Clean up expired cache entries periodically
if (configCache.size > 100) { if (configCache.size > 100) {
@ -111,7 +111,7 @@ export const parseMCPConfig = (configJson: string): MCPConfigValidationResult =>
// Validate that it's an object, not an array // Validate that it's an object, not an array
if (Array.isArray(parsed)) { if (Array.isArray(parsed)) {
console.error('[MCP Validator] ❌ Error: Config is an array, expected object'); console.error("[MCP Validator] ❌ Error: Config is an array, expected object");
return { return {
config: null, config: null,
error: "Please provide a single server configuration object, not an array", error: "Please provide a single server configuration object, not an array",
@ -131,20 +131,16 @@ export const parseMCPConfig = (configJson: string): MCPConfigValidationResult =>
// Replace technical error messages with user-friendly ones // Replace technical error messages with user-friendly ones
if (errorMsg.includes("expected string, received undefined")) { if (errorMsg.includes("expected string, received undefined")) {
errorMsg = fieldPath errorMsg = fieldPath ? `The '${fieldPath}' field is required` : "This field is required";
? `The '${fieldPath}' field is required`
: "This field is required";
} else if (errorMsg.includes("Invalid input")) { } else if (errorMsg.includes("Invalid input")) {
errorMsg = fieldPath errorMsg = fieldPath ? `The '${fieldPath}' field has an invalid value` : "Invalid value";
? `The '${fieldPath}' field has an invalid value`
: "Invalid value";
} else if (fieldPath && !errorMsg.toLowerCase().includes(fieldPath.toLowerCase())) { } else if (fieldPath && !errorMsg.toLowerCase().includes(fieldPath.toLowerCase())) {
// If error message doesn't mention the field name, prepend it // If error message doesn't mention the field name, prepend it
errorMsg = `The '${fieldPath}' field: ${errorMsg}`; errorMsg = `The '${fieldPath}' field: ${errorMsg}`;
} }
console.error('[MCP Validator] ❌ Validation error:', errorMsg); console.error("[MCP Validator] ❌ Validation error:", errorMsg);
console.error('[MCP Validator] Full Zod errors:', result.error.issues); console.error("[MCP Validator] Full Zod errors:", result.error.issues);
return { return {
config: null, config: null,
@ -165,7 +161,7 @@ export const parseMCPConfig = (configJson: string): MCPConfigValidationResult =>
timestamp: Date.now(), timestamp: Date.now(),
}); });
console.log('[MCP Validator] ✅ Config parsed successfully:', config); console.log("[MCP Validator] ✅ Config parsed successfully:", config);
return { return {
config, config,
@ -173,7 +169,7 @@ export const parseMCPConfig = (configJson: string): MCPConfigValidationResult =>
}; };
} catch (error) { } catch (error) {
const errorMsg = error instanceof Error ? error.message : "Invalid JSON"; const errorMsg = error instanceof Error ? error.message : "Invalid JSON";
console.error('[MCP Validator] ❌ JSON parse error:', errorMsg); console.error("[MCP Validator] ❌ JSON parse error:", errorMsg);
return { return {
config: null, config: null,
error: errorMsg, error: errorMsg,

View file

@ -84,7 +84,9 @@ export const ConnectorAccountsListView: FC<ConnectorAccountsListViewProps> = ({
const typeConnectors = connectors.filter((c) => c.connector_type === connectorType); const typeConnectors = connectors.filter((c) => c.connector_type === connectorType);
// Determine button text - default to "Add Account" unless specified // Determine button text - default to "Add Account" unless specified
const buttonText = addButtonText || (connectorType === EnumConnectorName.MCP_CONNECTOR ? "Add New MCP Server" : "Add Account"); const buttonText =
addButtonText ||
(connectorType === EnumConnectorName.MCP_CONNECTOR ? "Add New MCP Server" : "Add Account");
const isMCP = connectorType === EnumConnectorName.MCP_CONNECTOR; const isMCP = connectorType === EnumConnectorName.MCP_CONNECTOR;
// Helper to get display name for connector (handles MCP server name extraction) // Helper to get display name for connector (handles MCP server name extraction)

View file

@ -267,9 +267,13 @@ class ConnectorsApiService {
search_space_id: String(queryParams.search_space_id), search_space_id: String(queryParams.search_space_id),
}).toString(); }).toString();
return baseApiService.post<MCPConnectorRead>(`/api/v1/connectors/mcp?${queryString}`, undefined, { return baseApiService.post<MCPConnectorRead>(
`/api/v1/connectors/mcp?${queryString}`,
undefined,
{
body: data, body: data,
}); }
);
}; };
/** /**