From b8b92b8481ffbabcc521242f0b0d22ca5009bcc4 Mon Sep 17 00:00:00 2001 From: Lex Christopherson Date: Wed, 25 Mar 2026 15:30:49 -0600 Subject: [PATCH] revert: remove insertChildBefore usage in chat-controller The insertChildBefore approach doesn't fix tool ordering because the message component is already live-streaming text when tool_execution events arrive. Proper fix requires T3 Code-style session-lifetime architecture. Revert to simple addChild for now. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../interactive/controllers/chat-controller.ts | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts b/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts index f9f7a5c79..7f9fe7044 100644 --- a/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts +++ b/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts @@ -210,18 +210,7 @@ export async function handleAgentEvent(host: InteractiveModeStateHost & { host.ui, ); component.setExpanded(host.toolOutputExpanded); - - // For external tool execution: insert tool components before the - // last message component so tools render above the text response. - // The last child is the message that just finished streaming. - const children = host.chatContainer.children; - const lastChild = children.length > 0 ? children[children.length - 1] : undefined; - if (lastChild instanceof AssistantMessageComponent && !host.streamingComponent) { - host.chatContainer.insertChildBefore(component, lastChild); - } else { - host.chatContainer.addChild(component); - } - + host.chatContainer.addChild(component); host.pendingTools.set(event.toolCallId, component); host.ui.requestRender(); }