feat: add Ink-based fullscreen TUI components

This commit is contained in:
William Valentin
2026-02-05 00:39:53 -08:00
parent c0deeb5cf0
commit 53a8bd97eb
6 changed files with 197 additions and 1 deletions
@@ -0,0 +1,30 @@
import React from 'react';
import { Box, Text } from 'ink';
import type { Message } from '../../../models/types.js';
export interface MessageListProps {
messages: Message[];
maxHeight?: number;
}
export function MessageList({ messages, maxHeight = 20 }: MessageListProps): React.ReactElement {
// Show only recent messages that fit
const visibleMessages = messages.slice(-maxHeight);
return (
<Box flexDirection="column" flexGrow={1} paddingX={1}>
{visibleMessages.length === 0 ? (
<Text color="gray">No messages yet. Start typing to chat with Flynn.</Text>
) : (
visibleMessages.map((message, index) => (
<Box key={index} marginBottom={1}>
<Text color={message.role === 'user' ? 'blue' : 'green'}>
{message.role === 'user' ? 'You: ' : 'Flynn: '}
</Text>
<Text wrap="wrap">{message.content}</Text>
</Box>
))
)}
</Box>
);
}