Skip to content

feat: display subagent sessions as collapsible tree with cost roll-up#360

Merged
BYK merged 2 commits into
mainfrom
feat/subagent-tree-display
May 16, 2026
Merged

feat: display subagent sessions as collapsible tree with cost roll-up#360
BYK merged 2 commits into
mainfrom
feat/subagent-tree-display

Conversation

@BYK
Copy link
Copy Markdown
Owner

@BYK BYK commented May 16, 2026

Summary

  • Persist parent-child session relationships via new DB migration (v26: parent_session_id + is_subagent columns on session_state)
  • Resolve x-parent-session-id header value to Lore internal session ID via headerSessionIndex lookup at detection time
  • Render subagent sessions as collapsible tree rows in all dashboard session tables (Cost Intelligence, warming, project detail)
  • Parent rows show combined cost/savings (own + children) with expand/collapse toggle and (+N subagents) indicator
  • Child rows hidden by default, shown with prefix and indentation on toggle click

Files Changed

File Changes
packages/core/src/db.ts Migration v26, save/load for new fields, loadParentChildMap() query
packages/core/src/index.ts Export loadParentChildMap
packages/gateway/src/translate/types.ts Add parentSessionId to SessionState
packages/gateway/src/pipeline.ts Resolve + persist parent ID, restore on restart
packages/gateway/src/ui.ts Tree building, collapsible rendering, CSS, inline JS toggle
packages/core/test/db.test.ts Update expected schema version 25 → 26

How to Test

  1. Start gateway with an agent that spawns subagents (e.g., OpenCode with explore/task tools)
  2. Navigate to /ui/costs — subagent sessions should appear nested under their parent with a ▶ toggle
  3. Click toggle to expand — child rows appear with prefix
  4. Parent row "Total" column shows combined cost (own + children)
  5. Verify same tree display on /ui/warming and /ui/projects/:id pages
  6. Restart gateway — verify tree relationships survive restart

BYK added 2 commits May 16, 2026 13:03
Persist parent-child session relationships (migration v26) and render
subagent sessions as collapsible tree rows in all dashboard session
tables. Parent rows show combined cost (own + children) and a toggle
to expand/collapse child rows.

- Add parent_session_id and is_subagent columns to session_state
- Resolve x-parent-session-id header to Lore internal ID via headerSessionIndex
- Persist isSubagent and parentSessionId immediately on detection
- Restore parent-child relationships across gateway restarts
- Build tree structure in buildLiveSessionRows() with cost roll-up
- Render collapsible rows with toggle, indentation, and child count
- Apply to all session tables: costs, warming, project detail pages
- Search full headerSessionIndex for parent resolution (not just Tier 1)
- Re-attempt resolution on subsequent requests when parent is pending
- Log warning when parent resolution fails (Tier 3 limitation)
- Sort preserves parent-child row adjacency (treats tree as unit)
- Filter respects tree structure (matching child shows parent)
- Recursive cost roll-up and rendering for multi-level nesting
- Deduplicate loadParentChildMap() calls (compute once per page)
- Warming page stats include subagent children in counts
- Replace unsafe 'as' cast with proper SessionState type import
@BYK BYK merged commit 6bdab7a into main May 16, 2026
7 checks passed
@BYK BYK deleted the feat/subagent-tree-display branch May 16, 2026 13:21
@craft-deployer craft-deployer Bot mentioned this pull request May 16, 2026
6 tasks
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.

1 participant