@@ -5,6 +5,7 @@ import { useAtom, useAtomValue, useSetAtom } from "jotai";
55import {
66 FolderInput ,
77 FolderPlus ,
8+ FolderSync ,
89 ListFilter ,
910 Plus ,
1011 Settings2 ,
@@ -32,9 +33,12 @@ import type { FolderDisplay } from "@/components/documents/FolderNode";
3233import { FolderPickerDialog } from "@/components/documents/FolderPickerDialog" ;
3334import { FolderTreeView } from "@/components/documents/FolderTreeView" ;
3435import { VersionHistoryDialog } from "@/components/documents/version-history" ;
35- import { useIsSelfHosted , useRuntimeConfig } from "@/components/providers/runtime-config" ;
36+ import { useOptionalRuntimeConfig , useRuntimeConfig } from "@/components/providers/runtime-config" ;
3637import { EXPORT_FILE_EXTENSIONS } from "@/components/shared/ExportMenuItems" ;
37- import { DEFAULT_EXCLUDE_PATTERNS } from "@/components/sources/FolderWatchDialog" ;
38+ import {
39+ DEFAULT_EXCLUDE_PATTERNS ,
40+ FolderWatchDialog ,
41+ } from "@/components/sources/FolderWatchDialog" ;
3842import {
3943 AlertDialog ,
4044 AlertDialogAction ,
@@ -187,13 +191,27 @@ export function EmbeddedDocumentsMenu({
187191 * OAuth or open the existing account's config. In anonymous mode, `gate`
188192 * intercepts every item to trigger the login flow.
189193 */
190- export function EmbeddedImportMenu ( { gate } : { gate ?: ( feature : string ) => void } ) {
194+ export function EmbeddedImportMenu ( {
195+ gate,
196+ onFolderWatched,
197+ } : {
198+ gate ?: ( feature : string ) => void ;
199+ onFolderWatched ?: ( ) => void ;
200+ } ) {
191201 const { openDialog } = useDocumentUploadDialog ( ) ;
192202 const setImportRequest = useSetAtom ( importConnectorRequestAtom ) ;
193- const selfHosted = useIsSelfHosted ( ) ;
203+ // Provider is absent on anonymous /free pages, where every item is login-gated
204+ // anyway — defaulting to hosted (Composio) there is cosmetic.
205+ const selfHosted = useOptionalRuntimeConfig ( ) ?. deploymentMode === "self-hosted" ;
194206 const { isConnectorEnabled, getConnectorStatusMessage } = useConnectorStatus ( ) ;
195207 const { data : connectors } = useAtomValue ( connectorsAtom ) ;
196208
209+ // Watch Local Folder is a desktop-app feature (needs the Electron folder watcher).
210+ const { isDesktop } = usePlatform ( ) ;
211+ const params = useParams ( ) ;
212+ const workspaceId = getWorkspaceIdNumber ( params ) ?? 0 ;
213+ const [ folderWatchOpen , setFolderWatchOpen ] = useState ( false ) ;
214+
197215 // Native Google Drive connector self-hosted only; hosted deployments use Composio.
198216 const driveType = selfHosted
199217 ? EnumConnectorName . GOOGLE_DRIVE_CONNECTOR
@@ -223,6 +241,14 @@ export function EmbeddedImportMenu({ gate }: { gate?: (feature: string) => void
223241 < Upload className = "h-4 w-4" />
224242 Upload Files
225243 </ DropdownMenuItem >
244+ { isDesktop && (
245+ < DropdownMenuItem
246+ onSelect = { ( ) => ( gate ? gate ( "watch local folders" ) : setFolderWatchOpen ( true ) ) }
247+ >
248+ < FolderSync className = "h-4 w-4" />
249+ Watch Local Folder
250+ </ DropdownMenuItem >
251+ ) }
226252 < DropdownMenuSeparator />
227253 { cloudItems . map ( ( item ) => {
228254 const enabled = gate ? true : isConnectorEnabled ( item . type ) ;
@@ -297,6 +323,14 @@ export function EmbeddedImportMenu({ gate }: { gate?: (feature: string) => void
297323 ) ;
298324 } ) }
299325 </ DropdownMenuContent >
326+ { isDesktop && ! gate && (
327+ < FolderWatchDialog
328+ open = { folderWatchOpen }
329+ onOpenChange = { setFolderWatchOpen }
330+ workspaceId = { workspaceId }
331+ onSuccess = { onFolderWatched }
332+ />
333+ ) }
300334 </ DropdownMenu >
301335 ) ;
302336}
@@ -1180,7 +1214,7 @@ function AuthenticatedDocumentsSidebarBase({
11801214 contentClassName = "px-0"
11811215 persistentAction = {
11821216 < div className = "flex items-center gap-0.5" >
1183- < EmbeddedImportMenu />
1217+ < EmbeddedImportMenu onFolderWatched = { refreshWatchedIds } />
11841218 < EmbeddedDocumentsMenu
11851219 typeCounts = { typeCounts }
11861220 activeTypes = { activeTypes }
0 commit comments