Add debug logging for inventory live-update tracing + cache-bust fetch

Temporary instrumentation to diagnose why InventoryWindow doesn't refresh
on inventory_delta. Three log points:
- useLiveData: logs when inventory_delta arrives and version bump
- InventoryWindow effect: logs every run with state
- InventoryWindow fetch: logs when debounce fires and result count

Also added cache-buster (_t=timestamp) to the refetch URL in case HTTP
caching is masking fresh data.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Erik 2026-04-15 19:05:51 +02:00
parent d26f1f725c
commit 0ff396cd0e
15 changed files with 29 additions and 25 deletions

View file

@ -75,15 +75,14 @@ export function useLiveData(): DashboardState {
const r = msg as RareMessage;
setRecentRares(prev => [r, ...prev].slice(0, 50));
} else if (msg.type === 'inventory_delta') {
const d = msg as unknown as { character_name: string };
// Bump ONLY this character's inventory version so an open window for
// that character re-fetches. Deltas for other characters don't touch
// it, which keeps the 2s debounce in InventoryWindow from being reset
// forever by unrelated chatter.
const d = msg as unknown as { character_name: string; action?: string };
console.log('[INV_DEBUG] inventory_delta received', { char: d.character_name, action: d.action });
if (d.character_name) {
setInventoryVersions(prev => {
const next = new Map(prev);
next.set(d.character_name, (next.get(d.character_name) ?? 0) + 1);
const newVer = (next.get(d.character_name) ?? 0) + 1;
next.set(d.character_name, newVer);
console.log('[INV_DEBUG] bumped version', { char: d.character_name, newVer });
return next;
});
}