fix(agents): Compare a local-checkout task's changes against the current HEAD

Commits made in the project while a local task runs no longer show up in
its Changes pane, and Refresh lists what is actually uncommitted.
This commit is contained in:
l0ng-ai
2026-10-28 11:06:54 +08:00
parent 9ac4c379a4
commit 415ade72e7
2 changed files with 8 additions and 2 deletions
+7 -1
View File
@@ -577,7 +577,13 @@ impl Task {
fn cwd_and_base(&self) -> (PathBuf, String) {
let s = self.state.lock();
(s.task.cwd.0.clone(), s.task.base_commit.clone().unwrap_or_else(|| "HEAD".into()))
// In the project's own checkout the user commits too: compare against the current HEAD,
// as the Commit tool window does, so commits made since the task started drop out.
let base = match s.task.isolation {
Isolation::Local => None,
Isolation::Worktree => s.task.base_commit.clone(),
};
(s.task.cwd.0.clone(), base.unwrap_or_else(|| "HEAD".into()))
}
fn emit_task(&self) {
+1 -1
View File
@@ -44,7 +44,7 @@ pub struct AgentTask {
pub branch: Option<String>,
/// Branch (or revision) the worktree was created from.
pub base: Option<String>,
/// Commit the task's changes are compared against.
/// Commit the task's changes are compared against (worktree tasks; local ones use `HEAD`).
pub base_commit: Option<String>,
/// Why the task failed, when it did.
pub error: Option<String>,