-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathPromptInput.tsx
More file actions
63 lines (60 loc) · 1.29 KB
/
PromptInput.tsx
File metadata and controls
63 lines (60 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import {
VscodeIcon,
VscodeProgressRing,
} from "@vscode-elements/react-elements";
import { isSubmit } from "../utils/keys";
export interface PromptInputProps {
value: string;
onChange: (value: string) => void;
onSubmit: () => void;
disabled?: boolean;
loading?: boolean;
placeholder?: string;
actionIcon: "send" | "debug-pause" | "debug-start";
actionLabel: string;
actionEnabled: boolean;
}
export function PromptInput({
value,
onChange,
onSubmit,
disabled = false,
loading = false,
placeholder = "Prompt your AI agent to start a task...",
actionIcon,
actionLabel,
actionEnabled,
}: PromptInputProps) {
return (
<div className="prompt-input-container">
<textarea
className="prompt-input"
placeholder={placeholder}
value={value}
onChange={(e) => onChange(e.target.value)}
onKeyDown={(e) => {
if (isSubmit(e)) {
e.preventDefault();
if (actionEnabled) {
onSubmit();
}
}
}}
disabled={disabled || loading}
/>
<div className="prompt-send-button">
{loading ? (
<VscodeProgressRing />
) : (
<VscodeIcon
actionIcon
name={actionIcon}
label={actionLabel}
onClick={() => actionEnabled && onSubmit()}
className={actionEnabled ? "" : "disabled"}
/>
)}
</div>
</div>
);
}