{"record":{"id":"e963a3722cc92ee2","repo":"zed-industries/zed","slug":"restore-archive-checkpoint-canceled","errorCode":null,"errorMessage":"restore_archive_checkpoint canceled","messagePattern":"restore_archive_checkpoint canceled","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/agent_ui/src/thread_worktree_archive.rs","lineNumber":785,"sourceCode":"                    );\n                }\n            }\n        }\n    }\n\n    // Restore the staged/unstaged state from the WIP commit trees.\n    // read-tree --reset -u applies the unstaged tree (including deletions)\n    // to the working directory, then a bare read-tree sets the index to\n    // the staged tree without touching the working directory.\n    let restore_rx = wt_repo.update(cx, |repo, _cx| {\n        repo.restore_archive_checkpoint(\n            row.staged_commit_hash.clone(),\n            row.unstaged_commit_hash.clone(),\n        )\n    });\n    if let Err(error) = restore_rx\n        .await\n        .map_err(|_| anyhow!(\"restore_archive_checkpoint canceled\"))\n        .and_then(|r| r)\n    {\n        remove_new_worktree_on_error(created_new_worktree, &main_repo, worktree_path, cx).await;\n        return Err(error.context(\"failed to restore archive checkpoint\"));\n    }\n\n    if created_new_worktree {\n        // Re-register the restored worktree as Zed-created so it can be\n        // archived again later.\n        git_ui_core::created_worktrees::record_created_worktree_for_repo(\n            &wt_repo,\n            worktree_path,\n            remote_connection,\n            cx,\n        )\n        .await;\n    }\n","sourceCodeStart":767,"sourceCodeEnd":803,"githubUrl":"https://github.com/zed-industries/zed/blob/bc538def4545534201bbfcac4e95ac34ea6501b6/crates/agent_ui/src/thread_worktree_archive.rs#L767-L803","documentation":"After the worktree repository is available, the restore applies the archived staged/unstaged state via repo.restore_archive_checkpoint (git read-tree --reset -u plus a bare read-tree). This error means that operation's channel receiver was dropped before completion — teardown cancelled it; the caller then removes any newly created worktree and returns 'failed to restore archive checkpoint'.","triggerScenarios":"The window/project/repository entity is dropped while the checkpoint read-tree operations are running as part of unarchiving a thread.","commonSituations":"User closes Zed or the window during the final restore step; cancellation racing the spawned restore task.","solutions":["Retry the restore once the app/project is stable; the cleanup removed any half-created worktree.","Keep the window open until 'Restoring thread…' completes.","In code, treat cancellation as abort and make the error path (remove_new_worktree_on_error) idempotent."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match restore_rx.await {\n    Ok(result) => result.context(\"failed to restore archive checkpoint\")?,\n    Err(_canceled) => {\n        // checkpoint restore was cancelled by teardown;\n        // run remove_new_worktree_on_error and abort\n    }\n}","preventionTips":["Make the cleanup path (remove_new_worktree_on_error) idempotent so cancelled restores leave no residue.","Keep the window/entity alive until the restore finishes; disable close during restore.","Treat cancellation as a signal to restart the whole restore, not to retry the checkpoint step."],"tags":["zed","git","cancellation","checkpoint-restore","thread-restore"],"backgroundTag":null,"analyzedSha":"bc538def4545534201bbfcac4e95ac34ea6501b6","analyzedAt":"2026-08-16T07:30:46.435Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}