From b38b6ff12c8459466a2ad7ee4da0e22afe64032a Mon Sep 17 00:00:00 2001 From: Michael Sloan Date: Tue, 12 Aug 2025 01:11:05 -0600 Subject: [PATCH] agent checkpoint dbgs --- crates/agent/src/thread.rs | 8 +++++++- crates/git/src/repository.rs | 16 +++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/crates/agent/src/thread.rs b/crates/agent/src/thread.rs index 20d482f60d..b6f01ab278 100644 --- a/crates/agent/src/thread.rs +++ b/crates/agent/src/thread.rs @@ -813,6 +813,7 @@ impl Thread { } fn finalize_pending_checkpoint(&mut self, cx: &mut Context) { + dbg!("finalize_pending_checkpoint"); let pending_checkpoint = if self.is_generating() { return; } else if let Some(checkpoint) = self.pending_checkpoint.take() { @@ -829,10 +830,13 @@ impl Thread { pending_checkpoint: ThreadCheckpoint, cx: &mut Context, ) { + dbg!("finalize_checkpoint"); let git_store = self.project.read(cx).git_store().clone(); let final_checkpoint = git_store.update(cx, |git_store, cx| git_store.checkpoint(cx)); cx.spawn(async move |this, cx| match final_checkpoint.await { Ok(final_checkpoint) => { + dbg!(&pending_checkpoint.git_checkpoint); + dbg!(&final_checkpoint); let equal = git_store .update(cx, |store, cx| { store.compare_checkpoints( @@ -844,7 +848,7 @@ impl Thread { .await .unwrap_or(false); - if !equal { + if dbg!(!equal) { this.update(cx, |this, cx| { this.insert_checkpoint(pending_checkpoint, cx) })?; @@ -860,6 +864,7 @@ impl Thread { } fn insert_checkpoint(&mut self, checkpoint: ThreadCheckpoint, cx: &mut Context) { + dbg!("insert_checkpoint"); self.checkpoints_by_message .insert(checkpoint.message_id, checkpoint); cx.emit(ThreadEvent::CheckpointChanged); @@ -867,6 +872,7 @@ impl Thread { } pub fn last_restore_checkpoint(&self) -> Option<&LastRestoreCheckpoint> { + dbg!(); self.last_restore_checkpoint.as_ref() } diff --git a/crates/git/src/repository.rs b/crates/git/src/repository.rs index 518b6c4f46..8a9658c527 100644 --- a/crates/git/src/repository.rs +++ b/crates/git/src/repository.rs @@ -1492,13 +1492,19 @@ impl GitRepository for RealGitRepository { let mut excludes = exclude_files(git).await?; git.run(&["add", "--all"]).await?; - let tree = git.run(&["write-tree"]).await?; + dbg!("added all files"); + let tree = git.run(&["write-tree"]).await; + dbg!(&tree); + let tree = tree?; let checkpoint_sha = if let Some(head_sha) = head_sha.as_deref() { + dbg!(&["git", "commit-tree", &tree, "-p", head_sha, "-m", "Checkpoint"])); git.run(&["commit-tree", &tree, "-p", head_sha, "-m", "Checkpoint"]) .await? } else { + dbg!(&["git", "commit-tree", &tree, "-m", "Checkpoint"]); git.run(&["commit-tree", &tree, "-m", "Checkpoint"]).await? }; + dbg!(&checkpoint_sha); excludes.restore_original().await?; @@ -1551,6 +1557,8 @@ impl GitRepository for RealGitRepository { left: GitRepositoryCheckpoint, right: GitRepositoryCheckpoint, ) -> BoxFuture<'_, Result> { + // todo! fail or short circuit + let working_directory = self.working_directory(); let git_binary_path = self.git_binary_path.clone(); @@ -1559,6 +1567,11 @@ impl GitRepository for RealGitRepository { .spawn(async move { let working_directory = working_directory?; let git = GitBinary::new(git_binary_path, working_directory, executor); + log::error!( + "git diff-tree --quiet {} {}", + left.commit_sha, + right.commit_sha + ); let result = git .run(&[ "diff-tree", @@ -1567,6 +1580,7 @@ impl GitRepository for RealGitRepository { &right.commit_sha.to_string(), ]) .await; + dbg!(&result); match result { Ok(_) => Ok(true), Err(error) => {