{"record":{"id":"66dc2ab49fb4a517","repo":"zed-industries/zed","slug":"project-path-not-found-for-directory-mention-abs","errorCode":null,"errorMessage":"project path not found for directory mention {abs_path:?}","messagePattern":"project path not found for directory mention (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/agent_ui/src/mention_set.rs","lineNumber":1250,"sourceCode":"            } else if entry.is_file() {\n                files.push((\n                    entry.path.clone(),\n                    worktree\n                        .full_path(&entry.path)\n                        .to_string_lossy()\n                        .to_string(),\n                ));\n            }\n        }\n\n        files\n    }\n\n    let Some(project_path) = project\n        .read(cx)\n        .project_path_for_absolute_path(&abs_path, cx)\n    else {\n        return Task::ready(Err(anyhow!(\n            \"project path not found for directory mention {abs_path:?}\"\n        )));\n    };\n    let Some(entry) = project.read(cx).entry_for_path(&project_path, cx) else {\n        return Task::ready(Err(anyhow!(\"project entry not found\")));\n    };\n    let directory_path = entry.path.clone();\n    let worktree_id = project_path.worktree_id;\n    let Some(worktree) = project.read(cx).worktree_for_id(worktree_id, cx) else {\n        return Task::ready(Err(anyhow!(\"worktree not found\")));\n    };\n    let project = project.clone();\n    cx.spawn(async move |cx| {\n        let file_paths = worktree.read_with(cx, |worktree, _cx| {\n            collect_files_in_path(worktree, &directory_path)\n        });\n        let descendants_future = cx.update(|cx| {\n            futures::future::join_all(file_paths.into_iter().map(","sourceCodeStart":1232,"sourceCodeEnd":1268,"githubUrl":"https://github.com/zed-industries/zed/blob/bc538def4545534201bbfcac4e95ac34ea6501b6/crates/agent_ui/src/mention_set.rs#L1232-L1268","documentation":"Before attaching a directory mention, Zed maps the absolute directory path to a ProjectPath via project_path_for_absolute_path. This error means no open worktree contains the directory — the path is outside every worktree root of the current project.","triggerScenarios":"Mentioning a directory whose worktree was removed or that belongs to another window; a path built from a stale snapshot after the worktree was re-rooted; a remote-path mismatch where the absolute path does not correspond to the remote worktree root.","commonSituations":"Multi-root projects where a root was closed while the picker was open; mentioning directories found via search that spans other projects; moving or renaming project roots between sessions.","solutions":["Re-add or reopen the worktree containing the directory, then mention it again.","Pick the directory from the project panel so the path is guaranteed to be inside a worktree.","If the worktree was re-rooted or moved, reload the project window so paths resolve again."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let inside_project = project\n    .read(cx)\n    .worktrees(cx)\n    .any(|worktree| abs_path.starts_with(worktree.read(cx).abs_path()));\nif !inside_project {\n    // filter the directory out of mention candidates\n}","typeGuard":null,"tryCatchPattern":"match confirm_task.await {\n    Ok(mention) => { /* attach */ }\n    Err(err) if err.to_string().starts_with(\"project path not found\") => {\n        show_user(\"This directory is outside the open project\")\n    }\n    Err(err) => return Err(err),\n}","preventionTips":["Build directory mention candidates from worktree snapshots, not raw absolute paths.","Refresh candidates on worktree add/remove events.","For remote projects, translate paths to the worktree-relative form before offering them."],"tags":["zed","agent-ui","mentions","directory","worktree"],"backgroundTag":null,"analyzedSha":"bc538def4545534201bbfcac4e95ac34ea6501b6","analyzedAt":"2026-08-16T07:30:46.435Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}