mirror of
https://github.com/andrepimenta/claude-code-chat.git
synced 2025-12-12 13:19:47 +00:00
Handle conversation compacting with status messages and token reset
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -693,6 +693,36 @@ class ClaudeChatProvider {
|
|||||||
mcpServers: jsonData.mcp_servers || []
|
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;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -2193,6 +2193,22 @@ const getScript = (isTelemetryEnabled: boolean) => `<script>
|
|||||||
updateStatusWithTotals();
|
updateStatusWithTotals();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'compacting':
|
||||||
|
if (message.data.isCompacting) {
|
||||||
|
addMessage('📦 Compacting conversation...', 'system');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'compactBoundary':
|
||||||
|
// Reset token counts since conversation was compacted
|
||||||
|
totalTokensInput = 0;
|
||||||
|
totalTokensOutput = 0;
|
||||||
|
updateStatusWithTotals();
|
||||||
|
|
||||||
|
const preTokens = message.data.preTokens ? message.data.preTokens.toLocaleString() : 'unknown';
|
||||||
|
addMessage('✅ Compacted (' + preTokens + ' tokens → summary)', 'system');
|
||||||
|
break;
|
||||||
|
|
||||||
case 'loginRequired':
|
case 'loginRequired':
|
||||||
sendStats('Login required');
|
sendStats('Login required');
|
||||||
addMessage('🔐 Login Required\\n\\nYour Claude API key is invalid or expired.\\nA terminal has been opened - please run the login process there.\\n\\nAfter logging in, come back to this chat to continue.', 'error');
|
addMessage('🔐 Login Required\\n\\nYour Claude API key is invalid or expired.\\nA terminal has been opened - please run the login process there.\\n\\nAfter logging in, come back to this chat to continue.', 'error');
|
||||||
|
|||||||
@@ -2980,6 +2980,7 @@ const styles = `
|
|||||||
transform: scale(1.2) rotate(315deg);
|
transform: scale(1.2) rotate(315deg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>`
|
</style>`
|
||||||
|
|
||||||
export default styles
|
export default styles
|
||||||
Reference in New Issue
Block a user