11import type { Logger } from "../logger"
2- import type { SessionState , WithParts } from "../state"
2+ import type { SessionState } from "../state"
33import {
44 formatPrunedItemsList ,
55 formatProgressBar ,
99import { ToolParameterEntry } from "../state"
1010import { PluginConfig } from "../config"
1111import { getActiveSummaryTokenUsage } from "../state/utils"
12- import { isMessageCompacted } from "../shared-utils"
1312
1413export type PruneReason = "completion" | "noise" | "extraction"
1514export const PRUNE_REASON_LABELS : Record < PruneReason , string > = {
@@ -170,8 +169,7 @@ export async function sendCompressNotification(
170169 sessionId : string ,
171170 entries : CompressionNotificationEntry [ ] ,
172171 batchTopic : string | undefined ,
173- totalSessionTokens : number ,
174- sessionMessages : WithParts [ ] ,
172+ sessionMessageIds : string [ ] ,
175173 params : any ,
176174) : Promise < boolean > {
177175 if ( config . pruneNotification === "off" ) {
@@ -249,12 +247,10 @@ export async function sendCompressNotification(
249247
250248 const pruneTokenCounterStr = `~${ formatTokenCount ( compressedTokens ) } `
251249
252- const sessionMessageIds = sessionMessages . map ( ( msg ) => msg . info . id )
253250 const activePrunedMessages = new Map < string , number > ( )
254- for ( const msg of sessionMessages ) {
255- if ( isMessageCompacted ( state , msg ) ) {
256- const pruneEntry = state . prune . messages . byMessageId . get ( msg . info . id )
257- activePrunedMessages . set ( msg . info . id , pruneEntry ?. tokenCount ?? 0 )
251+ for ( const [ messageId , entry ] of state . prune . messages . byMessageId ) {
252+ if ( entry . activeBlockIds . length > 0 ) {
253+ activePrunedMessages . set ( messageId , entry . tokenCount )
258254 }
259255 }
260256 const progressBar = formatProgressBar (
@@ -263,11 +259,8 @@ export async function sendCompressNotification(
263259 newlyCompressedMessageIds ,
264260 70 ,
265261 )
266- const reduction =
267- totalSessionTokens > 0 ? Math . round ( ( compressedTokens / totalSessionTokens ) * 100 ) : 0
268-
269262 message += `\n\n${ progressBar } `
270- message += `\n▣ ${ compressionLabel } (${ pruneTokenCounterStr } removed, ${ reduction } % reduction, ~${ formatTokenCount ( summaryTokens , true ) } summary tokens added)`
263+ message += `\n▣ ${ compressionLabel } (${ pruneTokenCounterStr } removed, ~${ formatTokenCount ( summaryTokens , true ) } summary tokens added)`
271264 message += `\n→ Topic: ${ topic } `
272265 message += `\n→ Items: ${ newlyCompressedMessageIds . length } messages`
273266 if ( newlyCompressedToolIds . length > 0 ) {
0 commit comments