mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-04 13:22:41 +02:00
Merge pull request #1225 from oscarzhou511/feat/obsidian-connector-visibility
Some checks are pending
Build and Push Docker Images / tag_release (push) Waiting to run
Build and Push Docker Images / build (./surfsense_backend, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64) (push) Blocked by required conditions
Build and Push Docker Images / build (./surfsense_backend, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64) (push) Blocked by required conditions
Build and Push Docker Images / build (./surfsense_web, ./surfsense_web/Dockerfile, web, surfsense-web, ubuntu-24.04-arm, linux/arm64, arm64) (push) Blocked by required conditions
Build and Push Docker Images / build (./surfsense_web, ./surfsense_web/Dockerfile, web, surfsense-web, ubuntu-latest, linux/amd64, amd64) (push) Blocked by required conditions
Build and Push Docker Images / create_manifest (backend, surfsense-backend) (push) Blocked by required conditions
Build and Push Docker Images / create_manifest (web, surfsense-web) (push) Blocked by required conditions
Some checks are pending
Build and Push Docker Images / tag_release (push) Waiting to run
Build and Push Docker Images / build (./surfsense_backend, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-24.04-arm, linux/arm64, arm64) (push) Blocked by required conditions
Build and Push Docker Images / build (./surfsense_backend, ./surfsense_backend/Dockerfile, backend, surfsense-backend, ubuntu-latest, linux/amd64, amd64) (push) Blocked by required conditions
Build and Push Docker Images / build (./surfsense_web, ./surfsense_web/Dockerfile, web, surfsense-web, ubuntu-24.04-arm, linux/arm64, arm64) (push) Blocked by required conditions
Build and Push Docker Images / build (./surfsense_web, ./surfsense_web/Dockerfile, web, surfsense-web, ubuntu-latest, linux/amd64, amd64) (push) Blocked by required conditions
Build and Push Docker Images / create_manifest (backend, surfsense-backend) (push) Blocked by required conditions
Build and Push Docker Images / create_manifest (web, surfsense-web) (push) Blocked by required conditions
feat: improve Obsidian connector visibility and desktop sync flow
This commit is contained in:
commit
b659f41bab
4 changed files with 45 additions and 7 deletions
12
surfsense_web/atoms/folder-sync/folder-sync.atoms.ts
Normal file
12
surfsense_web/atoms/folder-sync/folder-sync.atoms.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
import { atom } from "jotai";
|
||||||
|
|
||||||
|
export interface SelectedFolder {
|
||||||
|
path: string;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Atom to control the folder watch dialog open state
|
||||||
|
export const folderWatchDialogOpenAtom = atom(false);
|
||||||
|
|
||||||
|
// Atom to store initial folder selection for the dialog
|
||||||
|
export const folderWatchInitialFolderAtom = atom<SelectedFolder | null>(null);
|
||||||
|
|
@ -180,9 +180,8 @@ export const OTHER_CONNECTORS = [
|
||||||
{
|
{
|
||||||
id: "obsidian-connector",
|
id: "obsidian-connector",
|
||||||
title: "Obsidian",
|
title: "Obsidian",
|
||||||
description: "Index your Obsidian vault (self-hosted only)",
|
description: "Index your Obsidian vault (Local folder scan on Desktop)",
|
||||||
connectorType: EnumConnectorName.OBSIDIAN_CONNECTOR,
|
connectorType: EnumConnectorName.OBSIDIAN_CONNECTOR,
|
||||||
selfHostedOnly: true,
|
|
||||||
},
|
},
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { format } from "date-fns";
|
import { format } from "date-fns";
|
||||||
import { useAtom, useAtomValue } from "jotai";
|
import { useAtom, useAtomValue, useSetAtom } from "jotai";
|
||||||
import { useCallback, useEffect, useRef, useState } from "react";
|
import { useCallback, useEffect, useRef, useState } from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { connectorDialogOpenAtom } from "@/atoms/connector-dialog/connector-dialog.atoms";
|
import { connectorDialogOpenAtom } from "@/atoms/connector-dialog/connector-dialog.atoms";
|
||||||
|
|
@ -33,6 +33,13 @@ import {
|
||||||
OAUTH_CONNECTORS,
|
OAUTH_CONNECTORS,
|
||||||
OTHER_CONNECTORS,
|
OTHER_CONNECTORS,
|
||||||
} from "../constants/connector-constants";
|
} from "../constants/connector-constants";
|
||||||
|
import { usePlatform } from "@/hooks/use-platform";
|
||||||
|
import { isSelfHosted } from "@/lib/env-config";
|
||||||
|
import {
|
||||||
|
folderWatchDialogOpenAtom,
|
||||||
|
folderWatchInitialFolderAtom,
|
||||||
|
} from "@/atoms/folder-sync/folder-sync.atoms";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
dateRangeSchema,
|
dateRangeSchema,
|
||||||
frequencyMinutesSchema,
|
frequencyMinutesSchema,
|
||||||
|
|
@ -61,6 +68,11 @@ export const useConnectorDialog = () => {
|
||||||
const { mutateAsync: updateConnector } = useAtomValue(updateConnectorMutationAtom);
|
const { mutateAsync: updateConnector } = useAtomValue(updateConnectorMutationAtom);
|
||||||
const { mutateAsync: deleteConnector } = useAtomValue(deleteConnectorMutationAtom);
|
const { mutateAsync: deleteConnector } = useAtomValue(deleteConnectorMutationAtom);
|
||||||
const { mutateAsync: createConnector } = useAtomValue(createConnectorMutationAtom);
|
const { mutateAsync: createConnector } = useAtomValue(createConnectorMutationAtom);
|
||||||
|
const setFolderWatchOpen = useSetAtom(folderWatchDialogOpenAtom);
|
||||||
|
const setFolderWatchInitialFolder = useSetAtom(folderWatchInitialFolderAtom);
|
||||||
|
const { isDesktop } = usePlatform();
|
||||||
|
const selfHosted = isSelfHosted();
|
||||||
|
|
||||||
|
|
||||||
// Use global atom for dialog open state so it can be controlled from anywhere
|
// Use global atom for dialog open state so it can be controlled from anywhere
|
||||||
const [isOpen, setIsOpen] = useAtom(connectorDialogOpenAtom);
|
const [isOpen, setIsOpen] = useAtom(connectorDialogOpenAtom);
|
||||||
|
|
@ -440,11 +452,21 @@ export const useConnectorDialog = () => {
|
||||||
const handleConnectNonOAuth = useCallback(
|
const handleConnectNonOAuth = useCallback(
|
||||||
(connectorType: string) => {
|
(connectorType: string) => {
|
||||||
if (!searchSpaceId) return;
|
if (!searchSpaceId) return;
|
||||||
|
|
||||||
|
// Handle Obsidian specifically on Desktop & Cloud
|
||||||
|
if (connectorType === EnumConnectorName.OBSIDIAN_CONNECTOR && !selfHosted && isDesktop) {
|
||||||
|
setIsOpen(false);
|
||||||
|
setFolderWatchInitialFolder(null);
|
||||||
|
setFolderWatchOpen(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setConnectingConnectorType(connectorType);
|
setConnectingConnectorType(connectorType);
|
||||||
},
|
},
|
||||||
[searchSpaceId]
|
[searchSpaceId, selfHosted, isDesktop, setIsOpen, setFolderWatchOpen, setFolderWatchInitialFolder]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// Handle submitting connect form
|
// Handle submitting connect form
|
||||||
const handleSubmitConnectForm = useCallback(
|
const handleSubmitConnectForm = useCallback(
|
||||||
async (
|
async (
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,10 @@ import { deleteDocumentMutationAtom } from "@/atoms/documents/document-mutation.
|
||||||
import { expandedFolderIdsAtom } from "@/atoms/documents/folder.atoms";
|
import { expandedFolderIdsAtom } from "@/atoms/documents/folder.atoms";
|
||||||
import { agentCreatedDocumentsAtom } from "@/atoms/documents/ui.atoms";
|
import { agentCreatedDocumentsAtom } from "@/atoms/documents/ui.atoms";
|
||||||
import { openEditorPanelAtom } from "@/atoms/editor/editor-panel.atom";
|
import { openEditorPanelAtom } from "@/atoms/editor/editor-panel.atom";
|
||||||
|
import {
|
||||||
|
folderWatchDialogOpenAtom,
|
||||||
|
folderWatchInitialFolderAtom,
|
||||||
|
} from "@/atoms/folder-sync/folder-sync.atoms";
|
||||||
import { rightPanelCollapsedAtom } from "@/atoms/layout/right-panel.atom";
|
import { rightPanelCollapsedAtom } from "@/atoms/layout/right-panel.atom";
|
||||||
import { searchSpacesAtom } from "@/atoms/search-spaces/search-space-query.atoms";
|
import { searchSpacesAtom } from "@/atoms/search-spaces/search-space-query.atoms";
|
||||||
import { CreateFolderDialog } from "@/components/documents/CreateFolderDialog";
|
import { CreateFolderDialog } from "@/components/documents/CreateFolderDialog";
|
||||||
|
|
@ -106,8 +110,8 @@ export function DocumentsSidebar({
|
||||||
const debouncedSearch = useDebouncedValue(search, 250);
|
const debouncedSearch = useDebouncedValue(search, 250);
|
||||||
const [activeTypes, setActiveTypes] = useState<DocumentTypeEnum[]>([]);
|
const [activeTypes, setActiveTypes] = useState<DocumentTypeEnum[]>([]);
|
||||||
const [watchedFolderIds, setWatchedFolderIds] = useState<Set<number>>(new Set());
|
const [watchedFolderIds, setWatchedFolderIds] = useState<Set<number>>(new Set());
|
||||||
const [folderWatchOpen, setFolderWatchOpen] = useState(false);
|
const [folderWatchOpen, setFolderWatchOpen] = useAtom(folderWatchDialogOpenAtom);
|
||||||
const [watchInitialFolder, setWatchInitialFolder] = useState<SelectedFolder | null>(null);
|
const [watchInitialFolder, setWatchInitialFolder] = useAtom(folderWatchInitialFolderAtom);
|
||||||
const isElectron = typeof window !== "undefined" && !!window.electronAPI;
|
const isElectron = typeof window !== "undefined" && !!window.electronAPI;
|
||||||
|
|
||||||
// AI File Sort state
|
// AI File Sort state
|
||||||
|
|
@ -161,7 +165,8 @@ export function DocumentsSidebar({
|
||||||
const folderName = folderPath.split("/").pop() || folderPath.split("\\").pop() || folderPath;
|
const folderName = folderPath.split("/").pop() || folderPath.split("\\").pop() || folderPath;
|
||||||
setWatchInitialFolder({ path: folderPath, name: folderName });
|
setWatchInitialFolder({ path: folderPath, name: folderName });
|
||||||
setFolderWatchOpen(true);
|
setFolderWatchOpen(true);
|
||||||
}, []);
|
}, [setWatchInitialFolder, setFolderWatchOpen]);
|
||||||
|
|
||||||
|
|
||||||
const refreshWatchedIds = useCallback(async () => {
|
const refreshWatchedIds = useCallback(async () => {
|
||||||
if (!electronAPI?.getWatchedFolders) return;
|
if (!electronAPI?.getWatchedFolders) return;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue