@@ -11,6 +11,7 @@ import { v4 as uuid } from 'uuid';
11
11
import { getExperienceMindState } from '../../common/game/get-experience-mindstate.js' ;
12
12
import type {
13
13
ExperienceGameEvent ,
14
+ GameCommandMessage ,
14
15
GameEvent ,
15
16
GameEventMessage ,
16
17
RoomGameEvent ,
@@ -280,6 +281,37 @@ const GridPage: React.FC = (): ReactNode => {
280
281
} ;
281
282
} , [ logger , gameEventsSubject$ ] ) ;
282
283
284
+ // When the user sends a command, echo it to the main game stream so that
285
+ // the user sees what they sent and can correlate to the game response.
286
+ useEffect ( ( ) => {
287
+ const unsubscribe = window . api . onMessage (
288
+ 'game:command' ,
289
+ ( _event : IpcRendererEvent , message : GameCommandMessage ) => {
290
+ const { command } = message ;
291
+ logger . debug ( 'game:command' , { command } ) ;
292
+ gameLogLineSubject$ . next ( {
293
+ eventId : uuid ( ) ,
294
+ // TODO create some constants for known stream ids, '' = main window
295
+ streamId : '' ,
296
+ // TODO clean up this mess
297
+ styles : css ( {
298
+ fontFamily : `Verdana, ${ euiTheme . font . familySerif } ` ,
299
+ fontSize : '14px' ,
300
+ fontWeight : euiTheme . font . weight . regular ,
301
+ color : euiTheme . colors . subduedText ,
302
+ lineHeight : 'initial' ,
303
+ paddingLeft : euiTheme . size . s ,
304
+ paddingRight : euiTheme . size . s ,
305
+ } ) ,
306
+ text : `> ${ command } ` ,
307
+ } ) ;
308
+ }
309
+ ) ;
310
+ return ( ) => {
311
+ unsubscribe ( ) ;
312
+ } ;
313
+ } , [ logger , gameLogLineSubject$ , euiTheme ] ) ;
314
+
283
315
// TODO move to a new GameCommandInput component
284
316
const onKeyDownCommandInput = useCallback <
285
317
KeyboardEventHandler < HTMLInputElement >
0 commit comments