Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: distinguish unavailable orchestration profile reads (#11145)
Adam Eivy435e45251edc
diff --git a/client/src/components/settings/OrchestrationTab.jsx b/client/src/components/settings/OrchestrationTab.jsxindex c79672423d..7bb9c38a10 100644--- a/client/src/components/settings/OrchestrationTab.jsx+++ b/client/src/components/settings/OrchestrationTab.jsx@@ -1,4 +1,4 @@-import { useState, useEffect, useCallback } from 'react';+import { useState, useEffect, useCallback, useRef } from 'react';import { shortClaudeModelName } from '../../utils/formatters';import { Plus, Edit2, Trash2, Cpu, Check, X, Shield, Sparkles } from 'lucide-react';import toast from '../ui/Toast';@@ -32,6 +32,10 @@ export default function OrchestrationTab() {const [profiles, setProfiles] = useState([]);const [providers, setProviders] = useState([]);const [loading, setLoading] = useState(true);+ const [profilesLoaded, setProfilesLoaded] = useState(false);+ const [profileError, setProfileError] = useState(false);+ const [providerError, setProviderError] = useState(false);+ const loadGeneration = useRef(0);const [editingProfile, setEditingProfile] = useState(null);const [isNew, setIsNew] = useState(false);const [saving, setSaving] = useState(false);@@ -39,24 +43,29 @@ export default function OrchestrationTab() {const deleteConfirm = useConfirmDelete();const loadData = useCallback(async () => {+ const generation = ++loadGeneration.current;setLoading(true);- try {- const [profList, provList] = await Promise.all([- api.getOrchestrationProfiles({ silent: true }).catch(() => []),- api.getProviders({ silent: true }).catch(() => ({ providers: [] })),- ]);- setProfiles(profList || []);+ const [profileResult, providerResult] = await Promise.allSettled([+ api.getOrchestrationProfiles({ silent: true }),+ api.getProviders({ silent: true, fresh: true }),+ ]);+ if (generation !== loadGeneration.current) return;+ setProfileError(profileResult.status === 'rejected');+ setProviderError(providerResult.status === 'rejected');+ if (profileResult.status === 'fulfilled') {+ setProfiles(profileResult.value || []);+ setProfilesLoaded(true);+ }+ if (providerResult.status === 'fulfilled') {// getProviders() resolves { activeProvider, providers }, not a bare array.- setProviders((provList?.providers || []).filter((p) => p.enabled));- } catch (err) {- toast.error(`Failed to load orchestration data: ${err.message}`);- } finally {- setLoading(false);+ setProviders((providerResult.value?.providers || []).filter((p) => p.enabled));}+ setLoading(false);}, []);useEffect(() => {loadData();+ return () => { loadGeneration.current += 1; };}, [loadData]);const handleStartCreate = () => {@@ -194,6 +203,24 @@ export default function OrchestrationTab() {)}</div>+ {(profileError || providerError) && (+ <div role="status" className="bg-port-card border border-port-border rounded-xl p-4 flex flex-wrap items-center justify-between gap-3">+ <div className="min-w-0 space-y-1 text-sm text-gray-400">+ {profileError && <p>{profilesLoaded+ ? 'Orchestration profiles could not be refreshed. Showing previously loaded profiles; they may be out of date.'+ : 'Orchestration profiles are unavailable.'}</p>}+ {providerError && <p>Provider metadata is unavailable. Provider IDs or previously loaded names are shown.</p>}+ </div>+ <button+ onClick={loadData}+ disabled={loading}+ className="px-4 py-2 min-h-[44px] bg-port-border hover:bg-port-border/80 text-white rounded-lg text-sm disabled:opacity-50"+ >+ {loading ? 'Retrying…' : 'Retry'}+ </button>+ </div>+ )}+{editingProfile ? (<div className="bg-port-card border border-port-border rounded-xl p-6 space-y-6"><div className="flex items-center justify-between border-b border-port-border pb-4">@@ -339,9 +366,9 @@ export default function OrchestrationTab() {</div>) : null}- {loading ? (+ {loading && !profilesLoaded ? (<div className="p-8 text-center text-gray-400">Loading orchestration profiles…</div>- ) : profiles.length === 0 ? (+ ) : !profilesLoaded || (profileError && profiles.length === 0) ? null : profiles.length === 0 ? (<div className="bg-port-card border border-port-border rounded-xl p-8 text-center space-y-3"><p className="text-gray-400">No orchestration profiles configured.</p><buttondiff --git a/client/src/components/settings/OrchestrationTab.test.jsx b/client/src/components/settings/OrchestrationTab.test.jsxindex 45297ab63f..83f8a774a6 100644--- a/client/src/components/settings/OrchestrationTab.test.jsx+++ b/client/src/components/settings/OrchestrationTab.test.jsx@@ -68,6 +68,50 @@ describe('OrchestrationTab', () => {expect(screen.queryByText('anthropic')).toBeNull();});+ it('distinguishes an unavailable inventory from a successful empty retry', async () => {+ api.getOrchestrationProfiles.mockRejectedValueOnce(new Error('Unavailable')).mockResolvedValueOnce([]);+ render(<OrchestrationTab />);+ expect(await screen.findByText('Orchestration profiles are unavailable.')).toBeTruthy();+ expect(screen.queryByText('No orchestration profiles configured.')).toBeNull();+ expect(screen.queryByText('Create your first profile')).toBeNull();++ fireEvent.click(screen.getByRole('button', { name: 'Retry' }));+ expect(await screen.findByText('No orchestration profiles configured.')).toBeTruthy();+ expect(screen.queryByText('Orchestration profiles are unavailable.')).toBeNull();+ });++ it('recovers profiles on retry while provider metadata fails independently', async () => {+ api.getOrchestrationProfiles.mockRejectedValueOnce(new Error('Unavailable')).mockResolvedValueOnce(mockProfiles);+ api.getProviders.mockRejectedValue(new Error('Unavailable'));+ render(<OrchestrationTab />);+ await screen.findByText('Orchestration profiles are unavailable.');+ fireEvent.click(screen.getByRole('button', { name: 'Retry' }));+ expect(await screen.findByText('Custom Team')).toBeTruthy();+ expect(screen.getByText(/Provider metadata is unavailable/)).toBeTruthy();+ expect(screen.getAllByText('anthropic').length).toBeGreaterThan(0);+ expect(screen.queryByText('No orchestration profiles configured.')).toBeNull();+ });++ it('retains profiles and provider names when a refresh fails, then clears stale notices on recovery', async () => {+ api.getProviders.mockRejectedValueOnce(new Error('Unavailable'));+ render(<OrchestrationTab />);+ await screen.findByText('Custom Team');+ api.getOrchestrationProfiles.mockRejectedValueOnce(new Error('Unavailable'));+ fireEvent.click(screen.getByRole('button', { name: 'Retry' }));+ expect(await screen.findByText(/Showing previously loaded profiles/)).toBeTruthy();+ expect(screen.getByText('Custom Team')).toBeTruthy();+ expect(screen.getAllByText('Anthropic').length).toBeGreaterThan(0);+ expect(screen.queryByText('No orchestration profiles configured.')).toBeNull();++ api.getProviders.mockRejectedValueOnce(new Error('Unavailable'));+ fireEvent.click(screen.getByRole('button', { name: 'Retry' }));+ await waitFor(() => expect(screen.queryByText(/Showing previously loaded profiles/)).toBeNull());+ expect(screen.getAllByText('Anthropic').length).toBeGreaterThan(0);+ expect(screen.getByText(/Provider metadata is unavailable/)).toBeTruthy();+ fireEvent.click(screen.getByRole('button', { name: 'Retry' }));+ await waitFor(() => expect(screen.queryByText(/Provider metadata is unavailable/)).toBeNull());+ });+it('opens create profile form and saves', async () => {api.saveOrchestrationProfile.mockResolvedValue({id: 'new-profile',