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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix(cos): derive Done metric from actual completed agents on disk
Adam Eivydae2ad533772
diff --git a/.changelog/v0.16.x.md b/.changelog/v0.16.x.mdindex 6877a9716a..01d91f5bed 100644--- a/.changelog/v0.16.x.md+++ b/.changelog/v0.16.x.md@@ -26,6 +26,10 @@ Agent persistence, reliability, and decision transparency improvements.- **8 agents with legacy metadata format normalized** -- older metadata files using `agentId` instead of `id` and missing `status` field are now properly loaded into the cache- **Zombie-cleaned agents now persist to disk** -- `cleanupZombieAgents()` previously only updated in-memory state; now writes `metadata.json` and updates the cache so zombie-cleaned agents survive state resets+### "Done" metric now reflects actual completed agent count+- **Stats counter drifted from reality** -- `state.stats.tasksCompleted` is an in-memory counter that resets when the state file is reset or corrupted; the "Done" stat on the CoS dashboard showed only completions since the last state reset (e.g., 6) instead of the actual count (e.g., 1991)+- **Now derived from disk** -- `getStatus()` counts unique completed agents from the disk-backed cache plus in-memory state, using `Math.max` with the counter to never undercount+### Completed agents now fully visible in UI- **Replaced hard limit of 15 with paginated "Show More"** -- previously the Agents tab showed only the 15 most recent completed agents with a static "+ N more" message and no way to see the rest; now shows 50 at a time with a "Show more (N remaining)" button to load the next batch- **Search results also paginated** -- filtered results use the same incremental loading, and visible count resets when the search query changesdiff --git a/server/services/cos.js b/server/services/cos.jsindex 6106263e08..44c0e0ad22 100644--- a/server/services/cos.js+++ b/server/services/cos.js@@ -295,17 +295,26 @@ async function saveState(state) {export async function getStatus() {const state = await loadState();const provider = await getActiveProvider();+ const cache = await loadCompletedAgentCache();- // Count active agents+ // Count active agents from stateconst activeAgents = Object.values(state.agents).filter(a => a.status === 'running').length;+ // Derive tasksCompleted from actual completed agents on disk + state,+ // since state.stats.tasksCompleted can drift after state resets+ const completedIds = new Set(cache.keys());+ for (const [id, agent] of Object.entries(state.agents)) {+ if (agent.status === 'completed') completedIds.add(id);+ }+ const tasksCompleted = Math.max(state.stats.tasksCompleted, completedIds.size);+return {running: daemonRunning,paused: state.paused || false,pausedAt: state.pausedAt,pauseReason: state.pauseReason,config: state.config,- stats: state.stats,+ stats: { ...state.stats, tasksCompleted },activeAgents,provider: provider ? { id: provider.id, name: provider.name } : null};