fix(worker-client): stop swallowing mutating hub call failures
TryInvokeAsync catches every exception and returns null, which is fine
for read-only calls but hid real HubException reasons behind a generic
"offline" message for the 7 mutating call sites (RestoreDefaultAgents,
UpsertPrimeSchedule, AddDailyNote, CleanupFinishedWorktrees,
ResetAllWorktrees, ForceRemoveWorktree, BuildPlanningIntegrationBranch)
— the same bug class fixed for ApproveReview in e1807fd. Each of the 22
TryInvokeAsync call sites was audited; the 15 read-only ones are left
unchanged (empty/offline is the right display). For the 7 switched to
a direct hub invoke, every caller was checked and, where it had no
catch, one was added so the exception surfaces (StatusMessage,
ShowErrorAsync/CombinedWarning) instead of crashing.
This commit is contained in:
@@ -27,6 +27,33 @@ public class NotesEditorViewModelTests
|
||||
public Task DeleteAsync(string id) { Store.RemoveAll(n => n.Id == id); return Task.CompletedTask; }
|
||||
}
|
||||
|
||||
private sealed class ThrowingNotes : INotesApi
|
||||
{
|
||||
public string ExceptionMessage { get; init; } = "worker offline";
|
||||
public Task<List<DailyNoteDto>> ListAsync(DateOnly day) => Task.FromResult(new List<DailyNoteDto>());
|
||||
public Task<DailyNoteDto?> AddAsync(DateOnly day, string text) => throw new Exception(ExceptionMessage);
|
||||
public Task UpdateAsync(string id, string text) => Task.CompletedTask;
|
||||
public Task DeleteAsync(string id) => Task.CompletedTask;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AddBullet_WhenApiThrows_RaisesErrorReported_AndKeepsDraftText()
|
||||
{
|
||||
var api = new ThrowingNotes();
|
||||
var vm = new NotesEditorViewModel(api);
|
||||
await vm.LoadDayAsync(new DateOnly(2026, 6, 1));
|
||||
|
||||
string? reportedError = null;
|
||||
vm.ErrorReported += msg => reportedError = msg;
|
||||
|
||||
vm.NewBulletText = "Standup vorbereitet";
|
||||
await vm.AddBulletCommand.ExecuteAsync(null);
|
||||
|
||||
Assert.Equal(api.ExceptionMessage, reportedError);
|
||||
Assert.Empty(vm.Bullets);
|
||||
Assert.Equal("Standup vorbereitet", vm.NewBulletText);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AddBullet_PersistsAndAppears_ForCurrentDay()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user