Skip to content

fix(desktop): unify Spawn tree scope with status bar indicator - #49819

Closed
Kewe63 wants to merge 1 commit into
NousResearch:mainfrom
Kewe63:fix/desktop-spawn-tree-aggregate-scope
Closed

Kewe63 wants to merge 1 commit into
NousResearch:mainfrom
Kewe63:fix/desktop-spawn-tree-aggregate-scope

Conversation

@Kewe63

@Kewe63 Kewe63 commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Two UI indicators read from $subagentsBySession but used different filters: the status bar's "Agents N running" aggregated across every session, while the Spawn tree overlay kept only the active session. Users saw "Agents 2 running" in the status bar while the Spawn tree rendered "No live subagents" because the running agents belonged to a non-active session (e.g. background work, cron polling).


Root Cause

apps/desktop/src/app/agents/index.tsx filtered the store down to activeSessionId before calling buildSubagentTree. The status bar (apps/desktop/src/app/shell/hooks/use-statusbar-items.tsx) already aggregated the same store via Object.values(...).reduce(..., activeSubagentCount).


Fix

Aggregate the same way in AgentsView:

const activeSubagents = useMemo(

  • () => (activeSessionId ? (subagentsBySession[activeSessionId] ?? []) : []),
  • [activeSessionId, subagentsBySession]
  • () => Object.values(subagentsBySession).flat(),
  • [subagentsBySession]
    )

This removes the now-unused $activeSessionId import and the activeSessionId useStore call. Both indicators now read from the same aggregate scope, restoring the contract that the user can trust: "Agents N running" === the number of running subagents visible in the Spawn tree.


Tests

apps/desktop/src/store/subagents.test.ts gains two regression tests under #49808 — Spawn tree / status bar aggregate scope:

  1. Aggregate parity — two sessions × two running subagents each → both indicators report 4 (the active-session-only filter would have reported 2 — counter-example documented in the test).
  2. Empty parity — only terminal subagents → both indicators report 0.

npx vitest run src/store/subagents.test.ts
✓ src/store/subagents.test.ts (8 tests) 11ms
Test Files 1 passed (1)
Tests 8 passed (8)


Files Changed

apps/desktop/src/app/agents/index.tsx | 14 +++++--
apps/desktop/src/store/subagents.test.ts | 66 ++++++++++++++++++++++


Fixes #49808

…ousResearch#49808)

Two UI indicators read from $subagentsBySession but used different
filters: the status bar's 'Agents N running' aggregated across every
session, while the Spawn tree overlay kept only the active session.
Users saw 'Agents 2 running' in the status bar while the Spawn tree
rendered 'No live subagents' because the running agents belonged to a
non-active session (e.g. background work, cron polling).

Root cause: apps/desktop/src/app/agents/index.tsx filtered the store
down to activeSessionId before calling buildSubagentTree. The status
bar (apps/desktop/src/app/shell/hooks/use-statusbar-items.tsx)
already aggregated the same store via Object.values(...).reduce(...,
activeSubagentCount).

Fix: aggregate the same way in AgentsView:

    const activeSubagents = useMemo(
      () => Object.values(subagentsBySession).flat(),
      [subagentsBySession]
    )

This removes the now-unused $activeSessionId import and the
activeSessionId useStore call. Both indicators now read from the same
aggregate scope, restoring the contract that the user can trust:
'Agents N running' === the number of running subagents visible in the
Spawn tree.

Tests pin the post-fix contract at the store layer:
  - test 1: two sessions × two running subagents each → both indicators
    report 4 (activeSessionId-only filter would report 2)
  - test 2: only terminal subagents → both indicators report 0

All 8 store tests pass.
@alt-glitch alt-glitch added type/bug Something isn't working comp/tui Terminal UI (ui-tui/ + tui_gateway/) P2 Medium — degraded but workaround exists labels Jun 20, 2026
JZKK720 pushed a commit to JZKK720/hermes-agent that referenced this pull request Jun 25, 2026
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 NousResearch#49808).

Unify the scope both surfaces speak:
- AgentsView aggregates subagents across every session (salvages NousResearch#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 NousResearch#49819. Fixes NousResearch#49808.
@alt-glitch alt-glitch added comp/desktop Electron desktop app (apps/desktop/*) P3 Low — cosmetic, nice to have and removed comp/tui Terminal UI (ui-tui/ + tui_gateway/) P2 Medium — degraded but workaround exists labels Jun 26, 2026
pai-scaffolde pushed a commit to Scaffolde/hermes-agent that referenced this pull request Jun 28, 2026
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 NousResearch#49808).

Unify the scope both surfaces speak:
- AgentsView aggregates subagents across every session (salvages NousResearch#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 NousResearch#49819. Fixes NousResearch#49808.
waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
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 NousResearch#49808).

Unify the scope both surfaces speak:
- AgentsView aggregates subagents across every session (salvages NousResearch#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 NousResearch#49819. Fixes NousResearch#49808.
habarmc1223-sudo pushed a commit to habarmc1223-sudo/hermes-agent-fluxmem that referenced this pull request Jul 8, 2026
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 NousResearch#49808).

Unify the scope both surfaces speak:
- AgentsView aggregates subagents across every session (salvages NousResearch#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 NousResearch#49819. Fixes NousResearch#49808.
santhreal pushed a commit to santhreal/hermes-agent that referenced this pull request Jul 13, 2026
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 NousResearch#49808).

Unify the scope both surfaces speak:
- AgentsView aggregates subagents across every session (salvages NousResearch#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 NousResearch#49819. Fixes NousResearch#49808.
@OutThisLife

Copy link
Copy Markdown
Contributor

Closing as superseded by #52183 (merged), which keeps the Agents indicator and Spawn-tree panel on the same subagent-only, cross-session scope (and also drops the false-positive system-action counts). Your cross-session aggregation change was salvaged into that fix — thank you.

Gravezzz pushed a commit to Gravezzz/hermes-agent that referenced this pull request Jul 21, 2026
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 NousResearch#49808).

Unify the scope both surfaces speak:
- AgentsView aggregates subagents across every session (salvages NousResearch#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 NousResearch#49819. Fixes NousResearch#49808.
leewenjie pushed a commit to leewenjie/hermes-agent that referenced this pull request Aug 7, 2026
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 NousResearch#49808).

Unify the scope both surfaces speak:
- AgentsView aggregates subagents across every session (salvages NousResearch#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 NousResearch#49819. Fixes NousResearch#49808.
melon-xf added a commit to melon-xf/hermes-agent that referenced this pull request Sep 3, 2026
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 NousResearch#49808).

Unify the scope both surfaces speak:
- AgentsView aggregates subagents across every session (salvages NousResearch#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 NousResearch#49819. Fixes NousResearch#49808.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/desktop Electron desktop app (apps/desktop/*) P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Desktop: Spawn tree shows empty state while status bar reports 'Agents 2 running' — desynced subagent state

3 participants