From 82899ebb4050c002e38a6fb86ed88dbe1e6b3427 Mon Sep 17 00:00:00 2001 From: andrepimenta Date: Tue, 2 Dec 2025 00:22:47 +0000 Subject: [PATCH] Handle conversation compacting with status messages and token reset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/extension.ts | 30 ++++++++++++++++++++++++++++++ src/script.ts | 18 +++++++++++++++++- src/ui-styles.ts | 1 + 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/extension.ts b/src/extension.ts index e8f92d0..aa79de3 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -693,6 +693,36 @@ class ClaudeChatProvider { mcpServers: jsonData.mcp_servers || [] } }); + } else if (jsonData.subtype === 'status') { + // Handle status changes (e.g., compacting) + if (jsonData.status === 'compacting') { + console.log('Conversation compacting started'); + this._sendAndSaveMessage({ + type: 'compacting', + data: { isCompacting: true } + }); + } else if (jsonData.status === null) { + console.log('Status cleared'); + this._sendAndSaveMessage({ + type: 'compacting', + data: { isCompacting: false } + }); + } + } else if (jsonData.subtype === 'compact_boundary') { + // Compact boundary - conversation was compacted, reset token counts + console.log('Compact boundary received', jsonData.compact_metadata); + + // Reset tokens since the conversation is now summarized + this._totalTokensInput = 0; + this._totalTokensOutput = 0; + + this._sendAndSaveMessage({ + type: 'compactBoundary', + data: { + trigger: jsonData.compact_metadata?.trigger, + preTokens: jsonData.compact_metadata?.pre_tokens + } + }); } break; diff --git a/src/script.ts b/src/script.ts index 3d5b069..cc8b56c 100644 --- a/src/script.ts +++ b/src/script.ts @@ -2192,7 +2192,23 @@ const getScript = (isTelemetryEnabled: boolean) => `