{"record":{"id":"92fa97ba4c18ecb4","repo":"can1357/oh-my-pi","slug":"session-sessionarg-belongs-to-a-directory-tha","errorCode":null,"errorMessage":"Session \"${sessionArg}\" belongs to a directory that no longer exists (${sourceCwd}); run interactively to move it into the current project.","messagePattern":"Session \"(.+?)\" belongs to a directory that no longer exists \\((.+?)\\); run interactively to move it into the current project\\.","errorType":"exception","errorClass":"SessionResolutionError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/main.ts","lineNumber":709,"sourceCode":"\t| { status: \"not-needed\" }\n\t| { status: \"declined\" }\n\t| { status: \"moved\"; manager: SessionManager };\n\nasync function moveMissingCwdSessionIfNeeded(\n\tsessionArg: string,\n\tsession: SessionInfo,\n\tcwd: string,\n\tsessionDir: string | undefined,\n\taskToMoveSession: SessionPrompt,\n): Promise<MissingCwdMoveResult> {\n\tconst sourceCwd = session.cwd;\n\tif (!sourceCwd || fsSync.existsSync(sourceCwd)) {\n\t\treturn { status: \"not-needed\" };\n\t}\n\n\tconst movePromptResult = await askToMoveSession(session);\n\tif (movePromptResult === \"unavailable\") {\n\t\tthrow new SessionResolutionError(\n\t\t\t`Session \"${sessionArg}\" belongs to a directory that no longer exists (${sourceCwd}); run interactively to move it into the current project.`,\n\t\t);\n\t}\n\tif (movePromptResult === \"declined\") {\n\t\treturn { status: \"declined\" };\n\t}\n\n\t// Open anchored at the (now-missing) recorded cwd: `open` otherwise falls back\n\t// to the launch cwd, which would make the `moveTo` below a no-op whenever the\n\t// move target equals the current project dir. moveTo never chdirs, so the\n\t// stale cwd is only a relocation source, not a directory we enter.\n\tconst manager = await SessionManager.open(session.path, sessionDir, undefined, { initialCwd: sourceCwd });\n\tawait manager.moveTo(cwd, sessionDir);\n\treturn { status: \"moved\", manager };\n}\n\ntype ResumedProjectResult = { cwd: string; chdirFailed?: string };\n","sourceCodeStart":691,"sourceCodeEnd":727,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/main.ts#L691-L727","documentation":"When resuming a session whose recorded project directory no longer exists on disk, omp offers to move the session into the current project. In non-interactive contexts no move prompt can be shown ('unavailable'), so moveMissingCwdSessionIfNeeded throws this SessionResolutionError telling the user to run interactively to perform the move.","triggerScenarios":"Resuming (or forking from) a session whose sourceCwd directory was deleted/renamed, while askToMoveSession returns 'unavailable' (no TTY / non-interactive mode).","commonSituations":"Project folder deleted or moved since the session was created; working inside a container/CI where the original path never existed; resuming over SSH without an interactive terminal.","solutions":["Run omp interactively (in a TTY) and resume the session; accept the move prompt to relocate it into the current project.","Recreate the original directory (mkdir -p <sourceCwd>) so the existence check passes, then resume.","Hand-edit/move the session .jsonl into the current project's sessions directory."],"exampleFix":"// non-interactive fails:\nomp --resume <id> < /dev/null\n// interactive instead:\nomp --resume <id>   # answer 'yes' to the move prompt","handlingStrategy":"try-catch","validationCode":"// check the session's recorded cwd before resuming non-interactively\nimport * as fsSync from \"node:fs\";\nif (!fsSync.existsSync(recordedSessionCwd)) {\n  console.error(`Session project dir ${recordedSessionCwd} is gone; resume interactively to move it.`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await resumeSession(id);\n} catch (err) {\n  if (err.message.includes(\"belongs to a directory that no longer exists\")) {\n    // fall back to interactive prompt or recreate the dir\n  }\n}","preventionTips":["Resume sessions from a TTY so the interactive move prompt is available.","Avoid deleting/renaming project directories that still own live sessions.","In CI, recreate the original directory path before resuming."],"tags":["cli","session-resolution","non-interactive","filesystem"],"backgroundTag":"session-cwd-missing","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}