diff --git a/plugin/views/ai-chat/chat.tsx b/plugin/views/ai-chat/chat.tsx index c8388c9e..b062c362 100644 --- a/plugin/views/ai-chat/chat.tsx +++ b/plugin/views/ai-chat/chat.tsx @@ -142,7 +142,6 @@ export const ChatComponent: React.FC = ({ return `Path: ${file.path}\nTitle: ${file.title}\nReference: ${file.reference}\nContent:\n${file.content}`; }) .join("\n\n-------\n\n"); - console.log(contextString, "contextString"); const result = await streamText({ model: ollama("llama3.2"), @@ -161,7 +160,7 @@ export const ChatComponent: React.FC = ({ return fetch(url, options); }, onToolCall({ toolCall }) { - console.log("toolCall", toolCall); + logMessage("toolCall", toolCall); }, keepLastMessageOnError: true, onError: error => { @@ -496,7 +495,6 @@ export const ChatComponent: React.FC = ({ const handleYouTubeTranscript = useCallback( (transcript: string, title: string, videoId: string) => { - console.log(transcript, "this is the transcript"); setSelectedYouTubeVideos(prev => [ ...prev, { diff --git a/plugin/views/organizer/ai-format/templates.tsx b/plugin/views/organizer/ai-format/templates.tsx index 53f7e7dd..bead2e62 100644 --- a/plugin/views/organizer/ai-format/templates.tsx +++ b/plugin/views/organizer/ai-format/templates.tsx @@ -51,7 +51,6 @@ export const ClassificationContainer: React.FC = ({ }); } - console.log("Content formatted successfully"); } catch (error) { console.error("Error in handleFormat:", error); } diff --git a/plugin/views/organizer/chunks.tsx b/plugin/views/organizer/chunks.tsx index 359c4c61..64244910 100644 --- a/plugin/views/organizer/chunks.tsx +++ b/plugin/views/organizer/chunks.tsx @@ -17,7 +17,6 @@ export const DocumentChunks: React.FC = ({ plugin, activeFi try { const content = await plugin.app.vault.read(activeFile); const result = await plugin.identifyConceptsAndFetchChunks(content); - console.log("result", result); setConcepts(result.map(c => c.name)); setChunks(result.map(c => ({ concept: c.name, content: c.chunk }))); } catch (error) { diff --git a/plugin/views/organizer/classification.tsx b/plugin/views/organizer/classification.tsx index 3fa17a5e..b4478c42 100644 --- a/plugin/views/organizer/classification.tsx +++ b/plugin/views/organizer/classification.tsx @@ -43,7 +43,6 @@ export const ClassificationContainer: React.FC = ({ formattingInstruction: formattingInstruction, }); - console.log("Content formatted successfully"); } catch (error) { console.error("Error in handleFormat:", error); } diff --git a/plugin/views/organizer/components/suggestion-buttons.tsx b/plugin/views/organizer/components/suggestion-buttons.tsx new file mode 100644 index 00000000..b3b5b2e6 --- /dev/null +++ b/plugin/views/organizer/components/suggestion-buttons.tsx @@ -0,0 +1,49 @@ +import * as React from "react"; +import { motion } from "framer-motion"; + +// Base Folder Button Component +const BaseFolderButton: React.FC<{ + folder: string; + onClick: (folder: string) => void; + className?: string; + score?: number; + reason?: string; +}> = ({ folder, onClick, className, score, reason }) => ( + onClick(folder)} + initial={{ opacity: 0, scale: 0.8 }} + animate={{ opacity: 1, scale: 1 }} + exit={{ opacity: 0, scale: 0.8 }} + transition={{ duration: 0.2 }} + title={`Score: ${score}, Reason: ${reason}`} + > + {folder} + +); + +// Existing Folder Button Component +export const ExistingFolderButton: React.FC<{ + folder: string; + onClick: (folder: string) => void; + score: number; + reason: string; +}> = props => ( + +); + +// New Folder Button Component +export const NewFolderButton: React.FC<{ + folder: string; + onClick: (folder: string) => void; + score: number; + reason: string; +}> = props => ( + +); \ No newline at end of file diff --git a/plugin/views/organizer/folders/box.tsx b/plugin/views/organizer/folders/box.tsx index 6511ecaf..f574d6e4 100644 --- a/plugin/views/organizer/folders/box.tsx +++ b/plugin/views/organizer/folders/box.tsx @@ -4,6 +4,8 @@ import FileOrganizer from "../../../index"; import { motion, AnimatePresence } from "framer-motion"; import { SkeletonLoader } from "../components/skeleton-loader"; import { FolderSuggestion } from "../../../index"; +import { logMessage } from "../../../../utils"; +import { ExistingFolderButton, NewFolderButton } from "../components/suggestion-buttons"; interface SimilarFolderBoxProps { plugin: FileOrganizer; @@ -34,22 +36,24 @@ export const SimilarFolderBox: React.FC = ({ content, file.path ); - + // Get all valid folders const validFolders = plugin.getAllUserFolders(); - + // Filter suggestions to only include existing folders or new folders - const filteredSuggestions = folderSuggestions.filter(suggestion => - suggestion.isNewFolder || validFolders.includes(suggestion.folder) + const filteredSuggestions = folderSuggestions.filter( + suggestion => + suggestion.isNewFolder || validFolders.includes(suggestion.folder) ); setSuggestions(filteredSuggestions); } catch (err) { console.error("Error fetching folders:", err); - const errorMessage = typeof err === 'object' && err !== null - ? (err.error?.message || err.error || err.message || "Unknown error") - : String(err); - + const errorMessage = + typeof err === "object" && err !== null + ? err.error?.message || err.error || err.message || "Unknown error" + : String(err); + setError(new Error(errorMessage)); } finally { setLoading(false); @@ -66,27 +70,36 @@ export const SimilarFolderBox: React.FC = ({ }; const handleFolderClick = async (folder: string) => { + // if same folder, do nothing + logMessage({ newFolder: folder, currentFolder: file?.parent?.path }); + if (folder === file?.parent?.path) return; if (!file) return; - + setLoading(true); try { await plugin.moveFile(file, file.basename, folder); new Notice(`Moved ${file.basename} to ${folder}`); } catch (error) { console.error("Error moving file:", error); - const errorMessage = error instanceof Error ? error.message : "Unknown error occurred"; - new Notice(`Failed to move ${file.basename} to ${folder}: ${errorMessage}`); + const errorMessage = + error instanceof Error ? error.message : "Unknown error occurred"; + new Notice( + `Failed to move ${file.basename} to ${folder}: ${errorMessage}` + ); } finally { setLoading(false); } }; + const filteredSuggestions = suggestions.filter( + s => s.folder !== file?.parent?.path + ); // Derive existing and new folders from suggestions - const existingFolders = suggestions.filter(s => !s.isNewFolder); - const newFolders = suggestions.filter(s => s.isNewFolder); + const existingFolders = filteredSuggestions.filter(s => !s.isNewFolder); + const newFolders = filteredSuggestions.filter(s => s.isNewFolder); const renderError = () => ( - = ({

- +
- -