@@ -335,6 +335,10 @@ function publicTranscriptParts(event) {
335335 parts . push ( {
336336 role : "agent" ,
337337 text,
338+ // Issue #611:把产文本的那份 content 一起带出去。判定与文本同源,计量才能
339+ // 跟着同一份判定走(见 collectMessages 里的 imageCount)——另写一套「哪些块
340+ // 算公开」给计量用,就是第二份实现,迟早与这份漂移。
341+ blocks : Array . isArray ( message ?. content ) ? message . content : [ ] ,
338342 // 同一条子会话消息可能同时出现在 user/message 与 agent/inbox/spliced
339343 // 里(投递路径重叠),按 id(无 id 时按内容)去重,否则转录会重复。
340344 key : typeof message ?. id === "string" && message . id
@@ -348,7 +352,7 @@ function publicTranscriptParts(event) {
348352 const text = textOf ( data ?. content ) ;
349353 if ( ! text . trim ( ) ) break ;
350354 if ( SUBAGENT_MESSAGE_KINDS . has ( kind ) ) pushAgentMessage ( data ) ;
351- else parts . push ( { role : "user" , text } ) ;
355+ else parts . push ( { role : "user" , text, blocks : Array . isArray ( data ?. content ) ? data . content : [ ] } ) ;
352356 break ;
353357 }
354358 case "agent/inbox/spliced" : {
@@ -360,7 +364,7 @@ function publicTranscriptParts(event) {
360364 const blocks = Array . isArray ( data ?. message ?. content ) ? data . message . content : [ ] ;
361365 const text = textOf ( blocks ) ;
362366 // 私有推理块(reasoning)刻意不采集:蒸馏记忆不得沉淀模型私有思考链。
363- if ( text . trim ( ) ) parts . push ( { role : "assistant" , text } ) ;
367+ if ( text . trim ( ) ) parts . push ( { role : "assistant" , text, blocks } ) ;
364368 break ;
365369 }
366370 default :
@@ -421,23 +425,26 @@ function collectMessages(session, maxChars = 8000, language = "zh", afterSeq, th
421425 } ;
422426 for ( const event of events ) {
423427 const data = event ?. data ?? { } ;
424- // Issue #611 计量:只数公开正文里的图块(user 消息的 data.content、
425- // assistant 消息的 data.message.content 与子会话插入的消息体)。私有的
426- // reasoning 块里不会有 image,这里不额外分支。
427- imageCount += countImages ( data . content ) ;
428- imageCount += countImages ( data . message ?. content ) ;
429- if ( Array . isArray ( data . inserted ) ) {
430- for ( const message of data . inserted ) imageCount += countImages ( message ?. content ) ;
431- }
432428 // #399:用户提示 / 助手公开正文 / 子会话交付三种可公开内容由共享谓词产出,
433429 // 渲染与落盘因此不可能对「什么算公开」产生分歧(见 publicTranscriptParts)。
434430 for ( const part of publicTranscriptParts ( event ) ) {
435431 if ( part . role === "agent" ) {
436432 if ( part . key && seenSubagentMessages . has ( part . key ) ) continue ;
437433 if ( part . key ) seenSubagentMessages . add ( part . key ) ;
438- lines . push ( STR . transcriptAgent [ language ] ( part . text ) ) ;
439- } else if ( part . role === "user" ) {
434+ }
435+ // Issue #611 计量:数「真正进了转录的图块」,所以按 part 数、并且在去重之后
436+ // ——同一条子会话消息会同时出现在 user/message 与 agent/inbox/spliced 里
437+ // (投递路径重叠),按事件数会把它算两遍。
438+ //
439+ // 不按事件数还有个更要紧的理由:被 publicTranscriptParts 挡掉的注入消息
440+ // (工具结果、插件注入、陌生 source.kind)里的图根本进不了转录,按事件累加
441+ // 会报「这一窗有 2 张图」而转录里一张都没有。part 是渲染与落盘共用的同一份
442+ // 判定,计量跟着它走,两处不会再各有一套口径。
443+ imageCount += countImages ( part . blocks ) ;
444+ if ( part . role === "user" ) {
440445 lines . push ( STR . transcriptUser [ language ] ( part . text ) ) ;
446+ } else if ( part . role === "agent" ) {
447+ lines . push ( STR . transcriptAgent [ language ] ( part . text ) ) ;
441448 } else {
442449 lines . push ( STR . transcriptAssistant [ language ] ( part . text ) ) ;
443450 }
0 commit comments