mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-05 12:42:30 +00:00
fix(desktop): make Agents indicator match the Spawn-tree panel
The status-bar "Agents" item conflated three unrelated signals — running subagents (aggregated across all sessions), in-flight session turns, and failed background *system* actions (gateway restarts, toolset installs, computer-use grants via $desktopActionTasks/preview restart) — yet clicking it opens AgentsView, which renders only subagents. A failed gateway restart therefore showed "Agents (1 Failed)" over an empty "No live subagents" tree. AgentsView also filtered to the active session, so a subagent running in a background session showed "Agents N running" with nothing in the tree (the desync reported in #49808). Unify the scope both surfaces speak: - AgentsView aggregates subagents across every session (salvages #49819). - The indicator's running/failed counts come from subagents only (aggregated), never background system actions — those keep their own surfaces in settings / command center. So "Agents (N …)" now always points at a populated Spawn tree. Supersedes #49819. Fixes #49808.
This commit is contained in:
parent
404b06ac4f
commit
a268dfff0a
4 changed files with 51 additions and 40 deletions
|
|
@ -3,8 +3,10 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|||
import {
|
||||
$subagentsBySession,
|
||||
activeSubagentCount,
|
||||
allSubagents,
|
||||
buildSubagentTree,
|
||||
clearSessionSubagents,
|
||||
failedSubagentCount,
|
||||
pruneDelegateFallbackSubagents,
|
||||
upsertSubagent
|
||||
} from './subagents'
|
||||
|
|
@ -99,6 +101,27 @@ describe('subagent store', () => {
|
|||
expect(listFor('s1').map(item => item.id)).toEqual(['sa-0-xyz'])
|
||||
})
|
||||
|
||||
// Contract: the status-bar "Agents" indicator and the Spawn-tree panel read
|
||||
// the same scope — every session's subagents — so a count can never point at
|
||||
// an empty tree (the desync behind "Agents (N)" vs "No live subagents").
|
||||
it('counts running/failed across every session, matching the aggregated tree', () => {
|
||||
upsertSubagent('s1', { goal: 'a', status: 'running', subagent_id: 'a', task_index: 0 })
|
||||
upsertSubagent('s1', { goal: 'b', status: 'failed', subagent_id: 'b', task_index: 1 })
|
||||
upsertSubagent('s2', { goal: 'c', status: 'running', subagent_id: 'c', task_index: 0 })
|
||||
upsertSubagent('s2', { goal: 'd', status: 'failed', subagent_id: 'd', task_index: 1 })
|
||||
|
||||
const flat = allSubagents($subagentsBySession.get())
|
||||
const indicatorRunning = Object.values($subagentsBySession.get()).reduce((n, l) => n + activeSubagentCount(l), 0)
|
||||
const indicatorFailed = Object.values($subagentsBySession.get()).reduce((n, l) => n + failedSubagentCount(l), 0)
|
||||
const tree = buildSubagentTree(flat)
|
||||
|
||||
// The active-session-only filter would have reported 1/1 here, not 2/2.
|
||||
expect(indicatorRunning).toBe(2)
|
||||
expect(indicatorFailed).toBe(2)
|
||||
expect(tree).toHaveLength(4)
|
||||
expect(indicatorRunning + indicatorFailed).toBe(tree.length)
|
||||
})
|
||||
|
||||
it('clears one session without touching another', () => {
|
||||
upsertSubagent('s1', { goal: 'one', status: 'running', subagent_id: 'a1', task_index: 0 })
|
||||
upsertSubagent('s2', { goal: 'two', status: 'running', subagent_id: 'a2', task_index: 0 })
|
||||
|
|
|
|||
|
|
@ -261,3 +261,10 @@ export function buildSubagentTree(items: readonly SubagentProgress[]): SubagentN
|
|||
|
||||
export const activeSubagentCount = (items: readonly SubagentProgress[]) =>
|
||||
items.filter(item => item.status === 'queued' || item.status === 'running').length
|
||||
|
||||
export const failedSubagentCount = (items: readonly SubagentProgress[]) =>
|
||||
items.filter(item => item.status === 'failed' || item.status === 'interrupted').length
|
||||
|
||||
/** Flatten every session's subagents — the scope the Spawn-tree panel and the
|
||||
* status-bar indicator must agree on. */
|
||||
export const allSubagents = (bySession: Record<string, SubagentProgress[]>) => Object.values(bySession).flat()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue