@@ -2,15 +2,17 @@ import { LoadingButton } from '@atlaskit/button';
2
2
import SendIcon from '@atlaskit/icon/core/arrow-up' ;
3
3
import StopIcon from '@atlaskit/icon/core/video-stop' ;
4
4
import React from 'react' ;
5
+ import { State } from 'src/rovo-dev/rovoDevTypes' ;
5
6
6
- import { AiGenerativeTextSummaryIcon , CloseIconDeepPlan , State } from '../../rovoDevView' ;
7
+ import { AiGenerativeTextSummaryIcon , CloseIconDeepPlan } from '../../rovoDevView' ;
7
8
import {
8
9
rovoDevDeepPlanStylesSelector ,
9
10
rovoDevPromptButtonStyles ,
10
11
rovoDevTextareaStyles ,
11
12
} from '../../rovoDevViewStyles' ;
12
13
13
14
interface PromptInputBoxProps {
15
+ disabled ?: boolean ;
14
16
state : State ;
15
17
promptText : string ;
16
18
onPromptTextChange : ( text : string ) => void ;
@@ -21,7 +23,22 @@ interface PromptInputBoxProps {
21
23
sendButtonDisabled ?: boolean ;
22
24
onAddContext : ( ) => void ;
23
25
}
26
+
27
+ const TextAreaMessages : Record < State , string > = {
28
+ [ State . Disabled ] : 'Rovo Dev is currently disabled. Please, refer to the error message in chat' ,
29
+ [ State . WaitingForPrompt ] : 'Type in a question' ,
30
+ [ State . NoWorkspaceOpen ] : 'Please, open a folder to start a chat session with Rovo Dev' ,
31
+ [ State . GeneratingResponse ] : 'Generating response...' ,
32
+ [ State . CancellingResponse ] : 'Cancelling the response...' ,
33
+ [ State . ExecutingPlan ] : 'Executing the code plan...' ,
34
+ } ;
35
+
36
+ const getTextAreaPlaceholder = ( state : State ) => {
37
+ return TextAreaMessages [ state ] ;
38
+ } ;
39
+
24
40
export const PromptInputBox : React . FC < PromptInputBoxProps > = ( {
41
+ disabled,
25
42
state,
26
43
promptText,
27
44
onPromptTextChange,
@@ -32,13 +49,6 @@ export const PromptInputBox: React.FC<PromptInputBoxProps> = ({
32
49
sendButtonDisabled = false ,
33
50
onAddContext,
34
51
} ) => {
35
- const TextAreaMessages : Record < State , string > = {
36
- [ State . WaitingForPrompt ] : 'Type in a question' ,
37
- [ State . GeneratingResponse ] : 'Generating response...' ,
38
- [ State . CancellingResponse ] : 'Cancelling the response...' ,
39
- [ State . ExecutingPlan ] : 'Executing the code plan...' ,
40
- } ;
41
-
42
52
const handleKeyDown = React . useCallback (
43
53
( event : React . KeyboardEvent < HTMLTextAreaElement > ) => {
44
54
if ( event . key === 'Enter' && ! event . shiftKey && state === State . WaitingForPrompt ) {
@@ -48,18 +58,16 @@ export const PromptInputBox: React.FC<PromptInputBoxProps> = ({
48
58
} ,
49
59
[ state , onSend , promptText ] ,
50
60
) ;
51
- const getTextAreaPlaceholder = ( ) => {
52
- return TextAreaMessages [ state ] || 'Type in a question' ;
53
- } ;
54
61
55
62
return (
56
63
< >
57
64
< textarea
58
65
style = { { ...{ fieldSizing : 'content' } , ...rovoDevTextareaStyles } }
59
- placeholder = { getTextAreaPlaceholder ( ) }
66
+ placeholder = { getTextAreaPlaceholder ( state ) }
60
67
onChange = { ( element ) => onPromptTextChange ( element . target . value ) }
61
68
onKeyDown = { handleKeyDown }
62
69
value = { promptText }
70
+ disabled = { disabled }
63
71
/>
64
72
< div
65
73
style = { {
@@ -71,54 +79,61 @@ export const PromptInputBox: React.FC<PromptInputBoxProps> = ({
71
79
} }
72
80
>
73
81
{ /* Left-side Add Context Button */ }
74
- < LoadingButton
75
- style = { {
76
- ...rovoDevPromptButtonStyles ,
77
- } }
78
- spacing = "compact"
79
- label = "Add context"
80
- iconBefore = { < i className = "codicon codicon-add" /> }
81
- onClick = { ( ) => onAddContext ( ) }
82
- />
83
- < div style = { { display : 'flex' , gap : 8 } } >
84
- < LoadingButton
85
- style = { {
86
- ...rovoDevDeepPlanStylesSelector ( isDeepPlanEnabled , state !== State . WaitingForPrompt ) ,
87
- } }
88
- spacing = "compact"
89
- label = "Enable deep plan"
90
- iconBefore = { < AiGenerativeTextSummaryIcon /> }
91
- iconAfter = { isDeepPlanEnabled ? < CloseIconDeepPlan /> : undefined }
92
- isDisabled = { state !== State . WaitingForPrompt }
93
- onClick = { ( ) => onDeepPlanToggled ( ) }
94
- >
95
- { isDeepPlanEnabled ? 'Deep plan enabled' : '' }
96
- </ LoadingButton >
97
- { state === State . WaitingForPrompt && (
82
+ { ! disabled && (
83
+ < >
98
84
< LoadingButton
99
85
style = { {
100
86
...rovoDevPromptButtonStyles ,
101
- color : 'var(--vscode-button-foreground) !important' ,
102
- backgroundColor : 'var(--vscode-button-background)' ,
103
87
} }
104
88
spacing = "compact"
105
- label = "Send prompt"
106
- iconBefore = { < SendIcon label = "Send prompt" /> }
107
- isDisabled = { sendButtonDisabled }
108
- onClick = { ( ) => onSend ( promptText ) }
109
- />
110
- ) }
111
- { state !== State . WaitingForPrompt && (
112
- < LoadingButton
113
- style = { rovoDevPromptButtonStyles }
114
- spacing = "compact"
115
- label = "Stop"
116
- iconBefore = { < StopIcon label = "Stop" /> }
117
- isDisabled = { state === State . CancellingResponse }
118
- onClick = { ( ) => onCancel ( ) }
89
+ label = "Add context"
90
+ iconBefore = { < i className = "codicon codicon-add" /> }
91
+ onClick = { ( ) => onAddContext ( ) }
119
92
/>
120
- ) }
121
- </ div >
93
+ < div style = { { display : 'flex' , gap : 8 } } >
94
+ < LoadingButton
95
+ style = { {
96
+ ...rovoDevDeepPlanStylesSelector (
97
+ isDeepPlanEnabled ,
98
+ state !== State . WaitingForPrompt ,
99
+ ) ,
100
+ } }
101
+ spacing = "compact"
102
+ label = "Enable deep plan"
103
+ iconBefore = { < AiGenerativeTextSummaryIcon /> }
104
+ iconAfter = { isDeepPlanEnabled ? < CloseIconDeepPlan /> : undefined }
105
+ isDisabled = { state !== State . WaitingForPrompt }
106
+ onClick = { ( ) => onDeepPlanToggled ( ) }
107
+ >
108
+ { isDeepPlanEnabled ? 'Deep plan enabled' : '' }
109
+ </ LoadingButton >
110
+ { state === State . WaitingForPrompt && (
111
+ < LoadingButton
112
+ style = { {
113
+ ...rovoDevPromptButtonStyles ,
114
+ color : 'var(--vscode-button-foreground) !important' ,
115
+ backgroundColor : 'var(--vscode-button-background)' ,
116
+ } }
117
+ spacing = "compact"
118
+ label = "Send prompt"
119
+ iconBefore = { < SendIcon label = "Send prompt" /> }
120
+ isDisabled = { sendButtonDisabled }
121
+ onClick = { ( ) => onSend ( promptText ) }
122
+ />
123
+ ) }
124
+ { state !== State . WaitingForPrompt && (
125
+ < LoadingButton
126
+ style = { rovoDevPromptButtonStyles }
127
+ spacing = "compact"
128
+ label = "Stop"
129
+ iconBefore = { < StopIcon label = "Stop" /> }
130
+ isDisabled = { state === State . CancellingResponse }
131
+ onClick = { ( ) => onCancel ( ) }
132
+ />
133
+ ) }
134
+ </ div >
135
+ </ >
136
+ ) }
122
137
</ div >
123
138
</ >
124
139
) ;
0 commit comments