Files
agent-wiki-ui/Gui/MainWindow.axaml
T
davideandClaude Sonnet 5.5 941d02110d GUI Avalonia multipiattaforma in solo C# e rinomina in agent-wiki-ui
Sostituisce WinForms, WebView2 e ui.html con una GUI Avalonia (XAML,
ViewModel, tema chiaro/scuro) e un renderer markdown che trasforma l'albero
di Markdig in controlli. Un solo progetto net10.0 per Windows e Linux, con
publish single-file compresso. L'avvio di claude è in un solo punto
(Core/Claude.cs) condiviso da CLI e GUI. Il nome dell'app viene
dall'AssemblyName; ChatStore migra la cartella dati LlmRun alla nuova.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-15 11:18:46 +02:00

168 lines
11 KiB
XML

<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:gui="using:AgentWikiUi.Gui"
xmlns:core="using:AgentWikiUi.Core"
x:Class="AgentWikiUi.Gui.MainWindow"
x:DataType="gui:MainViewModel"
Title="{x:Static core:AppInfo.Name}"
MinWidth="900" MinHeight="600">
<Grid ColumnDefinitions="Auto,*">
<!-- Barra laterale -->
<Border Grid.Column="0" Width="272" IsVisible="{Binding SidebarOpen}"
Background="{DynamicResource Muted}" BorderBrush="{DynamicResource Border}" BorderThickness="0,0,1,0">
<DockPanel>
<StackPanel DockPanel.Dock="Top" Margin="14,16,14,10" Spacing="14">
<StackPanel Orientation="Horizontal" Spacing="10" Margin="4,0">
<Border Width="28" Height="28" CornerRadius="8" Background="{DynamicResource Accent}">
<Viewbox Width="16" Height="16">
<Path Data="M12 2L14.4 8.6L21 11L14.4 13.4L12 20L9.6 13.4L3 11L9.6 8.6Z" Fill="{DynamicResource OnAccent}" />
</Viewbox>
</Border>
<TextBlock Text="{x:Static core:AppInfo.Name}" FontWeight="SemiBold" VerticalAlignment="Center" />
</StackPanel>
<Button Classes="ghost" Command="{Binding NewChatCommand}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Center"
Background="{DynamicResource Bg}" AutomationProperties.Name="Nuova chat">
<StackPanel Orientation="Horizontal" Spacing="8">
<Viewbox Width="16" Height="16"><Path Data="M12 5V19M5 12H19" Stroke="{DynamicResource Fg}" StrokeThickness="2" StrokeLineCap="Round" /></Viewbox>
<TextBlock Text="Nuova chat" />
</StackPanel>
</Button>
</StackPanel>
<TextBlock DockPanel.Dock="Top" Text="CHAT" FontSize="11.5" FontWeight="SemiBold" Foreground="{DynamicResource FgMuted}" Margin="22,8,14,4" />
<TextBlock DockPanel.Dock="Top" Text="Nessuna chat salvata" Foreground="{DynamicResource FgMuted}" FontSize="13.5" Margin="22,6"
IsVisible="{Binding !Chats.Count}" />
<ScrollViewer>
<ItemsControl ItemsSource="{Binding Chats}">
<ItemsControl.ItemTemplate>
<DataTemplate x:DataType="gui:ChatItem">
<Border Classes="item" Classes.active="{Binding IsActive}">
<Grid ColumnDefinitions="*,Auto">
<Button Grid.ColumnSpan="2" Background="Transparent" BorderThickness="0" HorizontalAlignment="Stretch"
HorizontalContentAlignment="Left" Padding="12,8,40,8"
Command="{Binding $parent[ItemsControl].((gui:MainViewModel)DataContext).OpenCommand}" CommandParameter="{Binding}"
AutomationProperties.Name="{Binding Title, StringFormat='Apri chat: {0}'}">
<StackPanel>
<TextBlock Text="{Binding Title}" TextTrimming="CharacterEllipsis" FontSize="14" />
<TextBlock Text="{Binding When}" FontSize="12" Foreground="{DynamicResource FgMuted}" />
</StackPanel>
</Button>
<Button Grid.Column="1" Background="Transparent" BorderThickness="0" Width="32" Height="32" Margin="0,0,4,0"
VerticalAlignment="Center" Padding="0" HorizontalContentAlignment="Center"
Command="{Binding $parent[ItemsControl].((gui:MainViewModel)DataContext).DeleteCommand}" CommandParameter="{Binding}"
AutomationProperties.Name="Elimina chat">
<Viewbox Width="12" Height="12"><Path Data="M6 6L18 18M18 6L6 18" Stroke="{DynamicResource FgMuted}" StrokeThickness="2.4" StrokeLineCap="Round" /></Viewbox>
</Button>
</Grid>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</DockPanel>
</Border>
<!-- Area principale -->
<Grid Grid.Column="1" RowDefinitions="*,Auto">
<ScrollViewer Grid.Row="0" x:Name="Scroll">
<StackPanel MaxWidth="780" Margin="24,56,24,16" Spacing="20">
<!-- Schermata iniziale -->
<StackPanel IsVisible="{Binding ShowEmpty}" Spacing="10" Margin="0,40,0,0" HorizontalAlignment="Center">
<Border Width="44" Height="44" CornerRadius="12" Background="{DynamicResource Accent}" HorizontalAlignment="Center">
<Viewbox Width="24" Height="24">
<Path Data="M12 2L14.4 8.6L21 11L14.4 13.4L12 20L9.6 13.4L3 11L9.6 8.6Z" Fill="{DynamicResource OnAccent}" />
</Viewbox>
</Border>
<TextBlock Text="Come posso aiutarti?" FontSize="28" FontWeight="SemiBold" HorizontalAlignment="Center" />
<TextBlock Text="Scrivi un messaggio oppure parti da uno di questi spunti." Foreground="{DynamicResource FgMuted}" HorizontalAlignment="Center" />
<ItemsControl ItemsSource="{Binding Suggestions}" Margin="0,16,0,0" Width="640">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate><UniformGrid Columns="2" /></ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate x:DataType="gui:Suggestion">
<Button Classes="chip" Margin="5" Command="{Binding $parent[ItemsControl].((gui:MainViewModel)DataContext).SuggestCommand}" CommandParameter="{Binding}">
<StackPanel>
<TextBlock Text="{Binding Title}" FontWeight="SemiBold" />
<TextBlock Text="{Binding Subtitle}" FontSize="12.5" Foreground="{DynamicResource FgMuted}" />
</StackPanel>
</Button>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
<!-- Conversazione -->
<ItemsControl ItemsSource="{Binding Messages}" AutomationProperties.Name="Conversazione">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate><StackPanel Spacing="22" /></ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate x:DataType="gui:MessageVm">
<Panel>
<Border IsVisible="{Binding IsUser}" HorizontalAlignment="Right" MaxWidth="620" CornerRadius="18,18,4,18"
Background="{DynamicResource AccentSoft}" Padding="16,10">
<SelectableTextBlock Text="{Binding Text}" TextWrapping="Wrap" />
</Border>
<StackPanel IsVisible="{Binding IsAi}" Spacing="6">
<TextBlock Text="Claude" FontWeight="SemiBold" FontSize="13.5" Foreground="{DynamicResource Accent}" />
<gui:MarkdownView Source="{Binding Text}" />
<Button Classes="ghost" HorizontalAlignment="Left" MinHeight="30" Padding="10,0" FontSize="13" Content="Copia"
Command="{Binding $parent[ItemsControl].((gui:MainViewModel)DataContext).CopyCommand}" CommandParameter="{Binding Text}"
AutomationProperties.Name="Copia la risposta" />
</StackPanel>
<SelectableTextBlock IsVisible="{Binding IsErr}" Text="{Binding Text}" TextWrapping="Wrap" Foreground="{DynamicResource Err}" />
</Panel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<!-- Attesa -->
<StackPanel IsVisible="{Binding IsBusy}" Orientation="Horizontal" Spacing="12">
<ProgressBar IsIndeterminate="True" Width="80" Height="4" Foreground="{DynamicResource Accent}" VerticalAlignment="Center" />
<TextBlock Text="Claude sta scrivendo…" Foreground="{DynamicResource FgMuted}" />
</StackPanel>
</StackPanel>
</ScrollViewer>
<Button Grid.Row="0" Classes="ghost" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="12" Padding="0" Width="36"
HorizontalContentAlignment="Center" Command="{Binding ToggleSidebarCommand}" AutomationProperties.Name="Mostra o nascondi le chat">
<Viewbox Width="16" Height="16"><Path Data="M4 6H20M4 12H20M4 18H20" Stroke="{DynamicResource Fg}" StrokeThickness="2" StrokeLineCap="Round" /></Viewbox>
</Button>
<!-- Composer -->
<StackPanel Grid.Row="1" MaxWidth="780" Margin="24,0,24,12">
<Border Classes="composer" Background="{DynamicResource Surface}" BorderBrush="{DynamicResource Border}" BorderThickness="1" CornerRadius="20" Padding="14,10">
<StackPanel Spacing="8">
<TextBox x:Name="InputBox" Classes="bare" Text="{Binding Input, Mode=TwoWay}" AcceptsReturn="True" TextWrapping="Wrap" MaxHeight="200"
PlaceholderText="Scrivi un messaggio a Claude…" BorderThickness="0" Background="Transparent"
AutomationProperties.Name="Messaggio" />
<Grid ColumnDefinitions="Auto,Auto,Auto,Auto,*,Auto">
<TextBlock Text="Modello" FontSize="13" Foreground="{DynamicResource FgMuted}" VerticalAlignment="Center" Margin="0,0,8,0" />
<ComboBox Grid.Column="1" ItemsSource="{Binding ModelChoices}" SelectedItem="{Binding SelectedModel}" MinWidth="150"
AutomationProperties.Name="Modello">
<ComboBox.ItemTemplate>
<DataTemplate x:DataType="core:ModelOption"><TextBlock Text="{Binding Label}" /></DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBox Grid.Column="2" Text="{Binding CustomModel}" IsVisible="{Binding IsCustomModel}" PlaceholderText="es. claude-opus-5-5" Width="190"
Margin="8,0,0,0" AutomationProperties.Name="ID modello personalizzato" />
<TextBlock Grid.Column="3" Text="Effort" FontSize="13" Foreground="{DynamicResource FgMuted}" VerticalAlignment="Center" Margin="16,0,8,0" />
<ComboBox Grid.Column="3" ItemsSource="{Binding EffortChoices}" SelectedItem="{Binding SelectedEffort}" MinWidth="130"
Margin="64,0,0,0" AutomationProperties.Name="Effort di ragionamento" />
<Button Grid.Column="5" Classes="send" Command="{Binding SendCommand}" AutomationProperties.Name="Invia messaggio">
<Viewbox Width="18" Height="18"><Path Data="M12 19V5M5 12L12 5L19 12" Stroke="{Binding $parent[Button].Foreground}" StrokeThickness="2.2" StrokeLineCap="Round" StrokeJoin="Round" /></Viewbox>
</Button>
</Grid>
</StackPanel>
</Border>
<TextBlock Text="Invio per inviare · Maiusc+Invio per andare a capo" FontSize="12" Foreground="{DynamicResource FgMuted}"
HorizontalAlignment="Center" Margin="0,8,0,0" />
</StackPanel>
</Grid>
</Grid>
</Window>