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: guard persistent mind catalog refreshes

Adam Eivyc9a4536c15b9
diff --git a/client/src/pages/PersistentMindTools.jsx b/client/src/pages/PersistentMindTools.jsx
index b4ec044fae..e5cd1254f6 100644
--- a/client/src/pages/PersistentMindTools.jsx
+++ b/client/src/pages/PersistentMindTools.jsx
@@ -1,4 +1,4 @@
-import { useCallback, useEffect, useState } from 'react';
+import { useCallback, useEffect, useRef, useState } from 'react';
import { ArrowLeft, CheckCircle2, LockKeyhole, RefreshCw, ShieldCheck, Wrench } from 'lucide-react';
import { Link } from 'react-router';
import * as api from '../services/api';
@@ -11,16 +11,23 @@ export default function PersistentMindTools() {
const [data, setData] = useState(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
+ const requestVersion = useRef(0);
const load = useCallback(() => {
+ const version = ++requestVersion.current;
setLoading(true);
api.getPersistentMindTools({ silent: true })
.then((response) => {
+ if (version !== requestVersion.current) return;
setData(response);
setError(null);
})
- .catch((requestError) => setError(requestError?.message || 'Could not load persistent mind tools'))
- .finally(() => setLoading(false));
+ .catch((requestError) => {
+ if (version === requestVersion.current) setError(requestError?.message || 'Could not load persistent mind tools');
+ })
+ .finally(() => {
+ if (version === requestVersion.current) setLoading(false);
+ });
}, []);
useEffect(() => {
@@ -31,6 +38,7 @@ export default function PersistentMindTools() {
const taskCatalog = data?.taskCatalog;
const grantedCount = tools.filter((tool) => tool.granted === true).length;
const updateCapabilities = (capabilities) => {
+ requestVersion.current += 1;
setData((current) => current ? {
...current,
capabilities,
@@ -41,6 +49,7 @@ export default function PersistentMindTools() {
})),
} : current);
if (capabilities.createTasks && !data?.taskCatalog) load();
+ else if (!capabilities.createTasks) setLoading(false);
};
return (
diff --git a/client/src/pages/PersistentMindTools.test.jsx b/client/src/pages/PersistentMindTools.test.jsx
index c9f507c59c..ebc5549d6b 100644
--- a/client/src/pages/PersistentMindTools.test.jsx
+++ b/client/src/pages/PersistentMindTools.test.jsx
@@ -84,6 +84,33 @@ describe('PersistentMindTools', () => {
expect(api.getPersistentMindTools).toHaveBeenCalledTimes(2);
});
+ it('does not let a stale catalog refresh restore a revoked grant', async () => {
+ const user = userEvent.setup();
+ let resolveCatalog;
+ api.getPersistentMindTools
+ .mockResolvedValueOnce(response())
+ .mockImplementationOnce(() => new Promise((resolve) => {
+ resolveCatalog = resolve;
+ }));
+ renderPage();
+
+ const toggle = await screen.findByRole('checkbox', { name: 'Allow mind to queue CoS agent tasks' });
+ await user.click(toggle);
+ await waitFor(() => expect(api.getPersistentMindTools).toHaveBeenCalledTimes(2));
+ await waitFor(() => expect(toggle).toBeChecked());
+
+ await user.click(toggle);
+ await waitFor(() => expect(toggle).not.toBeChecked());
+ resolveCatalog(response({
+ capabilities: { schemaVersion: 1, createTasks: true },
+ tools: [{ ...response().tools[0], granted: true }],
+ taskCatalog: { apps: [{ id: 'stale-app', name: 'Stale App', planOnly: false }], providers: [] },
+ }));
+
+ await waitFor(() => expect(toggle).not.toBeChecked());
+ expect(screen.queryByText('Available task filing choices')).not.toBeInTheDocument();
+ });
+
it('keeps the failure visible instead of presenting an empty inventory', async () => {
api.getPersistentMindTools.mockRejectedValue(new Error('Server unreachable'));
renderPage();