Skip to content

fix(desktop): collapse sub-agent trees and stream markdown in real time#3140

Open
HUQIANTAO wants to merge 2 commits into
esengine:main-v2from
HUQIANTAO:fix/desktop-explore-collapse-and-streaming-markdown
Open

fix(desktop): collapse sub-agent trees and stream markdown in real time#3140
HUQIANTAO wants to merge 2 commits into
esengine:main-v2from
HUQIANTAO:fix/desktop-explore-collapse-and-streaming-markdown

Conversation

@HUQIANTAO
Copy link
Copy Markdown
Contributor

Summary

Two related desktop UX fixes for the main-v2 build, both surfacing during long sub-agent (/explore, /research) runs.

1. /explore's step tree could not be collapsed

The parent task tool card's chevron only hid its args/output; the nested sub-agent calls (read_file / grep / ls / glob / web_fetch) always rendered underneath. A 50-step /explore therefore flooded the transcript with its full step list, with no way to fold it back. Reproduce:

/explore 找到所有调用 Foo 的地方

→ 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:

  • Open by default while the sub-agent is still running, so the user can watch it progress.
  • Closed by default once it settles, so a finished explore folds to a single summary line ("12 steps") on first paint.
  • A single click re-folds or re-expands the whole tree — and the user can still expand/collapse individual sub-calls independently.
  • Writer tools (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_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. Watching a 2 000-token response was a wall of monospace-looking text that suddenly reflowed into a formatted document.

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) at high priority, before the heavy parse catches up.
  • The deferred value converges on the full text when the stream ends, so the final render is byte-identical to the previous completion-time render.
  • The AssistantMessage memo 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

File Change
desktop/frontend/src/components/Message.tsx Replace the streaming ? raw : <Markdown> branch with a single <Markdown text={deferred}/> + cursor; add useDeferredValue and an explanatory comment.
desktop/frontend/src/components/ToolCard.tsx Make the chevron's open state cover both hasBody and hasNested; default open to item.status === "running" && hasNested.

Diff stat

desktop/frontend/src/components/Message.tsx    | 26 ++++++++++++++------------
desktop/frontend/src/components/ToolCard.tsx   | 15 +++++++++++----
2 files changed, 25 insertions(+), 16 deletions(-)

Verification

  • pnpm typecheck → clean.
  • pnpm build → clean (✓ built in 1.86s).
  • Manual: open the desktop client, run /explore over 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.
  • No new dependencies; no locale / i18n / CSS surface change.

HUQIANTAO added 2 commits June 4, 2026 23:10
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.
@HUQIANTAO HUQIANTAO requested a review from SivanCola as a code owner June 4, 2026 16:29
@github-actions github-actions Bot added the v2 Go rewrite (1.x) — main-v2 branch, active development label Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant