@@ -255,6 +255,57 @@ describeTelegramDispatch("dispatchTelegramMessage progress-updates", () => {
255255 expect ( draftStream . flush ) . toHaveBeenCalled ( ) ;
256256 } ) ;
257257
258+ it ( "keeps eight rolling tool rows beneath a preamble with verbose off" , async ( ) => {
259+ const draftStream = createSequencedDraftStream ( 2001 ) ;
260+ createTelegramDraftStream . mockReturnValue ( draftStream ) ;
261+ dispatchReplyWithBufferedBlockDispatcher . mockImplementation (
262+ async ( { dispatcherOptions, replyOptions } ) => {
263+ await replyOptions ?. onReplyStart ?.( ) ;
264+ await replyOptions ?. onAssistantMessageStart ?.( ) ;
265+ await replyOptions ?. onItemEvent ?.( {
266+ kind : "preamble" ,
267+ itemId : "preamble-1" ,
268+ progressText : "I'll make exactly 10 harmless, read-only tool calls." ,
269+ } ) ;
270+ for ( let index = 1 ; index <= 10 ; index += 1 ) {
271+ await replyOptions ?. onToolStart ?.( {
272+ phase : "start" ,
273+ name : "exec" ,
274+ toolCallId : `exec-${ index } ` ,
275+ args : { command : `command-${ index } ` } ,
276+ } ) ;
277+ }
278+ await dispatcherOptions . deliver ( { text : "Done" } , { kind : "final" } ) ;
279+ return { queuedFinal : true } ;
280+ } ,
281+ ) ;
282+
283+ await dispatchWithContext ( {
284+ context : createContext ( ) ,
285+ cfg : { agents : { defaults : { verboseDefault : "off" } } } ,
286+ streamMode : "progress" ,
287+ telegramCfg : {
288+ streaming : {
289+ mode : "progress" ,
290+ progress : { commandText : "raw" , maxLines : 8 , toolProgress : true } ,
291+ } ,
292+ } ,
293+ } ) ;
294+
295+ const rollingPreview = draftStream . updatePreview . mock . calls . at ( - 1 ) ?. [ 0 ] ;
296+ expect ( rollingPreview ?. text ) . toContain ( "I'll make exactly 10 harmless, read-only tool calls." ) ;
297+ expect ( rollingPreview ?. text ) . not . toContain ( "<code>command-1</code>" ) ;
298+ expect ( rollingPreview ?. text ) . not . toContain ( "<code>command-2</code>" ) ;
299+ for ( let index = 3 ; index <= 10 ; index += 1 ) {
300+ expect ( rollingPreview ?. text ) . toContain ( `command-${ index } ` ) ;
301+ }
302+ expectDeliveredReply ( 0 , { text : "Done" } ) ;
303+ const collapsePreview = draftStream . finalizeToPreview . mock . calls . at ( - 1 ) ?. [ 0 ] as
304+ | { text ?: string }
305+ | undefined ;
306+ expect ( collapsePreview ?. text ) . toMatch ( / ^ 🛠 ️ 1 0 t o o l c a l l s · ⏱ ️ \d + s $ / u) ;
307+ } ) ;
308+
258309 it ( "renders command status without command output in Telegram progress draft previews" , async ( ) => {
259310 const draftStream = createSequencedDraftStream ( 2001 ) ;
260311 createTelegramDraftStream . mockReturnValue ( draftStream ) ;
@@ -561,10 +612,78 @@ describeTelegramDispatch("dispatchTelegramMessage progress-updates", () => {
561612
562613 expect ( draftStream . updatePreview ) . toHaveBeenCalledWith (
563614 telegramProgressPreview (
564- "Shelling\n\nChecking recent context" ,
565- "<b>Shelling</b>\nChecking recent context" ,
615+ "Shelling\n\nChecking recent context\n🛠️ Exec" ,
616+ "<b>Shelling</b>\nChecking recent context\n<b>🛠️ Exec</b>" ,
617+ ) ,
618+ ) ;
619+ } ) ;
620+
621+ it ( "keeps fast-mode string progress beneath a Telegram preamble" , async ( ) => {
622+ const draftStream = createSequencedDraftStream ( 2001 ) ;
623+ createTelegramDraftStream . mockReturnValue ( draftStream ) ;
624+ dispatchReplyWithBufferedBlockDispatcher . mockImplementation (
625+ async ( { dispatcherOptions, replyOptions } ) => {
626+ await replyOptions ?. onReplyStart ?.( ) ;
627+ await replyOptions ?. onItemEvent ?.( {
628+ kind : "preamble" ,
629+ itemId : "preamble-1" ,
630+ progressText : "Checking recent context" ,
631+ } ) ;
632+ await dispatcherOptions . deliver (
633+ {
634+ text : "Fast mode enabled" ,
635+ channelData : { openclawProgressKind : "fast-mode-auto" } ,
636+ } ,
637+ { kind : "tool" } ,
638+ ) ;
639+ return { queuedFinal : false } ;
640+ } ,
641+ ) ;
642+
643+ await dispatchWithContext ( {
644+ context : createContext ( ) ,
645+ streamMode : "progress" ,
646+ telegramCfg : {
647+ streaming : { mode : "progress" , progress : { label : "Shelling" } } ,
648+ } ,
649+ } ) ;
650+
651+ expect ( draftStream . updatePreview ) . toHaveBeenLastCalledWith (
652+ telegramProgressPreview (
653+ "Shelling\n\nChecking recent context\nFast mode enabled" ,
654+ "<b>Shelling</b>\nChecking recent context\nFast mode enabled" ,
566655 ) ,
567656 ) ;
657+ expect ( deliverReplies ) . not . toHaveBeenCalled ( ) ;
658+ } ) ;
659+
660+ it ( "keeps string tool-result progress beneath a Telegram preamble" , async ( ) => {
661+ const draftStream = createSequencedDraftStream ( 2001 ) ;
662+ createTelegramDraftStream . mockReturnValue ( draftStream ) ;
663+ dispatchReplyWithBufferedBlockDispatcher . mockImplementation ( async ( { replyOptions } ) => {
664+ await replyOptions ?. onReplyStart ?.( ) ;
665+ await replyOptions ?. onItemEvent ?.( {
666+ kind : "preamble" ,
667+ itemId : "preamble-1" ,
668+ progressText : "Checking recent context" ,
669+ } ) ;
670+ await replyOptions ?. onToolResult ?.( { text : "Background task still running" } ) ;
671+ return { queuedFinal : false } ;
672+ } ) ;
673+
674+ await dispatchWithContext ( {
675+ context : createContext ( ) ,
676+ streamMode : "progress" ,
677+ telegramCfg : {
678+ richMessages : true ,
679+ streaming : { mode : "progress" , progress : { label : "Shelling" } } ,
680+ } ,
681+ } ) ;
682+
683+ const preview = draftStream . updatePreview . mock . calls . at ( - 1 ) ?. [ 0 ] ;
684+ expect ( preview ?. text ) . toBe ( "Shelling\nChecking recent context\nBackground task still running" ) ;
685+ expect ( JSON . stringify ( preview ?. richMessage ) ) . toContain ( "Background task still running" ) ;
686+ expect ( deliverReplies ) . not . toHaveBeenCalled ( ) ;
568687 } ) ;
569688
570689 it ( "retracts the Telegram preamble headline by item identity" , async ( ) => {
0 commit comments