@@ -396,10 +396,7 @@ export class AgentSession {
396396 }
397397
398398 private attachAiListeners ( ) : void {
399- const forward = (
400- event : string ,
401- handler : ( payload : WorkspaceChatMessage ) => void | Promise < void >
402- ) => {
399+ const forward = ( event : string , handler : ( payload : WorkspaceChatMessage ) => void ) => {
403400 const wrapped = ( ...args : unknown [ ] ) => {
404401 const [ payload ] = args ;
405402 if (
@@ -410,7 +407,7 @@ export class AgentSession {
410407 ) {
411408 return ;
412409 }
413- void handler ( payload as WorkspaceChatMessage ) ;
410+ handler ( payload as WorkspaceChatMessage ) ;
414411 } ;
415412 this . aiListeners . push ( { event, handler : wrapped } ) ;
416413 this . aiService . on ( event , wrapped as never ) ;
@@ -424,17 +421,16 @@ export class AgentSession {
424421 forward ( "reasoning-delta" , ( payload ) => this . emitChatEvent ( payload ) ) ;
425422 forward ( "reasoning-end" , ( payload ) => this . emitChatEvent ( payload ) ) ;
426423
427- forward ( "stream-end" , async ( payload ) => {
424+ forward ( "stream-end" , ( payload ) => {
425+ this . emitChatEvent ( payload ) ;
428426 // Stream end: auto-send queued messages
429427 if ( ! this . messageQueue . isEmpty ( ) ) {
430428 const { message, options } = this . messageQueue . produceMessage ( ) ;
431429 this . messageQueue . clear ( ) ;
432430 this . emitQueuedMessageChanged ( ) ;
433431
434- await this . sendMessage ( message , options ) ;
432+ void this . sendMessage ( message , options ) ;
435433 }
436- // Don't update the frontend until the message is sent
437- this . emitChatEvent ( payload ) ;
438434 } ) ;
439435
440436 forward ( "stream-abort" , ( payload ) => {
0 commit comments