Skip to content

bugfix(newchat): render parsed execution code - #3886

Open
xuyaqist wants to merge 2 commits into
developfrom
xyq/bugfix_frontend_code_render
Open

bugfix(newchat): render parsed execution code#3886
xuyaqist wants to merge 2 commits into
developfrom
xyq/bugfix_frontend_code_render

Conversation

@xuyaqist

@xuyaqist xuyaqist commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

删除在思考过程中对代码块的渲染,汇总至思考结束后,符合ReAct逻辑
image

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
Copilot AI lite review requested due to automatic review settings September 8, 2026 03:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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: ParseTransformer now passes through parsed code content (no tool header / fenced Markdown formatting).
  • Frontend: parse SSE/history parts are converted into a data part named execution-code and rendered via a new ExecutionCodeBlock.
  • 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 ReactMarkdown without 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 the execution-code part, 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.

Comment on lines +850 to +854
if (part.type === "parse") {
flushReasoning(part.invocation_id);
if (part.content.trim()) {
const executionCodePart = buildExecutionCodePart({
type: "parse",
Comment on lines +2293 to +2297
if (chunk.type === "parse") {
flushOpenReasoning(chunk.invocation_id);
if (chunk.content.trim()) {
const executionCodePart = buildExecutionCodePart(chunk);
const executionMeta = resolveSubAgent(chunk.invocation_id);
Comment on lines 284 to 288
<MarkdownTextPrimitive
remarkPlugins={[remarkGfm]}
className="aui-md prose prose-sm max-w-none dark:prose-invert"
components={{ ...defaultComponents, img: () => null }}
preprocess={normalizeReasoningCodeBlocks}
/>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

代码内容在 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 |
Comment on lines +36 to +40
<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

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@xuyaqist xuyaqist changed the title fix(newchat): render parsed execution code bugfix(newchat): render parsed execution code Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants