{"record":{"id":"04f24dc6f61d5f5b","repo":"zed-industries/zed","slug":"worktree-not-found","errorCode":null,"errorMessage":"worktree not found","messagePattern":"worktree not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/agent_ui/src/mention_set.rs","lineNumber":1260,"sourceCode":"\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(\n                |(worktree_path, full_path): (Arc<RelPath>, String)| {\n                    let rel_path = worktree_path\n                        .strip_prefix(&directory_path)\n                        .map_or_else(|_| worktree_path.clone(), |rel_path| rel_path.into());\n\n                    let open_task = project.update(cx, |project, cx| {\n                        project.buffer_store().update(cx, |buffer_store, cx| {\n                            let project_path = ProjectPath {\n                                worktree_id,\n                                path: worktree_path,","sourceCodeStart":1242,"sourceCodeEnd":1278,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/agent_ui/src/mention_set.rs#L1242-L1278","documentation":"Although the project produced a ProjectPath carrying a worktree_id, worktree_for_id could not resolve a live Entity<Worktree> for that id in full_mention_for_directory; the worktree was likely removed from the project between the path lookup and this read, leaving no way to enumerate the directory's files.","triggerScenarios":"Thrown at crates/agent_ui/src/mention_set.rs:1260 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the mention after re-opening or re-adding the worktree that was removed","Avoid mentioning directories in worktrees that are being closed or detached","Treat a missing worktree as a stale mention and re-expand it from a fresh path"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}