Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(brain): show a loading state while the memory graph loads

Shanub436159e111e
diff --git a/app/src/pages/Brain.tsx b/app/src/pages/Brain.tsx
index 01e9fbe06c..4cbdd4af52 100644
--- a/app/src/pages/Brain.tsx
+++ b/app/src/pages/Brain.tsx
@@ -24,6 +24,7 @@ import SettingsTabbedPage from '../components/settings/layout/SettingsTabbedPage
import MemoryEngineErrorAlert from '../components/settings/panels/MemoryEngineErrorAlert';
import { classifyMemoryEngineError } from '../components/settings/panels/memoryEngineUtils';
import { Alert, AlertDescription, Card } from '../components/ui';
+import { CenteredLoadingState } from '../components/ui/LoadingState';
import { useT } from '../lib/i18n/I18nContext';
import { useCoreState } from '../providers/CoreStateProvider';
import type { ToastNotification } from '../types/intelligence';
@@ -421,7 +422,17 @@ export default function Brain() {
/>
) : error !== null ? (
<MemoryEngineErrorAlert error={error} fallbackText={t('brain.error')} />
- ) : null}
+ ) : (
+ // The first load can take seconds — a hosted engine
+ // builds the graph from its derived layers — and an
+ // empty canvas meanwhile reads as a broken page.
+ <div role="status" data-testid="brain-graph-loading">
+ <CenteredLoadingState
+ label={t('workspace.loadingGraph')}
+ className="h-[640px] rounded-lg border border-line-subtle bg-surface-muted/40"
+ />
+ </div>
+ )}
</div>
</MemoryFamilyGate>
)}
diff --git a/app/src/pages/__tests__/Brain.test.tsx b/app/src/pages/__tests__/Brain.test.tsx
index 9b8819e193..1c92107ead 100644
--- a/app/src/pages/__tests__/Brain.test.tsx
+++ b/app/src/pages/__tests__/Brain.test.tsx
@@ -111,6 +111,28 @@ describe('Brain page', () => {
});
});
+ it('shows a loading state, not an empty canvas, until the graph arrives', async () => {
+ let resolveGraph!: (graph: ReturnType<typeof makeGraph>) => void;
+ graphExportMock.mockReturnValue(
+ new Promise(resolve => {
+ resolveGraph = resolve;
+ })
+ );
+ await act(async () => {
+ renderWithProviders(<Brain />, { initialEntries: ['/?tab=graph'] });
+ });
+ expect(screen.getByTestId('brain-graph-loading')).toHaveTextContent('workspace.loadingGraph');
+ expect(screen.queryByTestId('memory-graph')).not.toBeInTheDocument();
+
+ await act(async () => {
+ resolveGraph(makeGraph(2));
+ });
+ await waitFor(() => {
+ expect(screen.getByTestId('memory-graph')).toHaveTextContent('nodes:2');
+ });
+ expect(screen.queryByTestId('brain-graph-loading')).not.toBeInTheDocument();
+ });
+
it('renders empty-state graph when there are no nodes', async () => {
graphExportMock.mockResolvedValue(makeGraph(0));
await act(async () => {