zed-industries/zed · error
worktree not found
Error message
worktree not found
What it means
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.
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
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at crates/agent_ui/src/mention_set.rs:1260 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20).
Data as JSON: /api/errors/04f24dc6f61d5f5b.
Report an issue: GitHub.
Appendix: source
Thrown at crates/agent_ui/src/mention_set.rs:1260
files
}
let Some(project_path) = project
.read(cx)
.project_path_for_absolute_path(&abs_path, cx)
else {
return Task::ready(Err(anyhow!(
"project path not found for directory mention {abs_path:?}"
)));
};
let Some(entry) = project.read(cx).entry_for_path(&project_path, cx) else {
return Task::ready(Err(anyhow!("project entry not found")));
};
let directory_path = entry.path.clone();
let worktree_id = project_path.worktree_id;
let Some(worktree) = project.read(cx).worktree_for_id(worktree_id, cx) else {
return Task::ready(Err(anyhow!("worktree not found")));
};
let project = project.clone();
cx.spawn(async move |cx| {
let file_paths = worktree.read_with(cx, |worktree, _cx| {
collect_files_in_path(worktree, &directory_path)
});
let descendants_future = cx.update(|cx| {
futures::future::join_all(file_paths.into_iter().map(
|(worktree_path, full_path): (Arc<RelPath>, String)| {
let rel_path = worktree_path
.strip_prefix(&directory_path)
.map_or_else(|_| worktree_path.clone(), |rel_path| rel_path.into());
let open_task = project.update(cx, |project, cx| {
project.buffer_store().update(cx, |buffer_store, cx| {
let project_path = ProjectPath {
worktree_id,
path: worktree_path,View on GitHub (pinned to f4178619ac)