fix: Zustand selector anti-pattern causing infinite re-render + plugin loader path

- Fix usePluginStore(s => s.getAll*()) selectors that returned new arrays
  on every call, causing infinite re-render loops and permanent spinner
- Affected: Sidebar, Settings, ContactDetail, ContactEditModal, PluginRouteRenderer
- Use usePluginStore(s => s.manifests) + useMemo instead
- Fix PluginRouteRenderer: show spinner instead of null when manifests loading
- Fix PluginLoader: @/ path replacement ../ -> ../../ for correct dynamic imports
This commit is contained in:
Agent Zero
2026-07-24 19:29:48 +02:00
parent 6e930b814e
commit 4b9cb5a098
6 changed files with 57 additions and 16 deletions
+8 -2
View File
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useMemo } from 'react';
import { NavLink, Outlet } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { usePluginStore } from '@/store/pluginStore';
@@ -6,7 +6,13 @@ import * as LucideIcons from 'lucide-react';
export function SettingsPage() {
const { t } = useTranslation();
const pluginSettingsPages = usePluginStore(s => s.getAllSettingsPages());
const manifests = usePluginStore(s => s.manifests);
const pluginSettingsPages = useMemo(
() => manifests
.flatMap((m) => m.settings_pages)
.sort((a, b) => a.order - b.order),
[manifests]
);
const hardcodedNavItems = [
{ to: '/settings/system', label: t('systemSettings.title'), icon: '\u2699\ufe0f' },