StreamLineFormatter now returns kind-tagged entries (text, tool, edit, tool result, error, sys, result) instead of a flat string, so the existing LogKind colours finally apply to stream-json output. Tool argument/result limit raised from 120 to 500 chars.
46 lines
1.5 KiB
C#
46 lines
1.5 KiB
C#
using System.Globalization;
|
|
using Avalonia;
|
|
using Avalonia.Data.Converters;
|
|
using Avalonia.Media;
|
|
using Avalonia.Styling;
|
|
using ClaudeDo.Ui.ViewModels.Islands;
|
|
|
|
namespace ClaudeDo.Ui.Converters;
|
|
|
|
public sealed class LogKindForegroundConverter : IValueConverter
|
|
{
|
|
private static IBrush? Resolve(string key)
|
|
{
|
|
if (Application.Current is { } app &&
|
|
app.Resources.TryGetResource(key, app.ActualThemeVariant, out var res) &&
|
|
res is IBrush brush)
|
|
{
|
|
return brush;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
{
|
|
var key = value is LogKind kind ? kind switch
|
|
{
|
|
LogKind.Sys => "TextMuteBrush",
|
|
LogKind.Tool => "SageBrush",
|
|
LogKind.Claude => "TextBrush",
|
|
LogKind.Stdout => "TextDimBrush",
|
|
LogKind.Stderr => "BloodBrush",
|
|
LogKind.Done => "MossBrightBrush",
|
|
LogKind.Msg => "TextDimBrush",
|
|
LogKind.User => "AccentBrush",
|
|
LogKind.Edit => "AmberBrush",
|
|
LogKind.ToolResult => "TextMuteBrush",
|
|
_ => "TextDimBrush",
|
|
} : "TextDimBrush";
|
|
|
|
return Resolve(key) ?? AvaloniaProperty.UnsetValue;
|
|
}
|
|
|
|
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) =>
|
|
throw new NotSupportedException();
|
|
}
|