@@ -75,12 +75,6 @@ export const ConsoleOutput = (props: Props): React.ReactNode => {
75
75
return null ;
76
76
}
77
77
78
- const renderText = ( text : string ) => {
79
- return (
80
- < span dangerouslySetInnerHTML = { { __html : ansiUp . ansi_to_html ( text ) } } />
81
- ) ;
82
- } ;
83
-
84
78
const reversedOutputs = [ ...consoleOutputs ] . reverse ( ) ;
85
79
86
80
return (
@@ -99,39 +93,31 @@ export const ConsoleOutput = (props: Props): React.ReactNode => {
99
93
if ( output . channel === "pdb" ) {
100
94
return null ;
101
95
}
102
- const originalIdx = consoleOutputs . length - idx - 1 ;
103
96
104
97
if ( output . channel === "stdin" ) {
105
98
invariant (
106
99
typeof output . data === "string" ,
107
100
"Expected data to be a string" ,
108
101
) ;
109
102
103
+ const originalIdx = consoleOutputs . length - idx - 1 ;
104
+
110
105
if ( output . response == null ) {
111
106
return (
112
- < div key = { idx } className = "flex gap-2 items-center" >
113
- { renderText ( output . data ) }
114
- < Input
115
- data-testid = "console-input"
116
- type = "text"
117
- autoComplete = "off"
118
- autoFocus = { true }
119
- className = "m-0"
120
- placeholder = "stdin"
121
- onKeyDown = { ( e ) => {
122
- if ( e . key === "Enter" && ! e . shiftKey ) {
123
- onSubmitDebugger ( e . currentTarget . value , originalIdx ) ;
124
- }
125
- } }
126
- />
127
- </ div >
107
+ < StdInput
108
+ key = { idx }
109
+ output = { output . data }
110
+ onSubmit = { ( text ) => onSubmitDebugger ( text , originalIdx ) }
111
+ />
128
112
) ;
129
113
}
114
+
130
115
return (
131
- < div key = { idx } className = "flex gap-2 items-center" >
132
- { renderText ( output . data ) }
133
- < span className = "text-[var(--sky-11)]" > { output . response } </ span >
134
- </ div >
116
+ < StdInputWithResponse
117
+ key = { idx }
118
+ output = { output . data }
119
+ response = { output . response }
120
+ />
135
121
) ;
136
122
}
137
123
@@ -152,3 +138,46 @@ export const ConsoleOutput = (props: Props): React.ReactNode => {
152
138
</ div >
153
139
) ;
154
140
} ;
141
+
142
+ const StdInput = ( props : {
143
+ onSubmit : ( text : string ) => void ;
144
+ output : string ;
145
+ response ?: string ;
146
+ } ) => {
147
+ return (
148
+ < div className = "flex gap-2 items-center" >
149
+ { renderText ( props . output ) }
150
+ < Input
151
+ data-testid = "console-input"
152
+ type = "text"
153
+ autoComplete = "off"
154
+ autoFocus = { true }
155
+ className = "m-0"
156
+ placeholder = "stdin"
157
+ onKeyDown = { ( e ) => {
158
+ if ( e . key === "Enter" && ! e . shiftKey ) {
159
+ props . onSubmit ( e . currentTarget . value ) ;
160
+ }
161
+ } }
162
+ />
163
+ </ div >
164
+ ) ;
165
+ } ;
166
+
167
+ const StdInputWithResponse = ( props : {
168
+ output : string ;
169
+ response ?: string ;
170
+ } ) => {
171
+ return (
172
+ < div className = "flex gap-2 items-center" >
173
+ { renderText ( props . output ) }
174
+ < span className = "text-[var(--sky-11)]" > { props . response } </ span >
175
+ </ div >
176
+ ) ;
177
+ } ;
178
+
179
+ const renderText = ( text : string ) => {
180
+ return (
181
+ < span dangerouslySetInnerHTML = { { __html : ansiUp . ansi_to_html ( text ) } } />
182
+ ) ;
183
+ } ;
0 commit comments