Files
gemini-cli/packages/cli/src/ui/components/InputPrompt.tsx
Evan Senter 75ecb4a81f Adding in a history buffer (#38)
Up and down arrows traverse the command history.
2025-04-19 14:31:59 +01:00

46 lines
1.0 KiB
TypeScript

/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import React from 'react';
import { Box, Text } from 'ink';
import TextInput from 'ink-text-input';
import { globalConfig } from '../../config/config.js';
interface InputPromptProps {
query: string;
setQuery: (value: string) => void;
onSubmit: (value: string) => void;
isActive: boolean;
forceKey?: number;
}
export const InputPrompt: React.FC<InputPromptProps> = ({
query,
setQuery,
onSubmit,
isActive,
forceKey,
}) => {
const model = globalConfig.getModel();
return (
<Box marginTop={1} borderStyle="round" borderColor={'white'} paddingX={1}>
<Text color={'white'}>&gt; </Text>
<Box flexGrow={1}>
<TextInput
key={forceKey?.toString()}
value={query}
onChange={setQuery}
onSubmit={onSubmit}
showCursor={true}
focus={isActive}
placeholder={`Ask Gemini (${model})... (try "/init" or "/help")`}
/>
</Box>
</Box>
);
};