{"record":{"id":"aa573ad25aece330","repo":"can1357/oh-my-pi","slug":"no-sessions-found-for-cwd-pass-a-session-file","errorCode":null,"errorMessage":"No sessions found for ${cwd}. Pass a session file or id.","messagePattern":"No sessions found for (.+?)\\. Pass a session file or id\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/cli/render-cli.ts","lineNumber":153,"sourceCode":"/** Resolve the target session file from a path, id prefix, or cwd default. */\nasync function resolveTargetSession(sessionArg: string | undefined, cwd: string): Promise<string> {\n\tif (sessionArg) {\n\t\tif (sessionArg.includes(\"/\") || sessionArg.includes(\"\\\\\") || sessionArg.endsWith(\".jsonl\")) {\n\t\t\tconst resolved = path.resolve(sessionArg);\n\t\t\ttry {\n\t\t\t\tawait fs.access(resolved);\n\t\t\t\treturn resolved;\n\t\t\t} catch (err) {\n\t\t\t\tif (isEnoent(err)) throw new Error(`Session file not found: ${resolved}`);\n\t\t\t\tthrow err;\n\t\t\t}\n\t\t}\n\t\tconst match = await resolveResumableSession(sessionArg, cwd);\n\t\tif (!match) throw new Error(`Session \"${sessionArg}\" not found.`);\n\t\treturn match.session.path;\n\t}\n\tconst recent = await findMostRecentSession(SessionManager.getDefaultSessionDir(cwd));\n\tif (!recent) throw new Error(`No sessions found for ${cwd}. Pass a session file or id.`);\n\treturn recent;\n}\n\nfunction formatBytes(bytes: number): string {\n\tif (bytes >= 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MiB`;\n\tif (bytes >= 1024) return `${(bytes / 1024).toFixed(1)} KiB`;\n\treturn `${bytes} B`;\n}\n\nfunction formatMs(ms: number): string {\n\treturn `${ms.toFixed(0)} ms`;\n}\n\n/** Render the resolved session and report timings. Returns the exit code. */\nexport async function runRenderCommand(args: RenderCommandArgs): Promise<number> {\n\tconst cwd = getProjectDir();\n\tconst settings = await Settings.init({ cwd });\n\tawait initTheme();","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/cli/render-cli.ts#L135-L171","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nomp render            # no sessions recorded yet\n// after\nomp render ~/.omp/sessions/<project>/<session>.jsonl","handlingStrategy":"fallback","validationCode":"import { readdirSync } from \"node:fs\";\nconst dir = SessionManager.getDefaultSessionDir(cwd);\nconst hasSessions = (() => { try { return readdirSync(dir).length > 0; } catch { return false; } })();\nif (!hasSessions) console.error(\"No sessions recorded yet — pass a session file or id.\");","typeGuard":null,"tryCatchPattern":"try {\n  const target = await resolveTargetSession(arg ?? \"\", cwd);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith(\"No sessions found\")) {\n    console.error(`${err.message}\\nStart a session with omp first, then render it.`);\n    return;\n  }\n  throw err;\n}","preventionTips":["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"],"tags":["cli","session","empty-state"],"backgroundTag":"no-sessions-found","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}