@@ -539,4 +539,112 @@ describe("StreamingMessageAggregator - Agent Status", () => {
539539 expect ( status ) . toEqual ( { emoji : "✅" , message : truncatedMessage } ) ;
540540 expect ( status ?. message . length ) . toBe ( 60 ) ;
541541 } ) ;
542+
543+ it ( "should store URL when provided in status_set" , ( ) => {
544+ const aggregator = new StreamingMessageAggregator ( "2024-01-01T00:00:00.000Z" ) ;
545+ const messageId = "msg1" ;
546+ const toolCallId = "tool1" ;
547+
548+ // Start a stream
549+ aggregator . handleStreamStart ( {
550+ type : "stream-start" ,
551+ workspaceId : "workspace1" ,
552+ messageId,
553+ model : "test-model" ,
554+ historySequence : 1 ,
555+ } ) ;
556+
557+ // Add a status_set tool call with URL
558+ const testUrl = "https://github.com/owner/repo/pull/123" ;
559+ aggregator . handleToolCallStart ( {
560+ type : "tool-call-start" ,
561+ workspaceId : "workspace1" ,
562+ messageId,
563+ toolCallId,
564+ toolName : "status_set" ,
565+ args : { emoji : "🔗" , message : "PR submitted" , url : testUrl } ,
566+ tokens : 10 ,
567+ timestamp : Date . now ( ) ,
568+ } ) ;
569+
570+ // Complete the tool call
571+ aggregator . handleToolCallEnd ( {
572+ type : "tool-call-end" ,
573+ workspaceId : "workspace1" ,
574+ messageId,
575+ toolCallId,
576+ toolName : "status_set" ,
577+ result : { success : true , emoji : "🔗" , message : "PR submitted" , url : testUrl } ,
578+ } ) ;
579+
580+ const status = aggregator . getAgentStatus ( ) ;
581+ expect ( status ) . toBeDefined ( ) ;
582+ expect ( status ?. emoji ) . toBe ( "🔗" ) ;
583+ expect ( status ?. message ) . toBe ( "PR submitted" ) ;
584+ expect ( status ?. url ) . toBe ( testUrl ) ;
585+ } ) ;
586+
587+ it ( "should persist URL until replaced with new status" , ( ) => {
588+ const aggregator = new StreamingMessageAggregator ( "2024-01-01T00:00:00.000Z" ) ;
589+ const messageId = "msg1" ;
590+
591+ // Start a stream
592+ aggregator . handleStreamStart ( {
593+ type : "stream-start" ,
594+ workspaceId : "workspace1" ,
595+ messageId,
596+ model : "test-model" ,
597+ historySequence : 1 ,
598+ } ) ;
599+
600+ // First status with URL
601+ const testUrl = "https://github.com/owner/repo/pull/123" ;
602+ aggregator . handleToolCallStart ( {
603+ type : "tool-call-start" ,
604+ workspaceId : "workspace1" ,
605+ messageId,
606+ toolCallId : "tool1" ,
607+ toolName : "status_set" ,
608+ args : { emoji : "🔗" , message : "PR submitted" , url : testUrl } ,
609+ tokens : 10 ,
610+ timestamp : Date . now ( ) ,
611+ } ) ;
612+
613+ aggregator . handleToolCallEnd ( {
614+ type : "tool-call-end" ,
615+ workspaceId : "workspace1" ,
616+ messageId,
617+ toolCallId : "tool1" ,
618+ toolName : "status_set" ,
619+ result : { success : true , emoji : "🔗" , message : "PR submitted" , url : testUrl } ,
620+ } ) ;
621+
622+ expect ( aggregator . getAgentStatus ( ) ?. url ) . toBe ( testUrl ) ;
623+
624+ // Second status without URL - should clear URL
625+ aggregator . handleToolCallStart ( {
626+ type : "tool-call-start" ,
627+ workspaceId : "workspace1" ,
628+ messageId,
629+ toolCallId : "tool2" ,
630+ toolName : "status_set" ,
631+ args : { emoji : "✅" , message : "Done" } ,
632+ tokens : 10 ,
633+ timestamp : Date . now ( ) ,
634+ } ) ;
635+
636+ aggregator . handleToolCallEnd ( {
637+ type : "tool-call-end" ,
638+ workspaceId : "workspace1" ,
639+ messageId,
640+ toolCallId : "tool2" ,
641+ toolName : "status_set" ,
642+ result : { success : true , emoji : "✅" , message : "Done" } ,
643+ } ) ;
644+
645+ const finalStatus = aggregator . getAgentStatus ( ) ;
646+ expect ( finalStatus ?. emoji ) . toBe ( "✅" ) ;
647+ expect ( finalStatus ?. message ) . toBe ( "Done" ) ;
648+ expect ( finalStatus ?. url ) . toBeUndefined ( ) ;
649+ } ) ;
542650} ) ;
0 commit comments