Playground history not loading

I cannot load playground history. I am seeing the following errors in the console.

Your playground history is corrupted.

If you care about it we can fix this (hopefully) pretty easy by destroying the corrupted entries.

First we can try to identify them. Use this code:

const history = JSON.parse(localStorage.getItem(Object.keys(localStorage).filter(k => k.includes("/chat-history/data"))[0]));
const tests = [];
const allHaveMessagesPanel = history.every(c => 
  c.state.panels.some(p => 'messages' in p)
);
tests.push(allHaveMessagesPanel);

const allMessagesHaveContent = history.every(c => 
  c.state.panels.some(p => 
    p.messages.every(m => 'content' in m)
  )
);
tests.push(allMessagesHaveContent);

tests;

Your error message is indicating that your missing the expected message object to place content inside of i.

Using this test (if it passes you’ll see)
Array [ true, true ]

BUT, if the issue is caught it should either throw an error, or show a false value. Which if you paste here we can remediate the issue and fix your history so you don’t lose it.

Also. I wonder, do you have a very long history? OpenAI brutally stuffs the localStorage which can lead to some strange issues like the playground crashing or conversation becoming corrupted if it gets too long.

In that case I would highly recommend saving the conversation locally and then deleting it on the platform so you don’t experience this issues.

2 Likes

Thank you for the reply.

It passed. I got Array [ true, true ].

About a week ago, I was in playground screen flashed and all of the history was gone.

I am seeing this now as well.

Brutal. I was hoping it was an easy fix.

Maybe someone else can chime in. For now if you just want to use the playground you can empty your storage and that should clear things up.

First, you can save your current history to your PC so you don’t lose anything.
(ChatGPT wrote this but it should work fine)

const history = localStorage.getItem(Object.keys(localStorage).filter(k => k.includes("/chat-history/data"))[0]);

// Create a Blob object from the JSON string
const blob = new Blob([history], { type: 'application/json' });

// Create a temporary link element
const link = document.createElement('a');

// Set the download attribute with a filename
link.download = 'data.json';

// Create an object URL for the Blob and set it as the href attribute
link.href = window.URL.createObjectURL(blob);

// Append the link to the document body (required for Firefox)
document.body.appendChild(link);

// Programmatically click the link to trigger the download
link.click();

// Remove the link from the document
document.body.removeChild(link);

THis should cause a download to happen. It’s a JSON representation of your history.

Then, you can write this (Warning: this will completely delete all your history and settings)

localStorage.clear()

The [object Object] error is low key kind of hilarious. Writing the clear function and then refreshing should solve your issues. You may need to login again.

1 Like