diff --git a/frontend/src/components/simulator/LibraryManagerModal.tsx b/frontend/src/components/simulator/LibraryManagerModal.tsx index c182fb9..2e436fb 100644 --- a/frontend/src/components/simulator/LibraryManagerModal.tsx +++ b/frontend/src/components/simulator/LibraryManagerModal.tsx @@ -33,6 +33,14 @@ export const LibraryManagerModal: React.FC = ({ isOpen } }, []); + // Fetch installed list when modal opens (to cross-reference in search tab) + useEffect(() => { + if (isOpen) { + fetchInstalled(); + } + }, [isOpen, fetchInstalled]); + + // Also refresh when switching to the installed tab useEffect(() => { if (isOpen && activeTab === 'installed') { fetchInstalled(); @@ -69,6 +77,7 @@ export const LibraryManagerModal: React.FC = ({ isOpen const result = await installLibrary(libName); if (result.success) { setStatusMsg({ type: 'success', text: `"${libName}" installed successfully!` }); + fetchInstalled(); // Refresh installed list so search tab reflects new state } else { setStatusMsg({ type: 'error', text: result.error || `Failed to install "${libName}"` }); } @@ -88,6 +97,11 @@ export const LibraryManagerModal: React.FC = ({ isOpen if (!isOpen) return null; + const isInstalled = (libName: string): boolean => + installedLibraries.some( + (il) => (il.library?.name || il.name || '').toLowerCase() === libName.toLowerCase() + ); + const getLibName = (lib: ArduinoLibrary): string => lib.name || 'Unknown'; const getLibVersion = (lib: ArduinoLibrary): string => lib.latest?.version || lib.version || ''; const getLibAuthor = (lib: ArduinoLibrary): string => lib.latest?.author || lib.author || ''; @@ -207,17 +221,24 @@ export const LibraryManagerModal: React.FC = ({ isOpen {getLibVersion(lib) && ( {getLibVersion(lib)} )} - + {isInstalled(getLibName(lib)) ? ( + + INSTALLED + + + ) : ( + + )} ))}