@justinechang39/maki
Version:
AI-powered CLI agent for file operations, CSV manipulation, todo management, and web content fetching using OpenRouter
33 lines (32 loc) • 1.68 kB
JavaScript
import React from 'react';
import { Box, Text, useInput } from 'ink';
export const ThreadSelector = ({ threads, selectedIndex, onSelect }) => {
const items = [
{ name: 'Start a new thread', value: 'new', isNew: true },
...threads.map(thread => ({
name: `${thread.title || 'Untitled'}`,
value: thread.id,
subtitle: `${thread.messageCount} messages • ${thread.createdAt.toLocaleDateString()}`,
isNew: false
}))
];
useInput((input, key) => {
if (key.return) {
onSelect(items[selectedIndex].value);
}
});
return (React.createElement(Box, { flexDirection: "column", padding: 1 },
React.createElement(Box, { paddingBottom: 1 },
React.createElement(Text, { bold: true, color: "cyan" }, "\u258Cthreads")),
React.createElement(Box, { flexDirection: "column" }, items.map((item, index) => (React.createElement(Box, { key: index },
React.createElement(Text, { color: index === selectedIndex ? 'blue' : 'white', backgroundColor: index === selectedIndex ? 'blue' : undefined, inverse: index === selectedIndex },
index === selectedIndex ? '▶' : ' ',
" ",
item.isNew ? '+' : '•',
" ",
item.name),
!item.isNew && 'subtitle' in item && item.subtitle && (React.createElement(Box, { paddingLeft: 2 },
React.createElement(Text, { dimColor: true }, item.subtitle))))))),
React.createElement(Box, { paddingTop: 1 },
React.createElement(Text, { dimColor: true }, "\u2191\u2193 \u2022 \u23CE \u2022 ^C"))));
};