fix(coding-agent): preserve shared live tools across rebuilds

This commit is contained in:
can1357
2026-07-24 16:26:59 +02:00
parent b0f1b5c0c5
commit 68e76c6243
3 changed files with 110 additions and 4 deletions
@@ -76,6 +76,8 @@ type RenderSessionContextOptions = {
updateFooter?: boolean;
populateHistory?: boolean;
reuseSettledComponents?: boolean;
/** Tool calls whose existing live component remains the sole render owner across a rebuild. */
preservedLiveToolCallIds?: ReadonlySet<string>;
};
function imageLinksForMessage(
@@ -422,8 +424,12 @@ export class UiHelpers {
if (content.type !== "toolCall") {
continue;
}
resolveWaitingPoll(content.name);
const afterToolSegment = timeline.afterToolCalls.get(content.id);
if (options.preservedLiveToolCallIds?.has(content.id)) {
appendAssistantSegment(afterToolSegment);
continue;
}
resolveWaitingPoll(content.name);
if (content.name === "read" && readArgsCollapseIntoGroup(content.arguments)) {
if (hasErrorStop && errorMessage) {
@@ -538,6 +544,7 @@ export class UiHelpers {
pendingUsageTtft = message.ttft;
pendingUsageTimestamp = message.timestamp;
} else if (message.role === "toolResult") {
if (options.preservedLiveToolCallIds?.has(message.toolCallId)) continue;
const pendingReadComponent = this.ctx.pendingTools.get(message.toolCallId);
const isReadGroupResult =
message.toolName === "read" &&