fix(ui): improve sub-agent tree rendering, skill loading, and lifecycle management#201
fix(ui): improve sub-agent tree rendering, skill loading, and lifecycle management#201lavaman131 merged 3 commits intomainfrom
Conversation
Eagerly create ParallelAgent entries when the Task tool starts instead of waiting for the SDK's subagent.start event, preventing missing or delayed agent trees. Group sequential sub-agent spawns into separate trees at their chronological content offsets. Hide Task tool calls from the main tool result list since agents are rendered via ParallelAgentsTree. Finalize agent status on tool.complete even if subagent.complete never fired. Remove redundant result summary from completed agent rows. Fix prefix-based post-task text suppression to avoid incorrectly swallowing the model's genuine follow-up text. Fix duplicate streaming spinners when sendSilentMessage is called while a placeholder is active. Assistant-model: Claude Code
Add a <skill-loaded> directive to expanded skill prompts so the model acts on the already-expanded content instead of re-invoking the Skill tool (which would lose $ARGUMENTS expansion). Track loaded skills per session to suppress duplicate "loaded" UI indicators on repeat invocations while still showing errors. Fall back to input.name when input.skill is missing for skill tool title and result rendering. Assistant-model: Claude Code
Document findings on how blockedBy dependency enforcement, parallel worker dispatch, and DAG-based topological traversal can be integrated into the ralph workflow. Covers current architecture gaps, existing parallel execution infrastructure, file concurrency concerns, and worker task selection issues. Assistant-model: Claude Code
PR Review: fix(ui): improve sub-agent tree rendering, skill loading, and lifecycle managementOverviewThis PR addresses several interconnected UI issues: sub-agent tree rendering timing, skill loading deduplication, post-task text suppression accuracy, and agent tree grouping. The changes are well-organized across three commits with clear purposes. Code Quality & Best PracticesStrengths:
Suggestions:
Potential Bugs or Issues
Performance Considerations
Security ConcernsNo security issues identified. The changes are purely UI-related and don't handle user input in security-sensitive ways. Test CoverageMissing tests for new functionality:
Existing test coverage is maintained - The DocumentationThe research document (
Summary
Recommendation: This PR is ready to merge with one request: Required: Add unit tests for the skill loading deduplication and post-task text suppression changes. These are complex enough that regression risk is real without tests. Optional: Address the performance suggestions and document the eager agent ID lifecycle. Reviewed with attention to the atomic codebase patterns and conventions. |
Summary
Fixes multiple UI issues related to sub-agent tree rendering, skill loading indicators, and post-task text streaming. Key improvements include eager agent tree rendering, deduplication of skill load indicators, smarter post-task text suppression, and proper grouping of sequentially spawned sub-agents.
Key Changes
Sub-agent Tree Rendering (
src/ui/index.ts)ParallelAgententries immediately ontool.startfor Task tools instead of waiting forsubagent.starteventsubagent.startfires later, merge with realsubagentIdto prevent duplicatestool.completefor agents that skipsubagent.completeeventcurrentTool, and marks status as completedSkill Loading Deduplication (
src/ui/chat.tsx,src/ui/commands/skill-commands.ts)loadedSkillsRefto prevent duplicate "loaded" UI indicators<skill-loaded>directive to expanded skill prompts to prevent model from re-invoking Skill toolinput.namewheninput.skillis unavailablePost-Task Text Suppression (
src/ui/index.ts)Agent Tree Grouping (
src/ui/chat.tsx)Task Tool Hiding (
src/ui/chat.tsx)ParallelAgentsTreecomponent insteadUI Polish (
src/ui/components/parallel-agents-tree.tsx)Research Documentation
blockedBydependency enforcement, parallel worker dispatch, and file concurrencyTechnical Details
Eager Agent Pattern: When a Task tool starts, immediately create a placeholder agent with the tool ID. When the SDK's
subagent.startevent arrives, update the existing entry in-place with the real subagent ID rather than creating a duplicate.Skill Loading State: The
loadedSkillsReftracks which skills have been loaded in the current session. Only the first invocation shows the "loaded" indicator; subsequent invocations are silent unless there's an error.Text Suppression Logic: After a Task tool completes, the model may echo back the JSON result as streaming text. The new prefix-based accumulator tracks incoming text character-by-character, only suppressing if it matches the cached result sequentially from the beginning. Once non-matching text arrives, suppression is cleared.
Agent Grouping: Uses Task tool
contentOffsetAtStartto group agents. Agents with the same offset (spawned in parallel) share a tree. Agents with different offsets (spawned sequentially with intervening text) get separate trees.Breaking Changes
None
Test Plan
subagent.start)tool.startandsubagent.startfiresubagent.completenever fires/commandsonly show "loaded" indicator on first invocation per sessioninput.nameinstead ofinput.skill