Background
The `/trace [N|all]` slash command (added in #28) calls `API::list_trajectory(conversation_id)`, which queries:
```sql
SELECT * FROM trajectory_events
WHERE conversation_id = ? AND agent_id = <active_agent>
ORDER BY seq;
```
So `/trace` shows only the active agent's trajectory. When the active agent is the root and it spawned subagents (under different `agent_id`s), those subagent rows are invisible. To inspect them today you'd have to know each child's agent_id and run a separate query.
Proposed fix
Two pieces:
-
Repo: walk children. Add `TrajectoryRepo::list_with_children(conv, root_agent) -> Vec` that recursively pulls everything where `parent_agent_id` chains back to `root_agent`. Already supported by the `(conversation_id, agent_id, seq)` index — one query per level.
-
Renderer: indent by depth. Update the /trace renderer in `crates/forge_main/src/ui.rs::on_trace` to indent child events under their parent's row, so a tree like:
```
1 call Task call_id=t1
12 call read call_id=c1 (child agent A, indented)
13 result read duration=4ms
2 result Task duration=120ms
```
… makes the parent → child structure visible.
Acceptance
Depends on
Background
The `/trace [N|all]` slash command (added in #28) calls `API::list_trajectory(conversation_id)`, which queries:
```sql
SELECT * FROM trajectory_events
WHERE conversation_id = ? AND agent_id = <active_agent>
ORDER BY seq;
```
So `/trace` shows only the active agent's trajectory. When the active agent is the root and it spawned subagents (under different `agent_id`s), those subagent rows are invisible. To inspect them today you'd have to know each child's agent_id and run a separate query.
Proposed fix
Two pieces:
Repo: walk children. Add `TrajectoryRepo::list_with_children(conv, root_agent) -> Vec` that recursively pulls everything where `parent_agent_id` chains back to `root_agent`. Already supported by the `(conversation_id, agent_id, seq)` index — one query per level.
Renderer: indent by depth. Update the /trace renderer in `crates/forge_main/src/ui.rs::on_trace` to indent child events under their parent's row, so a tree like:
```
1 call Task call_id=t1
12 call read call_id=c1 (child agent A, indented)
13 result read duration=4ms
2 result Task duration=120ms
```
… makes the parent → child structure visible.
Acceptance
Depends on