Topic: agents
Type: Debugging & UX
Date: 2026-04-20
Last-Validated: 2026-05-21
Original-Query: Why does AO sidebar counter show stale session count vs active? (reconstructed)
Tier: archive-candidate
Status: Research complete - historical debugging report
Task: Investigate Composio AO's sidebar counter behavior and propose fixes
Composio AO's left sidebar shows ZAOOS project badge with count "11", but the main dashboard correctly displays "No active sessions". The counter counts all historical sessions (killed, merged) while the dashboard filters to active only. This creates UX confusion between sidebar and main content.
After archiving 11 stale sessions to ~/.agent-orchestrator/2883535895a7-ZAOOS/sessions-archived/:
- API endpoint
GET /api/sessionsreturns 4 sessions (reduced from 11) - All 4 remaining sessions have
status: "killed"withactivity: "exited" - Counter still reflects full list, not filtered count
{
"sessions": [
{
"id": "zaoos-1",
"projectId": "ZAOOS",
"status": "killed",
"activity": "exited",
"branch": "session/zaoos-1",
...
}
],
"stats": {
"totalSessions": 4,
"workingSessions": 0,
"openPRs": 0,
"needsReview": 0
},
"orchestrators": [...]
}The API already computes a stats object with filtered counts:
totalSessions: total count (unfiltered)workingSessions: filtered toactivity !== "exited"(current active)openPRs: filtered tostatus === "open"needsReview: filtered reviews pending
AO source is compiled Next.js. The /api/sessions route is at ~/.local/lib/node_modules/@aoagents/ao/node_modules/@aoagents/ao-web/.next/server/app/api/sessions/route.js (minified). Key findings from minified code:
- Statistics computed in route handler via
w.bV(r)call (minified function) - Dashboard likely uses
workingSessionsstat for "active" display - Sidebar counter likely uses
sessions.lengthfrom sessions array (unfiltered count) - No file watchers detected; API reads sessions directory on each request
- Dashboard endpoint:
/api/sessions?active=true- filters sessions toactivity !== "exited" - Sidebar component: likely calls
/api/sessionswithout filter param, receives full array - Sidebar renders length of full array; dashboard filters client-side to active only
Sidebar Component
|
+-- GET /api/sessions
|
+-- Returns all 4 sessions (killed, exited)
|
+-- Component renders sessions.length = 4 as badge
|
No filter applied client-side
Dashboard Page
|
+-- GET /api/sessions?active=true
|
+-- API filters to sessions where activity !== "exited"
|
+-- Returns 0 sessions
|
+-- Renders "No active sessions"
Archive terminal sessions to keep sidebar count accurate:
# Archive killed/merged sessions
mkdir -p ~/.agent-orchestrator/2883535895a7-ZAOOS/sessions-archived
mv ~/.agent-orchestrator/2883535895a7-ZAOOS/sessions/*/session.json | \
while read -r file; do
if grep -q '"status":"killed\|"status":"merged' "$file"; then
sessiondir=$(dirname "$file")
mv "$sessiondir" ~/.agent-orchestrator/2883535895a7-ZAOOS/sessions-archived/
fi
donePros: Works immediately, no code changes, respects AO architecture
Cons: Manual process, requires periodic cleanup
Modify sidebar component to show stats.workingSessions instead of sessions.length:
- File: Compiled chunk in
.next/static/chunks/(exact chunk unknown without source map) - Change: Badge renders
workingSessionsstat instead of array length - API already provides this data in response
Pros: Fixes at source, auto-maintains accuracy
Cons: Requires patching compiled code or rebuilding from source (source not included in npm package)
Use Option A (filesystem maintenance) as immediate solution.
Reasons:
- AO source not included in npm package - no clean way to patch compiled code
- Archive approach already deployed and working (counter dropped 11 to 4)
- Can create automated cleanup script triggered by cron or app startup
- Aligns with how AO manages session lifecycle (moved to archive dir = "not loaded")
If AO source becomes available in future:
- Consider patching
/api/sessionsto accept?filter=activeparam - Sidebar calls
/api/sessions?filter=activeto get onlyworkingSessions - Eliminates need for manual cleanup
- Create cron job or startup hook to auto-archive terminal sessions weekly
- Document archive location and cleanup procedure
- Monitor if sidebar counter stays in sync with active sessions
- If source becomes available, evaluate proper patch approach