/** * SimpleInput - basic single-line input (from git-agent style) */ import { Box, Text, useInput } from 'ink'; import { useState, useEffect } from 'react'; import type { SimpleInputProps } from '../types/ui.js'; /** * Simple, lightweight input component for quick interactions */ export function SimpleInput({ placeholder = '> ', onSubmit, disabled = false, value: controlledValue, onChange }: SimpleInputProps) { const [internalValue, setInternalValue] = useState(''); // Support both controlled and uncontrolled modes const isControlled = controlledValue !== undefined; const value = isControlled ? controlledValue : internalValue; const setValue = isControlled ? (onChange || (() => {})) : setInternalValue; useInput((input: string, key: any) => { if (disabled) return; if (key.return) { // Submit on Enter if (value.trim()) { onSubmit(value.trim()); if (!isControlled) { setInternalValue(''); } } } else if (key.backspace || key.delete) { setValue(value.slice(0, -1)); } else if (input && !key.ctrl && !key.meta) { setValue(value + input); } }); return ( {placeholder} {value} {!disabled && } {!disabled && ( Press Enter to send )} ); }