Refactor TUI into proper components

- Create UserMessageComponent - handles user messages with spacing
- Create AssistantMessageComponent - handles complete assistant messages
- Create ThinkingSelectorComponent - wraps selector with borders
- Add setSelectedIndex to SelectList for preselecting current level
- Simplify tui-renderer by using dedicated components
- Much cleaner architecture - each message type is now a component
This commit is contained in:
Mario Zechner 2025-11-11 21:55:29 +01:00
parent e2649341f0
commit 741add4411
5 changed files with 158 additions and 99 deletions

View file

@ -0,0 +1,23 @@
import { Container, Markdown, Spacer } from "@mariozechner/pi-tui";
/**
* Component that renders a user message
*/
export class UserMessageComponent extends Container {
private spacer: Spacer | null = null;
private markdown: Markdown;
constructor(text: string, isFirst: boolean) {
super();
// Add spacer before user message (except first one)
if (!isFirst) {
this.spacer = new Spacer(1);
this.addChild(this.spacer);
}
// User messages with dark gray background
this.markdown = new Markdown(text, undefined, undefined, { r: 52, g: 53, b: 65 });
this.addChild(this.markdown);
}
}