can1357/oh-my-pi · error · SessionResolutionError
Failed to list ${sourceName} sessions: ${message}
Error message
Failed to list ${sourceName} sessions: ${message} What it means
When a foreign session source is selected, main.ts calls `store.list()` (timed/logged) to enumerate that tool's sessions. Any thrown error — underlying tool crash, unreadable session storage, JSON parse failure — is caught and rethrown as `SessionResolutionError: Failed to list <Claude|Codex> sessions: <message>`. The inner message names the real cause.
Source
Thrown at packages/coding-agent/src/main.ts:1627
// Resolve native resume/fork flags or import one foreign transcript into a
// fresh persisted OMP session before constructing the AgentSession.
let sessionManager: SessionManager | undefined;
let foreignSource: ForeignSessionSource | undefined;
try {
foreignSource = resolveForeignSessionSource(parsedArgs);
if (foreignSource) {
if (isProtocolMode) {
throw new SessionResolutionError(`--from-${foreignSource} is not supported in ${mode} mode`);
}
const sourceName = foreignSessionSourceName(foreignSource);
const store = (deps.createForeignSessionStore ?? createForeignSessionStore)(foreignSource);
let foreignSessions: ForeignSessionInfo[];
try {
foreignSessions = await logger.time(`list${sourceName}Sessions`, () => store.list());
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
throw new SessionResolutionError(`Failed to list ${sourceName} sessions: ${message}`);
}
if (foreignSessions.length === 0) {
writeStartupNotice(parsedArgs, `${chalk.dim(`No ${sourceName} sessions found`)}\n`);
stopStartupWatchdog();
process.exit(0);
}
const choices = foreignSessions.map(foreignSessionInfoToSessionInfo);
pauseStartupWatchdog();
let selected: SessionInfo | null;
try {
selected = await logger.time(
`select${sourceName}Session`,
deps.selectSession ?? selectSession,
choices,
{
title: `Import ${sourceName} Session`,
scopeLabel: false,
showCwd: true,View on GitHub (pinned to 9690622007)
Solutions
- Read the wrapped inner message — it identifies the failing file or cause — and fix that specific issue.
- Verify the foreign tool still runs and its session directory exists and is readable (`ls ~/.claude/projects` or `~/.codex`).
- Repair or remove the corrupt session file(s); if the foreign CLI changed format, upgrade omp to a matching version.
- Fall back to resuming omp-native sessions without `--from-*`.
Example fix
// before omp --from-claude # EACCES on ~/.claude/projects // after chmod u+rx ~/.claude/projects omp --from-claude
Defensive patterns
Strategy: try-catch
Validate before calling
import * as fs from "node:fs";
// Sanity-check the foreign tool's session storage before importing
for (const dir of ["~/.claude/projects", "~/.codex/sessions"]) {
const p = dir.replace("~", process.env.HOME ?? "");
fs.accessSync(p, fs.constants.R_OK | fs.constants.X_OK);
} Try / catch
try {
await omp(["--from-claude"]);
} catch (err) {
if (err instanceof SessionResolutionError && err.message.startsWith("Failed to list")) {
console.error("Foreign session store unreadable:", err.message);
// fall back to native sessions
await omp([]);
} else throw err;
} Prevention
- Keep the foreign CLI (Claude/Codex) and omp versions in sync — format changes break listing.
- Don't hand-edit or partially delete files under the foreign tool's session directories.
- Back up session storage before cleaning it up.
When it happens
Trigger: `--from-claude`/`--from-codex` where the foreign store's `list()` throws: corrupt or unreadable session files, storage directory missing/permission-denied, unexpected schema in the foreign tool's session files.
Common situations: Foreign CLI (Claude/Codex) upgraded and changed its on-disk session format; session directory moved or partially deleted; disk/permission problems under `~/.claude`/`~/.codex`.
Related errors
- Failed to import ${sourceName} session: ${message}
- Import source is neither file nor directory: ${target}
- Session file not found: ${resolved}
- No files matched "${pattern}"
- Not a file: ${shortenPath(resolved)}
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/0ce11725fa461e80.
Report an issue: GitHub.