{"record":{"id":"91eeb9dc6f310e3e","repo":"xai-org/grok-build","slug":"no-session-found-for-current-directory-use-grok","errorCode":null,"errorMessage":"No session found for current directory. Use 'grok' to start a new session.","messagePattern":"No session found for current directory\\. Use 'grok' to start a new session\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-pager/src/app/session_startup.rs","lineNumber":758,"sourceCode":"///\n/// When the parent lives under another directory, the fork effect sets `newCwd` to that parent session cwd; preflight must use the same path.\npub fn effective_fork_new_cwd(process_cwd: &str, parent_cwd: Option<&Path>) -> String {\n    parent_cwd\n        .map(|p| p.to_string_lossy().into_owned())\n        .unwrap_or_else(|| process_cwd.to_string())\n}\npub use xai_grok_shell::session::persistence::RecentSessionSelection;\n/// Resolve most-recent session id for cwd, or error.\nasync fn most_recent_session_id(\n    cwd: &str,\n    selection: RecentSessionSelection,\n) -> anyhow::Result<(String, Option<String>)> {\n    let summaries = xai_grok_shell::session::persistence::list_summaries(Some(cwd)).await?;\n    let first = summaries\n        .iter()\n        .find(|summary| selection.admits(summary))\n        .ok_or_else(|| {\n            anyhow::anyhow!(\n                \"No session found for current directory. \\\n                 Use 'grok' to start a new session.\"\n            )\n        })?;\n    Ok((first.info.id.to_string(), first.display_title_opt()))\n}\n/// `AuthManager` for direct grok.com calls made outside the agent (pre-ACP `--continue` conversation listing, the GCS restore effect).\n/// Wires the auth-provider refresher before the first `auth()`.\n/// Without it, environments that mint credentials via `auth_provider_command` report `NoOauth`.\npub(crate) fn pre_acp_auth_manager(\n    agent_config: &xai_grok_shell::agent::config::Config,\n) -> std::sync::Arc<xai_grok_shell::auth::AuthManager> {\n    let auth = std::sync::Arc::new(xai_grok_shell::auth::AuthManager::new(\n        &xai_grok_shell::util::grok_home::grok_home(),\n        agent_config.grok_com_config.clone(),\n    ));\n    auth.configure_refresher(\n        agent_config.grok_com_config.auth_provider_command.clone(),","sourceCodeStart":740,"sourceCodeEnd":776,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-pager/src/app/session_startup.rs#L740-L776","documentation":"When resuming an existing session for the current directory, list_summaries(Some(cwd)) is queried and the first summary admitted by the selection filter is taken. If no persisted session for this cwd passes the filter, the resolver fails with this guidance message telling the user to start a fresh session.","triggerScenarios":"Running a resume command (e.g. grok resume) in a directory with no previously saved session summaries, or where the selection predicate (admits) excludes all candidates — e.g. filtering by title/ID/age that matches nothing.","commonSituations":"Starting a project in a brand-new directory; resuming after session storage was cleared or moved to another machine; cwd differs (symlink vs canonical path, trailing path differences) from the one recorded at save time; an ID/title filter typo.","solutions":["Start a new session with plain 'grok' as the message suggests","Verify you are in the exact directory (canonical path) where the original session was created","Check the session storage location for existing summaries (confirm they were not wiped or relocated)","If resuming by title/ID, verify the filter matches an existing summary"],"exampleFix":"// before: resume in a dir with no sessions\ngrok resume\n// after: start fresh or pass an explicit id\nmkdir -p ~/project && cd ~/project && grok\n// or: grok resume <session-id>","handlingStrategy":"try-catch","validationCode":"// check for a resumable session before invoking resume\nlet summaries = xai_grok_shell::session::persistence::list_summaries(Some(cwd)).await?;\nlet resumable = summaries.iter().any(|s| selection.admits(s));\nif !resumable {\n    eprintln!(\"no session here; starting new one instead\");\n    start_new_session().await?;\n}","typeGuard":null,"tryCatchPattern":"match resume_session_for_cwd(cwd, selection).await {\n    Ok((id, title)) => restore(id, title).await,\n    Err(e) if e.to_string().contains(\"No session found for current directory\") => {\n        start_new_session().await\n    }\n    Err(e) => Err(e),\n}","preventionTips":["Resume only from the exact directory (canonical path) where the session was created","Fall back to starting a new session when resume misses","Back up the session storage directory if sessions matter across machines","When filtering by id/title, verify against the summary list first"],"tags":["session","resume","not-found"],"backgroundTag":"session-not-found","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}