refactor(agent-config): single AgentConfigEditor for list + task scopes
This commit is contained in:
@@ -69,72 +69,10 @@
|
||||
<Grid ColumnDefinitions="*,Auto" Margin="4,0,0,6">
|
||||
<TextBlock Classes="section-label" Text="{loc:Tr modals.listSettings.sectionAgent}" Margin="0"/>
|
||||
<Button Classes="btn" Grid.Column="1" Content="{loc:Tr modals.listSettings.resetAgentSettings}"
|
||||
Command="{Binding ResetAgentSettingsCommand}" />
|
||||
Command="{Binding Agent.ResetAllCommand}" />
|
||||
</Grid>
|
||||
<Border Classes="section">
|
||||
<StackPanel Spacing="12">
|
||||
<StackPanel Spacing="4">
|
||||
<Grid ColumnDefinitions="Auto,Auto,*,Auto" ColumnSpacing="6">
|
||||
<TextBlock Grid.Column="0" Classes="field-label" Text="{loc:Tr modals.listSettings.model}" VerticalAlignment="Center"/>
|
||||
<ctl:InheritedBadge Grid.Column="1" BadgeText="{Binding ModelBadge}"/>
|
||||
<Button Grid.Column="3" Classes="btn" Content="↺" ToolTip.Tip="{loc:Tr settings.inherit.resetToInherited}"
|
||||
Command="{Binding ResetModelCommand}" Padding="6,1"/>
|
||||
</Grid>
|
||||
<ComboBox ItemsSource="{Binding ModelOptions}"
|
||||
SelectedItem="{Binding SelectedModel, Mode=TwoWay}"
|
||||
PlaceholderText="{Binding ModelInheritedHint}"
|
||||
HorizontalAlignment="Left" MinWidth="160" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Spacing="4">
|
||||
<Grid ColumnDefinitions="Auto,Auto,*,Auto" ColumnSpacing="6">
|
||||
<TextBlock Grid.Column="0" Classes="field-label" Text="{loc:Tr modals.listSettings.maxTurns}" VerticalAlignment="Center"/>
|
||||
<ctl:InheritedBadge Grid.Column="1" BadgeText="{Binding TurnsBadge}"/>
|
||||
<Button Grid.Column="3" Classes="btn" Content="↺" ToolTip.Tip="{loc:Tr settings.inherit.resetToInherited}"
|
||||
Command="{Binding ResetTurnsCommand}" Padding="6,1"/>
|
||||
</Grid>
|
||||
<NumericUpDown Value="{Binding MaxTurns, Mode=TwoWay}"
|
||||
PlaceholderText="{Binding TurnsInheritedHint}"
|
||||
Minimum="1" Maximum="200" Increment="1" FormatString="0"
|
||||
HorizontalAlignment="Left" Width="160"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Spacing="4">
|
||||
<TextBlock Classes="field-label" Text="{loc:Tr modals.listSettings.systemPrompt}"/>
|
||||
<TextBox Text="{Binding SystemPrompt, Mode=TwoWay}"
|
||||
AcceptsReturn="True" TextWrapping="Wrap"
|
||||
MinHeight="80" />
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Spacing="4">
|
||||
<Grid ColumnDefinitions="Auto,Auto,*,Auto" ColumnSpacing="6">
|
||||
<TextBlock Grid.Column="0" Classes="field-label" Text="{loc:Tr modals.listSettings.agentFile}" VerticalAlignment="Center"/>
|
||||
<ctl:InheritedBadge Grid.Column="1" BadgeText="{Binding AgentBadge}"/>
|
||||
<Button Grid.Column="3" Classes="btn" Content="↺" ToolTip.Tip="{loc:Tr settings.inherit.resetToInherited}"
|
||||
Command="{Binding ResetAgentCommand}" Padding="6,1"/>
|
||||
</Grid>
|
||||
<Grid ColumnDefinitions="*,Auto">
|
||||
<ComboBox Grid.Column="0"
|
||||
ItemsSource="{Binding Agents}"
|
||||
SelectedItem="{Binding SelectedAgent, Mode=TwoWay}"
|
||||
HorizontalAlignment="Stretch">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel>
|
||||
<TextBlock Classes="title" Text="{Binding Name}"/>
|
||||
<TextBlock Classes="meta" Text="{Binding Description}"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
<Button Classes="btn" Grid.Column="1" Content="{loc:Tr modals.listSettings.browse}"
|
||||
Margin="8,0,0,0" Click="BrowseAgentClicked" />
|
||||
</Grid>
|
||||
<TextBlock Classes="path-mono" Text="{Binding SelectedAgent.Path}"
|
||||
TextTrimming="PrefixCharacterEllipsis"
|
||||
IsVisible="{Binding SelectedAgent.Path, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<ctl:AgentConfigEditor DataContext="{Binding Agent}" ShowAgentBrowse="True"/>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Platform.Storage;
|
||||
using ClaudeDo.Data.Models;
|
||||
using ClaudeDo.Ui.ViewModels.Modals;
|
||||
|
||||
namespace ClaudeDo.Ui.Views.Modals;
|
||||
@@ -13,57 +12,6 @@ public partial class ListSettingsModalView : Window
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private async void BrowseAgentClicked(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is not ListSettingsModalViewModel vm) return;
|
||||
var top = TopLevel.GetTopLevel(this);
|
||||
if (top is null) return;
|
||||
|
||||
var files = await top.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
{
|
||||
Title = "Choose agent file",
|
||||
AllowMultiple = false,
|
||||
FileTypeFilter = new[]
|
||||
{
|
||||
new FilePickerFileType("Agent files (*.md)") { Patterns = new[] { "*.md" } },
|
||||
new FilePickerFileType("All files") { Patterns = new[] { "*" } },
|
||||
},
|
||||
});
|
||||
if (files.Count == 0) return;
|
||||
|
||||
var path = files[0].Path.LocalPath;
|
||||
var existing = vm.Agents.FirstOrDefault(a => string.Equals(a.Path, path, StringComparison.OrdinalIgnoreCase));
|
||||
if (existing is not null)
|
||||
{
|
||||
vm.SelectedAgent = existing;
|
||||
return;
|
||||
}
|
||||
|
||||
var (name, description) = ReadFrontmatter(path);
|
||||
var agent = new AgentInfo(name, description, path);
|
||||
vm.Agents.Add(agent);
|
||||
vm.SelectedAgent = agent;
|
||||
}
|
||||
|
||||
private static (string name, string description) ReadFrontmatter(string filePath)
|
||||
{
|
||||
var fallback = System.IO.Path.GetFileNameWithoutExtension(filePath);
|
||||
try
|
||||
{
|
||||
using var reader = new System.IO.StreamReader(filePath);
|
||||
if (reader.ReadLine()?.Trim() != "---") return (fallback, "");
|
||||
string name = fallback, description = "";
|
||||
while (reader.ReadLine() is { } line)
|
||||
{
|
||||
if (line.Trim() == "---") break;
|
||||
if (line.StartsWith("name:")) name = line["name:".Length..].Trim();
|
||||
else if (line.StartsWith("description:")) description = line["description:".Length..].Trim();
|
||||
}
|
||||
return (name, description);
|
||||
}
|
||||
catch { return (fallback, ""); }
|
||||
}
|
||||
|
||||
private async void BrowseClicked(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is not ListSettingsModalViewModel vm) return;
|
||||
|
||||
Reference in New Issue
Block a user