can1357/oh-my-pi · error · Error
No sessions found for ${cwd}. Pass a session file or id.
Error message
No sessions found for ${cwd}. Pass a session file or id. What it means
Fallback branch of `resolveTargetSession`: when no argument is given, the CLI looks for the most recent session in the default session dir for the current cwd. If the directory has no sessions at all, this error instructs the user to supply one explicitly. It surfaces an empty local session history rather than failing obscurely later.
Source
Thrown at packages/coding-agent/src/cli/render-cli.ts:153
/** Resolve the target session file from a path, id prefix, or cwd default. */
async function resolveTargetSession(sessionArg: string | undefined, cwd: string): Promise<string> {
if (sessionArg) {
if (sessionArg.includes("/") || sessionArg.includes("\\") || sessionArg.endsWith(".jsonl")) {
const resolved = path.resolve(sessionArg);
try {
await fs.access(resolved);
return resolved;
} catch (err) {
if (isEnoent(err)) throw new Error(`Session file not found: ${resolved}`);
throw err;
}
}
const match = await resolveResumableSession(sessionArg, cwd);
if (!match) throw new Error(`Session "${sessionArg}" not found.`);
return match.session.path;
}
const recent = await findMostRecentSession(SessionManager.getDefaultSessionDir(cwd));
if (!recent) throw new Error(`No sessions found for ${cwd}. Pass a session file or id.`);
return recent;
}
function formatBytes(bytes: number): string {
if (bytes >= 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MiB`;
if (bytes >= 1024) return `${(bytes / 1024).toFixed(1)} KiB`;
return `${bytes} B`;
}
function formatMs(ms: number): string {
return `${ms.toFixed(0)} ms`;
}
/** Render the resolved session and report timings. Returns the exit code. */
export async function runRenderCommand(args: RenderCommandArgs): Promise<number> {
const cwd = getProjectDir();
const settings = await Settings.init({ cwd });
await initTheme();View on GitHub (pinned to 9690622007)
Solutions
- Pass a session file path or id explicitly: `omp render <file-or-id>`
- Start a session with omp first so one gets recorded, then render it
- Verify you are in the project directory whose sessions you expect
- Check the default session dir location for stray sessions from other cwds
Example fix
// before omp render # no sessions recorded yet // after omp render ~/.omp/sessions/<project>/<session>.jsonl
Defensive patterns
Strategy: fallback
Validate before calling
import { readdirSync } from "node:fs";
const dir = SessionManager.getDefaultSessionDir(cwd);
const hasSessions = (() => { try { return readdirSync(dir).length > 0; } catch { return false; } })();
if (!hasSessions) console.error("No sessions recorded yet — pass a session file or id."); Try / catch
try {
const target = await resolveTargetSession(arg ?? "", cwd);
} catch (err) {
if (err instanceof Error && err.message.startsWith("No sessions found")) {
console.error(`${err.message}\nStart a session with omp first, then render it.`);
return;
}
throw err;
} Prevention
- Record at least one session before using argument-less render
- Always pass an explicit session file or id in scripts/CI
- Confirm you launched from the expected project directory
When it happens
Trigger: Running the render command with no session argument in a directory where `findMostRecentSession(SessionManager.getDefaultSessionDir(cwd))` returns nothing — the session dir is empty or absent.
Common situations: Fresh checkout/new project where no omp session has ever been recorded; sessions stored under a different project dir than the one you launched from; cleaned-up or wiped session storage.
Related errors
- Session file not found: ${resolved}
- Session "${sessionArg}" not found.
- --list-details, --exec, and --exec-batch are not supported b
- positional paths cannot be combined with --search-path
- unknown file type: {value}
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/aa573ad25aece330.
Report an issue: GitHub.