can1357/oh-my-pi · error · Error

Selected ${sourceName} session is no longer available

Error message

Selected ${sourceName} session is no longer available

What it means

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.

Source

Thrown at packages/coding-agent/src/modes/controllers/selector-controller.ts:1600

				return;
			}
			if (foreignSessions.length === 0) {
				this.ctx.showWarning(`No ${sourceName} sessions found`);
				return;
			}
			const foreignByPath = new Map(foreignSessions.map(session => [session.path, session]));
			sessions = foreignSessions.map(foreignSessionInfoToSessionInfo);
			onSelectSession = async session => {
				try {
					await this.ctx.settings.flush();
				} catch (error) {
					this.ctx.showError(
						`Failed to save pending settings: ${error instanceof Error ? error.message : String(error)}`,
					);
					return false;
				}
				const foreignSession = foreignByPath.get(session.path);
				if (!foreignSession) throw new Error(`Selected ${sourceName} session is no longer available`);
				const imported = await persistForeignSession(store, foreignSession, {
					fallbackCwd: this.ctx.sessionManager.getCwd(),
					suppressBreadcrumb: true,
				});
				const sessionFile = imported.getSessionFile();
				if (!sessionFile) throw new Error(`Failed to persist ${sourceName} session`);
				await imported.close();
				return await this.handleResumeSession(sessionFile, { settingsFlushed: true });
			};
			selectorOptions = {
				title: `Import ${sourceName} Session`,
				scopeLabel: false,
				showCwd: true,
			};
		} else {
			const [loadedSessions, pinnedIds] = await Promise.all([
				SessionManager.list(this.ctx.sessionManager.getCwd(), this.ctx.sessionManager.getSessionDir()),
				loadPinnedSessionIds(),

View on GitHub (pinned to 9690622007)

Solutions

  1. Reopen the session selector (retry the import) so the list is refreshed from the current state of the foreign store.
  2. Verify the session file still exists in the source tool's sessions directory; if it was deleted there, it cannot be imported.
  3. 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.
  4. 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.
Defensive patterns

Strategy: try-catch

Validate before calling

// Re-list from the foreign store right before importing to confirm the session still exists
const still = (await store.list()).find(s => s.path === selectedPath);
if (!still) console.warn(`Foreign session ${selectedPath} disappeared; refresh the selector before importing.`);

Type guard

function isForeignSessionGone(err: unknown): err is Error {
  return err instanceof Error && /is no longer available$/.test(err.message);
}

Try / catch

try {
  await importForeignSession(source, sessionPath);
} catch (err) {
  if (isForeignSessionGone(err)) {
    showWarning("That session disappeared from the source — reopening the selector to refresh the list.");
    await reopenSessionSelector(source);
  } else throw err;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/f1b62804f13693d7. Report an issue: GitHub.