feat(merge): Stash-Option fuer uncommittete Aenderungen im Ziel-Tree
Changelog / changelog (push) Successful in 2s
Release / release (push) Successful in 43s

Ein dirty Ziel-Arbeitsverzeichnis gibt jetzt den eigenen Status
dirty_target zurueck statt blocked. Die UI bietet daraufhin einen
Retry an, der per git merge --autostash stasht, merged und die
Aenderungen danach wiederherstellt - opt-in pro Merge:

- Approve & Merge: Bestaetigungsdialog
- Merge-Modal: Button "Aenderungen stashen und mergen"
- MCP (merge_task/review_task) wirft weiterhin, kein autostash dort
This commit is contained in:
mika kuns
2026-09-11 11:43:28 +02:00
parent 8e2d37e63e
commit 251b70ce83
20 changed files with 164 additions and 43 deletions
@@ -31,6 +31,10 @@ public sealed partial class MergeModalViewModel : ViewModelBase
[ObservableProperty] private string? _warningMessage;
[ObservableProperty] private string? _successMessage;
[ObservableProperty][NotifyCanExecuteChangedFor(nameof(SubmitCommand))] private bool _hasConflict;
/// The merge was refused because the target working dir is dirty — offer the stash retry
/// instead of dead-ending on the error text.
[ObservableProperty] private bool _showStashRetry;
[ObservableProperty] private IReadOnlyList<string> _conflictFiles = Array.Empty<string>();
public Action? CloseAction { get; set; }
@@ -84,13 +88,21 @@ public sealed partial class MergeModalViewModel : ViewModelBase
!IsBusy && !HasConflict && !string.IsNullOrWhiteSpace(SelectedBranch);
[RelayCommand(CanExecute = nameof(CanSubmit))]
private async Task SubmitAsync()
private Task SubmitAsync() => RunMergeAsync(autostash: false);
/// Retry after "dirty_target": git stashes the target working tree's uncommitted changes,
/// merges, and restores them afterwards.
[RelayCommand(CanExecute = nameof(CanSubmit))]
private Task StashAndMergeAsync() => RunMergeAsync(autostash: true);
private async Task RunMergeAsync(bool autostash)
{
if (string.IsNullOrWhiteSpace(SelectedBranch)) return;
IsBusy = true;
ErrorMessage = null;
WarningMessage = null;
SuccessMessage = null;
ShowStashRetry = false;
// Subscribed only for the duration of the call: the worker's broadcast reaches every
// client, and a transient VM left on that event would outlive its window.
ProgressMessage = Loc.T("vm.merge.progressMerging");
@@ -98,7 +110,7 @@ public sealed partial class MergeModalViewModel : ViewModelBase
try
{
var result = await _worker.MergeTaskAsync(
TaskId, SelectedBranch!, RemoveWorktree, CommitMessage);
TaskId, SelectedBranch!, RemoveWorktree, CommitMessage, autostash);
switch (result.Status)
{
@@ -130,6 +142,12 @@ public sealed partial class MergeModalViewModel : ViewModelBase
// point of the gate.
ErrorMessage = result.ErrorMessage ?? Loc.T("vm.merge.verifyFailed");
break;
case "dirty_target":
// Nothing landed -- the target working dir has uncommitted changes. Offer the
// stash retry; git restores the changes after the merge.
ErrorMessage = result.ErrorMessage ?? Loc.T("vm.merge.dirtyTarget");
ShowStashRetry = true;
break;
case "untracked_collision":
// Nothing landed -- the merge was refused before touching the repo. Show the
// real message (it names the colliding path and size); the locale string is
@@ -415,7 +415,8 @@ public sealed partial class WorktreesOverviewModalViewModel : ViewModelBase
private bool CanMergeAll() => !BatchMergeStatus.IsRunning && SelectedCount > 0 && !string.IsNullOrWhiteSpace(SelectedTarget);
[RelayCommand(CanExecute = nameof(CanMergeAll))]
private Task MergeAll() => MergeSelectedAsync(_worker.MergeTaskAsync);
private Task MergeAll() => MergeSelectedAsync(
(taskId, target, removeWorktree, message) => _worker.MergeTaskAsync(taskId, target, removeWorktree, message));
[RelayCommand]
private void ResolveConflict(WorktreeOverviewRowViewModel? row)