{"record":{"id":"22c8dc4d158c6b5e","repo":"tonhowtf/omniget","slug":"reopen-failed","errorCode":null,"errorMessage":"reopen failed","messagePattern":"reopen failed","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/lib/study-notes/notebooks-store.svelte.ts","lineNumber":141,"sourceCode":"\n  async close(notebookId: number) {\n    try {\n      await notesNotebooksClose(notebookId);\n      if (this.activeId === notebookId) {\n        await this.setActive(1);\n      }\n      await this.refresh();\n    } catch (e) {\n      console.warn(\"close failed\", e);\n    }\n  }\n\n  async reopen(notebookId: number) {\n    try {\n      await notesNotebooksReopen(notebookId);\n      await this.refresh();\n    } catch (e) {\n      console.warn(\"reopen failed\", e);\n    }\n  }\n\n  async delete(notebookId: number, force = false): Promise<NotebookDeleteReport> {\n    try {\n      const r = await notesNotebooksDelete({ notebookId, force });\n      if (r.deleted && this.activeId === notebookId) {\n        await this.setActive(1);\n      }\n      await this.refresh();\n      return r;\n    } catch (e) {\n      console.warn(\"delete failed\", e);\n      return { deleted: false, page_count: 0 };\n    }\n  }\n\n  async movePage(args: {","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src/lib/study-notes/notebooks-store.svelte.ts#L123-L159","documentation":"notebooksStore.reopen() reopens a closed notebook via notesNotebooksReopen (Tauri command 'study:notes:notebooks:reopen') then refresh(). On rejection the catch logs 'reopen failed' and the notebook stays in the closed list with no user-visible error.","triggerScenarios":"notesNotebooksReopen(notebookId) rejects: the notebook is not in a closed state (backend state validation), the notebook was deleted, DB write failure, plugin/capability misconfiguration, or IPC failure.","commonSituations":"Reopening a notebook that was hard-deleted in another session; double-click producing a second reopen of an already-open notebook; backend rejects because reopen is only valid for closed entities; DB locked; command not present in the installed backend version.","solutions":["Read the logged rejection reason from notesNotebooksReopen.","Verify the notebook is actually closed (check this.list) before calling reopen; skip the call if already open.","Confirm 'study:notes:notebooks:reopen' exists and is permitted in capabilities.","Handle 'already open' / 'not found' backend errors as non-fatal and just refresh().","Retry once on transient IPC failures and surface a toast if it still fails."],"exampleFix":"// before\nawait notesNotebooksReopen(notebookId);\n// after\nconst nb = this.list.find((n) => n.id === notebookId);\nif (nb && nb.closed) {\n  await notesNotebooksReopen(notebookId);\n}\nawait this.refresh();","handlingStrategy":"validation","validationCode":"const nb = notebooksStore.list.find((n) => n.id === notebookId);\nif (!nb) { showToast('Notebook no longer exists'); return; }\nif (!nb.closed) return; // already open, nothing to do","typeGuard":"function isReopenable(nb: Notebook | undefined): nb is Notebook {\n  return !!nb && nb.closed === true;\n}","tryCatchPattern":"try {\n  await notebooksStore.reopen(notebookId);\n} catch (e) {\n  console.warn('reopen rejected:', e);\n  await notebooksStore.refresh(); // re-sync real closed/open state\n  showToast('Reopen failed — state refreshed');\n}","preventionTips":["Only call reopen for notebooks currently marked closed","Treat 'already open' or 'not found' backend errors as benign and refresh","Refresh after failure so the closed-list stays accurate","Handle double-click/debounce on reopen buttons","Verify the reopen command exists in the deployed backend version"],"tags":["svelte","tauri","ipc","state-transition","error-handling"],"backgroundTag":"invalid-state-transition","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}