mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
Starting to modularize into separate cli / server packages. (#55)
* Starting to move a lot of code into packages/server * More of the massive refactor, builds and runs, some issues though. * Fixing outstanding issue with double messages. * Fixing a minor UI issue. * Fixing the build post-merge. * Running formatting. * Addressing comments.
This commit is contained in:
@@ -5,41 +5,43 @@
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Box, Text } from 'ink';
|
||||
import { Box, useInput, useFocus } 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();
|
||||
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 marginTop={1} borderStyle="round" borderColor={'white'} paddingX={1}>
|
||||
<Text color={'white'}>> </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
|
||||
borderStyle="round"
|
||||
borderColor={isFocused ? 'blue' : 'gray'}
|
||||
paddingX={1}
|
||||
>
|
||||
<TextInput
|
||||
value={value}
|
||||
onChange={setValue}
|
||||
placeholder="Enter your message or use tools..."
|
||||
onSubmit={() => {
|
||||
/* Empty to prevent double submission */
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user