{"record":{"id":"f1b62804f13693d7","repo":"can1357/oh-my-pi","slug":"selected-sourcename-session-is-no-longer-availa-f1b628","errorCode":null,"errorMessage":"Selected ${sourceName} session is no longer available","messagePattern":"Selected (.+?) session is no longer available","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/modes/controllers/selector-controller.ts","lineNumber":1600,"sourceCode":"\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (foreignSessions.length === 0) {\n\t\t\t\tthis.ctx.showWarning(`No ${sourceName} sessions found`);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst foreignByPath = new Map(foreignSessions.map(session => [session.path, session]));\n\t\t\tsessions = foreignSessions.map(foreignSessionInfoToSessionInfo);\n\t\t\tonSelectSession = async session => {\n\t\t\t\ttry {\n\t\t\t\t\tawait this.ctx.settings.flush();\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthis.ctx.showError(\n\t\t\t\t\t\t`Failed to save pending settings: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\t\t);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tconst foreignSession = foreignByPath.get(session.path);\n\t\t\t\tif (!foreignSession) throw new Error(`Selected ${sourceName} session is no longer available`);\n\t\t\t\tconst imported = await persistForeignSession(store, foreignSession, {\n\t\t\t\t\tfallbackCwd: this.ctx.sessionManager.getCwd(),\n\t\t\t\t\tsuppressBreadcrumb: true,\n\t\t\t\t});\n\t\t\t\tconst sessionFile = imported.getSessionFile();\n\t\t\t\tif (!sessionFile) throw new Error(`Failed to persist ${sourceName} session`);\n\t\t\t\tawait imported.close();\n\t\t\t\treturn await this.handleResumeSession(sessionFile, { settingsFlushed: true });\n\t\t\t};\n\t\t\tselectorOptions = {\n\t\t\t\ttitle: `Import ${sourceName} Session`,\n\t\t\t\tscopeLabel: false,\n\t\t\t\tshowCwd: true,\n\t\t\t};\n\t\t} else {\n\t\t\tconst [loadedSessions, pinnedIds] = await Promise.all([\n\t\t\t\tSessionManager.list(this.ctx.sessionManager.getCwd(), this.ctx.sessionManager.getSessionDir()),\n\t\t\t\tloadPinnedSessionIds(),","sourceCodeStart":1582,"sourceCodeEnd":1618,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/modes/controllers/selector-controller.ts#L1582-L1618","documentation":"Thrown inside the foreign-session import callback of SelectorController.showSessionSelector. The selector lists sessions from an external source (e.g. Claude Code or another tool's session store); when the user picks one, the callback looks the session up by path in the foreignByPath map built from the earlier listing. If the path is not found — the listed data and the lookup diverged — it means the selected session record vanished from the source between listing and selection.","triggerScenarios":"Selecting a session in the 'Import <source> Session' selector whose path no longer resolves in the foreignByPath map — the foreign session was deleted/moved after the list was rendered, or the SessionInfo mapping lost the original path so the reverse lookup misses.","commonSituations":"The foreign tool (e.g. Claude Code) deleted or rotated its session files while the OMP selector was open; a sync process (iCloud/Dropbox) moved the sessions directory mid-selection; a mapping bug where foreignSessionInfoToSessionInfo produced a path that no longer matches the store keys.","solutions":["Reopen the session selector (retry the import) so the list is refreshed from the current state of the foreign store.","Verify the session file still exists in the source tool's sessions directory; if it was deleted there, it cannot be imported.","Check for sync/moving directories (cloud folder syncing) that relocate session files while OMP is open; pause syncing or point at a stable local path.","If it reproduces deterministically for every session, the path mapping between the selector entries and the foreign store is broken — report it with the source name shown in the selector title."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Re-list from the foreign store right before importing to confirm the session still exists\nconst still = (await store.list()).find(s => s.path === selectedPath);\nif (!still) console.warn(`Foreign session ${selectedPath} disappeared; refresh the selector before importing.`);","typeGuard":"function isForeignSessionGone(err: unknown): err is Error {\n  return err instanceof Error && /is no longer available$/.test(err.message);\n}","tryCatchPattern":"try {\n  await importForeignSession(source, sessionPath);\n} catch (err) {\n  if (isForeignSessionGone(err)) {\n    showWarning(\"That session disappeared from the source — reopening the selector to refresh the list.\");\n    await reopenSessionSelector(source);\n  } else throw err;\n}","preventionTips":["Don't leave the session selector open indefinitely — reopen it if it has been idle while other tools may have modified sessions.","Avoid deleting or moving foreign session files (e.g. Claude Code sessions) while the import selector is open.","Pause cloud-sync services on the sessions directory during imports.","Retry the import once — the error is a list/lookup race that a fresh listing normally resolves."],"tags":["sessions","import","race","selector"],"backgroundTag":"session-not-found","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}