Hey, I ran into a confusing bug while playing with the agent chat UI. I had a long conversation going (maybe 50–60 turns with some image attachments), and at some point new messages started "disappearing" — they'd render briefly, then on refresh the latest few would be gone.
After poking around, I think I found the cause in Frontend/js/agent-chat/store.js:18:
function writeAll(list) {
localStorage.setItem(STORAGE_KEY, JSON.stringify(list));
}
When localStorage.setItem exceeds the per-origin quota (usually 5MB or 10MB depending on browser), it throws a QuotaExceededError. Since there's no try/catch around the call, the exception bubbles up — but in the React render path it may be caught and silently logged somewhere harmless. The result is that the in-memory state has the new message but the persisted state doesn't, so a refresh "loses" it.
A few things would help here:
- Wrap
setItem in a try/catch and on quota errors, prune the oldest N messages and retry.
- Surface a user-visible warning ("conversation getting long, oldest messages may be dropped").
- Consider switching to IndexedDB for the chat history — it has a much larger quota and proper async semantics.
Happy to take a stab at (1) and (2) if maintainers agree. Not sure about appetite for (3).
Reproduction: open the chat UI, send messages with large image attachments until you hit ~5MB of serialized JSON.
Hey, I ran into a confusing bug while playing with the agent chat UI. I had a long conversation going (maybe 50–60 turns with some image attachments), and at some point new messages started "disappearing" — they'd render briefly, then on refresh the latest few would be gone.
After poking around, I think I found the cause in
Frontend/js/agent-chat/store.js:18:When
localStorage.setItemexceeds the per-origin quota (usually 5MB or 10MB depending on browser), it throws aQuotaExceededError. Since there's no try/catch around the call, the exception bubbles up — but in the React render path it may be caught and silently logged somewhere harmless. The result is that the in-memory state has the new message but the persisted state doesn't, so a refresh "loses" it.A few things would help here:
setItemin a try/catch and on quota errors, prune the oldest N messages and retry.Happy to take a stab at (1) and (2) if maintainers agree. Not sure about appetite for (3).
Reproduction: open the chat UI, send messages with large image attachments until you hit ~5MB of serialized JSON.