feat(ui): Log Visualizer overlay reachable from a clickable footer log line
This commit is contained in:
@@ -21,6 +21,7 @@ public interface IDialogService
|
||||
Task ShowWorktreesOverviewAsync(WorktreesOverviewModalViewModel vm);
|
||||
Task ShowWorkerConnectionAsync(WorkerConnectionModalViewModel vm);
|
||||
Task ShowConflictResolverAsync(ConflictResolverViewModel vm);
|
||||
Task ShowLogVisualizerAsync(LogVisualizerViewModel vm);
|
||||
|
||||
/// <summary>Modal yes/no confirmation. Returns true only when confirmed.</summary>
|
||||
Task<bool> ConfirmAsync(string message);
|
||||
|
||||
@@ -85,6 +85,7 @@ public interface IWorkerClient : INotifyPropertyChanged
|
||||
Task UpdateDailyNoteAsync(string id, string text);
|
||||
Task DeleteDailyNoteAsync(string id);
|
||||
Task<string> GetLastPrepLogAsync();
|
||||
Task<IReadOnlyList<WorkerLogEntry>> GetRecentLogsAsync();
|
||||
|
||||
Task<List<PrimeScheduleDto>> GetPrimeSchedulesAsync();
|
||||
Task<PrimeScheduleDto?> UpsertPrimeScheduleAsync(PrimeScheduleDto dto);
|
||||
|
||||
@@ -388,6 +388,9 @@ public partial class WorkerClient : ObservableObject, IAsyncDisposable, IWorkerC
|
||||
public async Task<string> GetLastPrepLogAsync()
|
||||
=> 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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
[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;
|
||||
|
||||
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>
|
||||
</Button>
|
||||
|
||||
<!-- Right: worker log line -->
|
||||
<TextBlock DockPanel.Dock="Right"
|
||||
Classes="meta"
|
||||
Text="{Binding WorkerLogText}"
|
||||
IsVisible="{Binding IsWorkerLogVisible}"
|
||||
Foreground="{Binding WorkerLogLevel, Converter={StaticResource WorkerLogLevelToBrush}}"
|
||||
LetterSpacing="1.4"
|
||||
TextTrimming="CharacterEllipsis"
|
||||
VerticalAlignment="Center"/>
|
||||
<!-- Right: worker log line — click to open the Log Visualizer overlay -->
|
||||
<Button DockPanel.Dock="Right"
|
||||
Command="{Binding OpenLogVisualizerCommand}"
|
||||
Background="Transparent" BorderThickness="0" Padding="6,0"
|
||||
Cursor="Hand" VerticalAlignment="Center"
|
||||
ToolTip.Tip="{loc:Tr modals.logVisualizer.openTooltip}">
|
||||
<Panel>
|
||||
<TextBlock Classes="meta"
|
||||
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 -->
|
||||
<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);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
var tcs = new TaskCompletionSource<bool>();
|
||||
|
||||
Reference in New Issue
Block a user