/** * ============================================================ * src/ui/QueuedMessagesBanner.tsx —— 排队消息横幅 * ------------------------------------------------------------ * 当 AI 工作过程中用户发送了多条插话时,在输入框上方显示排队消息列表。 * 插话成功处理后队列清空,横幅自动消失。 * ============================================================ */ import React from 'react'; import { Box, Text } from 'ink'; import type { QueuedInput } from '../messageQueue.js'; import { theme } from './theme.js'; import { terminalText } from './terminalText.js'; interface Props { items: readonly QueuedInput[]; } function truncate(s: string, maxLen: number): string { const oneLine = terminalText(s).replace(/\n/g, ' ').trim(); if (oneLine.length <= maxLen) return oneLine; return `${oneLine.slice(0, maxLen - 1)}…`; } export function QueuedMessagesBanner({ items }: Props): JSX.Element | null { if (items.length === 0) return null; return ( 📬 排队中 {items.length} 条补充消息(当前任务结束后将逐条处理): {items.slice(-1).map((item) => ( 最新:{' '} {truncate(item.value, 80)} ))} ); }