Skip to content

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

fix: keep Brain Inbox capture usable during loading (#9724)

Adam Eivy6e62e76e1353
diff --git a/client/src/components/brain/tabs/InboxTab.browser.test.js b/client/src/components/brain/tabs/InboxTab.browser.test.js
index b638f0cf3a..cd87d95562 100644
--- a/client/src/components/brain/tabs/InboxTab.browser.test.js
+++ b/client/src/components/brain/tabs/InboxTab.browser.test.js
@@ -47,7 +47,11 @@ describe.skipIf(!chrome)('Brain inbox capture geometry', () => {
},
load(id) {
if (id === '\0inbox-api') return `
- export async function getBrainInbox() { return { entries: [], counts: {} }; }
+ let history;
+ export function getBrainInbox() {
+ if (!history) history = new Promise(resolve => { window.resolveInboxHistory = resolve; });
+ return history;
+ }
export async function captureBrainThought(...args) {
window.captures = [...(window.captures || []), args];
return { inboxLog: { id: 'example-thought', status: 'filed', capturedText: args[0] } };
@@ -108,6 +112,7 @@ describe.skipIf(!chrome)('Brain inbox capture geometry', () => {
await page.goto(`${origin}inbox-test`);
const input = page.getByRole('textbox', { name: 'New inbox thought' });
await input.fill('An example thought');
+ await page.getByText('Loading inbox history').waitFor();
const capture = page.getByRole('button', { name: 'Capture thought' });
const creative = page.getByRole('button', { name: 'Toggle creative capture mode' });
const mic = page.getByRole('button', { name: 'Voice capture' });
@@ -131,6 +136,12 @@ describe.skipIf(!chrome)('Brain inbox capture geometry', () => {
await page.waitForFunction(() => window.captures?.length === 1);
expect(await page.evaluate(() => window.captures[0][0])).toBe('An example thought');
expect(await page.evaluate(() => window.captures[0][3].creative)).toBe(true);
+ await page.evaluate(() => window.resolveInboxHistory({
+ entries: [{ id: 'example-thought', status: 'filed', capturedText: 'An example thought', creative: true }],
+ counts: { filed: 1 },
+ }));
+ await page.getByText('Loading inbox history').waitFor({ state: 'hidden' });
+ expect(await page.getByText('An example thought', { exact: true }).count()).toBe(1);
await input.fill('https://example.com');
await page.getByRole('textbox', { name: /Why are you saving this link/ }).fill('Example note');
expect(await creative.isDisabled()).toBe(true);
diff --git a/client/src/components/brain/tabs/InboxTab.jsx b/client/src/components/brain/tabs/InboxTab.jsx
index 9d0952b4e0..4c69dce6a8 100644
--- a/client/src/components/brain/tabs/InboxTab.jsx
+++ b/client/src/components/brain/tabs/InboxTab.jsx
@@ -364,14 +364,6 @@ export default function InboxTab({ onRefresh, settings }) {
navigate('/catalog/ingest', { state: { prefill } });
};
- if (!paged.loaded && paged.loading) {
- return (
- <div className="flex items-center justify-center h-64">
- <BrailleSpinner text="Loading" />
- </div>
- );
- }
-
// Compact per-status overview rendered in the desktop rail so the page reads
// as a dashboard rather than a centered document.
const overviewStats = [
@@ -518,6 +510,12 @@ export default function InboxTab({ onRefresh, settings }) {
</div>
</div>
+ {!paged.loaded && paged.loading && (
+ <div role="status" className="p-3 text-sm text-gray-400">
+ <BrailleSpinner text="Loading inbox history" />
+ </div>
+ )}
+
{/* Needs Review section */}
{needsReviewEntries.length > 0 ? (
<div>
@@ -662,7 +660,7 @@ export default function InboxTab({ onRefresh, settings }) {
) : (
<div className="hidden @5xl/inbox:flex items-center gap-2 p-3 bg-port-card border border-port-border rounded-lg text-sm text-gray-500">
<CheckCircle size={16} className="text-port-success" />
- Nothing needs review.
+ {paged.loaded ? 'Nothing needs review.' : 'Review counts pending.'}
</div>
)}
</div>
@@ -945,7 +943,7 @@ export default function InboxTab({ onRefresh, settings }) {
})}
{filedEntries.length === 0 && (
- <p className="text-gray-500 text-sm">No filed entries yet. Start capturing thoughts above.</p>
+ <p className="text-gray-500 text-sm">{paged.loaded ? 'No filed entries yet. Start capturing thoughts above.' : 'Inbox history is loading. You can capture thoughts above.'}</p>
)}
</div>
)}
diff --git a/client/src/components/brain/tabs/InboxTab.test.jsx b/client/src/components/brain/tabs/InboxTab.test.jsx
index c52fdbbc63..31be911d15 100644
--- a/client/src/components/brain/tabs/InboxTab.test.jsx
+++ b/client/src/components/brain/tabs/InboxTab.test.jsx
@@ -1,5 +1,5 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';
-import { fireEvent, render, screen, waitFor } from '@testing-library/react';
+import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';
import { MemoryRouter, useLocation } from 'react-router';
vi.mock('../../../services/api', () => ({
@@ -68,6 +68,28 @@ beforeEach(() => {
});
describe('Brain inbox capture', () => {
+ it('captures before history resolves and keeps the accepted entry once history arrives', async () => {
+ let resolveHistory;
+ const history = new Promise(resolve => { resolveHistory = resolve; });
+ getBrainInbox.mockReturnValue(history);
+ const accepted = {
+ id: 'example-accepted', capturedText: 'An example thought',
+ status: 'filed', capturedAt: '2026-01-01T00:00:00.000Z',
+ };
+ captureBrainThought.mockResolvedValue({ inboxLog: accepted });
+ render(<MemoryRouter><InboxTab /></MemoryRouter>);
+
+ fireEvent.change(screen.getByLabelText('New inbox thought'), { target: { value: accepted.capturedText } });
+ fireEvent.click(screen.getByLabelText('Capture thought'));
+ await waitFor(() => expect(screen.getByText(accepted.capturedText)).toBeInTheDocument());
+ expect(screen.getByText('Loading inbox history')).toBeInTheDocument();
+ expect(captureBrainThought.mock.calls[0].slice(1, 3)).toEqual([undefined, undefined]);
+
+ await act(async () => { resolveHistory({ entries: [accepted], counts: { filed: 1 } }); });
+ await waitFor(() => expect(screen.queryByText('Loading inbox history')).toBeNull());
+ expect(screen.getAllByText(accepted.capturedText)).toHaveLength(1);
+ });
+
it('sends an optional note when a URL is filed to Links', async () => {
render(<MemoryRouter><InboxTab /></MemoryRouter>);
const input = await screen.findByLabelText('New inbox thought');
diff --git a/client/src/pages/Brain.jsx b/client/src/pages/Brain.jsx
index b2c1238669..2aee22c9aa 100644
--- a/client/src/pages/Brain.jsx
+++ b/client/src/pages/Brain.jsx
@@ -97,7 +97,7 @@ export default function Brain() {
}
};
- if (loading) {
+ if (loading && activeTab !== 'inbox') {
return (
<PageSkeleton
header="bar"
@@ -120,7 +120,9 @@ export default function Brain() {
icon={BrainIcon}
title="Brain"
subtitle="Second brain for capturing and organizing thoughts"
- actions={summary && (
+ actions={loading && !summary ? (
+ <span role="status" className="text-xs text-gray-500">Loading Brain summary</span>
+ ) : summary && (
// Quick stats — wrap on small screens; only "needs review" stays loud
<div className="flex flex-wrap items-center gap-x-3 gap-y-1 text-xs sm:text-sm">
{summary.needsReview > 0 && (
diff --git a/client/src/pages/Brain.test.jsx b/client/src/pages/Brain.test.jsx
index d4b0d26a86..c3b246e781 100644
--- a/client/src/pages/Brain.test.jsx
+++ b/client/src/pages/Brain.test.jsx
@@ -102,3 +102,21 @@ it('updates its summary from events without polling and reconciles once on recon
vi.useRealTimers();
}
});
+
+it('renders Inbox while summary and settings are pending, then updates metadata', async () => {
+ let resolveSummary;
+ let resolveSettings;
+ api.getBrainSummary.mockReturnValue(new Promise(resolve => { resolveSummary = resolve; }));
+ api.getBrainSettings.mockReturnValue(new Promise(resolve => { resolveSettings = resolve; }));
+ renderPageAt('inbox');
+
+ expect(await screen.findByTestId('inbox-tab')).toBeInTheDocument();
+ expect(screen.getByText('Loading Brain summary')).toBeInTheDocument();
+ await act(async () => {
+ resolveSummary({ counts: { links: 7 }, needsReview: 2 });
+ resolveSettings({ defaultProvider: 'example-provider' });
+ });
+ expect(await screen.findByText('7 links')).toBeInTheDocument();
+ expect(screen.queryByText('Loading Brain summary')).toBeNull();
+ expect(screen.getByTestId('inbox-tab')).toBeInTheDocument();
+});