feat(ui): Log Visualizer overlay reachable from a clickable footer log line
This commit is contained in:
@@ -234,6 +234,15 @@
|
|||||||
"reviewResetTip": "Alle Änderungen verwerfen und die Aufgabe auf Leerlauf zurücksetzen"
|
"reviewResetTip": "Alle Änderungen verwerfen und die Aufgabe auf Leerlauf zurücksetzen"
|
||||||
},
|
},
|
||||||
"modals": {
|
"modals": {
|
||||||
|
"logVisualizer": {
|
||||||
|
"title": "WORKER-LOGS — LETZTE 30 MIN",
|
||||||
|
"warnErrorOnly": "Nur Warnungen & Fehler",
|
||||||
|
"refresh": "Aktualisieren",
|
||||||
|
"empty": "Keine Logs in den letzten 30 Minuten.",
|
||||||
|
"count": "{0} Einträge",
|
||||||
|
"footerHint": "logs",
|
||||||
|
"openTooltip": "Aktuelle Worker-Logs anzeigen"
|
||||||
|
},
|
||||||
"about": {
|
"about": {
|
||||||
"title": "ÜBER",
|
"title": "ÜBER",
|
||||||
"version": "Version",
|
"version": "Version",
|
||||||
|
|||||||
@@ -234,6 +234,15 @@
|
|||||||
"reviewResetTip": "Discard all changes and reset the task to Idle"
|
"reviewResetTip": "Discard all changes and reset the task to Idle"
|
||||||
},
|
},
|
||||||
"modals": {
|
"modals": {
|
||||||
|
"logVisualizer": {
|
||||||
|
"title": "WORKER LOGS — LAST 30 MIN",
|
||||||
|
"warnErrorOnly": "Warnings & errors only",
|
||||||
|
"refresh": "Refresh",
|
||||||
|
"empty": "No logs in the last 30 minutes.",
|
||||||
|
"count": "{0} entries",
|
||||||
|
"footerHint": "logs",
|
||||||
|
"openTooltip": "View recent worker logs"
|
||||||
|
},
|
||||||
"about": {
|
"about": {
|
||||||
"title": "ABOUT",
|
"title": "ABOUT",
|
||||||
"version": "Version",
|
"version": "Version",
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ public interface IDialogService
|
|||||||
Task ShowWorktreesOverviewAsync(WorktreesOverviewModalViewModel vm);
|
Task ShowWorktreesOverviewAsync(WorktreesOverviewModalViewModel vm);
|
||||||
Task ShowWorkerConnectionAsync(WorkerConnectionModalViewModel vm);
|
Task ShowWorkerConnectionAsync(WorkerConnectionModalViewModel vm);
|
||||||
Task ShowConflictResolverAsync(ConflictResolverViewModel vm);
|
Task ShowConflictResolverAsync(ConflictResolverViewModel vm);
|
||||||
|
Task ShowLogVisualizerAsync(LogVisualizerViewModel vm);
|
||||||
|
|
||||||
/// <summary>Modal yes/no confirmation. Returns true only when confirmed.</summary>
|
/// <summary>Modal yes/no confirmation. Returns true only when confirmed.</summary>
|
||||||
Task<bool> ConfirmAsync(string message);
|
Task<bool> ConfirmAsync(string message);
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ public interface IWorkerClient : INotifyPropertyChanged
|
|||||||
Task UpdateDailyNoteAsync(string id, string text);
|
Task UpdateDailyNoteAsync(string id, string text);
|
||||||
Task DeleteDailyNoteAsync(string id);
|
Task DeleteDailyNoteAsync(string id);
|
||||||
Task<string> GetLastPrepLogAsync();
|
Task<string> GetLastPrepLogAsync();
|
||||||
|
Task<IReadOnlyList<WorkerLogEntry>> GetRecentLogsAsync();
|
||||||
|
|
||||||
Task<List<PrimeScheduleDto>> GetPrimeSchedulesAsync();
|
Task<List<PrimeScheduleDto>> GetPrimeSchedulesAsync();
|
||||||
Task<PrimeScheduleDto?> UpsertPrimeScheduleAsync(PrimeScheduleDto dto);
|
Task<PrimeScheduleDto?> UpsertPrimeScheduleAsync(PrimeScheduleDto dto);
|
||||||
|
|||||||
@@ -388,6 +388,9 @@ public partial class WorkerClient : ObservableObject, IAsyncDisposable, IWorkerC
|
|||||||
public async Task<string> GetLastPrepLogAsync()
|
public async Task<string> GetLastPrepLogAsync()
|
||||||
=> await TryInvokeAsync<string>("GetLastPrepLog") ?? string.Empty;
|
=> await TryInvokeAsync<string>("GetLastPrepLog") ?? string.Empty;
|
||||||
|
|
||||||
|
public async Task<IReadOnlyList<WorkerLogEntry>> GetRecentLogsAsync()
|
||||||
|
=> await TryInvokeAsync<List<WorkerLogEntry>>("GetRecentLogs") ?? new List<WorkerLogEntry>();
|
||||||
|
|
||||||
public async Task UpdateListAsync(UpdateListDto dto)
|
public async Task UpdateListAsync(UpdateListDto dto)
|
||||||
{
|
{
|
||||||
await _hub.InvokeAsync("UpdateList", dto);
|
await _hub.InvokeAsync("UpdateList", dto);
|
||||||
|
|||||||
@@ -290,6 +290,15 @@ public sealed partial class IslandsShellViewModel : ViewModelBase, IDisposable
|
|||||||
if (Dialogs is not null) await Dialogs.ShowAboutAsync(vm);
|
if (Dialogs is not null) await Dialogs.ShowAboutAsync(vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[RelayCommand]
|
||||||
|
private async Task OpenLogVisualizer()
|
||||||
|
{
|
||||||
|
if (Dialogs is null || Worker is null) return;
|
||||||
|
var vm = new LogVisualizerViewModel(Worker);
|
||||||
|
await vm.RefreshAsync();
|
||||||
|
await Dialogs.ShowLogVisualizerAsync(vm);
|
||||||
|
}
|
||||||
|
|
||||||
private bool _connectionPromptShown;
|
private bool _connectionPromptShown;
|
||||||
|
|
||||||
internal bool DecideShowConnectionPrompt(bool isOffline)
|
internal bool DecideShowConnectionPrompt(bool isOffline)
|
||||||
|
|||||||
58
src/ClaudeDo.Ui/ViewModels/Modals/LogVisualizerViewModel.cs
Normal file
58
src/ClaudeDo.Ui/ViewModels/Modals/LogVisualizerViewModel.cs
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using ClaudeDo.Data.Models;
|
||||||
|
using ClaudeDo.Ui.Localization;
|
||||||
|
using ClaudeDo.Ui.Services;
|
||||||
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
|
||||||
|
namespace ClaudeDo.Ui.ViewModels.Modals;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Log Visualizer overlay — shows the worker's last 30 min of log records (all levels),
|
||||||
|
/// fetched once on open via <see cref="IWorkerClient.GetRecentLogsAsync"/> with a manual
|
||||||
|
/// Refresh and a "warnings & errors only" filter.
|
||||||
|
/// </summary>
|
||||||
|
public sealed partial class LogVisualizerViewModel : ViewModelBase
|
||||||
|
{
|
||||||
|
private readonly IWorkerClient _worker;
|
||||||
|
private IReadOnlyList<WorkerLogEntry> _all = Array.Empty<WorkerLogEntry>();
|
||||||
|
|
||||||
|
public ObservableCollection<LogVisualizerRow> Rows { get; } = new();
|
||||||
|
|
||||||
|
[ObservableProperty] private bool _warnErrorOnly;
|
||||||
|
[ObservableProperty] private string _statusText = "";
|
||||||
|
|
||||||
|
public Action? CloseAction { get; set; }
|
||||||
|
|
||||||
|
public LogVisualizerViewModel(IWorkerClient worker) => _worker = worker;
|
||||||
|
|
||||||
|
[RelayCommand]
|
||||||
|
public async Task RefreshAsync()
|
||||||
|
{
|
||||||
|
_all = await _worker.GetRecentLogsAsync();
|
||||||
|
Apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
partial void OnWarnErrorOnlyChanged(bool value) => Apply();
|
||||||
|
|
||||||
|
private void Apply()
|
||||||
|
{
|
||||||
|
Rows.Clear();
|
||||||
|
IEnumerable<WorkerLogEntry> items = WarnErrorOnly
|
||||||
|
? _all.Where(e => e.Level is WorkerLogLevel.Warn or WorkerLogLevel.Error)
|
||||||
|
: _all;
|
||||||
|
foreach (var e in items)
|
||||||
|
Rows.Add(new LogVisualizerRow(e.TimestampUtc.ToLocalTime().ToString("HH:mm:ss"), e.Message, e.Level));
|
||||||
|
StatusText = Rows.Count == 0
|
||||||
|
? Loc.T("modals.logVisualizer.empty")
|
||||||
|
: Loc.T("modals.logVisualizer.count", Rows.Count);
|
||||||
|
}
|
||||||
|
|
||||||
|
[RelayCommand] private void Close() => CloseAction?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed record LogVisualizerRow(string Time, string Message, WorkerLogLevel Level);
|
||||||
@@ -215,15 +215,28 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<!-- Right: worker log line -->
|
<!-- Right: worker log line — click to open the Log Visualizer overlay -->
|
||||||
<TextBlock DockPanel.Dock="Right"
|
<Button DockPanel.Dock="Right"
|
||||||
Classes="meta"
|
Command="{Binding OpenLogVisualizerCommand}"
|
||||||
Text="{Binding WorkerLogText}"
|
Background="Transparent" BorderThickness="0" Padding="6,0"
|
||||||
IsVisible="{Binding IsWorkerLogVisible}"
|
Cursor="Hand" VerticalAlignment="Center"
|
||||||
Foreground="{Binding WorkerLogLevel, Converter={StaticResource WorkerLogLevelToBrush}}"
|
ToolTip.Tip="{loc:Tr modals.logVisualizer.openTooltip}">
|
||||||
LetterSpacing="1.4"
|
<Panel>
|
||||||
TextTrimming="CharacterEllipsis"
|
<TextBlock Classes="meta"
|
||||||
VerticalAlignment="Center"/>
|
Text="{loc:Tr modals.logVisualizer.footerHint}"
|
||||||
|
IsVisible="{Binding !IsWorkerLogVisible}"
|
||||||
|
Foreground="{DynamicResource TextMuteBrush}"
|
||||||
|
LetterSpacing="1.4"
|
||||||
|
VerticalAlignment="Center"/>
|
||||||
|
<TextBlock Classes="meta"
|
||||||
|
Text="{Binding WorkerLogText}"
|
||||||
|
IsVisible="{Binding IsWorkerLogVisible}"
|
||||||
|
Foreground="{Binding WorkerLogLevel, Converter={StaticResource WorkerLogLevelToBrush}}"
|
||||||
|
LetterSpacing="1.4"
|
||||||
|
TextTrimming="CharacterEllipsis"
|
||||||
|
VerticalAlignment="Center"/>
|
||||||
|
</Panel>
|
||||||
|
</Button>
|
||||||
|
|
||||||
<!-- Right: prime status notification -->
|
<!-- Right: prime status notification -->
|
||||||
<TextBlock DockPanel.Dock="Right"
|
<TextBlock DockPanel.Dock="Right"
|
||||||
|
|||||||
59
src/ClaudeDo.Ui/Views/Modals/LogVisualizerView.axaml
Normal file
59
src/ClaudeDo.Ui/Views/Modals/LogVisualizerView.axaml
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
<Window xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:vm="using:ClaudeDo.Ui.ViewModels.Modals"
|
||||||
|
xmlns:ctl="using:ClaudeDo.Ui.Views.Controls"
|
||||||
|
xmlns:converters="using:ClaudeDo.Ui.Converters"
|
||||||
|
xmlns:loc="using:ClaudeDo.Ui.Localization"
|
||||||
|
x:Class="ClaudeDo.Ui.Views.Modals.LogVisualizerView"
|
||||||
|
x:DataType="vm:LogVisualizerViewModel"
|
||||||
|
Title="{loc:Tr modals.logVisualizer.title}"
|
||||||
|
Width="760" Height="520"
|
||||||
|
WindowDecorations="None"
|
||||||
|
ExtendClientAreaToDecorationsHint="True"
|
||||||
|
WindowStartupLocation="CenterOwner"
|
||||||
|
Background="{DynamicResource SurfaceBrush}">
|
||||||
|
<Window.Resources>
|
||||||
|
<converters:WorkerLogLevelToBrushConverter x:Key="WorkerLogLevelToBrush"/>
|
||||||
|
</Window.Resources>
|
||||||
|
<Window.KeyBindings>
|
||||||
|
<KeyBinding Gesture="Escape" Command="{Binding CloseCommand}"/>
|
||||||
|
</Window.KeyBindings>
|
||||||
|
|
||||||
|
<ctl:ModalShell Title="{loc:Tr modals.logVisualizer.title}" CloseCommand="{Binding CloseCommand}">
|
||||||
|
<DockPanel LastChildFill="True">
|
||||||
|
<!-- Toolbar: filter · status · refresh -->
|
||||||
|
<Grid DockPanel.Dock="Top" ColumnDefinitions="Auto,*,Auto" Margin="14,10">
|
||||||
|
<CheckBox Grid.Column="0"
|
||||||
|
Content="{loc:Tr modals.logVisualizer.warnErrorOnly}"
|
||||||
|
IsChecked="{Binding WarnErrorOnly}"
|
||||||
|
VerticalAlignment="Center"/>
|
||||||
|
<TextBlock Grid.Column="1" Classes="meta"
|
||||||
|
Text="{Binding StatusText}"
|
||||||
|
HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||||
|
Foreground="{DynamicResource TextMuteBrush}"/>
|
||||||
|
<Button Grid.Column="2" Classes="btn"
|
||||||
|
Content="{loc:Tr modals.logVisualizer.refresh}"
|
||||||
|
Command="{Binding RefreshCommand}"/>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<!-- Last 30 min, oldest-first -->
|
||||||
|
<Border Classes="terminal" Margin="14,0,14,14">
|
||||||
|
<ScrollViewer VerticalScrollBarVisibility="Visible" AllowAutoHide="False" Padding="10,8">
|
||||||
|
<ItemsControl ItemsSource="{Binding Rows}">
|
||||||
|
<ItemsControl.ItemTemplate>
|
||||||
|
<DataTemplate DataType="vm:LogVisualizerRow">
|
||||||
|
<Grid ColumnDefinitions="64,*" Margin="0,1">
|
||||||
|
<TextBlock Grid.Column="0" Classes="log-ts" Text="{Binding Time}"/>
|
||||||
|
<SelectableTextBlock Grid.Column="1"
|
||||||
|
Text="{Binding Message}"
|
||||||
|
Foreground="{Binding Level, Converter={StaticResource WorkerLogLevelToBrush}}"
|
||||||
|
TextWrapping="Wrap"/>
|
||||||
|
</Grid>
|
||||||
|
</DataTemplate>
|
||||||
|
</ItemsControl.ItemTemplate>
|
||||||
|
</ItemsControl>
|
||||||
|
</ScrollViewer>
|
||||||
|
</Border>
|
||||||
|
</DockPanel>
|
||||||
|
</ctl:ModalShell>
|
||||||
|
</Window>
|
||||||
10
src/ClaudeDo.Ui/Views/Modals/LogVisualizerView.axaml.cs
Normal file
10
src/ClaudeDo.Ui/Views/Modals/LogVisualizerView.axaml.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Markup.Xaml;
|
||||||
|
|
||||||
|
namespace ClaudeDo.Ui.Views.Modals;
|
||||||
|
|
||||||
|
public partial class LogVisualizerView : Window
|
||||||
|
{
|
||||||
|
public LogVisualizerView() => InitializeComponent();
|
||||||
|
private void InitializeComponent() => AvaloniaXamlLoader.Load(this);
|
||||||
|
}
|
||||||
@@ -104,6 +104,13 @@ public sealed class WindowDialogService : IDialogService
|
|||||||
await dlg.ShowDialog(_owner);
|
await dlg.ShowDialog(_owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task ShowLogVisualizerAsync(LogVisualizerViewModel vm)
|
||||||
|
{
|
||||||
|
var dlg = new LogVisualizerView { DataContext = vm };
|
||||||
|
vm.CloseAction = () => dlg.Close();
|
||||||
|
await dlg.ShowDialog(_owner);
|
||||||
|
}
|
||||||
|
|
||||||
public Task<bool> ConfirmAsync(string message)
|
public Task<bool> ConfirmAsync(string message)
|
||||||
{
|
{
|
||||||
var tcs = new TaskCompletionSource<bool>();
|
var tcs = new TaskCompletionSource<bool>();
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ public abstract class StubWorkerClient : IWorkerClient
|
|||||||
public virtual Task FinalizePlanningSessionAsync(string taskId, bool queueAgentTasks = true, CancellationToken ct = default) => Task.CompletedTask;
|
public virtual Task FinalizePlanningSessionAsync(string taskId, bool queueAgentTasks = true, CancellationToken ct = default) => Task.CompletedTask;
|
||||||
public virtual Task<int> GetPendingDraftCountAsync(string taskId, CancellationToken ct = default) => Task.FromResult(0);
|
public virtual Task<int> GetPendingDraftCountAsync(string taskId, CancellationToken ct = default) => Task.FromResult(0);
|
||||||
public virtual Task<MergeTargetsDto?> GetMergeTargetsAsync(string taskId) => Task.FromResult<MergeTargetsDto?>(null);
|
public virtual Task<MergeTargetsDto?> GetMergeTargetsAsync(string taskId) => Task.FromResult<MergeTargetsDto?>(null);
|
||||||
|
public virtual Task<IReadOnlyList<WorkerLogEntry>> GetRecentLogsAsync() => Task.FromResult<IReadOnlyList<WorkerLogEntry>>(Array.Empty<WorkerLogEntry>());
|
||||||
public virtual Task<IReadOnlyList<SubtaskDiffDto>> GetPlanningAggregateAsync(string planningTaskId)
|
public virtual Task<IReadOnlyList<SubtaskDiffDto>> GetPlanningAggregateAsync(string planningTaskId)
|
||||||
=> Task.FromResult<IReadOnlyList<SubtaskDiffDto>>(Array.Empty<SubtaskDiffDto>());
|
=> Task.FromResult<IReadOnlyList<SubtaskDiffDto>>(Array.Empty<SubtaskDiffDto>());
|
||||||
public virtual Task<CombinedDiffResultDto?> BuildPlanningIntegrationBranchAsync(string planningTaskId, string targetBranch)
|
public virtual Task<CombinedDiffResultDto?> BuildPlanningIntegrationBranchAsync(string planningTaskId, string targetBranch)
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
using ClaudeDo.Data.Models;
|
||||||
|
using ClaudeDo.Ui.Services;
|
||||||
|
using ClaudeDo.Ui.ViewModels.Modals;
|
||||||
|
|
||||||
|
namespace ClaudeDo.Ui.Tests.ViewModels;
|
||||||
|
|
||||||
|
public class LogVisualizerViewModelTests
|
||||||
|
{
|
||||||
|
private sealed class FakeClient : StubWorkerClient
|
||||||
|
{
|
||||||
|
private readonly IReadOnlyList<WorkerLogEntry> _logs;
|
||||||
|
public FakeClient(IReadOnlyList<WorkerLogEntry> logs) => _logs = logs;
|
||||||
|
public override Task<IReadOnlyList<WorkerLogEntry>> GetRecentLogsAsync() => Task.FromResult(_logs);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static WorkerLogEntry E(WorkerLogLevel lvl, string msg)
|
||||||
|
=> new(msg, lvl, new DateTime(2026, 6, 23, 8, 0, 0, DateTimeKind.Utc));
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task Refresh_populates_rows_from_worker()
|
||||||
|
{
|
||||||
|
var vm = new LogVisualizerViewModel(new FakeClient(new[] { E(WorkerLogLevel.Info, "a"), E(WorkerLogLevel.Error, "b") }));
|
||||||
|
|
||||||
|
await vm.RefreshAsync();
|
||||||
|
|
||||||
|
Assert.Equal(new[] { "a", "b" }, vm.Rows.Select(r => r.Message));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task WarnErrorOnly_filters_out_info()
|
||||||
|
{
|
||||||
|
var vm = new LogVisualizerViewModel(new FakeClient(new[]
|
||||||
|
{ E(WorkerLogLevel.Info, "a"), E(WorkerLogLevel.Warn, "w"), E(WorkerLogLevel.Error, "e") }));
|
||||||
|
await vm.RefreshAsync();
|
||||||
|
|
||||||
|
vm.WarnErrorOnly = true;
|
||||||
|
|
||||||
|
Assert.Equal(new[] { "w", "e" }, vm.Rows.Select(r => r.Message));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task Empty_logs_yield_no_rows_and_a_status()
|
||||||
|
{
|
||||||
|
var vm = new LogVisualizerViewModel(new FakeClient(Array.Empty<WorkerLogEntry>()));
|
||||||
|
|
||||||
|
await vm.RefreshAsync();
|
||||||
|
|
||||||
|
Assert.Empty(vm.Rows);
|
||||||
|
Assert.False(string.IsNullOrEmpty(vm.StatusText));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -71,6 +71,7 @@ sealed class FakeWorkerClient : IWorkerClient
|
|||||||
}
|
}
|
||||||
public Task FinalizePlanningSessionAsync(string taskId, bool queueAgentTasks = true, CancellationToken ct = default) { FinalizePlanningCalls++; return Task.CompletedTask; }
|
public Task FinalizePlanningSessionAsync(string taskId, bool queueAgentTasks = true, CancellationToken ct = default) { FinalizePlanningCalls++; return Task.CompletedTask; }
|
||||||
public Task<int> GetPendingDraftCountAsync(string taskId, CancellationToken ct = default) => Task.FromResult(0);
|
public Task<int> GetPendingDraftCountAsync(string taskId, CancellationToken ct = default) => Task.FromResult(0);
|
||||||
|
public Task<IReadOnlyList<WorkerLogEntry>> GetRecentLogsAsync() => Task.FromResult<IReadOnlyList<WorkerLogEntry>>(System.Array.Empty<WorkerLogEntry>());
|
||||||
|
|
||||||
public event Action? PrepStartedEvent;
|
public event Action? PrepStartedEvent;
|
||||||
public event Action<string>? PrepLineEvent;
|
public event Action<string>? PrepLineEvent;
|
||||||
|
|||||||
Reference in New Issue
Block a user