Add Git worktree pane

This commit is contained in:
Georg Bauer
2026-07-27 19:44:12 +02:00
parent aebfe7aeb6
commit b9933ae076
9 changed files with 2630 additions and 5 deletions

View File

@@ -220,8 +220,17 @@ impl App {
/// Selects a project and stores it as the one to reopen on the next launch.
pub(super) fn remember_project(&mut self, project_id: i32) {
if self.selected_project != Some(project_id) {
self.git_selected_project = None;
self.git_selected_files.clear();
self.git_diff = None;
self.git_commit_all_confirmation = false;
}
self.selected_project = Some(project_id);
self.refresh_git_state();
if self.detail_tab == DetailTab::Git {
self.refresh_git_worktree(project_id);
}
if self.config.interface.last_project_id == Some(project_id) {
return;
}
@@ -273,6 +282,7 @@ impl App {
}
None => {
self.git_states.remove(&project_id);
self.git_worktrees.remove(&project_id);
}
}
}
@@ -281,6 +291,15 @@ impl App {
let Some(project_id) = self.selected_project else {
return;
};
if self
.git_operation
.as_ref()
.is_some_and(|operation| operation.project_id == project_id)
{
self.error =
Some("Wait for the current Git operation before switching branches.".into());
return;
}
if self.project_has_active_chat(project_id) {
self.error = Some("Stop active chats before switching branches.".into());
return;
@@ -304,8 +323,9 @@ impl App {
};
match git_switch(&path, branch) {
Ok(()) => {
self.refresh_git_state();
self.error = None;
self.refresh_git_state();
self.refresh_git_worktree(project_id);
}
Err(error) => self.error = Some(error),
}