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: refine persistent mind diagnostics (#5066)

[._.]/ Adam Eivybfbd858f0996
diff --git a/client/src/components/cos/tabs/MindTab.jsx b/client/src/components/cos/tabs/MindTab.jsx
index 3bcc465b42..f6062d1627 100644
--- a/client/src/components/cos/tabs/MindTab.jsx
+++ b/client/src/components/cos/tabs/MindTab.jsx
@@ -17,6 +17,7 @@ const EVENT_LABELS = {
'mind.annotation.accepted': 'Annotation',
'mind.summary': 'Mind summary',
'mind.model.result': 'Mind summary',
+ 'mind.turn.completed': 'Mind summary',
'mind.capability.request': 'Action request',
'mind.capability.result': 'Action outcome',
'mind.memory.promoted': 'Memory promoted',
@@ -27,9 +28,16 @@ const eventText = (event) => {
const data = event?.data || {};
if (typeof data.displayText === 'string') return data.displayText;
if (typeof data.summaryText === 'string') return data.summaryText;
- if (typeof data.error === 'string') return data.error;
+ if (event?.kind === 'mind.failed') return data.status === 'interrupted'
+ ? 'The previous wake was interrupted'
+ : 'The provider was unavailable or the wake failed';
+ if (event?.kind === 'mind.paused') return data.status === 'idle'
+ ? 'The persistent mind was stopped'
+ : 'The persistent mind was paused';
+ if (event?.kind === 'mind.capability.request' && typeof data.capabilityId === 'string') {
+ return `Capability request ${data.capabilityId}`;
+ }
if (typeof data.status === 'string') return data.status;
- if (typeof data.capability === 'string') return data.capability;
return null;
};
@@ -248,7 +256,7 @@ export default function MindTab() {
</header>
{gap && <Banner tone="warning" title="History gap detected">The saved cursor is no longer retained. The visible trace was reloaded from the newest bounded snapshot.</Banner>}
- {truncated && <Banner tone="info" title="Showing recent history">The trace is bounded to the newest {MAX_VISIBLE_EVENTS} events; older retained events are not shown.</Banner>}
+ {truncated && <Banner tone="info" title="Showing recent history">The initial trace shows the newest {PAGE_LIMIT} events; older retained events are not shown.</Banner>}
{loadError && <Banner tone="error" title="Conversation unavailable">{loadError}. Existing messages are preserved; retry when the connection recovers.</Banner>}
{lifecycleError && <Banner tone="error" title="Action failed">{lifecycleError}</Banner>}
@@ -257,6 +265,9 @@ export default function MindTab() {
<div className="border-b border-port-border px-4 py-3 text-sm text-port-text-muted">
Status: <span className="font-medium text-port-text">{state?.status || 'unknown'}</span>
{state?.pauseReason ? ` · ${state.pauseReason}` : ''}
+ {state?.failureCount > 0 ? ` · ${state.failureCount} failed wake${state.failureCount === 1 ? '' : 's'}` : ''}
+ {state?.nextEligibleWakeAt ? ` · retry after ${formatDateTime(state.nextEligibleWakeAt)}` : ''}
+ {state?.lastError ? ` · ${state.lastError}` : ''}
</div>
{loading && events === null ? (
<div className="flex justify-center p-10"><BrailleSpinner text="Loading mind history" /></div>
@@ -304,7 +315,7 @@ export default function MindTab() {
<ActionButton label="Acknowledge" icon={Check} pending={eventActionPending === selectedEvent.eventId} onClick={() => acknowledge(selectedEvent)} />
</div>
)}
- {['mind.capability.request', 'mind.summary', 'mind.model.result'].includes(selectedEvent.kind) && (
+ {['mind.summary', 'mind.model.result', 'mind.turn.completed'].includes(selectedEvent.kind) && (
<ActionButton label="Promote" icon={Upload} pending={eventActionPending === selectedEvent.eventId} disabled={!eventText(selectedEvent)} onClick={() => promote(selectedEvent)} />
)}
</>
diff --git a/server/lib/persistentMindPublic.js b/server/lib/persistentMindPublic.js
index 26a7397548..20880fce89 100644
--- a/server/lib/persistentMindPublic.js
+++ b/server/lib/persistentMindPublic.js
@@ -3,7 +3,7 @@
const publicReason = (state) => {
if (!state.pauseReason) return null;
if (state.status === 'paused') return 'Paused by user';
- if (state.status === 'degraded' || state.status === 'failed') return 'Provider unavailable or wake failed';
+ if (state.status === 'degraded' || state.status === 'interrupted') return 'Provider unavailable or wake failed';
return 'Waiting for the next eligible wake';
};
diff --git a/server/routes/cosMindRoutes.js b/server/routes/cosMindRoutes.js
index 0180afc5f8..055021b24e 100644
--- a/server/routes/cosMindRoutes.js
+++ b/server/routes/cosMindRoutes.js
@@ -80,8 +80,9 @@ router.get('/mind', asyncHandler(async (req, res) => {
loadState(),
]);
const profile = normalizePersistentMindProfile(root.config?.persistentMindProfile);
+ const { snapshot: _snapshot, ...publicHistory } = history;
res.json({
- ...history,
+ ...publicHistory,
state: publicPersistentMindState(state),
profile: {
enabled: profile.enabled,
@@ -101,6 +102,7 @@ router.post('/mind/messages', asyncHandler(async (req, res) => {
router.post('/mind/annotations', asyncHandler(async (req, res) => {
const input = validateRequest(annotationSchema, req.body);
+ if (input.targetEventId) await requireMindEvent(input.targetEventId);
const result = await appendPersistentMindAnnotation(input);
if (result.error) throw new ServerError(result.error, { status: 409, code: 'INVALID_STATE' });
res.status(202).json({ success: true, duplicate: result.duplicate === true, annotationId: input.id });
diff --git a/server/routes/cosMindRoutes.test.js b/server/routes/cosMindRoutes.test.js
index 4b150cfe8f..dcbf485cfa 100644
--- a/server/routes/cosMindRoutes.test.js
+++ b/server/routes/cosMindRoutes.test.js
@@ -78,6 +78,7 @@ describe('persistent mind routes', () => {
autonomyMode: 'execute',
});
expect(res.body.profile).not.toHaveProperty('credential');
+ expect(res.body).not.toHaveProperty('snapshot');
expect(res.body.state).not.toHaveProperty('queuedMessages');
expect(res.body.state.queuedMessageCount).toBe(1);
expect(JSON.stringify(res.body)).not.toContain('secret-value');
@@ -115,6 +116,15 @@ describe('persistent mind routes', () => {
});
});
+ it('rejects an annotation target outside the retained mind ledger', async () => {
+ mocks.readPersistentMindHistory.mockResolvedValue([]);
+ const res = await post('/mind/annotations', {
+ id: 'annotation-1', text: 'Dangling idea.', targetEventId: 'missing',
+ });
+ expect(res.status).toBe(404);
+ expect(mocks.appendPersistentMindAnnotation).not.toHaveBeenCalled();
+ });
+
it('projects lifecycle state instead of returning queued message bodies', async () => {
mocks.pausePersistentMind.mockResolvedValue({
success: true,
diff --git a/server/services/agentRunEventLog.test.js b/server/services/agentRunEventLog.test.js
index b5045d76cb..4d4a70f412 100644
--- a/server/services/agentRunEventLog.test.js
+++ b/server/services/agentRunEventLog.test.js
@@ -245,6 +245,16 @@ describe('persistent-mind ordering, replay, and cursors', () => {
expect(recovered.events.map((item) => item.data.messageId)).toEqual(['two', 'three']);
expect(recovered.snapshot.messages.map((item) => item.messageId)).toEqual(['two', 'three']);
});
+
+ it('marks a cursorless bounded tail as truncated', async () => {
+ await appendMessage('one');
+ await appendMessage('two');
+ await appendMessage('three');
+
+ const page = await readPersistentMindEvents({ limit: 2 });
+ expect(page).toMatchObject({ gap: false, hasMore: false, truncated: true });
+ expect(page.events.map((item) => item.data.messageId)).toEqual(['two', 'three']);
+ });
});
describe('retention / rotation bound', () => {