The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
fix(mobile): the restore at the start counts only a chat store it can read
purple6cc5bd094188
diff --git a/src/mobile/boot/__tests__/restore-document-journal.test.ts b/src/mobile/boot/__tests__/restore-document-journal.test.tsindex 945d494e..7dc955d7 100644--- a/src/mobile/boot/__tests__/restore-document-journal.test.ts+++ b/src/mobile/boot/__tests__/restore-document-journal.test.ts@@ -33,6 +33,7 @@ vi.mock('../../policy/decision-vault', () => ({}))vi.mock('../../../lib/idbStorage', () => ({hasStoredItem: async () => true,+ hasReadableItem: async () => true,hasFailedRead: () => false,onIdbWrite: () => () => {},idbStorage: { getItem: async () => 'present', setItem: async () => {}, removeItem: async () => {} },diff --git a/src/mobile/boot/__tests__/restore-document-list.test.ts b/src/mobile/boot/__tests__/restore-document-list.test.tsindex 0a2a5c8f..68abb7c4 100644--- a/src/mobile/boot/__tests__/restore-document-list.test.ts+++ b/src/mobile/boot/__tests__/restore-document-list.test.ts@@ -32,6 +32,7 @@ vi.mock('../../policy/decision-vault', () => ({}))vi.mock('../../../lib/idbStorage', () => ({hasStoredItem: async () => true,+ hasReadableItem: async () => true,hasFailedRead: () => false,onIdbWrite: () => () => {},idbStorage: { getItem: async () => 'present', setItem: async () => {}, removeItem: async () => {} },diff --git a/src/mobile/boot/__tests__/restore-documents.test.ts b/src/mobile/boot/__tests__/restore-documents.test.tsindex 3cfed599..8e17acbe 100644--- a/src/mobile/boot/__tests__/restore-documents.test.ts+++ b/src/mobile/boot/__tests__/restore-documents.test.ts@@ -23,6 +23,7 @@ vi.mock('../../../api/backend', () => ({}))vi.mock('../../../lib/idbStorage', () => ({hasStoredItem: async () => true,+ hasReadableItem: async () => true,hasFailedRead: () => false,onIdbWrite: () => () => {},idbStorage: { getItem: async () => 'present', setItem: async () => {}, removeItem: async () => {} },diff --git a/src/mobile/boot/__tests__/restore-full-merge.test.ts b/src/mobile/boot/__tests__/restore-full-merge.test.tsindex a87e8c1d..f71c24de 100644--- a/src/mobile/boot/__tests__/restore-full-merge.test.ts+++ b/src/mobile/boot/__tests__/restore-full-merge.test.ts@@ -28,6 +28,7 @@ vi.mock('../../../api/backend', () => ({}))vi.mock('../../../lib/idbStorage', () => ({hasStoredItem: async (key: string) => world.idb.has(key),+ hasReadableItem: async (key: string) => world.idb.has(key),hasFailedRead: () => false,onIdbWrite: () => () => {},idbStorage: {diff --git a/src/mobile/boot/__tests__/restore-unreadable-row.test.ts b/src/mobile/boot/__tests__/restore-unreadable-row.test.tsnew file mode 100644index 00000000..b4dabe1c--- /dev/null+++ b/src/mobile/boot/__tests__/restore-unreadable-row.test.ts@@ -0,0 +1,65 @@+// @vitest-environment jsdom+/**+ * C46 (3.1.0): the gap of the desktop before 3.0.10, on the phone.+ *+ * perrt, 05.11.2026: the chat row in IndexedDB came back as something+ * hydration cannot read (no string, or a leftover "[object Object]" in+ * localStorage). `hasStoredItem` counts such a row as there, so the quiet+ * repair at the start believed the chats were present and put nothing back,+ * while the chat store hydrated empty. The next backup then wrote the empty+ * list over the only good copy.+ *+ * The quiet repair asks `hasReadableItem` now: present means a value+ * hydration can read.+ */+import { beforeEach, describe, expect, it, vi } from 'vitest'++const idb = vi.hoisted(() => ({ writes: [] as string[] }))++vi.mock('../../../api/backend', () => ({+ isTauri: () => true,+ backendCall: async (cmd: string) => {+ if (cmd === 'restore_stores') {+ const chats = JSON.stringify({ state: { conversations: [{ id: 'from-backup', messages: [] }] } })+ return JSON.stringify({ 'chat-conversations': chats })+ }+ return null+ },+}))+vi.mock('../../../lib/idbStorage', () => ({+ // The row of the chat store is there for count(), but it is no string: getItem hands hydration null.+ hasStoredItem: async (key: string) => key === 'chat-conversations',+ hasReadableItem: async () => false,+ hasFailedRead: () => false,+ onIdbWrite: () => () => {},+ idbStorage: {+ getItem: async () => null,+ setItem: async (key: string) => {+ idb.writes.push(key)+ },+ removeItem: async () => {},+ },+}))+vi.mock('../../../lib/chat-backup-recovery', () => ({ recoverChatsFromBackup: async () => {} }))+vi.mock('../../../stores/chatStore', () => ({+ useChatStore: { persist: { hasHydrated: () => true, onFinishHydration: () => {} }, getState: () => ({ conversations: [], importConversations: () => {} }) },+}))+vi.mock('../../../lib/ragDB', () => ({ exportAllChunks: async () => ({}), importAllChunks: async () => {} }))++beforeEach(() => {+ vi.resetModules()+ idb.writes = []+ localStorage.clear()+ sessionStorage.clear()+ localStorage.setItem('chat-settings', '{"state":{}}')+ Object.defineProperty(window, 'location', { value: { ...window.location, reload: vi.fn() }, configurable: true })+})++describe('the quiet repair at the start, with a chat row hydration cannot read', () => {+ it('puts the chats of the backup back instead of taking the row for chats', async () => {+ const { runStoreRestore, restoreDecided } = await import('../restore')+ await runStoreRestore()+ await restoreDecided+ expect(idb.writes).toContain('chat-conversations')+ })+})diff --git a/src/mobile/boot/__tests__/restore-unreadable.test.ts b/src/mobile/boot/__tests__/restore-unreadable.test.tsindex b46bf867..17980ae8 100644--- a/src/mobile/boot/__tests__/restore-unreadable.test.ts+++ b/src/mobile/boot/__tests__/restore-unreadable.test.ts@@ -29,6 +29,7 @@ vi.mock('../../../api/backend', () => ({vi.mock('../../../lib/idbStorage', () => ({// null: IndexedDB could not be asked.hasStoredItem: async () => (idb.unreadable ? null : false),+ hasReadableItem: async () => (idb.unreadable ? null : false),hasFailedRead: () => idb.unreadable,onIdbWrite: () => () => {},idbStorage: {diff --git a/src/mobile/boot/restore.ts b/src/mobile/boot/restore.tsindex 6a2a0757..94988eeb 100644--- a/src/mobile/boot/restore.ts+++ b/src/mobile/boot/restore.ts@@ -21,7 +21,7 @@import { backendCall, isTauri } from '../../api/backend'import { recoverChatsFromBackup } from '../../lib/chat-backup-recovery'import { idbKeysToRestore, mayReloadForIdbRestore, mergeIdbStoreValue } from '../../lib/idb-restore'-import { hasFailedRead, hasStoredItem, idbStorage } from '../../lib/idbStorage'+import { hasFailedRead, hasReadableItem, idbStorage } from '../../lib/idbStorage'import { log } from '../../lib/logger'import { IDB_STORE_KEYS, STORE_KEYS } from '../../lib/store-backup'import { useChatStore } from '../../stores/chatStore'@@ -114,7 +114,10 @@ async function quietRepair(): Promise<boolean> {try {const live: Record<string, string | null> = {}for (const key of IDB_STORE_KEYS) {- const present = await hasStoredItem(key)+ // Present means a value hydration can read, not a row count() sees: a row that is no string, or a+ // leftover "[object Object]" in localStorage, hydrated the chat store empty while the old check+ // (hasStoredItem) took it for chats and put nothing back (perrt on the desktop, 05.11.2026; C46).+ const present = await hasReadableItem(key)live[key] = present === true ? 'present' : present === false ? null : await Promise.resolve(idbStorage.getItem(key)).catch(() => null)// Not readable is not empty. With a full phone IndexedDB cannot be opened at all, every key// looked empty here, and the backup was "restored" over stores that were all still there@@ -235,7 +238,7 @@ async function quietRepair(): Promise<boolean> {* Not readable: left alone, like the quiet repair does (F11).*/async function restoreIdbStore(key: string, saved: string): Promise<boolean> {- const present = await hasStoredItem(key)+ const present = await hasReadableItem(key)if (present === null || hasFailedRead(key)) return falseif (!present) {await Promise.resolve(idbStorage.setItem(key, saved))