Fix hook message duplication in TUI

Two bugs:
1. createCustomMessage was returning role: 'user' instead of preserving
   the hook message structure (role: 'hookMessage', customType, etc.)
2. rebuildChatFromMessages wasn't clearing the container before rebuilding
This commit is contained in:
Mario Zechner 2025-12-28 12:16:36 +01:00
parent 01c4e879a1
commit ecef601d19
2 changed files with 6 additions and 2 deletions

View file

@ -165,10 +165,13 @@ export function createSummaryMessage(summary: string, timestamp: string): AgentM
/** Convert CustomMessageEntry to AgentMessage format */
function createCustomMessage(entry: CustomMessageEntry): AgentMessage {
return {
role: "user",
role: "hookMessage",
customType: entry.customType,
content: entry.content,
display: entry.display,
details: entry.details,
timestamp: new Date(entry.timestamp).getTime(),
};
} as AgentMessage;
}
/** Generate a unique short ID (8 hex chars, collision-checked) */

View file

@ -1208,6 +1208,7 @@ export class InteractiveMode {
}
private rebuildChatFromMessages(): void {
this.chatContainer.clear();
const context = this.sessionManager.buildSessionContext();
this.renderSessionContext(context);
}