Skip to content

feat: detect sub-agents and show them as a tree under the parent session#12

Merged
Clast merged 2 commits into
Affirm:mainfrom
tarkatronic:feat/subagent-tree
Jun 10, 2026
Merged

feat: detect sub-agents and show them as a tree under the parent session#12
Clast merged 2 commits into
Affirm:mainfrom
tarkatronic:feat/subagent-tree

Conversation

@tarkatronic

Copy link
Copy Markdown
Member

Summary

Navi was blind to sub-agents (the Agent/Task tool — Explore, general-purpose, custom agents). When a session fanned out, you saw only the parent "Working" with no insight into what was running underneath. This adds sub-agent detection and renders them as a tree nested under the parent session that spawned them.

Verified on disk: sub-agents are not separate sessions — they share the parent's sessionId and pid and get no ~/.claude/sessions entry. The authoritative record lives beside the transcript at <project>/<sessionId>/subagents/agent-<id>.meta.json (carries agentType, description, and the parent toolUseId). So this is implemented as a new filesystem enrichment, structurally identical to the existing transcript/git enrichments — no new hooks and no Claude session restart required.

Changes

  • SubagentInfo model (NaviCore).
  • EnrichmentService: new subagentsBySid published dict + scheduleSubagentsRefresh/runSubagentsRefresh. Scans the subagents/ dir, parses each .meta.json, takes timestamps from the .jsonl file attributes (falling back to the meta file so values stay stable), and derives running vs. finished from the parent transcript's tool_result blocks (2 MB tail) plus a 60s mtime backstop so a finished agent can never get stuck showing "running".
  • showSubagentsEnabled toggle (default off, per the existing Show* badge convention) + an Experimental settings row.
  • SessionSection: nested tree view (├─/└─ connectors, agent type + description, green-gear "running" / dimmed-checkmark "finished", relative time), driven by a 1s TimelineView for live time and the recently-finished drop-off.
  • Unit tests for SubagentInfo equality (guards the publish-on-change diff).
  • Version bump 1.2.2 → 1.3.0 (both plugin.json and naviCurrentVersion).

Display behavior

Shows running + recently-finished sub-agents; finished ones linger briefly (dimmed) then age out after ~30s. Multiple concurrent sub-agents appear as siblings under the same parent.

Testing

  • swift build clean; swift test 99/99 pass (incl. the new SubagentInfo suite).
  • scripts/build-from-source.sh produces a signed Navi.app.
  • Live: launched the from-source build with the toggle on, spawned a real background Explore sub-agent — the detection logic classified it running while active and correctly hid an hours-old finished agent (this surfaced and fixed a real bug: a 64 KB transcript tail was too small to find a buried tool_result, hence the 2 MB tail + mtime backstop).

🤖 Generated with Claude Code

tarkatronic and others added 2 commits June 8, 2026 16:26
Navi was blind to sub-agents (the Agent/Task tool). Sub-agents share the
parent session's sessionId and pid, so they are not separate sessions; the
authoritative record lives on disk beside the transcript at
<project>/<sessionId>/subagents/agent-<id>.meta.json. Add a filesystem
enrichment that scans that directory and renders running and
recently-finished sub-agents nested under the parent session, gated behind
an experimental toggle (default off, per the existing Show* badge
convention). No new hooks and no Claude session restart required.

- SubagentInfo model (NaviCore)
- EnrichmentService: subagentsBySid + scan and completion detection
  (2 MB parent-transcript tail for the tool_result, plus a 60s mtime
  backstop so a finished agent can never get stuck showing "running")
- showSubagentsEnabled toggle + experimental settings row
- SessionSection: nested tree view, driven by a 1s TimelineView for live
  relative time and the recently-finished drop-off
- unit tests for SubagentInfo equality (guards the publish-on-change diff)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Bumps both version sources that must stay in sync: plugin.json (read by
build.sh to fetch the matching release) and naviCurrentVersion (the
compiled marker / upgrade-banner check).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@tarkatronic

Copy link
Copy Markdown
Member Author
Screenshot 2026-06-08 at 15 20 14

@Clast

Clast commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Nice

@Clast Clast merged commit c1e2f06 into Affirm:main Jun 10, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants