Skip to content

Open a Task step's subagent trajectory from the chat - #2

Draft
Weili-0234 wants to merge 4 commits into
mainfrom
subagent-trajectory
Draft

Open a Task step's subagent trajectory from the chat#2
Weili-0234 wants to merge 4 commits into
mainfrom
subagent-trajectory

Conversation

@Weili-0234

Copy link
Copy Markdown
Collaborator

What

When Claude Code spawns a subagent (the Task/Agent tool), its trajectory is a separate transcript the chat never linked to. With the matching Loom server change (task-subagent-links on the Loom repo), the conversation payload now attaches tool.subagent = {session_id, agent_type, title} to steps the server matched to a sidechain session. This PR renders that:

  • ConversationTool gains an optional subagent link (absent field on older servers decodes to nil, so the UI degrades to today's behavior).
  • Linked tool cards get a "View trajectory →" button, threaded through both the flat rows and the folded "N steps" runs.
  • Tapping it opens a sheet with the subagent's full trajectory, rendered with the feed's own row styles and re-fetched every 2.5s while open (same cadence as the web console), so a still-running subagent streams in.
  • LoomAPI.conversation gains the session query parameter the server already supports.

The sheet is read-only: sidechain questions were the subagent's to answer, so they render as captions, not live question cards.

Testing

  • swift build clean.
  • Server-side linkage verified against a real Claude Code session (meta.json toolUseId and toolUseResult.agentId both resolve); end-to-end UI pass pending the server deploy.

A Task/Agent tool call rendered as an ordinary tool box: the
subagent's transcript existed on the server but nothing in the chat
led to it.

The server now attaches tool.subagent = {session_id, agent_type,
title} to steps it matched to a sidechain session; the tool card shows
a 'View <type> trajectory' button for those, opening a sheet that
reads the child transcript through the conversation endpoint's
session parameter and re-reads every 2.5s while open, so a
still-running subagent streams in. The sheet reuses the feed's own
rows, read-only: sidechain questions were the subagent's to answer,
so they render as captions rather than live question cards.
Which subagents existed, which were working, and where to read their
trajectories was invisible outside the Chat tab's tool cards.

The selected task's sidebar row now grows a collapsible Subagents list
fed by the session poll (the conversation payload already carries the
children): a live status dot each — pulsing while the transcript is
growing, a check once it stops, red on error — plus an amber envelope
counting the main agent's sends still queued for a busy child.
Clicking a row replaces the detail pane with the subagent's trajectory
rendered like the main chat (markdown turns, tool cards with arguments
and results, the inputs the main agent sent), with a back button; the
Task step's button keeps its in-context sheet, now presented from the
task pane so it opens from any tab. Queued sends render at the feed's
end in amber, so what the subagent has not yet seen reads as pending
rather than lost.
The sidebar's blue dot covered thinking, mid-tool, and idly waiting
between monitor events alike. The server's activity field tells them
apart now: a solid pulsing dot with a 'thinking' / 'running Bash'
label while the agent is doing something, a hollow accent ring with
'waiting' when its turn ended and it sits ready for the next event.
The header splits its count the same way (working vs ready), and the
trajectory chip spells the activity out.
Mail from another agent and background-task notifications land in the
user turn, so both wore the human's indigo bubble — a monitor snapshot
read as something you typed. The server now labels them (origin agent
with the sender and the unwrapped body; origin system with the
notification's own summary), and the chat renders each honestly: an
incoming attention-green card naming its sender, and a quiet folded
event line with the payload behind a click. Applies to the main chat
and subagent trajectories alike.
@Weili-0234
Weili-0234 marked this pull request as draft August 17, 2026 00:44
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