feat(daily-prep): load persisted prep log into the terminal on open
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -63,4 +63,5 @@ public interface IWorkerClient : INotifyPropertyChanged
|
|||||||
Task<DailyNoteDto?> AddDailyNoteAsync(DateOnly day, string text);
|
Task<DailyNoteDto?> AddDailyNoteAsync(DateOnly day, string text);
|
||||||
Task UpdateDailyNoteAsync(string id, string text);
|
Task UpdateDailyNoteAsync(string id, string text);
|
||||||
Task DeleteDailyNoteAsync(string id);
|
Task DeleteDailyNoteAsync(string id);
|
||||||
|
Task<string> GetLastPrepLogAsync();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -360,6 +360,9 @@ public partial class WorkerClient : ObservableObject, IAsyncDisposable, IWorkerC
|
|||||||
public async Task DeleteDailyNoteAsync(string id)
|
public async Task DeleteDailyNoteAsync(string id)
|
||||||
=> await _hub.InvokeAsync("DeleteDailyNote", id);
|
=> await _hub.InvokeAsync("DeleteDailyNote", id);
|
||||||
|
|
||||||
|
public async Task<string> GetLastPrepLogAsync()
|
||||||
|
=> await TryInvokeAsync<string>("GetLastPrepLog") ?? string.Empty;
|
||||||
|
|
||||||
public async Task UpdateListAsync(UpdateListDto dto)
|
public async Task UpdateListAsync(UpdateListDto dto)
|
||||||
{
|
{
|
||||||
await _hub.InvokeAsync("UpdateList", dto);
|
await _hub.InvokeAsync("UpdateList", dto);
|
||||||
|
|||||||
@@ -518,6 +518,21 @@ public sealed partial class DetailsIslandViewModel : ViewModelBase
|
|||||||
Bind(null);
|
Bind(null);
|
||||||
IsNotesMode = false;
|
IsNotesMode = false;
|
||||||
IsPrepMode = true;
|
IsPrepMode = true;
|
||||||
|
_ = LoadLastPrepLogIfEmptyAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task LoadLastPrepLogIfEmptyAsync()
|
||||||
|
{
|
||||||
|
if (_worker is null || IsPrepRunning || PrepLog.Count > 0) return;
|
||||||
|
string text;
|
||||||
|
try { text = await _worker.GetLastPrepLogAsync(); }
|
||||||
|
catch { return; }
|
||||||
|
if (IsPrepRunning || PrepLog.Count > 0) return;
|
||||||
|
foreach (var line in text.Split('\n'))
|
||||||
|
{
|
||||||
|
var trimmed = line.TrimEnd('\r');
|
||||||
|
if (trimmed.Length > 0) AppendStdoutLine(PrepLog, trimmed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Bind(TaskRowViewModel? row)
|
public void Bind(TaskRowViewModel? row)
|
||||||
|
|||||||
@@ -78,6 +78,8 @@ public abstract class StubWorkerClient : IWorkerClient
|
|||||||
public virtual Task<DailyNoteDto?> AddDailyNoteAsync(DateOnly day, string text) => Task.FromResult<DailyNoteDto?>(null);
|
public virtual Task<DailyNoteDto?> AddDailyNoteAsync(DateOnly day, string text) => Task.FromResult<DailyNoteDto?>(null);
|
||||||
public virtual Task UpdateDailyNoteAsync(string id, string text) => Task.CompletedTask;
|
public virtual Task UpdateDailyNoteAsync(string id, string text) => Task.CompletedTask;
|
||||||
public virtual Task DeleteDailyNoteAsync(string id) => Task.CompletedTask;
|
public virtual Task DeleteDailyNoteAsync(string id) => Task.CompletedTask;
|
||||||
|
public string LastPrepLog = "";
|
||||||
|
public virtual Task<string> GetLastPrepLogAsync() => Task.FromResult(LastPrepLog);
|
||||||
|
|
||||||
protected void RaisePropertyChanged(string name) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
protected void RaisePropertyChanged(string name) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,4 +80,16 @@ public class DetailsIslandPrepModeTests : IDisposable
|
|||||||
Assert.False(vm.IsNotesMode);
|
Assert.False(vm.IsNotesMode);
|
||||||
Assert.False(vm.IsTaskDetailVisible);
|
Assert.False(vm.IsTaskDetailVisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task ShowPrep_loads_persisted_log_when_empty()
|
||||||
|
{
|
||||||
|
var stub = new DefaultStub { LastPrepLog = "{\"type\":\"assistant\",\"message\":{\"content\":[{\"type\":\"text\",\"text\":\"restored\"}]}}" };
|
||||||
|
var vm = NewDetailsVm(stub);
|
||||||
|
|
||||||
|
vm.ShowPrep();
|
||||||
|
await vm.LoadLastPrepLogIfEmptyAsync();
|
||||||
|
|
||||||
|
Assert.NotEmpty(vm.PrepLog);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ sealed class FakeWorkerClient : IWorkerClient
|
|||||||
public Task<DailyNoteDto?> AddDailyNoteAsync(DateOnly day, string text) => Task.FromResult<DailyNoteDto?>(null);
|
public Task<DailyNoteDto?> AddDailyNoteAsync(DateOnly day, string text) => Task.FromResult<DailyNoteDto?>(null);
|
||||||
public Task UpdateDailyNoteAsync(string id, string text) => Task.CompletedTask;
|
public Task UpdateDailyNoteAsync(string id, string text) => Task.CompletedTask;
|
||||||
public Task DeleteDailyNoteAsync(string id) => Task.CompletedTask;
|
public Task DeleteDailyNoteAsync(string id) => Task.CompletedTask;
|
||||||
|
public Task<string> GetLastPrepLogAsync() => Task.FromResult(string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Helper to build VM with pre-seeded Items ──────────────────────────────────
|
// ── Helper to build VM with pre-seeded Items ──────────────────────────────────
|
||||||
|
|||||||
Reference in New Issue
Block a user