From de0236676391d3798bcf806dd7b16e6332a4379e Mon Sep 17 00:00:00 2001 From: xintaofei Date: Thu, 12 Mar 2026 00:57:23 +0800 Subject: [PATCH] =?UTF-8?q?plan=E6=B6=88=E6=81=AFmd=E6=B8=B2=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../message/content-parts-renderer.tsx | 61 ++++++++++++++++++- 1 file changed, 58 insertions(+), 3 deletions(-) diff --git a/src/components/message/content-parts-renderer.tsx b/src/components/message/content-parts-renderer.tsx index d691c79..23a40e5 100644 --- a/src/components/message/content-parts-renderer.tsx +++ b/src/components/message/content-parts-renderer.tsx @@ -875,6 +875,7 @@ function getToolIcon( if (name === "skill") return if (name === "enterplanmode" || name === "exitplanmode") return + if (name === "switch_mode") return return undefined } @@ -1049,8 +1050,16 @@ function deriveToolTitle( if (sk) return `Skill: ${sk}` } - // EnterPlanMode / ExitPlanMode - if (name === "enterplanmode" || name === "exitplanmode") return toolName + // EnterPlanMode / ExitPlanMode / SwitchMode + if ( + name === "enterplanmode" || + name === "exitplanmode" || + name === "switch_mode" + ) { + const title = getField("title") + if (title) return title + return "Plan" + } // Generic: try to show the first string field as context if (parsed) { @@ -1655,6 +1664,39 @@ function ApplyPatchToolInput({ input }: { input: string }) { ) } +// ── Switch mode (plan) input ────────────────────────────────────────── + +function extractPlanMarkdown(input: Record): string | null { + const direct = input.plan ?? input.Plan + if (typeof direct === "string" && direct.trim().length > 0) return direct + + const nested = + typeof input.rawInput === "object" && input.rawInput !== null + ? (input.rawInput as Record) + : typeof input.raw_input === "object" && input.raw_input !== null + ? (input.raw_input as Record) + : null + if (nested) { + const nestedPlan = nested.plan ?? nested.Plan + if (typeof nestedPlan === "string" && nestedPlan.trim().length > 0) { + return nestedPlan + } + } + + return null +} + +function SwitchModeToolInput({ input }: { input: Record }) { + const planMarkdown = extractPlanMarkdown(input) + if (!planMarkdown) return null + + return ( +
+ {planMarkdown} +
+ ) +} + // ── Generic structured input (fallback) ────────────────────────────── /** Fields that typically contain code / long text → render in code blocks */ @@ -1813,6 +1855,15 @@ function StructuredToolInput({ name === "tasklist" ) return + if ( + name === "switch_mode" || + name === "enterplanmode" || + name === "exitplanmode" + ) { + if (extractPlanMarkdown(parsed)) { + return + } + } return } @@ -2143,7 +2194,11 @@ const ToolCallPart = memo(function ToolCallPart({ isRunning, ]) const shouldHideDuplicateResult = - (toolNameLower === "edit" || toolNameLower === "apply_patch") && + (toolNameLower === "edit" || + toolNameLower === "apply_patch" || + toolNameLower === "switch_mode" || + toolNameLower === "enterplanmode" || + toolNameLower === "exitplanmode") && !part.errorText const open = (isRunning && (isCommandTool || hasLiveOutput)) || manualOpen