Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions public/js/conversations.js
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,7 @@ export async function openConversation(id) {

state.setCurrentConversationId(id);
state.deleteUnread(id);
state.resetCompressionPromptShown(); // Reset for fresh check in this conversation
// Clear any text from previous conversation
if (messageInput) messageInput.value = '';
setLoading(chatView, true);
Expand Down
17 changes: 15 additions & 2 deletions public/js/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,18 +446,31 @@ export function finalizeMessage(data) {
// Import dynamically to avoid circular dependency
import('./ui.js').then(ui => {
// Calculate cumulative tokens from all messages (since we resume sessions)
const { inputTokens, outputTokens } = ui.calculateCumulativeTokens(state.getAllMessages());
const allMessages = state.getAllMessages();
const { inputTokens, outputTokens } = ui.calculateCumulativeTokens(allMessages);
ui.updateContextBar(inputTokens, outputTokens, state.getCurrentModel());

// Check if context is near limit (85%) and show compression prompt
// But don't show if conversation was already compressed recently
const models = state.getModels();
const modelId = state.getCurrentModel();
const model = models.find(m => m.id === modelId);
const contextLimit = model ? model.context : 200000;
const totalTokens = inputTokens + outputTokens;
const pct = (totalTokens / contextLimit) * 100;

if (pct >= 85 && !state.getCompressionPromptShown()) {
// Check if conversation has been compressed
const hasCompression = allMessages.some(m => m.compressionMeta);

// Only show compression prompt if:
// 1. At 85%+ context
// 2. Haven't shown the prompt this session
// 3. Either never compressed OR at 95%+ (need to compress again urgently)
const shouldPrompt = pct >= 85 &&
!state.getCompressionPromptShown() &&
(!hasCompression || pct >= 95);

if (shouldPrompt) {
ui.showCompressionPrompt(pct, totalTokens, contextLimit);
}
});
Expand Down
2 changes: 1 addition & 1 deletion public/sw.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const CACHE_NAME = 'concierge-v126';
const CACHE_NAME = 'concierge-v127';
const STATIC_ASSETS = [
'/',
'/index.html',
Expand Down