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: show a failure row instead of stale results when the ⌘K knowledge search fails (#12824)
Adam Eivy7c55b4d3c909
diff --git a/client/src/components/CmdKSearch.jsx b/client/src/components/CmdKSearch.jsxindex 5ce7f3f5e1..0e5099171b 100644--- a/client/src/components/CmdKSearch.jsx+++ b/client/src/components/CmdKSearch.jsx@@ -84,6 +84,8 @@ export default function CmdKSearch() {const [catalogResults, setCatalogResults] = useState([]);// A failed catalog lookup must not read as "No results" for the query.const [catalogFailed, setCatalogFailed] = useState(false);+ // Same contract for the knowledge search: a rejected request must not leave the previous query's results on screen.+ const [searchFailed, setSearchFailed] = useState(false);const [loading, setLoading] = useState(false);const [focusedIndex, setFocusedIndex] = useState(0);const [expandedSources, setExpandedSources] = useState(new Set());@@ -184,6 +186,7 @@ export default function CmdKSearch() {}, [open]);useEffect(() => {+ setSearchFailed(false);if (query.length < 2) {setSearchResults([]);setLoading(false);@@ -197,6 +200,11 @@ export default function CmdKSearch() {const timer = setTimeout(() => {search(query).then((data) => { if (!cancelled) setSearchResults(data?.sources ?? []); })+ .catch(() => {+ if (cancelled) return;+ setSearchResults([]);+ setSearchFailed(true);+ }).finally(() => { if (!cancelled) setLoading(false); });}, 300);return () => { cancelled = true; clearTimeout(timer); };@@ -614,6 +622,9 @@ export default function CmdKSearch() {No results for “{query}”</div>)}+ {searchFailed && (+ <div role="alert" className="px-4 py-2 text-center text-xs text-port-error">Search failed, so results may be missing.</div>+ )}{catalogFailed && (<div role="alert" className="px-4 py-2 text-center text-xs text-port-error">Catalog search failed, so catalog matches may be missing.</div>)}diff --git a/client/src/components/CmdKSearch.test.jsx b/client/src/components/CmdKSearch.test.jsxindex 729f44346b..ac7cd0a66d 100644--- a/client/src/components/CmdKSearch.test.jsx+++ b/client/src/components/CmdKSearch.test.jsx@@ -584,3 +584,34 @@ describe('CmdKSearch catalog lookup failure', () => {vi.useRealTimers();});});++describe('CmdKSearch knowledge search failure', () => {+ it('shows a failure row instead of stale results when search() rejects, and clears on the next query', async () => {+ vi.useFakeTimers();+ search+ .mockResolvedValueOnce({ sources: [{ id: 'brain', label: 'Brain', icon: 'brain', results: [{ id: 'r1', title: 'Stale result', url: '/brain/r1' }] }] })+ .mockRejectedValueOnce(new Error('search down'))+ .mockResolvedValueOnce({ sources: [] });+ render(+ <MemoryRouter initialEntries={['/current']}>+ <CmdKSearch />+ </MemoryRouter>,+ );+ await act(async () => { fireEvent.keyDown(document, { key: 'k', metaKey: true }); });+ const input = screen.getByPlaceholderText(/Go to page/);++ await act(async () => { fireEvent.change(input, { target: { value: 'aaaa' } }); });+ await act(async () => { await vi.advanceTimersByTimeAsync(300); });+ expect(screen.getByText('Stale result')).toBeInTheDocument();++ await act(async () => { fireEvent.change(input, { target: { value: 'bbbb' } }); });+ await act(async () => { await vi.advanceTimersByTimeAsync(300); });+ expect(screen.getByRole('alert')).toHaveTextContent(/search failed/i);+ expect(screen.queryByText('Stale result')).not.toBeInTheDocument();++ await act(async () => { fireEvent.change(input, { target: { value: 'cccc' } }); });+ expect(screen.queryByRole('alert')).not.toBeInTheDocument();++ vi.useRealTimers();+ });+});