Refactor: shared exec utility, rename CustomMessageRenderer to HookMessageRenderer

- Extract execCommand to src/core/exec.ts, shared by hooks and custom-tools
- Rename CustomMessageRenderer -> HookMessageRenderer
- Rename registerCustomMessageRenderer -> registerMessageRenderer
- Renderer now receives HookMessage instead of CustomMessageEntry
- CustomMessageComponent now has setExpanded() and responds to Ctrl+E toggle
- Re-export ExecOptions/ExecResult from exec.ts for backward compatibility
This commit is contained in:
Mario Zechner 2025-12-27 03:10:08 +01:00
parent 5fee9005b7
commit a8866d7a83
12 changed files with 199 additions and 261 deletions

View file

@ -1028,7 +1028,7 @@ export class InteractiveMode {
parentId: null,
timestamp: new Date().toISOString(),
};
const renderer = this.session.hookRunner?.getCustomMessageRenderer(message.customType);
const renderer = this.session.hookRunner?.getMessageRenderer(message.customType);
this.chatContainer.addChild(new CustomMessageComponent(entry, renderer));
}
} else if (message.role === "user") {
@ -1077,7 +1077,7 @@ export class InteractiveMode {
// Check if this is a custom_message entry
if (entry?.type === "custom_message") {
if (entry.display) {
const renderer = this.session.hookRunner?.getCustomMessageRenderer(entry.customType);
const renderer = this.session.hookRunner?.getMessageRenderer(entry.customType);
this.chatContainer.addChild(new CustomMessageComponent(entry, renderer));
}
continue;
@ -1271,6 +1271,8 @@ export class InteractiveMode {
child.setExpanded(this.toolOutputExpanded);
} else if (child instanceof BashExecutionComponent) {
child.setExpanded(this.toolOutputExpanded);
} else if (child instanceof CustomMessageComponent) {
child.setExpanded(this.toolOutputExpanded);
}
}
this.ui.requestRender();