refactor: remove Local Folder connector components and related configurations from the UI

This commit is contained in:
Anish Sarkar 2026-04-02 22:19:55 +05:30
parent 40ade4889e
commit 1ef0d913e7
9 changed files with 35 additions and 472 deletions

View file

@ -1,272 +0,0 @@
"use client";
import { zodResolver } from "@hookform/resolvers/zod";
import { FolderSync, Info } from "lucide-react";
import type { FC } from "react";
import { useRef } from "react";
import { useForm } from "react-hook-form";
import * as z from "zod";
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
import { Button } from "@/components/ui/button";
import {
Form,
FormControl,
FormDescription,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/components/ui/form";
import { Input } from "@/components/ui/input";
import { EnumConnectorName } from "@/contracts/enums/connector";
import { getConnectorBenefits } from "../connector-benefits";
import type { ConnectFormProps } from "../index";
const localFolderFormSchema = z.object({
name: z.string().min(3, {
message: "Connector name must be at least 3 characters.",
}),
folder_path: z.string().min(1, {
message: "Folder path is required.",
}),
folder_name: z.string().min(1, {
message: "Folder name is required.",
}),
exclude_patterns: z.string().optional(),
file_extensions: z.string().optional(),
});
type LocalFolderFormValues = z.infer<typeof localFolderFormSchema>;
export const LocalFolderConnectForm: FC<ConnectFormProps> = ({ onSubmit, isSubmitting }) => {
const isSubmittingRef = useRef(false);
const isElectron = typeof window !== "undefined" && !!window.electronAPI;
const form = useForm<LocalFolderFormValues>({
resolver: zodResolver(localFolderFormSchema),
defaultValues: {
name: "Local Folder",
folder_path: "",
folder_name: "",
exclude_patterns: "node_modules,.git,.DS_Store",
file_extensions: "",
},
});
const handleBrowse = async () => {
if (!isElectron) return;
const selected = await window.electronAPI!.selectFolder();
if (selected) {
form.setValue("folder_path", selected);
const folderName = selected.split(/[\\/]/).pop() || "folder";
if (!form.getValues("folder_name")) {
form.setValue("folder_name", folderName);
}
if (form.getValues("name") === "Local Folder") {
form.setValue("name", folderName);
}
}
};
const handleSubmit = async (values: LocalFolderFormValues) => {
if (isSubmittingRef.current || isSubmitting) return;
isSubmittingRef.current = true;
try {
const excludePatterns = values.exclude_patterns
? values.exclude_patterns
.split(",")
.map((p) => p.trim())
.filter(Boolean)
: [];
const fileExtensions = values.file_extensions
? values.file_extensions
.split(",")
.map((e) => {
const ext = e.trim();
return ext.startsWith(".") ? ext : `.${ext}`;
})
.filter(Boolean)
: null;
await onSubmit({
name: values.name,
connector_type: EnumConnectorName.LOCAL_FOLDER_CONNECTOR,
config: {
folder_path: values.folder_path,
folder_name: values.folder_name,
exclude_patterns: excludePatterns,
file_extensions: fileExtensions,
},
is_indexable: true,
is_active: true,
last_indexed_at: null,
periodic_indexing_enabled: false,
indexing_frequency_minutes: null,
next_scheduled_at: null,
});
} finally {
isSubmittingRef.current = false;
}
};
return (
<div className="space-y-6 pb-6">
<Alert className="bg-blue-500/10 dark:bg-blue-500/10 border-blue-500/30 p-2 sm:p-3">
<Info className="size-4 shrink-0 text-blue-500" />
<AlertTitle className="text-xs sm:text-sm">Desktop App Required</AlertTitle>
<AlertDescription className="text-[10px] sm:text-xs">
Real-time file watching is powered by the SurfSense desktop app. Files are
automatically synced whenever changes are detected.
</AlertDescription>
</Alert>
<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">
<Form {...form}>
<form
id="local-folder-connect-form"
onSubmit={form.handleSubmit(handleSubmit)}
className="space-y-4 sm:space-y-6"
>
<FormField
control={form.control}
name="name"
render={({ field }) => (
<FormItem>
<FormLabel className="text-xs sm:text-sm">Connector Name</FormLabel>
<FormControl>
<Input
placeholder="My Documents"
className="h-8 sm:h-10 px-2 sm:px-3 text-xs sm:text-sm border-slate-400/20 focus-visible:border-slate-400/40"
disabled={isSubmitting}
{...field}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="folder_path"
render={({ field }) => (
<FormItem>
<FormLabel className="text-xs sm:text-sm">Folder Path</FormLabel>
<div className="flex gap-2">
<FormControl>
<Input
placeholder="/path/to/your/folder"
className="h-8 sm:h-10 px-2 sm:px-3 text-xs sm:text-sm border-slate-400/20 focus-visible:border-slate-400/40 font-mono flex-1"
disabled={isSubmitting}
{...field}
/>
</FormControl>
{isElectron && (
<Button
type="button"
variant="outline"
size="sm"
onClick={handleBrowse}
disabled={isSubmitting}
className="shrink-0"
>
<FolderSync className="h-4 w-4 mr-1" />
Browse
</Button>
)}
</div>
<FormDescription className="text-[10px] sm:text-xs">
The absolute path to the folder to watch and sync.
</FormDescription>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="folder_name"
render={({ field }) => (
<FormItem>
<FormLabel className="text-xs sm:text-sm">Display Name</FormLabel>
<FormControl>
<Input
placeholder="My Notes"
className="h-8 sm:h-10 px-2 sm:px-3 text-xs sm:text-sm border-slate-400/20 focus-visible:border-slate-400/40"
disabled={isSubmitting}
{...field}
/>
</FormControl>
<FormDescription className="text-[10px] sm:text-xs">
A friendly name shown in the documents sidebar.
</FormDescription>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="exclude_patterns"
render={({ field }) => (
<FormItem>
<FormLabel className="text-xs sm:text-sm">Exclude Patterns</FormLabel>
<FormControl>
<Input
placeholder="node_modules,.git,.DS_Store"
className="h-8 sm:h-10 px-2 sm:px-3 text-xs sm:text-sm border-slate-400/20 focus-visible:border-slate-400/40 font-mono"
disabled={isSubmitting}
{...field}
/>
</FormControl>
<FormDescription className="text-[10px] sm:text-xs">
Comma-separated patterns of directories/files to exclude.
</FormDescription>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="file_extensions"
render={({ field }) => (
<FormItem>
<FormLabel className="text-xs sm:text-sm">File Extensions (optional)</FormLabel>
<FormControl>
<Input
placeholder=".md,.txt,.rst"
className="h-8 sm:h-10 px-2 sm:px-3 text-xs sm:text-sm border-slate-400/20 focus-visible:border-slate-400/40 font-mono"
disabled={isSubmitting}
{...field}
/>
</FormControl>
<FormDescription className="text-[10px] sm:text-xs">
Leave empty to index all supported files, or specify comma-separated extensions.
</FormDescription>
<FormMessage />
</FormItem>
)}
/>
</form>
</Form>
</div>
{getConnectorBenefits(EnumConnectorName.LOCAL_FOLDER_CONNECTOR) && (
<div className="rounded-xl border border-border bg-slate-400/5 dark:bg-white/5 px-3 sm:px-6 py-4 space-y-2">
<h4 className="text-xs sm:text-sm font-medium">
What you get with Local Folder sync:
</h4>
<ul className="list-disc pl-5 text-[10px] sm:text-xs text-muted-foreground space-y-1">
{getConnectorBenefits(EnumConnectorName.LOCAL_FOLDER_CONNECTOR)?.map(
(benefit) => <li key={benefit}>{benefit}</li>
)}
</ul>
</div>
)}
</div>
);
};

View file

@ -111,14 +111,6 @@ export function getConnectorBenefits(connectorType: string): string[] | null {
"Incremental sync - only changed files are re-indexed",
"Full support for your vault's folder structure",
],
LOCAL_FOLDER_CONNECTOR: [
"Watch local folders for real-time changes via the desktop app",
"Automatic change detection — only modified files are re-indexed",
"Version history with up to 20 snapshots per document",
"Mirrors your folder structure in the SurfSense sidebar",
"Supports any text-based file format",
"Works as a periodic sync fallback when the desktop app is not running",
],
};
return benefits[connectorType] || null;

View file

@ -7,7 +7,6 @@ import { GithubConnectForm } from "./components/github-connect-form";
import { LinkupApiConnectForm } from "./components/linkup-api-connect-form";
import { LumaConnectForm } from "./components/luma-connect-form";
import { MCPConnectForm } from "./components/mcp-connect-form";
import { LocalFolderConnectForm } from "./components/local-folder-connect-form";
import { ObsidianConnectForm } from "./components/obsidian-connect-form";
import { TavilyApiConnectForm } from "./components/tavily-api-connect-form";
@ -59,8 +58,6 @@ export function getConnectFormComponent(connectorType: string): ConnectFormCompo
return MCPConnectForm;
case "OBSIDIAN_CONNECTOR":
return ObsidianConnectForm;
case "LOCAL_FOLDER_CONNECTOR":
return LocalFolderConnectForm;
default:
return null;
}

View file

@ -1,163 +0,0 @@
"use client";
import type { FC } from "react";
import { useState } from "react";
import { FolderSync } from "lucide-react";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import type { ConnectorConfigProps } from "../index";
export const LocalFolderConfig: FC<ConnectorConfigProps> = ({
connector,
onConfigChange,
onNameChange,
}) => {
const isElectron = typeof window !== "undefined" && !!window.electronAPI;
const [folderPath, setFolderPath] = useState<string>(
(connector.config?.folder_path as string) || ""
);
const [folderName, setFolderName] = useState<string>(
(connector.config?.folder_name as string) || ""
);
const [excludePatterns, setExcludePatterns] = useState<string>(() => {
const patterns = connector.config?.exclude_patterns;
if (Array.isArray(patterns)) {
return patterns.join(", ");
}
return (patterns as string) || "node_modules, .git, .DS_Store";
});
const [fileExtensions, setFileExtensions] = useState<string>(() => {
const exts = connector.config?.file_extensions;
if (Array.isArray(exts)) {
return exts.join(", ");
}
return (exts as string) || "";
});
const [name, setName] = useState<string>(connector.name || "");
const handleFolderPathChange = (value: string) => {
setFolderPath(value);
onConfigChange?.({ ...connector.config, folder_path: value });
};
const handleFolderNameChange = (value: string) => {
setFolderName(value);
onConfigChange?.({ ...connector.config, folder_name: value });
};
const handleExcludePatternsChange = (value: string) => {
setExcludePatterns(value);
const arr = value
.split(",")
.map((p) => p.trim())
.filter(Boolean);
onConfigChange?.({ ...connector.config, exclude_patterns: arr });
};
const handleFileExtensionsChange = (value: string) => {
setFileExtensions(value);
const arr = value
? value
.split(",")
.map((e) => {
const ext = e.trim();
return ext.startsWith(".") ? ext : `.${ext}`;
})
.filter(Boolean)
: null;
onConfigChange?.({ ...connector.config, file_extensions: arr });
};
const handleNameChange = (value: string) => {
setName(value);
onNameChange?.(value);
};
const handleBrowse = async () => {
if (!isElectron) return;
const selected = await window.electronAPI!.selectFolder();
if (selected) {
handleFolderPathChange(selected);
const autoName = selected.split(/[\\/]/).pop() || "folder";
if (!folderName) handleFolderNameChange(autoName);
}
};
return (
<div className="space-y-6">
<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">
<Label className="text-xs sm:text-sm">Connector Name</Label>
<Input
value={name}
onChange={(e) => handleNameChange(e.target.value)}
placeholder="Local Folder"
className="border-slate-400/20 focus-visible:border-slate-400/40"
/>
</div>
</div>
<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">
<h3 className="font-medium text-sm sm:text-base">Folder Configuration</h3>
<div className="space-y-4">
<div className="space-y-2">
<Label className="text-xs sm:text-sm">Folder Path</Label>
<div className="flex gap-2">
<Input
value={folderPath}
onChange={(e) => handleFolderPathChange(e.target.value)}
placeholder="/path/to/your/folder"
className="border-slate-400/20 focus-visible:border-slate-400/40 font-mono flex-1"
/>
{isElectron && (
<Button type="button" variant="outline" size="sm" onClick={handleBrowse} className="shrink-0">
<FolderSync className="h-4 w-4 mr-1" />
Browse
</Button>
)}
</div>
</div>
<div className="space-y-2">
<Label className="text-xs sm:text-sm">Display Name</Label>
<Input
value={folderName}
onChange={(e) => handleFolderNameChange(e.target.value)}
placeholder="My Notes"
className="border-slate-400/20 focus-visible:border-slate-400/40"
/>
</div>
<div className="space-y-2">
<Label className="text-xs sm:text-sm">Exclude Patterns</Label>
<Input
value={excludePatterns}
onChange={(e) => handleExcludePatternsChange(e.target.value)}
placeholder="node_modules, .git, .DS_Store"
className="border-slate-400/20 focus-visible:border-slate-400/40 font-mono"
/>
<p className="text-[10px] sm:text-xs text-muted-foreground">
Comma-separated patterns of directories/files to exclude.
</p>
</div>
<div className="space-y-2">
<Label className="text-xs sm:text-sm">File Extensions (optional)</Label>
<Input
value={fileExtensions}
onChange={(e) => handleFileExtensionsChange(e.target.value)}
placeholder=".md, .txt, .rst"
className="border-slate-400/20 focus-visible:border-slate-400/40 font-mono"
/>
<p className="text-[10px] sm:text-xs text-muted-foreground">
Leave empty to index all supported files.
</p>
</div>
</div>
</div>
</div>
);
};

View file

@ -19,7 +19,6 @@ import { JiraConfig } from "./components/jira-config";
import { LinkupApiConfig } from "./components/linkup-api-config";
import { LumaConfig } from "./components/luma-config";
import { MCPConfig } from "./components/mcp-config";
import { LocalFolderConfig } from "./components/local-folder-config";
import { ObsidianConfig } from "./components/obsidian-config";
import { OneDriveConfig } from "./components/onedrive-config";
import { SlackConfig } from "./components/slack-config";
@ -83,8 +82,6 @@ export function getConnectorConfigComponent(
return MCPConfig;
case "OBSIDIAN_CONNECTOR":
return ObsidianConfig;
case "LOCAL_FOLDER_CONNECTOR":
return LocalFolderConfig;
case "COMPOSIO_GOOGLE_DRIVE_CONNECTOR":
return ComposioDriveConfig;
case "COMPOSIO_GMAIL_CONNECTOR":

View file

@ -20,7 +20,6 @@ const FORM_ID_MAP: Record<string, string> = {
CIRCLEBACK_CONNECTOR: "circleback-connect-form",
MCP_CONNECTOR: "mcp-connect-form",
OBSIDIAN_CONNECTOR: "obsidian-connect-form",
LOCAL_FOLDER_CONNECTOR: "local-folder-connect-form",
};
interface ConnectorConnectViewProps {

View file

@ -278,8 +278,7 @@ export const ConnectorEditView: FC<ConnectorEditViewProps> = ({
connector.connector_type !== "DROPBOX_CONNECTOR" &&
connector.connector_type !== "ONEDRIVE_CONNECTOR" &&
connector.connector_type !== "WEBCRAWLER_CONNECTOR" &&
connector.connector_type !== "GITHUB_CONNECTOR" &&
connector.connector_type !== "LOCAL_FOLDER_CONNECTOR" && (
connector.connector_type !== "GITHUB_CONNECTOR" && (
<DateRangeSelector
startDate={startDate}
endDate={endDate}
@ -294,9 +293,7 @@ export const ConnectorEditView: FC<ConnectorEditViewProps> = ({
/>
)}
{/* Periodic sync - shown for all indexable connectors except Local Folder */}
{connector.connector_type !== "LOCAL_FOLDER_CONNECTOR" &&
(() => {
{(() => {
const isGoogleDrive = connector.connector_type === "GOOGLE_DRIVE_CONNECTOR";
const isComposioGoogleDrive =
connector.connector_type === "COMPOSIO_GOOGLE_DRIVE_CONNECTOR";

View file

@ -164,8 +164,7 @@ export const IndexingConfigurationView: FC<IndexingConfigurationViewProps> = ({
config.connectorType !== "DROPBOX_CONNECTOR" &&
config.connectorType !== "ONEDRIVE_CONNECTOR" &&
config.connectorType !== "WEBCRAWLER_CONNECTOR" &&
config.connectorType !== "GITHUB_CONNECTOR" &&
config.connectorType !== "LOCAL_FOLDER_CONNECTOR" && (
config.connectorType !== "GITHUB_CONNECTOR" && (
<DateRangeSelector
startDate={startDate}
endDate={endDate}
@ -180,12 +179,10 @@ export const IndexingConfigurationView: FC<IndexingConfigurationViewProps> = ({
/>
)}
{/* Periodic sync - not shown for file-based connectors (Drive, Dropbox, OneDrive) or Local Folder in initial setup; configured in edit view instead */}
{config.connectorType !== "GOOGLE_DRIVE_CONNECTOR" &&
config.connectorType !== "COMPOSIO_GOOGLE_DRIVE_CONNECTOR" &&
config.connectorType !== "DROPBOX_CONNECTOR" &&
config.connectorType !== "ONEDRIVE_CONNECTOR" &&
config.connectorType !== "LOCAL_FOLDER_CONNECTOR" && (
config.connectorType !== "ONEDRIVE_CONNECTOR" && (
<PeriodicSyncConfig
enabled={periodicEnabled}
frequencyMinutes={frequencyMinutes}