feat: preserve messages after compaction (IndexedDB cache) + show agent name in header

- Add IndexedDB message cache to retain pre-compaction history locally
- Show compaction separator with amber styling when messages are compacted
- Archived messages render at 60% opacity above the separator
- Display agent name (from gateway identity) in header instead of 'PinchChat' when available
- Fallback to 'PinchChat' when no agent name is configured
- Add i18n keys for compaction separator (EN/FR)

Closes #72, #69
This commit is contained in:
Nicolas Varrot
2026-02-14 14:25:41 +00:00
parent a83be24192
commit 70d29dc70e
7 changed files with 153 additions and 5 deletions

View File

@@ -3,6 +3,7 @@ import { GatewayClient, type JsonPayload } from '../lib/gateway';
import { genIdempotencyKey } from '../lib/utils';
import { getStoredCredentials, storeCredentials, clearCredentials } from '../lib/credentials';
import { isSystemEvent } from '../lib/systemEvent';
import { getCachedMessages, setCachedMessages, mergeWithCache } from '../lib/messageCache';
import type { ChatMessage, MessageBlock, ConnectionStatus, Session, AgentIdentity } from '../types';
interface ChatPayloadMessage {
@@ -249,7 +250,19 @@ export function useGateway() {
}
}
}
setMessages(merged);
// Merge with cached messages to preserve pre-compaction history
const cached = await getCachedMessages(sessionKey);
const { messages: finalMessages, wasCompacted } = mergeWithCache(merged, cached);
if (wasCompacted) {
// Store the full merged set so future loads keep the archive
setCachedMessages(sessionKey, finalMessages.filter(m => !m.isCompactionSeparator));
} else {
// No compaction — update cache with latest gateway messages
setCachedMessages(sessionKey, merged);
}
setMessages(finalMessages);
}
} catch {
// Silently ignore history load failures