diff --git a/surfsense_web/app/dashboard/[search_space_id]/editor/[documentId]/page.tsx b/surfsense_web/app/dashboard/[search_space_id]/editor/[documentId]/page.tsx index e0984801e..8fc2fb825 100644 --- a/surfsense_web/app/dashboard/[search_space_id]/editor/[documentId]/page.tsx +++ b/surfsense_web/app/dashboard/[search_space_id]/editor/[documentId]/page.tsx @@ -332,7 +332,7 @@ export default function EditorPage() { // Clear global unsaved state setGlobalHasUnsavedChanges(false); setHasUnsavedChanges(false); - + // If there's a pending navigation (from sidebar), use that; otherwise go back to researcher if (pendingNavigation) { router.push(pendingNavigation); @@ -470,9 +470,12 @@ export default function EditorPage() { {/* Unsaved Changes Dialog */} - { - if (!open) handleCancelLeave(); - }}> + { + if (!open) handleCancelLeave(); + }} + > Unsaved Changes diff --git a/surfsense_web/app/dashboard/[search_space_id]/researcher/[[...chat_id]]/page.tsx b/surfsense_web/app/dashboard/[search_space_id]/researcher/[[...chat_id]]/page.tsx index 70b9505e9..60980f034 100644 --- a/surfsense_web/app/dashboard/[search_space_id]/researcher/[[...chat_id]]/page.tsx +++ b/surfsense_web/app/dashboard/[search_space_id]/researcher/[[...chat_id]]/page.tsx @@ -135,9 +135,9 @@ export default function ResearcherPage() { chatRequestOptions?: { data?: any } ) => { // Use the first message content as the chat title (truncated to 100 chars) - const messageContent = typeof message.content === 'string' ? message.content : ''; + const messageContent = typeof message.content === "string" ? message.content : ""; const chatTitle = messageContent.slice(0, 100) || "Untitled Chat"; - + const newChat = await createChat({ type: researchMode, title: chatTitle, diff --git a/surfsense_web/components/sidebar/AppSidebarProvider.tsx b/surfsense_web/components/sidebar/AppSidebarProvider.tsx index 0e4ca0460..aa1478be6 100644 --- a/surfsense_web/components/sidebar/AppSidebarProvider.tsx +++ b/surfsense_web/components/sidebar/AppSidebarProvider.tsx @@ -56,7 +56,7 @@ export function AppSidebarProvider({ const { data: chats, error: chatError, isLoading: isLoadingChats } = useAtomValue(chatsAtom); const [{ isPending: isDeletingChat, mutateAsync: deleteChat, error: deleteError }] = useAtom(deleteChatMutationAtom); - + // Editor state for handling unsaved changes const hasUnsavedEditorChanges = useAtomValue(hasUnsavedEditorChangesAtom); const setPendingNavigation = useSetAtom(pendingEditorNavigationAtom); @@ -97,7 +97,11 @@ export function AppSidebarProvider({ const [showDeleteDialog, setShowDeleteDialog] = useState(false); const [chatToDelete, setChatToDelete] = useState<{ id: number; name: string } | null>(null); const [showDeleteNoteDialog, setShowDeleteNoteDialog] = useState(false); - const [noteToDelete, setNoteToDelete] = useState<{ id: number; name: string; search_space_id: number } | null>(null); + const [noteToDelete, setNoteToDelete] = useState<{ + id: number; + name: string; + search_space_id: number; + } | null>(null); const [isDeletingNote, setIsDeletingNote] = useState(false); const [isClient, setIsClient] = useState(false); @@ -230,7 +234,11 @@ export function AppSidebarProvider({ name: "Delete", icon: "Trash2", onClick: () => { - setNoteToDelete({ id: note.id, name: note.title, search_space_id: note.search_space_id }); + setNoteToDelete({ + id: note.id, + name: note.title, + search_space_id: note.search_space_id, + }); setShowDeleteNoteDialog(true); }, }, @@ -241,7 +249,7 @@ export function AppSidebarProvider({ // Handle add note - check for unsaved changes first const handleAddNote = useCallback(() => { const newNoteUrl = `/dashboard/${searchSpaceId}/editor/new`; - + if (hasUnsavedEditorChanges) { // Set pending navigation - the editor will show the unsaved changes dialog setPendingNavigation(newNoteUrl); diff --git a/surfsense_web/components/sidebar/all-chats-sidebar.tsx b/surfsense_web/components/sidebar/all-chats-sidebar.tsx index b1a19e38a..5feb4ce3d 100644 --- a/surfsense_web/components/sidebar/all-chats-sidebar.tsx +++ b/surfsense_web/components/sidebar/all-chats-sidebar.tsx @@ -34,11 +34,7 @@ interface AllChatsSidebarProps { searchSpaceId: string; } -export function AllChatsSidebar({ - open, - onOpenChange, - searchSpaceId, -}: AllChatsSidebarProps) { +export function AllChatsSidebar({ open, onOpenChange, searchSpaceId }: AllChatsSidebarProps) { const t = useTranslations("sidebar"); const router = useRouter(); const queryClient = useQueryClient(); @@ -99,7 +95,7 @@ export function AllChatsSidebar({ // Filter and sort chats based on search query (client-side filtering) const chats = useMemo(() => { const allChats = chatsData ?? []; - + // Sort chats by created_at (most recent first) const sortedChats = [...allChats].sort((a, b) => { const dateA = new Date(a.created_at).getTime(); @@ -111,9 +107,7 @@ export function AllChatsSidebar({ return sortedChats; } const query = debouncedSearchQuery.toLowerCase(); - return sortedChats.filter((chat) => - chat.title.toLowerCase().includes(query) - ); + return sortedChats.filter((chat) => chat.title.toLowerCase().includes(query)); }, [chatsData, debouncedSearchQuery]); const isSearchMode = !!debouncedSearchQuery; @@ -190,7 +184,10 @@ export function AllChatsSidebar({ -

{t("created") || "Created"}: {format(new Date(chat.created_at), "MMM d, yyyy 'at' h:mm a")}

+

+ {t("created") || "Created"}:{" "} + {format(new Date(chat.created_at), "MMM d, yyyy 'at' h:mm a")} +

@@ -242,9 +239,7 @@ export function AllChatsSidebar({ ) : (
-

- {t("no_chats") || "No chats yet"} -

+

{t("no_chats") || "No chats yet"}

{t("start_new_chat_hint") || "Start a new chat from the researcher"}

diff --git a/surfsense_web/components/sidebar/all-notes-sidebar.tsx b/surfsense_web/components/sidebar/all-notes-sidebar.tsx index 20070a580..20622c13e 100644 --- a/surfsense_web/components/sidebar/all-notes-sidebar.tsx +++ b/surfsense_web/components/sidebar/all-notes-sidebar.tsx @@ -125,8 +125,14 @@ export function AllNotesSidebar({ // Transform and sort notes data - handle both regular notes and search results const notes = useMemo(() => { - let notesList: { id: number; title: string; search_space_id: number; created_at: string; updated_at?: string | null }[]; - + let notesList: { + id: number; + title: string; + search_space_id: number; + created_at: string; + updated_at?: string | null; + }[]; + if (isSearchMode && searchData?.items) { notesList = searchData.items.map((doc) => ({ id: doc.id, @@ -224,9 +230,15 @@ export function AllNotesSidebar({
-

{t("created") || "Created"}: {format(new Date(note.created_at), "MMM d, yyyy 'at' h:mm a")}

+

+ {t("created") || "Created"}:{" "} + {format(new Date(note.created_at), "MMM d, yyyy 'at' h:mm a")} +

{note.updated_at && ( -

{t("updated") || "Updated"}: {format(new Date(note.updated_at), "MMM d, yyyy 'at' h:mm a")}

+

+ {t("updated") || "Updated"}:{" "} + {format(new Date(note.updated_at), "MMM d, yyyy 'at' h:mm a")} +

)}
diff --git a/surfsense_web/components/sidebar/app-sidebar.tsx b/surfsense_web/components/sidebar/app-sidebar.tsx index ede8999fd..63101f2de 100644 --- a/surfsense_web/components/sidebar/app-sidebar.tsx +++ b/surfsense_web/components/sidebar/app-sidebar.tsx @@ -446,22 +446,22 @@ export const AppSidebar = memo(function AppSidebar({ - - + + - + - - + + {pageUsage && ( diff --git a/surfsense_web/components/sidebar/nav-chats.tsx b/surfsense_web/components/sidebar/nav-chats.tsx index dafe2fd9c..1165d6057 100644 --- a/surfsense_web/components/sidebar/nav-chats.tsx +++ b/surfsense_web/components/sidebar/nav-chats.tsx @@ -3,8 +3,8 @@ import { ChevronRight, FolderOpen, - type LucideIcon, Loader2, + type LucideIcon, MessageCircleMore, MoreHorizontal, RefreshCw, @@ -63,7 +63,12 @@ const actionIconMap: Record = { RefreshCw, }; -export function NavChats({ chats, defaultOpen = true, searchSpaceId, isSourcesExpanded = false }: NavChatsProps) { +export function NavChats({ + chats, + defaultOpen = true, + searchSpaceId, + isSourcesExpanded = false, +}: NavChatsProps) { const t = useTranslations("sidebar"); const router = useRouter(); const isMobile = useIsMobile(); @@ -174,7 +179,9 @@ export function NavChats({ chats, defaultOpen = true, searchSpaceId, isSourcesEx ) : ( )} - {t("more_options") || "More options"} + + {t("more_options") || "More options"} + diff --git a/surfsense_web/components/sidebar/nav-notes.tsx b/surfsense_web/components/sidebar/nav-notes.tsx index 383338d77..f634c2b72 100644 --- a/surfsense_web/components/sidebar/nav-notes.tsx +++ b/surfsense_web/components/sidebar/nav-notes.tsx @@ -63,7 +63,13 @@ const actionIconMap: Record = { MoreHorizontal, }; -export function NavNotes({ notes, onAddNote, defaultOpen = true, searchSpaceId, isSourcesExpanded = false }: NavNotesProps) { +export function NavNotes({ + notes, + onAddNote, + defaultOpen = true, + searchSpaceId, + isSourcesExpanded = false, +}: NavNotesProps) { const t = useTranslations("sidebar"); const router = useRouter(); const isMobile = useIsMobile(); @@ -188,7 +194,9 @@ export function NavNotes({ notes, onAddNote, defaultOpen = true, searchSpaceId, ) : ( )} - {t("more_options") || "More options"} + + {t("more_options") || "More options"} +