mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-20 02:51:55 -07:00
- The push for these changes didn't make it through.... Just doing a quick fix here which should have been in: https://github.com/google-gemini/gemini-code/pull/181
49 lines
1.1 KiB
TypeScript
49 lines
1.1 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright 2025 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
import React from 'react';
|
|
import { Text, Box, useInput, useFocus } from 'ink';
|
|
import TextInput from 'ink-text-input';
|
|
import { Colors } from '../colors.js';
|
|
|
|
interface InputPromptProps {
|
|
onSubmit: (value: string) => void;
|
|
}
|
|
|
|
export const InputPrompt: React.FC<InputPromptProps> = ({ onSubmit }) => {
|
|
const [value, setValue] = React.useState('');
|
|
|
|
const { isFocused } = useFocus({ autoFocus: true });
|
|
|
|
useInput(
|
|
(input, key) => {
|
|
if (key.return) {
|
|
if (value.trim()) {
|
|
onSubmit(value);
|
|
setValue('');
|
|
}
|
|
}
|
|
},
|
|
{ isActive: isFocused },
|
|
);
|
|
|
|
return (
|
|
<Box borderStyle="round" borderColor={Colors.AccentBlue} paddingX={1}>
|
|
<Text color={Colors.AccentPurple}>> </Text>
|
|
<Box flexGrow={1}>
|
|
<TextInput
|
|
value={value}
|
|
onChange={setValue}
|
|
placeholder="Enter your message or use tools..."
|
|
onSubmit={() => {
|
|
/* Empty to prevent double submission */
|
|
}}
|
|
/>
|
|
</Box>
|
|
</Box>
|
|
);
|
|
};
|