fix(cli): resolve subagent grouping and UI state persistence#22252
fix(cli): resolve subagent grouping and UI state persistence#22252abhipatel12 merged 4 commits intomainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the user experience, stability, and type safety of subagent rendering within the CLI. It ensures that the subagent's progress interface remains interactive and informative even after completion, visually groups related tool calls to prevent display issues, and addresses various underlying typing and rendering inconsistencies for a more robust and polished command-line interface. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces significant improvements to the subagent UI, enhancing both user experience and stability. The move to a structured SubagentProgress object for display is a great architectural change that enables a more persistent and richer UI. The batching of tool calls to prevent rendering artifacts is also a clever and effective solution. The code is well-organized and includes necessary test updates. I've identified one area for improvement regarding display consistency between collapsed and expanded views, which is crucial for maintaining consistent UI behavior as per our guidelines.
|
Size Change: +11.2 kB (+0.04%) Total Size: 26.2 MB
ℹ️ View Unchanged
|
81cc44c to
59f5aed
Compare
jacob314
left a comment
There was a problem hiding this comment.
🚨 Critical Issue: Initial State Hiding / Flickering in SubagentGroupDisplay.tsx
Currently, SubagentGroupDisplay filters the passed toolCalls to only those that have a valid SubagentProgress object:
const validAgentCalls = toolCalls.filter((tc) =>
isSubagentProgress(tc.resultDisplay),
);
if (validAgentCalls.length === 0) {
return null;
}The Bug: When an agent tool call is first initiated by the model, its resultDisplay (which is mapped from liveOutput during execution) may briefly be undefined before the backend yields the first progress event.
Because of the strict filter, the component will return null and the agent will not be visible at all in the UI until it emits its first progress. If you group 2 agents and one is slightly slower to start, it will throw off the "X Agents Running" counts and pop in abruptly.
Recommendation: Remove the validAgentCalls filter. Trust the toolCalls array passed into the component (since ToolGroupMessage already groups them by Kind.Agent). If tc.resultDisplay is undefined (or not a progress object), render a generic "Starting..." state.
packages/cli/src/ui/components/messages/SubagentGroupDisplay.test.tsx
Outdated
Show resolved
Hide resolved
packages/cli/src/ui/components/messages/SubagentGroupDisplay.test.tsx
Outdated
Show resolved
Hide resolved
packages/cli/src/ui/components/messages/SubagentGroupDisplay.tsx
Outdated
Show resolved
Hide resolved
packages/cli/src/ui/components/messages/SubagentGroupDisplay.tsx
Outdated
Show resolved
Hide resolved
packages/cli/src/ui/components/messages/SubagentGroupDisplay.tsx
Outdated
Show resolved
Hide resolved
jacob314
left a comment
There was a problem hiding this comment.
Approved with some minor nits.
59f5aed to
d557384
Compare
|
Thanks for the review! |
Summary
This PR significantly improves the UX, stability, and type safety of subagent rendering in the CLI. It ensures that subagent progress UI persists gracefully after completion, connects related tool calls visually through batching to prevent tearing, and resolves several strict typing and rendering bugs.
Details
1. Persistent Rich UI for Subagents (
@google/gemini-cli-core)local-invocation.ts: ModifiedLocalSubagentInvocationto return a structuredSubagentProgressobject in itsreturnDisplayrather than a flat Markdown string. This ensures the rich subagent UI (expandable progress, thought bubbles, etc.) persists properly even after the subagent finishes execution.types.ts: Expanded theSubagentProgressinterface to includeresultandterminateReason.index.ts: ExportedsafeJsonToMarkdownfor use by the CLI package.2. History Batching & Rendering Stability (
packages/cli/src/ui/hooks/useGeminiStream)useGeminiStream.ts: Refactored the stream polling logic to batch contiguous completed tools into a single history item. This prevents Ink rendering bugs (tearing/stretching) and connects borders beautifully between sequential tool responses.3. UI Alignment & Bug Fixes (
packages/cli/src/ui/components/messages)ToolGroupMessage.tsx: Updated to handle the newly batched history items. It now preserves the exact chronological ordering of interleaved agent and regular tool calls while cleanly grouping contiguous subagents into a single array before mapping. This prevents individual sticky headers (e.g.,≡ Running Agent...) from duplicating repeatedly.SubagentGroupDisplay.tsx/SubagentProgressDisplay.tsx:wrap="truncate") and using exhaustiveswitchcases viacheckExhaustivefor status indicators (avoiding nested ternaries).@typescript-eslint/no-unsafe-assignmentissue by securely narrowingSubagentActivityItemtypes usinginoperator andtypeofchecks for optional properties (displayName,description,content,args).ToolResultDisplay.tsx: Now leverages the exportedsafeJsonToMarkdownutility directly from core.Related Issues
N/A
How to Validate
npm run preflightto confirm that all strict linting (@typescript-eslint/array-type, unsafe assignment) and typechecks pass flawlessly.Pre-Merge Checklist