fix(desktop): collapse sub-agent trees and stream markdown in real time#3140
Open
HUQIANTAO wants to merge 2 commits into
Open
fix(desktop): collapse sub-agent trees and stream markdown in real time#3140HUQIANTAO wants to merge 2 commits into
HUQIANTAO wants to merge 2 commits into
Conversation
AI agents habitually use grep/read_file/ls instead of codegraph tools for architecture and symbol-level questions. Root cause is a guidance vacuum: codegraph tools are registered but never introduced to the model via system prompt, tool descriptions, or skill bodies. Changes: - Inject codegraph steer text into system prompt when tools are available - Add codegraph hint to bash tool's steer constant - Update explore/research/review/security-review skill bodies to prefer codegraph tools for symbol/code-structure questions - Dynamically inject codegraph tool names into subagent allowed-tools via SetExtraReadTools() so skills can use them at runtime - Add StripRawPrefix to plugin.Spec to eliminate the double-prefix naming (mcp__codegraph__codegraph_context -> mcp__codegraph__context)
Two related desktop UX fixes for the main-v2 build: 1. /explore's step tree could not be collapsed. The parent task card's chevron only hid its args/output, while the nested sub-agent calls (read_file / grep / ls / …) always rendered. A 50-step explore therefore flooded the transcript with its full step list and there was no way to fold it back. The chevron now toggles the whole subagent tree: open by default while the sub-agent is still running so the user can watch it progress, closed by default once it settles, and a single click re-folds a finished explore to one line. Writer tools (edit_file / write_file / multi_edit) keep their diff-rendered bodies, which were never affected. 2. Assistant markdown rendered all at once on turn_done. During streaming we deliberately showed raw text to avoid re-parsing markdown on every token, but the trade-off was that headings, lists, code blocks, and links all snapped into place on the closing message event. Switch to react-markdown for the live bubble too, with useDeferredValue marking the re-parse as a low-priority update. The cursor and scroll stay smooth because React commits the streaming flag (which controls the cursor) before the heavy parse catches up, and the final render is identical to the previous completion-time render. The AssistantMessage memo is preserved, so the per-token re-render still touches only the live bubble, not the backlog.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two related desktop UX fixes for the
main-v2build, both surfacing during long sub-agent (/explore,/research) runs.1.
/explore's step tree could not be collapsedThe parent
tasktool card's chevron only hid itsargs/output; the nested sub-agent calls (read_file/grep/ls/glob/web_fetch) always rendered underneath. A 50-step/exploretherefore flooded the transcript with its full step list, with no way to fold it back. Reproduce:→ 50 read_file cards pile up, no way to collapse the whole block to one line.
The chevron now toggles the whole subagent tree. Behavior:
running, so the user can watch it progress.edit_file/write_file/multi_edit) keep their diff-rendered bodies, which were never affected by this bug.2. Assistant markdown rendered all at once on
turn_doneDuring streaming we deliberately showed raw text to avoid re-parsing markdown on every token, but the trade-off was that headings, lists, code blocks, and links all snapped into place on the closing
messageevent. Watching a 2 000-token response was a wall of monospace-looking text that suddenly reflowed into a formatted document.Switch to
react-markdownfor the live bubble too, withuseDeferredValuemarking the re-parse as a low-priority update:streamingflag (which controls the cursor) at high priority, before the heavy parse catches up.AssistantMessagememo is preserved, so a per-token re-render still touches only the live bubble, not the backlog — the streaming-perf fix from fix: show sent desktop messages immediately #3056 stays intact.Files
desktop/frontend/src/components/Message.tsxstreaming ? raw : <Markdown>branch with a single<Markdown text={deferred}/>+ cursor; adduseDeferredValueand an explanatory comment.desktop/frontend/src/components/ToolCard.tsxopenstate cover bothhasBodyandhasNested; defaultopentoitem.status === "running" && hasNested.Diff stat
Verification
pnpm typecheck→ clean.pnpm build→ clean (✓ built in 1.86s)./exploreover a 20+ file repo, confirm the steps tree collapses to one line on completion and re-expands on chevron click. Run a regular chat turn and confirm markdown formatting appears progressively as the response streams, with the cursor still blinking at the end.