@@ -42,8 +42,11 @@ import type { CardDef } from 'https://cardstack.com/base/card-api';
42
42
43
43
import ApplyButton from ' ../ai-assistant/apply-button' ;
44
44
import { type ApplyButtonState } from ' ../ai-assistant/apply-button' ;
45
+
45
46
import Preview from ' ../preview' ;
46
47
48
+ import PreparingRoomMessageCommand from ' ./preparing-room-message-command' ;
49
+
47
50
interface Signature {
48
51
Element: HTMLDivElement ;
49
52
Args: {
@@ -53,6 +56,7 @@ interface Signature {
53
56
runCommand: () => void ;
54
57
isError? : boolean ;
55
58
isPending? : boolean ;
59
+ isStreaming: boolean ;
56
60
monacoSDK: MonacoSDK ;
57
61
};
58
62
}
@@ -193,44 +197,24 @@ export default class RoomMessageCommand extends Component<Signature> {
193
197
{{#if @ messageCommand.description }}
194
198
<div class =' command-description' >{{@ messageCommand.description }} </div >
195
199
{{/if }}
196
- <div
197
- class =' command-button-bar'
198
- {{! In test, if we change this isIdle check to the task running locally on this component, it will fail because roomMessages get destroyed during re-indexing.
199
- Since services are long-lived so it we will not have this issue. I think this will go away when we convert our room field into a room component }}
200
- {{! TODO : Convert to non-EC async method after fixing CS-6987 }}
201
- data-test-command-card-idle ={{this .commandService.run.isIdle }}
202
- >
203
- <Button
204
- class =' view-code-button'
205
- {{on ' click' this . toggleViewCode}}
206
- @ kind ={{if this . isDisplayingCode ' primary-dark' ' secondary-dark' }}
207
- @ size =' extra-small'
208
- data-test-view-code-button
200
+ {{#if @ isStreaming }}
201
+ <PreparingRoomMessageCommand />
202
+ {{else }}
203
+ <div
204
+ class =' command-button-bar'
205
+ {{! In test, if we change this isIdle check to the task running locally on this component, it will fail because roomMessages get destroyed during re-indexing.
206
+ Since services are long-lived so it we will not have this issue. I think this will go away when we convert our room field into a room component }}
207
+ {{! TODO : Convert to non-EC async method after fixing CS-6987 }}
208
+ data-test-command-card-idle ={{this .commandService.run.isIdle }}
209
209
>
210
- {{if this . isDisplayingCode ' Hide Code' ' View Code' }}
211
- </Button >
212
- <ApplyButton
213
- @ state ={{this .applyButtonState }}
214
- {{on ' click' @ runCommand}}
215
- data-test-command-apply ={{this .applyButtonState }}
216
- />
217
- </div >
218
- {{#if this . isDisplayingCode }}
219
- <div class =' preview-code' >
220
210
<Button
221
- class =' code-copy-button'
222
- @ kind =' text-only'
211
+ class =' view-code-button'
212
+ {{on ' click' this . toggleViewCode}}
213
+ @ kind ={{if this . isDisplayingCode ' primary-dark' ' secondary-dark' }}
223
214
@ size =' extra-small'
224
- {{on ' click' this . copyToClipboard}}
225
- data-test-copy-code
215
+ data-test-view-code-button
226
216
>
227
- <CopyIcon
228
- width =' 16'
229
- height =' 16'
230
- role =' presentation'
231
- aria-hidden =' true'
232
- />
233
- <span class =' copy-text' >Copy to clipboard</span >
217
+ {{if this . isDisplayingCode ' Hide Code' ' View Code' }}
234
218
</Button >
235
219
<div
236
220
class =' monaco-container'
@@ -253,37 +237,82 @@ export default class RoomMessageCommand extends Component<Signature> {
253
237
<span class =' failed-command-text' >
254
238
{{this .failedCommandState.message }}
255
239
</span >
256
- <Button
240
+ <ApplyButton
241
+ @ state ={{this .applyButtonState }}
257
242
{{on ' click' @ runCommand}}
258
- class =' retry-button'
259
- @ size =' small'
260
- @ kind =' secondary-dark'
261
- data-test-retry-command-button
262
- >
263
- Retry
264
- </Button >
265
- </div >
266
- {{/if }}
267
- {{#if this . commandResultCard.card }}
268
- <CardContainer
269
- @ displayBoundaries ={{ false }}
270
- class =' command-result-card-preview'
271
- data-test-command-result-container
272
- >
273
- <CardHeader
274
- @ cardTypeDisplayName ={{this .headerTitle }}
275
- @ cardTypeIcon ={{cardTypeIcon this . commandResultCard.card}}
276
- @ moreOptionsMenuItems ={{this .moreOptionsMenuItems }}
277
- class =' header'
278
- data-test-command-result-header
279
- />
280
- <Preview
281
- @ card ={{this .commandResultCard.card }}
282
- @ format =' embedded'
283
- @ displayContainer ={{ false }}
284
- data-test-boxel-command-result
243
+ data-test-command-apply ={{this .applyButtonState }}
285
244
/>
286
- </CardContainer >
245
+ </div >
246
+ {{#if this . isDisplayingCode }}
247
+ <div class =' preview-code' >
248
+ <Button
249
+ class =' code-copy-button'
250
+ @ kind =' text-only'
251
+ @ size =' extra-small'
252
+ {{on ' click' this . copyToClipboard}}
253
+ data-test-copy-code
254
+ >
255
+ <CopyIcon
256
+ width =' 16'
257
+ height =' 16'
258
+ role =' presentation'
259
+ aria-hidden =' true'
260
+ />
261
+ <span class =' copy-text' >Copy to clipboard</span >
262
+ </Button >
263
+ <div
264
+ class =' monaco-container'
265
+ {{! this.scrollBottomIntoView }}
266
+ {{monacoModifier
267
+ content =this . previewCommandCode
268
+ contentChanged =undefined
269
+ monacoSDK =@ monacoSDK
270
+ language =' json'
271
+ readOnly =true
272
+ editorDisplayOptions =this . editorDisplayOptions
273
+ }}
274
+ data-test-editor
275
+ data-test-percy-hide
276
+ />
277
+ </div >
278
+ {{/if }}
279
+ {{#if this . failedCommandState }}
280
+ <div class =' failed-command-result' >
281
+ <span class =' failed-command-text' >
282
+ {{this .failedCommandState.message }}
283
+ </span >
284
+ <Button
285
+ {{on ' click' @ runCommand}}
286
+ class =' retry-button'
287
+ @ size =' small'
288
+ @ kind =' secondary-dark'
289
+ data-test-retry-command-button
290
+ >
291
+ Retry
292
+ </Button >
293
+ </div >
294
+ {{/if }}
295
+ {{#if this . commandResultCard.card }}
296
+ <CardContainer
297
+ @ displayBoundaries ={{ false }}
298
+ class =' command-result-card-preview'
299
+ data-test-command-result-container
300
+ >
301
+ <CardHeader
302
+ @ cardTypeDisplayName ={{this .headerTitle }}
303
+ @ cardTypeIcon ={{cardTypeIcon this . commandResultCard.card}}
304
+ @ moreOptionsMenuItems ={{this .moreOptionsMenuItems }}
305
+ class =' header'
306
+ data-test-command-result-header
307
+ />
308
+ <Preview
309
+ @ card ={{this .commandResultCard.card }}
310
+ @ format =' embedded'
311
+ @ displayContainer ={{ false }}
312
+ data-test-boxel-command-result
313
+ />
314
+ </CardContainer >
315
+ {{/if }}
287
316
{{/if }}
288
317
</div >
289
318
0 commit comments