{"record":{"id":"ca6f4116dae68786","repo":"can1357/oh-my-pi","slug":"selected-sourcename-session-is-no-longer-availa","errorCode":null,"errorMessage":"Selected ${sourceName} session is no longer available","messagePattern":"Selected (.+?) session is no longer available","errorType":"exception","errorClass":"SessionResolutionError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/main.ts","lineNumber":1663,"sourceCode":"\t\t\t\t\t\t\tshowCwd: true,\n\t\t\t\t\t\t\tallowDelete: false,\n\t\t\t\t\t\t\tallowGlobalScope: false,\n\t\t\t\t\t\t\thistorySearch: false,\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\t\t\t\t} finally {\n\t\t\t\t\tresumeStartupWatchdog();\n\t\t\t\t}\n\t\t\t\tif (!selected) {\n\t\t\t\t\twriteStartupNotice(parsedArgs, `${chalk.dim(`No ${sourceName} session selected`)}\\n`);\n\t\t\t\t\tstopStartupWatchdog();\n\t\t\t\t\tprocess.exit(0);\n\t\t\t\t}\n\t\t\t\tconst foreignSession = foreignSessions.find(\n\t\t\t\t\tsession => session.id === selected.id && session.path === selected.path,\n\t\t\t\t);\n\t\t\t\tif (!foreignSession) {\n\t\t\t\t\tthrow new SessionResolutionError(`Selected ${sourceName} session is no longer available`);\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tsessionManager = await logger.time(\n\t\t\t\t\t\t`import${sourceName}Session`,\n\t\t\t\t\t\tpersistForeignSession,\n\t\t\t\t\t\tstore,\n\t\t\t\t\t\tforeignSession,\n\t\t\t\t\t\t{ fallbackCwd: cwd, sessionDir: parsedArgs.sessionDir },\n\t\t\t\t\t);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\t\tthrow new SessionResolutionError(`Failed to import ${sourceName} session: ${message}`);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tsessionManager = await logger.time(\n\t\t\t\t\t\"createSessionManager\",\n\t\t\t\t\tcreateSessionManager,\n\t\t\t\t\tparsedArgs,","sourceCodeStart":1645,"sourceCodeEnd":1681,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/main.ts#L1645-L1681","documentation":"After listing, main.ts looks up the session matching the user's selection by both `id` and `path` in the just-fetched list. If no entry matches (the stored selection is stale), it throws this `SessionResolutionError`. The session you picked was deleted or altered between listing and matching, or selection state refers to an old path.","triggerScenarios":"`--from-<source>` with a previously saved/selected session whose `id` or `path` no longer appears in the freshly listed foreign sessions — typically the foreign session was deleted, or its project directory moved so `path` changed.","commonSituations":"The Claude/Codex session was cleaned up by that tool's retention; project folder renamed/moved so the recorded cwd path differs; restoring selection from old state after switching machines.","solutions":["Re-run and pick the session interactively from the fresh list instead of reusing saved selection.","Verify the session still exists in the foreign tool (`claude`/`codex` resume list) and restore or recreate it if needed.","If the project directory moved, start omp from the new directory so the path matches, or update the saved selection."],"exampleFix":"// before (stale saved selection)\nomp --from-claude --session <old-id>   # path no longer matches\n\n// after\nomp --from-claude   # choose from the current list","handlingStrategy":"retry","validationCode":"// Re-enumerate foreign sessions and confirm the selected id/path still exists before resuming\nconst sessions = await store.list();\nif (!sessions.some(s => s.id === selectedId && s.path === selectedPath)) {\n  console.warn(\"Selected foreign session is gone; pick again interactively.\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  await omp([\"--from-claude\", \"--session\", id]);\n} catch (err) {\n  if (err instanceof SessionResolutionError && err.message.includes(\"no longer available\")) {\n    // stale selection: retry interactively\n    await omp([\"--from-claude\"]);\n  } else throw err;\n}","preventionTips":["Don't cache foreign session selections across cleanups/machine switches.","Resume from the same working directory the session was created in.","Prefer interactive picking for older sessions."],"tags":["cli","session-import","stale-state"],"backgroundTag":"session-not-found","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}