bugfix(newchat): render parsed execution code - #3886
Conversation
Keep parse events as pure code and show them after reasoning without rendering execution tags inside the reasoning stream. Co-authored-by: Codex <noreply@openai.com> Generated-by: gpt-5
Make parsed execution code collapsible and reuse Shiki syntax highlighting in the execution card. Co-authored-by: Codex <noreply@openai.com> Generated-by: gpt-5
There was a problem hiding this comment.
🟡 Changes recommended
Converting parse into a data part risks dropping/mis-attaching execution_logs (which currently only attach to tool-call parts, often without a tool_call_id), and reasoning now risks showing raw <code> tags unless stripped.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR adjusts the newchat ReAct rendering pipeline so executable code is no longer rendered inline during reasoning, and instead is surfaced as a dedicated “execution code” UI block when the backend emits the parsed parse result.
Changes:
- SDK:
ParseTransformernow passes through parsed code content (no tool header / fenced Markdown formatting). - Frontend:
parseSSE/history parts are converted into adatapart namedexecution-codeand rendered via a newExecutionCodeBlock. - Frontend: reasoning streaming UI is simplified by removing
<code>...</code>block normalization/splitting during streaming and on completion.
File summaries
| File | Description |
|---|---|
| test/sdk/core/utils/test_observer.py | Updates ParseTransformer expectations to match new pass-through behavior. |
| sdk/nexent/core/utils/observer.py | Makes ParseTransformer return raw parsed code content. |
| frontend/app/[locale]/newchat/ui/reasoning.tsx | Removes special handling for <code> blocks during reasoning rendering. |
| frontend/app/[locale]/newchat/ui/execution-code-block.tsx | Adds a dedicated UI component for parsed executable code display. |
| frontend/app/[locale]/newchat/assistant-ui/thread.tsx | Renders the new execution-code data part and groups it in the chain-of-thought section. |
| frontend/app/[locale]/newchat/adapter/remote-chat-model-adapter.ts | Converts parse SSE chunks into execution-code data parts. |
| frontend/app/[locale]/newchat/adapter/conversation-thread-list-adapter.tsx | Converts persisted history parse parts into execution-code data parts. |
Review details
Suppressed comments (1)
frontend/app/[locale]/newchat/ui/reasoning.tsx:294
- While streaming, reasoning content is passed to
ReactMarkdownwithout stripping executable<code>...</code>blocks. With react-markdown's default HTML escaping, these tags will show up verbatim during the run; since parsed code is now rendered via theexecution-codepart, consider removing executable<code>blocks from the streamed reasoning text.
<StreamingMarkdownSegment content={text} />
- Files reviewed: 7/7 changed files
- Comments generated: 5
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| if (part.type === "parse") { | ||
| flushReasoning(part.invocation_id); | ||
| if (part.content.trim()) { | ||
| const executionCodePart = buildExecutionCodePart({ | ||
| type: "parse", |
| if (chunk.type === "parse") { | ||
| flushOpenReasoning(chunk.invocation_id); | ||
| if (chunk.content.trim()) { | ||
| const executionCodePart = buildExecutionCodePart(chunk); | ||
| const executionMeta = resolveSubAgent(chunk.invocation_id); |
| <MarkdownTextPrimitive | ||
| remarkPlugins={[remarkGfm]} | ||
| className="aui-md prose prose-sm max-w-none dark:prose-invert" | ||
| components={{ ...defaultComponents, img: () => null }} | ||
| preprocess={normalizeReasoningCodeBlocks} | ||
| /> |
There was a problem hiding this comment.
代码内容在 reasoning 中保留、同时在执行卡片中单独展示并不构成问题:前者是模型过程记录,后者是“实际执行代码”的强调展示。所以不需要对reasoning中的块进行过滤。
| * | model_output_code | reasoning | Model code output (streamed) | | ||
| * | step_count | text | Current execution step number | | ||
| * | parse | tool-call | Code parsing result | | ||
| * | parse | execution-code | Parsed executable code | |
| <TerminalIcon className="size-3.5 text-primary" /> | ||
| <span>Executed code</span> | ||
| <span className="ml-auto font-mono text-[11px] uppercase text-muted-foreground/80"> | ||
| {language} | ||
| </span> |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
删除在思考过程中对代码块的渲染,汇总至思考结束后,符合ReAct逻辑
