You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Lost your chat history after upgrading to LocalAI 4.12.x? Here's a fix.
#13022
After upgrading LocalAI to 4.12.x, my chat history disappeared from the web UI. It turns out the chats were never actually lost: they're stored in the browser's localStorage, and after the update a second key appeared — localai_chats_data: — alongside the original localai_chats_data. The new UI reads/writes the suffixed key, while all my old conversations remained in the original one.
Here's a small script that merges both keys (deduplicating by chat id) instead of overwriting either one. Run it in the browser console (F12 → Console) on the LocalAI page, then reload with F5:
{
// 1. Find all localStorage keys that hold LocalAI chat data
// (plain "localai_chats_data" plus any "localai_chats_data:<suffix>" variant)
const keys = Object.keys(localStorage).filter(k => k.startsWith('localai_chats_data'));
console.log('Keys found:', keys);
// 2. Identify the suffixed key (the one the current UI is actively using)
const suffixedKey = keys.find(k => k !== 'localai_chats_data');
const rawA = localStorage.getItem('localai_chats_data');
const rawB = localStorage.getItem(suffixedKey);
// Safety backup: copy these outputs to a text file BEFORE the write below!
console.log('BACKUP A:', rawA);
console.log('BACKUP B:', rawB);
// 3. Parse both payloads and merge the chats, deduplicating by chat id
const a = JSON.parse(rawA);
const b = JSON.parse(rawB);
const byId = new Map();
[...(a?.chats || []), ...(b?.chats || [])].forEach(c => byId.set(c.id, c));
const merged = {
chats: [...byId.values()],
// Keep the activeChatId of the most recent key if it still exists
activeChatId: byId.has(b?.activeChatId) ? b.activeChatId
: (byId.has(a?.activeChatId) ? a.activeChatId : null),
lastSaved: Date.now()
};
// 4. Write the merged payload into the active (suffixed) key
localStorage.setItem(suffixedKey, JSON.stringify(merged));
console.log('Merge complete:', merged.chats.length, 'total chats');
}
Notes: the script prints both payloads as BACKUP A/BACKUP B to the console — save them to a file before reloading for rollback. The old key is left untouched. Since chat history lives in localStorage, it's also bound to the exact origin: localhost:8080 and 127.0.0.1:8080 are different origins, so check that you're accessing LocalAI from the same URL you used before the upgrade.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
After upgrading LocalAI to 4.12.x, my chat history disappeared from the web UI. It turns out the chats were never actually lost: they're stored in the browser's localStorage, and after the update a second key appeared — localai_chats_data: — alongside the original localai_chats_data. The new UI reads/writes the suffixed key, while all my old conversations remained in the original one.
Here's a small script that merges both keys (deduplicating by chat id) instead of overwriting either one. Run it in the browser console (F12 → Console) on the LocalAI page, then reload with F5:
Notes: the script prints both payloads as BACKUP A/BACKUP B to the console — save them to a file before reloading for rollback. The old key is left untouched. Since chat history lives in localStorage, it's also bound to the exact origin: localhost:8080 and 127.0.0.1:8080 are different origins, so check that you're accessing LocalAI from the same URL you used before the upgrade.
All reactions