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

address review: three more catch-to-fallback callers wipe last-good state on poll blip

[._.]/ Adam Eivy09a25cc328d6
diff --git a/client/src/components/cos/tabs/AgentCard.jsx b/client/src/components/cos/tabs/AgentCard.jsx
index 96ff81a74f..a08ce6863b 100644
--- a/client/src/components/cos/tabs/AgentCard.jsx
+++ b/client/src/components/cos/tabs/AgentCard.jsx
@@ -205,10 +205,16 @@ export default function AgentCard({ agent, onKill, onDelete, onResume, completed
return () => clearInterval(interval);
}, [completed]);
- // Fetch process stats for running agents (skip for remote peers)
+ // Fetch process stats for running agents (skip for remote peers).
+ // Only overwrite prior stats on a successful response so a transient
+ // error doesn't blank out the previously displayed CPU/mem/PID.
const fetchStats = useCallback(async () => {
- const stats = await api.getCosAgentStats(agent.id).catch(() => null);
- setProcessStats(stats);
+ try {
+ const stats = await api.getCosAgentStats(agent.id, { silent: true });
+ setProcessStats(stats);
+ } catch {
+ // preserve last-good stats on transient blip
+ }
}, [agent.id]);
useAutoRefetch(fetchStats, 5000, { enabled: !completed && !remote, pollOnly: true });
diff --git a/client/src/hooks/useCityData.js b/client/src/hooks/useCityData.js
index d4d8e5ff97..09f733ca20 100644
--- a/client/src/hooks/useCityData.js
+++ b/client/src/hooks/useCityData.js
@@ -69,9 +69,16 @@ export const useCityData = () => {
});
}, []);
+ // Only overwrite the running-agents HUD/list when a fresh fetch lands —
+ // a transient blip used to wipe the visible agents to `[]` until the
+ // next successful poll.
const fetchRunningAgents = useCallback(async () => {
- const agents = await api.getRunningAgents().catch(() => []);
- setRunningAgents(agents);
+ try {
+ const agents = await api.getRunningAgents({ silent: true });
+ setRunningAgents(agents);
+ } catch {
+ // preserve last-good agents on transient blip
+ }
}, []);
// `immediate: false` — `fetchAll()` (run from the socket-setup effect below
diff --git a/client/src/pages/AgentsPage.jsx b/client/src/pages/AgentsPage.jsx
index a82406140d..ba1847ba41 100644
--- a/client/src/pages/AgentsPage.jsx
+++ b/client/src/pages/AgentsPage.jsx
@@ -8,7 +8,9 @@ export function AgentsPage() {
const [expandedPid, setExpandedPid] = useState(null);
const REFRESH_INTERVAL = 3;
- const loadAgents = useCallback(() => api.getAgents().catch(() => []), []);
+ // Let errors throw — `useAutoRefetch` preserves the last-good agents list
+ // on transient failures. `silent: true` keeps the 3s poll quiet on blips.
+ const loadAgents = useCallback(() => api.getAgents({ silent: true }), []);
const { data, loading, refetch } = useAutoRefetch(loadAgents, REFRESH_INTERVAL * 1000);
const agents = data ?? [];
diff --git a/client/src/services/apiAgents.js b/client/src/services/apiAgents.js
index d06a9de8e7..fe997e6cdf 100644
--- a/client/src/services/apiAgents.js
+++ b/client/src/services/apiAgents.js
@@ -1,7 +1,7 @@
import { request } from './apiCore.js';
// Running Agents (Process Management)
-export const getRunningAgents = () => request('/agents');
+export const getRunningAgents = (options) => request('/agents', options);
export const getRunningAgentInfo = (pid) => request(`/agents/${pid}`);
export const killRunningAgent = (pid) => request(`/agents/${pid}`, { method: 'DELETE' });
// Legacy aliases
@@ -82,7 +82,7 @@ export const getCosAgentsByDate = (date) => request(`/cos/agents/history/${date}
export const getCosAgent = (id) => request(`/cos/agents/${id}`);
export const terminateCosAgent = (id) => request(`/cos/agents/${id}/terminate`, { method: 'POST' });
export const killCosAgent = (id) => request(`/cos/agents/${id}/kill`, { method: 'POST' });
-export const getCosAgentStats = (id) => request(`/cos/agents/${id}/stats`);
+export const getCosAgentStats = (id, options) => request(`/cos/agents/${id}/stats`, options);
export const getCosAgentPrompt = (id) => request(`/cos/agents/${id}/prompt`);
export const deleteCosAgent = (id) => request(`/cos/agents/${id}`, { method: 'DELETE' });
export const clearCompletedCosAgents = () => request('/cos/agents/completed', { method: 'DELETE' });