Fix compaction message rendering to go through addMessageToChat

Both auto_compaction_end and executeCompaction were manually adding
CompactionSummaryMessageComponent instead of using addMessageToChat,
which caused missing spacers. Now both use addMessageToChat for
consistent spacing and expansion state handling.
This commit is contained in:
Mario Zechner 2025-12-29 23:06:18 +01:00
parent 8fe8fe9920
commit 0445da666c

View file

@ -992,15 +992,13 @@ export class InteractiveMode {
// Rebuild chat to show compacted state
this.chatContainer.clear();
this.rebuildChatFromMessages();
// Add compaction component (same as manual /compact)
const compactionComponent = new CompactionSummaryMessageComponent({
// Add compaction component at bottom so user sees it without scrolling
this.addMessageToChat({
role: "compactionSummary",
tokensBefore: event.result.tokensBefore,
summary: event.result.summary,
timestamp: Date.now(),
});
compactionComponent.setExpanded(this.toolOutputExpanded);
this.chatContainer.addChild(compactionComponent);
this.footer.updateState(this.session.state);
}
this.ui.requestRender();
@ -2128,11 +2126,9 @@ export class InteractiveMode {
// Rebuild UI
this.rebuildChatFromMessages();
// Add compaction component
// Add compaction component at bottom so user sees it without scrolling
const msg = createCompactionSummaryMessage(result.summary, result.tokensBefore, new Date().toISOString());
const compactionComponent = new CompactionSummaryMessageComponent(msg);
compactionComponent.setExpanded(this.toolOutputExpanded);
this.chatContainer.addChild(compactionComponent);
this.addMessageToChat(msg);
this.footer.updateState(this.session.state);
} catch (error) {