Wire up original_commit_hash in archive and restore flows

Richard Feldman created

persist_worktree_state:
- Read HEAD SHA before creating WIP commits as original_commit_hash
- Pass it to create_archived_worktree

restore_worktree_via_git:
- Pre-restore: verify original_commit_hash exists via resolve_commit;
  abort with user-facing error if the git history is gone
- Worktree-already-exists: check for .git file to detect if path is a
  real git worktree; if not, call repair_worktrees to adopt it
- Resilient WIP resets: track success of mixed and soft resets
  independently; if either fails, fall back to mixed reset directly to
  original_commit_hash
- Post-reset HEAD verification: confirm HEAD landed at
  original_commit_hash after all resets
- Branch restoration: after switching, verify branch points at
  original_commit_hash; if it doesn't, reset and create a fresh branch

Change summary

crates/agent_ui/src/thread_worktree_archive.rs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

Detailed changes

crates/agent_ui/src/thread_worktree_archive.rs 🔗

@@ -971,10 +971,10 @@ pub async fn restore_worktree_via_git(
 
     let commit_exists = main_repo
         .update(cx, |repo, _cx| {
-            repo.resolve_commit(row.original_commit_hash.clone())
+            repo.commit_exists(row.original_commit_hash.clone())
         })
         .await
-        .map_err(|_| anyhow!("resolve_commit was canceled"))?
+        .map_err(|_| anyhow!("commit_exists check was canceled"))?
         .context("failed to check if original commit exists")?;
 
     if !commit_exists {