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: show loading animation in task queue and drafts while loading

Adam Eivy3240bd5ef24d
diff --git a/client/src/components/cos/tabs/TasksTab.jsx b/client/src/components/cos/tabs/TasksTab.jsx
index 233bf558d8..f579ce61e2 100644
--- a/client/src/components/cos/tabs/TasksTab.jsx
+++ b/client/src/components/cos/tabs/TasksTab.jsx
@@ -26,6 +26,7 @@ import { MicroGlyph, SchematicLabel } from '../../micrographics';
import useAssignableInstances from '../../../hooks/useAssignableInstances';
import { formatCount } from '../../../utils/formatters';
import { runningAgentsByTaskId, isSpawningTask } from '../../../lib/cosSpawnWindow';
+import BrailleSpinner from '../../BrailleSpinner';
// Maps a task-section status → micrographic glyph spec. Animation only on
// states where motion communicates real work happening (running tasks).
@@ -237,6 +238,10 @@ export default function TasksTab({ completedRevision = 0, tasks, agents = [], li
onRefresh();
}, [onRefresh, onTaskAdded]);
+ const isUserLoading = tasks?.user == null;
+ const isCosLoading = tasks?.cos == null;
+ const isQueueLoading = isUserLoading || isCosLoading;
+
return (
<div className="space-y-6">
{/* User Tasks */}
@@ -246,15 +251,25 @@ export default function TasksTab({ completedRevision = 0, tasks, agents = [], li
</div>
<p className="mb-3 text-sm text-gray-400" aria-label="Queue status">
- {formatCount(pendingUserTasksLocal.length + pendingSystemTasks.length)} pending
- {' · '}{formatCount(activeUserTasksLocal.length + activeSystemTasks.length)} active
- {' · '}{formatCount(blockedUserTasksLocal.length + blockedSystemTasks.length)} blocked
+ {isQueueLoading ? (
+ <BrailleSpinner text="Loading task queue…" />
+ ) : (
+ <>
+ {formatCount(pendingUserTasksLocal.length + pendingSystemTasks.length)} pending
+ {' · '}{formatCount(activeUserTasksLocal.length + activeSystemTasks.length)} active
+ {' · '}{formatCount(blockedUserTasksLocal.length + blockedSystemTasks.length)} blocked
+ </>
+ )}
</p>
{/* Compact capture keeps the queue above detailed configuration. */}
<TaskAddForm queueFirst providers={providers} providersLoaded={providersLoaded} apps={apps} onTaskAdded={handleTaskAdded} />
{/* User Tasks Sections */}
- {pendingUserTasksLocal.length === 0 && activeUserTasksLocal.length === 0 && blockedUserTasksLocal.length === 0 && (tasks.user?.completedCount ?? completedUserTasksLocal.length) === 0 ? (
+ {isUserLoading ? (
+ <div className="relative bg-port-card border border-port-border rounded-lg p-6 text-center text-gray-400">
+ <BrailleSpinner text="Loading task queue…" />
+ </div>
+ ) : pendingUserTasksLocal.length === 0 && activeUserTasksLocal.length === 0 && blockedUserTasksLocal.length === 0 && (tasks.user?.completedCount ?? completedUserTasksLocal.length) === 0 ? (
<div className="relative bg-port-card border border-port-border rounded-lg p-6 text-center text-gray-500">
<SchematicLabel module="USER" status="EMPTY" glyph="bracket-pair" state="idle" variant="tab" />
No user tasks. Add one above or edit TASKS.md directly.
@@ -358,7 +373,11 @@ export default function TasksTab({ completedRevision = 0, tasks, agents = [], li
<h3 className="text-lg font-semibold text-white mb-3">System Tasks (COS-TASKS.md)</h3>
{/* System Tasks Sections */}
- {pendingSystemTasks.length === 0 && activeSystemTasks.length === 0 && blockedSystemTasks.length === 0 && (tasks.cos?.completedCount ?? completedSystemTasks.length) === 0 ? (
+ {isCosLoading ? (
+ <div className="relative bg-port-card border border-port-border rounded-lg p-6 text-center text-gray-400">
+ <BrailleSpinner text="Loading system tasks…" />
+ </div>
+ ) : pendingSystemTasks.length === 0 && activeSystemTasks.length === 0 && blockedSystemTasks.length === 0 && (tasks.cos?.completedCount ?? completedSystemTasks.length) === 0 ? (
<div className="relative bg-port-card border border-port-border rounded-lg p-6 text-center text-gray-500">
<SchematicLabel module="COS" status="EMPTY" glyph="bracket-pair" state="idle" variant="tab" />
No system tasks.
diff --git a/client/src/components/cos/tabs/TasksTab.test.jsx b/client/src/components/cos/tabs/TasksTab.test.jsx
index d69301d36b..e50bc9a4d6 100644
--- a/client/src/components/cos/tabs/TasksTab.test.jsx
+++ b/client/src/components/cos/tabs/TasksTab.test.jsx
@@ -1,5 +1,5 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
-import { fireEvent, render, screen, waitFor } from '@testing-library/react';
+import { fireEvent, render, screen, waitFor, act } from '@testing-library/react';
import { MemoryRouter } from 'react-router';
vi.mock('../../../hooks/useAssignableInstances', () => ({ default: () => ({ instances: [], isFederated: false }) }));
@@ -150,3 +150,15 @@ it('refreshes expanded history on completed changes without fetching it for queu
expect(screen.queryByText('Completed old')).not.toBeInTheDocument();
expect(api.getCosTasks).toHaveBeenCalledTimes(3);
});
+
+it('displays loading spinners while tasks are loading instead of empty messages', async () => {
+ renderTab({ tasks: { user: null, cos: null } });
+ await act(async () => {});
+
+ expect(screen.queryByText('No user tasks. Add one above or edit TASKS.md directly.')).not.toBeInTheDocument();
+ expect(screen.queryByText('No system tasks.')).not.toBeInTheDocument();
+ expect(screen.queryByText(/0 pending · 0 active · 0 blocked/)).not.toBeInTheDocument();
+
+ expect(screen.getAllByLabelText('Loading task queue…').length).toBeGreaterThanOrEqual(1);
+ expect(screen.getByLabelText('Loading system tasks…')).toBeInTheDocument();
+});
diff --git a/client/src/components/messages/DraftsTab.jsx b/client/src/components/messages/DraftsTab.jsx
index 00b99f3503..9e315f812b 100644
--- a/client/src/components/messages/DraftsTab.jsx
+++ b/client/src/components/messages/DraftsTab.jsx
@@ -5,6 +5,7 @@ import * as api from '../../services/api';
import InlineConfirmRow from '../ui/InlineConfirmRow';
import { useConfirmDelete } from '../../hooks/useConfirmDelete';
import { copyToClipboard } from '../../lib/clipboard.js';
+import BrailleSpinner from '../BrailleSpinner';
function DeliveryReconciliation({ draft, onReconciled }) {
const [checkedMailbox, setCheckedMailbox] = useState(false);
@@ -153,6 +154,12 @@ export default function DraftsTab({ accounts }) {
</button>
</div>
+ {loading && drafts.length === 0 && (
+ <div className="text-center py-12 text-gray-400">
+ <BrailleSpinner text="Loading drafts…" />
+ </div>
+ )}
+
{drafts.length === 0 && !loading && (
<div className="text-center py-12 text-gray-500">
<FileText size={48} className="mx-auto mb-4 opacity-50" />
diff --git a/client/src/components/messages/DraftsTab.test.jsx b/client/src/components/messages/DraftsTab.test.jsx
index 8e538f8bf8..0d70f2a31e 100644
--- a/client/src/components/messages/DraftsTab.test.jsx
+++ b/client/src/components/messages/DraftsTab.test.jsx
@@ -181,4 +181,24 @@ describe('DraftsTab send capabilities', () => {
fireEvent.click(screen.getByRole('button', { name: 'Send' }));
await waitFor(() => expect(api.sendMessageDraft).toHaveBeenCalledWith('gmail-draft'));
});
+
+ it('displays a loading spinner while drafts are loading and shows empty state when done', async () => {
+ let resolveDrafts;
+ const draftsPromise = new Promise((resolve) => {
+ resolveDrafts = resolve;
+ });
+ api.getMessageDrafts.mockReturnValueOnce(draftsPromise);
+
+ render(<DraftsTab accounts={[]} />);
+
+ expect(screen.getByLabelText('Loading drafts…')).toBeInTheDocument();
+ expect(screen.queryByText('No drafts')).not.toBeInTheDocument();
+
+ await act(async () => {
+ resolveDrafts([]);
+ });
+
+ await waitFor(() => expect(screen.getByText('No drafts')).toBeInTheDocument());
+ expect(screen.queryByLabelText('Loading drafts…')).not.toBeInTheDocument();
+ });
});
diff --git a/client/src/pages/X.jsx b/client/src/pages/X.jsx
index 52f36a4523..9cf383d26d 100644
--- a/client/src/pages/X.jsx
+++ b/client/src/pages/X.jsx
@@ -6,6 +6,7 @@ import Drawer from '../components/Drawer';
import PageHeader from '../components/PageHeader';
import PageSkeleton from '../components/ui/PageSkeleton';
import TabPills from '../components/ui/TabPills';
+import BrailleSpinner from '../components/BrailleSpinner';
import { useValidTab } from '../hooks/useValidTab';
import { formatCount, formatDateTime } from '../utils/formatters';
@@ -255,9 +256,9 @@ export default function XPage() {
</div>;
};
- const renderPosts = () => <section className="rounded border border-port-border bg-port-card p-4"><div className="flex flex-wrap items-start justify-between gap-3"><div><h2 className="font-semibold text-white">Captured post reach</h2><p className="mt-1 text-sm text-gray-400">Public metrics from the last browser diagnostic; counts are impressions, not unique people.</p></div><button type="button" className={secondaryButton} disabled={accountActionsDisabled} onClick={sync}><RefreshCw size={15} className="mr-1 inline" />Refresh</button></div>{!visiblePosts.length ? <p className="mt-4 text-sm text-gray-500">No captured posts yet. Run a diagnostic from Reach &amp; health.</p> : <div className="mt-4 space-y-2">{visiblePosts.map((post) => <article key={post.id} className="rounded border border-port-border p-3"><div className="flex flex-wrap items-center justify-between gap-2 text-xs text-gray-500"><span>{post.kind === 'reply' ? 'Reply' : 'Post'} · {formatDate(post.remoteCreatedAt)}</span><span>{post.sourceUrl ? <a className="text-port-accent hover:underline" href={post.sourceUrl} target="_blank" rel="noreferrer">Open on X</a> : null}</span></div><p className="mt-2 whitespace-pre-wrap text-sm text-gray-200">{post.body || '(no text captured)'}</p><div className="mt-3 flex flex-wrap gap-3 text-xs text-gray-400"><span><strong className="text-white">{formatCount(post.impressions)}</strong> impressions</span><span><strong className="text-white">{formatCount(post.engagements)}</strong> engagements</span><span>{formatCount(post.likes)} likes</span><span>{formatCount(post.reposts)} reposts</span><span>{formatCount(post.replies)} replies</span></div></article>)}</div>}</section>;
+ const renderPosts = () => <section className="rounded border border-port-border bg-port-card p-4"><div className="flex flex-wrap items-start justify-between gap-3"><div><h2 className="font-semibold text-white">Captured post reach</h2><p className="mt-1 text-sm text-gray-400">Public metrics from the last browser diagnostic; counts are impressions, not unique people.</p></div><button type="button" className={secondaryButton} disabled={accountActionsDisabled} onClick={sync}><RefreshCw size={15} className="mr-1 inline" />Refresh</button></div>{resourcesAccountId !== selected?.id ? <div className="mt-4 text-sm text-gray-400"><BrailleSpinner text="Loading posts…" /></div> : !visiblePosts.length ? <p className="mt-4 text-sm text-gray-500">No captured posts yet. Run a diagnostic from Reach &amp; health.</p> : <div className="mt-4 space-y-2">{visiblePosts.map((post) => <article key={post.id} className="rounded border border-port-border p-3"><div className="flex flex-wrap items-center justify-between gap-2 text-xs text-gray-500"><span>{post.kind === 'reply' ? 'Reply' : 'Post'} · {formatDate(post.remoteCreatedAt)}</span><span>{post.sourceUrl ? <a className="text-port-accent hover:underline" href={post.sourceUrl} target="_blank" rel="noreferrer">Open on X</a> : null}</span></div><p className="mt-2 whitespace-pre-wrap text-sm text-gray-200">{post.body || '(no text captured)'}</p><div className="mt-3 flex flex-wrap gap-3 text-xs text-gray-400"><span><strong className="text-white">{formatCount(post.impressions)}</strong> impressions</span><span><strong className="text-white">{formatCount(post.engagements)}</strong> engagements</span><span>{formatCount(post.likes)} likes</span><span>{formatCount(post.reposts)} reposts</span><span>{formatCount(post.replies)} replies</span></div></article>)}</div>}</section>;
- const renderDrafts = () => <div className="space-y-4"><section className="rounded border border-port-border bg-port-card p-4"><h2 className="font-semibold text-white">Draft a post for review</h2><p className="mt-1 text-sm text-gray-400">Drafts stay local until you submit them to Review Hub. PortOS will never publish automatically.</p><form className="mt-3 space-y-3" onSubmit={createDraft}><label htmlFor="x-draft-body" className="sr-only">X draft text</label><textarea id="x-draft-body" className={fieldClass} rows="5" maxLength="4000" placeholder="Write something you actually want to say…" value={draftBody} onChange={(event) => setDraftBody(event.target.value)} /><div className="flex flex-wrap items-center justify-between gap-2"><span className="text-xs text-gray-500">{draftBody.length}/4000</span><button className={buttonClass} disabled={!draftBody.trim() || Boolean(busy)}>Save draft</button></div></form></section><section className="rounded border border-port-border bg-port-card p-4"><h2 className="font-semibold text-white">Draft queue</h2>{!visibleDrafts.length ? <p className="mt-3 text-sm text-gray-500">No drafts for @{selected.username}.</p> : <div className="mt-3 space-y-2">{visibleDrafts.map((draft) => <article key={draft.id} className="rounded border border-port-border p-3"><div className="flex flex-wrap items-center justify-between gap-2"><StatusBadge value={draft.state === 'approved' || draft.state === 'opened'}>{stateLabel(draft.state)}</StatusBadge><span className="text-xs text-gray-500">{formatDate(draft.updatedAt)}</span></div><p className="mt-3 whitespace-pre-wrap text-sm text-gray-200">{draft.body}</p><div className="mt-3 flex flex-wrap gap-2">{draft.state === 'draft' && <button type="button" className={secondaryButton} disabled={Boolean(busy)} onClick={() => reviewDraft(draft, 'pending_review')}>Submit for review</button>}{draft.state === 'pending_review' && <><button type="button" className={buttonClass} disabled={Boolean(busy)} onClick={() => reviewDraft(draft, 'approved')}>Approve</button><button type="button" className={secondaryButton} disabled={Boolean(busy)} onClick={() => reviewDraft(draft, 'rejected')}>Reject</button></>}{draft.state === 'approved' && <button type="button" className={buttonClass} disabled={Boolean(busy)} onClick={() => openDraft(draft)}><ExternalLink size={15} className="mr-1 inline" />Open compose in X</button>}{draft.reviewNote && <span className="self-center text-xs text-gray-500">{draft.reviewNote}</span>}</div></article>)}</div>}</section></div>;
+ const renderDrafts = () => <div className="space-y-4"><section className="rounded border border-port-border bg-port-card p-4"><h2 className="font-semibold text-white">Draft a post for review</h2><p className="mt-1 text-sm text-gray-400">Drafts stay local until you submit them to Review Hub. PortOS will never publish automatically.</p><form className="mt-3 space-y-3" onSubmit={createDraft}><label htmlFor="x-draft-body" className="sr-only">X draft text</label><textarea id="x-draft-body" className={fieldClass} rows="5" maxLength="4000" placeholder="Write something you actually want to say…" value={draftBody} onChange={(event) => setDraftBody(event.target.value)} /><div className="flex flex-wrap items-center justify-between gap-2"><span className="text-xs text-gray-500">{draftBody.length}/4000</span><button className={buttonClass} disabled={!draftBody.trim() || Boolean(busy)}>Save draft</button></div></form></section><section className="rounded border border-port-border bg-port-card p-4"><h2 className="font-semibold text-white">Draft queue</h2>{resourcesAccountId !== selected?.id ? <div className="mt-3 text-sm text-gray-400"><BrailleSpinner text="Loading drafts…" /></div> : !visibleDrafts.length ? <p className="mt-3 text-sm text-gray-500">No drafts for @{selected.username}.</p> : <div className="mt-3 space-y-2">{visibleDrafts.map((draft) => <article key={draft.id} className="rounded border border-port-border p-3"><div className="flex flex-wrap items-center justify-between gap-2"><StatusBadge value={draft.state === 'approved' || draft.state === 'opened'}>{stateLabel(draft.state)}</StatusBadge><span className="text-xs text-gray-500">{formatDate(draft.updatedAt)}</span></div><p className="mt-3 whitespace-pre-wrap text-sm text-gray-200">{draft.body}</p><div className="mt-3 flex flex-wrap gap-2">{draft.state === 'draft' && <button type="button" className={secondaryButton} disabled={Boolean(busy)} onClick={() => reviewDraft(draft, 'pending_review')}>Submit for review</button>}{draft.state === 'pending_review' && <><button type="button" className={buttonClass} disabled={Boolean(busy)} onClick={() => reviewDraft(draft, 'approved')}>Approve</button><button type="button" className={secondaryButton} disabled={Boolean(busy)} onClick={() => reviewDraft(draft, 'rejected')}>Reject</button></>}{draft.state === 'approved' && <button type="button" className={buttonClass} disabled={Boolean(busy)} onClick={() => openDraft(draft)}><ExternalLink size={15} className="mr-1 inline" />Open compose in X</button>}{draft.reviewNote && <span className="self-center text-xs text-gray-500">{draft.reviewNote}</span>}</div></article>)}</div>}</section></div>;
const renderAccounts = () => <section className="rounded border border-port-border bg-port-card p-4"><div className="flex flex-wrap items-start justify-between gap-3"><div><h2 className="font-semibold text-white">X accounts</h2><p className="mt-1 text-sm text-gray-400">Browser-only diagnostics and review-gated compose handoffs. No X credentials are stored.</p></div><button type="button" className={buttonClass} onClick={() => { setAccountForm(emptyAccount); openAccountForm('new'); }}><Plus size={15} className="mr-1 inline" />Add account</button></div>{!accounts.length ? <div className="mt-4 rounded border border-port-border p-4 text-sm text-gray-400">Add an X account to begin. Sync is manual, so nothing contacts X at boot.</div> : <div className="mt-4 grid gap-3 md:grid-cols-2">{accounts.map((account) => <article key={account.id} className="rounded border border-port-border p-4"><div className="flex items-start justify-between gap-2"><div><h3 className="font-semibold text-white">{account.label}</h3><p className="text-sm text-gray-400">@{account.username}</p></div><StatusBadge value={account.enabled}>{account.enabled ? 'Enabled' : 'Disabled'}</StatusBadge></div><p className="mt-3 text-xs text-gray-500">{account.lastSyncAt ? `Last diagnostic ${formatDate(account.lastSyncAt)}` : 'No diagnostic yet'}</p><div className="mt-3 flex flex-wrap gap-2"><button type="button" className={secondaryButton} onClick={() => openEditAccount(account)}>Edit</button><button type="button" className={secondaryButton} onClick={() => navigate(accountPath(account.id, 'health'))}>Open</button>{deleteAccountId === account.id ? <><button type="button" className="rounded border border-port-error px-3 py-2 text-sm text-port-error disabled:opacity-50" disabled={Boolean(busy)} onClick={() => removeAccount(account.id)}>Delete</button><button type="button" className={secondaryButton} onClick={() => setDeleteAccountId(null)}>Cancel</button></> : <button type="button" className={secondaryButton} onClick={() => setDeleteAccountId(account.id)}>Remove</button>}</div></article>)}</div>}</section>;
diff --git a/client/src/pages/X.test.jsx b/client/src/pages/X.test.jsx
index 452ee8aa56..dcb14a2c47 100644
--- a/client/src/pages/X.test.jsx
+++ b/client/src/pages/X.test.jsx
@@ -135,4 +135,23 @@ describe('X page', () => {
expect(await screen.findByText(/This X account was not found/)).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Return to accounts.' })).toBeInTheDocument();
});
+
+ it('displays a loading spinner in the draft queue while drafts are loading', async () => {
+ let resolveDrafts;
+ const draftsPromise = new Promise((resolve) => {
+ resolveDrafts = resolve;
+ });
+ api.getXDrafts.mockReturnValueOnce(draftsPromise);
+
+ renderPage(`/x/${account.id}/drafts`);
+ await screen.findByRole('heading', { name: 'Draft queue' });
+
+ expect(screen.getByLabelText('Loading drafts…')).toBeInTheDocument();
+ expect(screen.queryByText(`No drafts for @${account.username}.`)).not.toBeInTheDocument();
+
+ await resolveDrafts({ drafts: [] });
+
+ expect(await screen.findByText(`No drafts for @${account.username}.`)).toBeInTheDocument();
+ expect(screen.queryByLabelText('Loading drafts…')).not.toBeInTheDocument();
+ });
});