chore(claude-do): fix(ui): DiffModal — Commit-Range ohne HeadCommit zeigt stil

Befund (bestätigt): src/ClaudeDo.Ui/ViewModels/Modals/DiffModalViewModel.cs, LoadAsync (~Zeile 116): bei FromCommitRange=true aber HeadCommit==null fällt der Ternary still auf GetBranchDiffAsync(WorktreePath, BaseRef) zurück. In diesem Modus ist WorktreePath aber das Listen-Working-Dir (Repo-Root, kein Worktree) — es wird ein falscher Diff angezeigt, ohne jeden Hinweis.

Änderungen:
1. Guard: From

ClaudeDo-Task: d667c80c-3f32-478c-8584-46aec78357b6
This commit is contained in:
mika kuns
2026-06-09 23:14:37 +02:00
parent ddeded988a
commit 7e739afafb
4 changed files with 62 additions and 2 deletions

View File

@@ -0,0 +1,54 @@
using System.IO;
using ClaudeDo.Localization;
using ClaudeDo.Ui.Localization;
using ClaudeDo.Ui.ViewModels.Modals;
namespace ClaudeDo.Ui.Tests.ViewModels;
public class DiffModalViewModelTests
{
public DiffModalViewModelTests()
{
var dir = AppContext.BaseDirectory;
while (dir is not null && !Directory.Exists(Path.Combine(dir, "src", "ClaudeDo.Localization", "locales")))
dir = Path.GetDirectoryName(dir);
Loc.Current = new Localizer(
LocaleStore.Load(Path.Combine(dir!, "src", "ClaudeDo.Localization", "locales")), "en");
}
[Fact]
public async Task LoadAsync_CommitRange_NullHeadCommit_ShowsUnavailableState()
{
var vm = new DiffModalViewModel(null!)
{
WorktreePath = "/some/repo",
BaseRef = "abc123",
HeadCommit = null,
FromCommitRange = true,
};
await vm.LoadAsync();
Assert.Empty(vm.Files);
Assert.NotNull(vm.StatusMessage);
Assert.Contains("no longer available", vm.StatusMessage, StringComparison.OrdinalIgnoreCase);
}
[Fact]
public async Task LoadAsync_CommitRange_NullBaseRef_ShowsUnavailableState()
{
var vm = new DiffModalViewModel(null!)
{
WorktreePath = "/some/repo",
BaseRef = null,
HeadCommit = "def456",
FromCommitRange = true,
};
await vm.LoadAsync();
Assert.Empty(vm.Files);
Assert.NotNull(vm.StatusMessage);
Assert.Contains("no longer available", vm.StatusMessage, StringComparison.OrdinalIgnoreCase);
}
}