/** * Terminal Compose Bar * An immersive, borderless prompt bar that blends into the terminal's * background — like the Claude Code compose area. Enter sends, Escape * closes, Shift+Enter inserts a newline. The only visible chrome is a * hair-line top border separating it from the terminal output. */ import { Radio, X } from 'lucide-react'; import React, { useCallback, useEffect, useRef } from 'react'; import { useI18n } from '../../application/i18n/I18nProvider'; import { Tooltip, TooltipContent, TooltipTrigger } from '../ui/tooltip'; import { cn } from '../../lib/utils'; export interface TerminalComposeBarProps { onSend: (text: string) => void; onClose: () => void; isBroadcastEnabled?: boolean; themeColors?: { background: string; foreground: string; }; } export const TerminalComposeBar: React.FC = ({ onSend, onClose, isBroadcastEnabled, themeColors, }) => { const { t } = useI18n(); const textareaRef = useRef(null); const isComposingRef = useRef(false); // Auto-focus on mount useEffect(() => { // Small delay to ensure the element is rendered const timer = setTimeout(() => textareaRef.current?.focus(), 50); return () => clearTimeout(timer); }, []); // Auto-resize textarea const handleInput = useCallback(() => { const el = textareaRef.current; if (!el) return; el.style.height = 'auto'; el.style.height = `${Math.min(el.scrollHeight, 120)}px`; }, []); const handleSend = useCallback(() => { const el = textareaRef.current; if (!el) return; const text = el.value; if (!text) return; onSend(text); el.value = ''; el.style.height = 'auto'; el.focus(); }, [onSend]); const handleKeyDown = useCallback((e: React.KeyboardEvent) => { if (e.key === 'Enter' && !e.shiftKey && !isComposingRef.current) { e.preventDefault(); handleSend(); } else if (e.key === 'Escape') { e.preventDefault(); onClose(); } }, [handleSend, onClose]); const bg = themeColors?.background ?? '#0a0a0a'; const fg = themeColors?.foreground ?? '#d4d4d4'; const resolvedBg = 'var(--terminal-ui-bg, ' + bg + ')'; const resolvedFg = 'var(--terminal-ui-fg, ' + fg + ')'; return (
{/* Broadcast indicator */} {isBroadcastEnabled && (
{t("terminal.composeBar.broadcasting")}
)} {/* Borderless input — lives flush on the terminal bg so the bar feels like part of the terminal rather than a panel. */}