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) <noreply@anthropic.com>
This commit is contained in:
Lex Christopherson 2026-03-25 15:30:49 -06:00
parent 263d725ecd
commit b8b92b8481

View file

@ -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();
}