refactor(branch-dropdown): drop worktree parent-branch merge shortcut

Remove the parent-branch button shown beside the branch selector along
with its supporting API, command, service, model, and i18n strings.
Add migration m20260423 to drop the now-unused folder.parent_branch
column.
This commit is contained in:
xintaofei
2026-04-23 14:02:46 +08:00
parent 377ae6d8e6
commit 50c5b12d53
23 changed files with 38 additions and 128 deletions

View File

@@ -19,6 +19,7 @@ use tauri::Manager;
use crate::app_error::AppCommandError;
#[cfg(feature = "tauri-runtime")]
use crate::db::error::DbError;
#[cfg(feature = "tauri-runtime")]
use crate::db::service::folder_service;
use crate::db::AppDatabase;
use crate::models::GitCredentials;
@@ -479,40 +480,6 @@ pub async fn add_folder_to_history(
folder_service::add_folder(&db.conn, &path).await
}
pub(crate) async fn set_folder_parent_branch_core(
conn: &sea_orm::DatabaseConnection,
path: &str,
parent_branch: Option<String>,
) -> Result<(), AppCommandError> {
use crate::db::entities::folder;
use sea_orm::{ColumnTrait, EntityTrait, QueryFilter};
let row = folder::Entity::find()
.filter(folder::Column::Path.eq(path))
.filter(folder::Column::DeletedAt.is_null())
.one(conn)
.await
.map_err(|e| {
AppCommandError::database_error("Failed to query folder").with_detail(e.to_string())
})?;
if let Some(folder_model) = row {
folder_service::set_folder_parent_branch(conn, folder_model.id, parent_branch)
.await
.map_err(AppCommandError::from)?;
}
Ok(())
}
#[cfg(feature = "tauri-runtime")]
#[cfg_attr(feature = "tauri-runtime", tauri::command)]
pub async fn set_folder_parent_branch(
db: tauri::State<'_, AppDatabase>,
path: String,
parent_branch: Option<String>,
) -> Result<(), AppCommandError> {
set_folder_parent_branch_core(&db.conn, &path, parent_branch).await
}
#[cfg(feature = "tauri-runtime")]
#[cfg_attr(feature = "tauri-runtime", tauri::command)]
pub async fn remove_folder_from_history(

View File

@@ -15,7 +15,6 @@ pub struct Model {
pub updated_at: DateTimeUtc,
pub deleted_at: Option<DateTimeUtc>,
pub is_open: bool,
pub parent_branch: Option<String>,
pub sort_order: i32,
}

View File

@@ -0,0 +1,35 @@
use sea_orm_migration::prelude::*;
#[derive(DeriveMigrationName)]
pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.alter_table(
Table::alter()
.table(Folder::Table)
.drop_column(Folder::ParentBranch)
.to_owned(),
)
.await
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.alter_table(
Table::alter()
.table(Folder::Table)
.add_column(ColumnDef::new(Folder::ParentBranch).string().null())
.to_owned(),
)
.await
}
}
#[derive(DeriveIden)]
enum Folder {
Table,
ParentBranch,
}

View File

@@ -11,6 +11,7 @@ mod m20260404_000001_model_provider;
mod m20260406_000001_agent_setting_model_provider;
mod m20260420_000001_opened_tabs;
mod m20260422_000001_folder_sort_order;
mod m20260423_000001_drop_folder_parent_branch;
pub struct Migrator;
#[async_trait::async_trait]
@@ -28,6 +29,7 @@ impl MigratorTrait for Migrator {
Box::new(m20260406_000001_agent_setting_model_provider::Migration),
Box::new(m20260420_000001_opened_tabs::Migration),
Box::new(m20260422_000001_folder_sort_order::Migration),
Box::new(m20260423_000001_drop_folder_parent_branch::Migration),
]
}
}

View File

@@ -31,7 +31,6 @@ fn to_detail(m: folder::Model) -> FolderDetail {
name: m.name,
path: m.path,
git_branch: m.git_branch,
parent_branch: m.parent_branch,
default_agent_type,
last_opened_at: m.last_opened_at,
sort_order: m.sort_order,
@@ -85,7 +84,6 @@ pub async fn add_folder(
name: Set(name),
path: Set(path.to_string()),
git_branch: Set(None),
parent_branch: Set(None),
default_agent_type: Set(None),
last_opened_at: Set(now),
created_at: Set(now),
@@ -127,22 +125,6 @@ pub async fn remove_folder(conn: &DatabaseConnection, path: &str) -> Result<(),
Ok(())
}
pub async fn set_folder_parent_branch(
conn: &DatabaseConnection,
folder_id: i32,
parent_branch: Option<String>,
) -> Result<(), DbError> {
let row = folder::Entity::find_by_id(folder_id).one(conn).await?;
if let Some(row) = row {
let mut active = row.into_active_model();
active.parent_branch = Set(parent_branch);
active.updated_at = Set(Utc::now());
active.update(conn).await?;
}
Ok(())
}
pub async fn set_folder_open(
conn: &DatabaseConnection,
folder_id: i32,

View File

@@ -225,7 +225,6 @@ mod tauri_app {
folders::remove_folder_from_workspace,
folders::reorder_folders,
folders::add_folder_to_history,
folders::set_folder_parent_branch,
folders::remove_folder_from_history,
folders::create_folder_directory,
folders::clone_repository,

View File

@@ -17,7 +17,6 @@ pub struct FolderDetail {
pub name: String,
pub path: String,
pub git_branch: Option<String>,
pub parent_branch: Option<String>,
pub default_agent_type: Option<AgentType>,
pub last_opened_at: DateTime<Utc>,
pub sort_order: i32,

View File

@@ -287,13 +287,6 @@ pub async fn open_push_window(
}))
}
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SetFolderParentBranchParams {
pub path: String,
pub parent_branch: Option<String>,
}
pub async fn add_folder_to_history(
Extension(state): Extension<Arc<AppState>>,
Json(params): Json<AddFolderParams>,
@@ -305,16 +298,6 @@ pub async fn add_folder_to_history(
Ok(Json(result))
}
pub async fn set_folder_parent_branch(
Extension(state): Extension<Arc<AppState>>,
Json(params): Json<SetFolderParentBranchParams>,
) -> Result<Json<()>, AppCommandError> {
let db = &state.db;
folder_commands::set_folder_parent_branch_core(&db.conn, &params.path, params.parent_branch)
.await?;
Ok(Json(()))
}
pub async fn remove_folder_from_history(
Extension(state): Extension<Arc<AppState>>,
Json(params): Json<AddFolderParams>,

View File

@@ -114,10 +114,6 @@ pub fn build_router(state: Arc<AppState>, token: String, static_dir: std::path::
"/add_folder_to_history",
post(handlers::folders::add_folder_to_history),
)
.route(
"/set_folder_parent_branch",
post(handlers::folders::set_folder_parent_branch),
)
.route(
"/remove_folder_from_history",
post(handlers::folders::remove_folder_from_history),