mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-06-06 10:41:21 +02:00
fix: add critical encrypted content cache diagnostics
Add comprehensive logging to trace JSON parse errors: 1. **EncryptedContentStorage logging**: - Log all getItem calls showing what's retrieved from IndexedDB - Log all setItem calls showing what's being stored - Shows first 100 chars of plaintext to identify corruption 2. **Gift wrap unlock state tracking**: - Count events with applesauce symbols attached - Count events found in persistedIds cache - Distinguish between symbol-based vs cache-based unlocking - Format: 'N unlocked (X symbols, Y cached), Z pending' This will reveal if: - Wrong data is being stored in IndexedDB (test strings instead of JSON) - Timing issues where symbols aren't attached yet - Cache not being properly populated from IndexedDB
This commit is contained in:
@@ -453,10 +453,22 @@ export const relayLivenessStorage = {
|
||||
export const encryptedContentStorage = {
|
||||
async getItem(id: string): Promise<string | null> {
|
||||
const entry = await db.encryptedContent.get(id);
|
||||
return entry?.plaintext ?? null;
|
||||
const plaintext = entry?.plaintext ?? null;
|
||||
|
||||
if (plaintext) {
|
||||
console.log(
|
||||
`[EncryptedContentStorage] getItem(${id.slice(0, 8)}): ${plaintext.slice(0, 100)}...`,
|
||||
);
|
||||
}
|
||||
|
||||
return plaintext;
|
||||
},
|
||||
|
||||
async setItem(id: string, plaintext: string): Promise<void> {
|
||||
console.log(
|
||||
`[EncryptedContentStorage] setItem(${id.slice(0, 8)}): ${plaintext.slice(0, 100)}...`,
|
||||
);
|
||||
|
||||
await db.encryptedContent.put({
|
||||
id,
|
||||
plaintext,
|
||||
|
||||
@@ -799,12 +799,18 @@ class GiftWrapService {
|
||||
// Update decrypt states for new gift wraps
|
||||
let newUnlocked = 0;
|
||||
let newPending = 0;
|
||||
let hasSymbolCount = 0;
|
||||
let hasPersistedCount = 0;
|
||||
|
||||
for (const gw of giftWraps) {
|
||||
if (!this.decryptStates.has(gw.id)) {
|
||||
const hasSymbol = isGiftWrapUnlocked(gw);
|
||||
const hasPersisted = this.persistedIds.has(gw.id);
|
||||
const isUnlocked = hasSymbol || hasPersisted;
|
||||
|
||||
if (hasSymbol) hasSymbolCount++;
|
||||
if (hasPersisted) hasPersistedCount++;
|
||||
|
||||
if (isUnlocked) {
|
||||
newUnlocked++;
|
||||
} else {
|
||||
@@ -840,7 +846,7 @@ class GiftWrapService {
|
||||
|
||||
dmInfo(
|
||||
"GiftWrap",
|
||||
`Decrypt states: ${newUnlocked} unlocked, ${newPending} pending (total: ${this.decryptStates.size})`,
|
||||
`Decrypt states: ${newUnlocked} unlocked (${hasSymbolCount} symbols, ${hasPersistedCount} cached), ${newPending} pending (total: ${this.decryptStates.size})`,
|
||||
);
|
||||
|
||||
this.decryptStates$.next(new Map(this.decryptStates));
|
||||
|
||||
Reference in New Issue
Block a user