features: add commit and push option to git commit window

- Add split button with dropdown in commit dialog supporting both
  "Commit" and "Commit and Push" actions
- Pass folderId through gitCommit/gitPush API calls so backend emits
  events that the folder window can receive for toast notifications
- Update Tauri git_commit and git_push commands to accept folder_id
  parameter with window label fallback for cross-window compatibility
- Wrap commit page with GitCredentialProvider for push authentication
- Keep commit window open when push fails so user can see the error
- Add i18n translations for all 10 locales

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
xintaofei
2026-04-02 16:22:41 +08:00
parent 1287dab37c
commit efd8e1104f
16 changed files with 184 additions and 82 deletions

View File

@@ -1052,12 +1052,15 @@ pub async fn git_push(
path: String,
remote: Option<String>,
credentials: Option<GitCredentials>,
folder_id: Option<i32>,
db: tauri::State<'_, AppDatabase>,
) -> Result<GitPushResult, AppCommandError> {
let folder_id = window
.label()
.strip_prefix("push-")
.and_then(|value| value.parse::<i32>().ok());
let folder_id = folder_id.or_else(|| {
window
.label()
.strip_prefix("push-")
.and_then(|value| value.parse::<i32>().ok())
});
let data_dir = app.path().app_data_dir().map_err(|e| {
AppCommandError::external_command("Failed to resolve app data dir", e.to_string())
})?;
@@ -1658,11 +1661,14 @@ pub async fn git_commit(
path: String,
message: String,
files: Vec<String>,
folder_id: Option<i32>,
) -> Result<GitCommitResult, AppCommandError> {
let folder_id = window
.label()
.strip_prefix("commit-")
.and_then(|value| value.parse::<i32>().ok());
let folder_id = folder_id.or_else(|| {
window
.label()
.strip_prefix("commit-")
.and_then(|value| value.parse::<i32>().ok())
});
let emitter = EventEmitter::Tauri(app.clone());
git_commit_core(&emitter, folder_id, &db.conn, &path, &message, &files).await
}