{"record":{"id":"1fec01ccb5d64a27","repo":"zed-industries/zed","slug":"worktree-creation-was-canceled","errorCode":null,"errorMessage":"worktree creation was canceled","messagePattern":"worktree creation was canceled","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/agent_ui/src/thread_worktree_archive.rs","lineNumber":677,"sourceCode":"            resolve_git_worktree_to_main_repo(app_state.fs.as_ref(), worktree_path)\n                .await\n                .is_some();\n\n        if !is_git_worktree {\n            let rx = main_repo.update(cx, |repo, _cx| repo.repair_worktrees());\n            rx.await\n                .map_err(|_| anyhow!(\"worktree repair was canceled\"))?\n                .context(\"failed to repair worktrees\")?;\n        }\n        false\n    } else {\n        // Create worktree at the original commit — the branch still points\n        // here because archival used detached commits.\n        let rx = main_repo.update(cx, |repo, _cx| {\n            repo.create_worktree_detached(worktree_path.clone(), row.original_commit_hash.clone())\n        });\n        rx.await\n            .map_err(|_| anyhow!(\"worktree creation was canceled\"))?\n            .context(\"failed to create worktree\")?;\n        true\n    };\n\n    let (wt_repo, _temp_wt_project) =\n        match find_or_create_repository(worktree_path, remote_connection, cx).await {\n            Ok(result) => result,\n            Err(error) => {\n                remove_new_worktree_on_error(created_new_worktree, &main_repo, worktree_path, cx)\n                    .await;\n                return Err(error);\n            }\n        };\n\n    if let Some(branch_name) = &row.branch_name {\n        // Attempt to check out the branch the worktree was previously on.\n        let checkout_result = wt_repo\n            .update(cx, |repo, _cx| repo.change_branch(branch_name.clone()))","sourceCodeStart":659,"sourceCodeEnd":695,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/agent_ui/src/thread_worktree_archive.rs#L659-L695","documentation":"In restore_worktree_via_git, when no worktree exists at the archived path, git worktree creation is initiated via the main repo and awaited through a receiver; the receiver closed without delivering a result (Repository dropped or creation cancelled), which is reported with this sentinel error meaning the creation never completed rather than that git itself failed.","triggerScenarios":"Thrown at crates/agent_ui/src/thread_worktree_archive.rs:677 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry restoration once the main repository is reachable and not mid-mutation","Ensure the detached commit referenced by the archive row still exists in the main repo (git fetch or prune may have removed it)","Keep the temporary project alive until worktree creation finishes"],"exampleFix":null,"handlingStrategy":"retry","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"}