Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
Style="{StaticResource PageScrollViewerStyle}"
Visibility="{x:Bind ViewModel.IsHistoryEmpty, Mode=OneWay, Converter={StaticResource BoolToVisibilityReverseConverter}}">
<Grid Margin="0,12,0,20">
<ItemsRepeater ItemsSource="{x:Bind ViewModel.History}">
<ItemsRepeater x:Name="HistoryRepeater" ItemsSource="{x:Bind ViewModel.History}">
<ItemsRepeater.ItemTemplate>
<DataTemplate x:DataType="items:AudioRecordItemViewModel">
<base:CardControl Command="{x:Bind DisplayCommand}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ public sealed partial class AudioSideBody : AudioPageControlBase
/// Initializes a new instance of the <see cref="AudioSideBody"/> class.
/// </summary>
public AudioSideBody() => InitializeComponent();

protected override void OnControlUnloaded()
=> HistoryRepeater.ItemsSource = null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
</Style>
</Flyout.FlyoutPresenterStyle>
<Grid Width="240">
<ItemsRepeater ItemsSource="{x:Bind ViewModel.TotalAgents}">
<ItemsRepeater x:Name="AgentRepeater" ItemsSource="{x:Bind ViewModel.TotalAgents}">
<ItemsRepeater.ItemTemplate>
<DataTemplate x:DataType="items:ChatAgentItemViewModel">
<local:ChatAgentItemControl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ protected override async void OnControlLoaded()
}
}

protected override void OnControlUnloaded()
=> AgentRepeater.ItemsSource = null;

private string GetEmoji()
=> _selectedEmoji?.Unicode ?? string.Empty;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@
Grid.Row="1"
Padding="8,0"
Style="{StaticResource PageScrollViewerStyle}">
<ItemsRepeater Margin="0,0,0,12" ItemsSource="{x:Bind ViewModel.History}">
<ItemsRepeater
x:Name="HistoryRepeater"
Margin="0,0,0,12"
ItemsSource="{x:Bind ViewModel.History}">
<ItemsRepeater.Layout>
<StackLayout Spacing="4" />
</ItemsRepeater.Layout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ public sealed partial class ChatHistoryPanel : ChatSessionControlBase
/// Initializes a new instance of the <see cref="ChatHistoryPanel"/> class.
/// </summary>
public ChatHistoryPanel() => InitializeComponent();

protected override void OnControlUnloaded()
=> HistoryRepeater.ItemsSource = null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@
MaxHeight="400"
Padding="12,8"
Style="{StaticResource PageScrollViewerStyle}">
<ItemsRepeater MinWidth="220" ItemsSource="{x:Bind ViewModel.Models}">
<ItemsRepeater
x:Name="ModelRepeater"
MinWidth="220"
ItemsSource="{x:Bind ViewModel.Models}">
<ItemsRepeater.ItemTemplate>
<DataTemplate x:DataType="viewmodels:ChatModelItemViewModel">
<local:ChatModelItemControl ViewModel="{x:Bind}" />
Expand Down Expand Up @@ -89,7 +92,10 @@
Padding="12,0"
Style="{StaticResource PageScrollViewerStyle}"
Visibility="{x:Bind ViewModel.IsServerEmpty, Mode=OneWay, Converter={StaticResource BoolToVisibilityReverseConverter}}">
<ItemsRepeater Margin="0,12" ItemsSource="{x:Bind ViewModel.Servers}">
<ItemsRepeater
x:Name="ServerRepeater"
Margin="0,12"
ItemsSource="{x:Bind ViewModel.Servers}">
<ItemsRepeater.Layout>
<StackLayout Spacing="4" />
</ItemsRepeater.Layout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ protected override void OnControlLoaded()
/// <inheritdoc/>
protected override void OnControlUnloaded()
{
ModelRepeater.ItemsSource = null;
ServerRepeater.ItemsSource = null;
ViewModel.RequestFocusInput -= OnRequestFocusInput;
ViewModel.RequestCloseFlyout -= OnRequestCloseFlyout;
}
Expand Down
20 changes: 16 additions & 4 deletions src/Desktop/RodelAgent.UI/Controls/Chat/ChatSideBody.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
</StackPanel.ChildrenTransitions>
<controls:CollapseHeader Title="{ext:Locale Name=Services}" IsCollapsed="{x:Bind ViewModel.IsServicesCollapsed, Mode=TwoWay}">
<controls:CollapseHeader.Element>
<ItemsRepeater ItemsSource="{x:Bind ViewModel.Services, Mode=OneWay}" Layout="{StaticResource BasicLayout}">
<ItemsRepeater
x:Name="ServiceRepeater"
ItemsSource="{x:Bind ViewModel.Services, Mode=OneWay}"
Layout="{StaticResource BasicLayout}">
<ItemsRepeater.ItemTemplate>
<DataTemplate x:DataType="viewmodels:ChatServiceItemViewModel">
<local:ChatServiceItemControl ViewModel="{x:Bind}" />
Expand All @@ -42,7 +45,10 @@
<StackPanel Margin="0,12,0,0" Visibility="{x:Bind ViewModel.IsAgentListVisible, Mode=OneWay}">
<controls:CollapseHeader Title="{ext:Locale Name=Agents}" IsCollapsed="{x:Bind ViewModel.IsAgentsCollapsed, Mode=TwoWay}">
<controls:CollapseHeader.Element>
<ItemsRepeater ItemsSource="{x:Bind ViewModel.Agents}" Layout="{StaticResource BasicLayout}">
<ItemsRepeater
x:Name="AgentRepeater"
ItemsSource="{x:Bind ViewModel.Agents}"
Layout="{StaticResource BasicLayout}">
<ItemsRepeater.ItemTemplate>
<DataTemplate x:DataType="items:ChatAgentItemViewModel">
<local:ChatAgentItemControl Click="OnAgentItemClick" ViewModel="{x:Bind}">
Expand Down Expand Up @@ -76,7 +82,10 @@
<StackPanel Margin="0,12,0,0" Visibility="{x:Bind ViewModel.IsGroupListVisible, Mode=OneWay}">
<controls:CollapseHeader Title="{ext:Locale Name=Groups}" IsCollapsed="{x:Bind ViewModel.IsGroupsCollapsed, Mode=TwoWay}">
<controls:CollapseHeader.Element>
<ItemsRepeater ItemsSource="{x:Bind ViewModel.Groups}" Layout="{StaticResource BasicLayout}">
<ItemsRepeater
x:Name="GroupRepeater"
ItemsSource="{x:Bind ViewModel.Groups}"
Layout="{StaticResource BasicLayout}">
<ItemsRepeater.ItemTemplate>
<DataTemplate x:DataType="items:ChatGroupItemViewModel">
<local:ChatGroupItemControl ViewModel="{x:Bind}" />
Expand All @@ -95,7 +104,10 @@
Style="{StaticResource PageScrollViewerStyle}"
Visibility="{x:Bind ViewModel.IsServerEmpty, Mode=OneWay, Converter={StaticResource BoolToVisibilityReverseConverter}}">
<StackPanel Margin="0,0,0,20">
<ItemsRepeater ItemsSource="{x:Bind ViewModel.Servers}" Layout="{StaticResource BasicLayout}">
<ItemsRepeater
x:Name="ServerRepeater"
ItemsSource="{x:Bind ViewModel.Servers}"
Layout="{StaticResource BasicLayout}">
<ItemsRepeater.ItemTemplate>
<DataTemplate x:DataType="items:McpServerItemViewModel">
<local:McpServerItemControl ViewModel="{x:Bind}" />
Expand Down
8 changes: 8 additions & 0 deletions src/Desktop/RodelAgent.UI/Controls/Chat/ChatSideBody.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ public sealed partial class ChatSideBody : ChatPageControlBase
{
public ChatSideBody() => InitializeComponent();

protected override void OnControlUnloaded()
{
ServiceRepeater.ItemsSource = null;
AgentRepeater.ItemsSource = null;
GroupRepeater.ItemsSource = null;
ServerRepeater.ItemsSource = null;
}

private void OnAgentItemClick(object sender, EventArgs e)
{
var data = (sender as ChatAgentItemControl)?.ViewModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@

<Grid>
<ScrollViewer Padding="8,0" Style="{StaticResource PageScrollViewerStyle}">
<ItemsRepeater Margin="0,8" ItemsSource="{x:Bind ViewModel.Agents}">
<ItemsRepeater
x:Name="AgentRepeater"
Margin="0,8"
ItemsSource="{x:Bind ViewModel.Agents}">
<ItemsRepeater.ItemTemplate>
<DataTemplate x:DataType="items:ChatAgentItemViewModel">
<local:ChatAgentItemControl ViewModel="{x:Bind}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ public sealed partial class GroupAgentsPanel : ChatSessionControlBase
/// Initializes a new instance of the <see cref="GroupAgentsPanel"/> class.
/// </summary>
public GroupAgentsPanel() => InitializeComponent();

protected override void OnControlUnloaded()
=> AgentRepeater.ItemsSource = null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
Style="{StaticResource PageScrollViewerStyle}"
VerticalScrollBarVisibility="Hidden"
Visibility="Collapsed">
<ItemsRepeater ItemsSource="{x:Bind Variables}">
<ItemsRepeater x:Name="VariableRepeater" ItemsSource="{x:Bind Variables}">
<ItemsRepeater.Layout>
<StackLayout Spacing="4" />
</ItemsRepeater.Layout>
Expand Down
12 changes: 11 additions & 1 deletion src/Desktop/RodelAgent.UI/Controls/Chat/McpConfigDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ public sealed partial class McpConfigDialog : AppDialog
private readonly McpServerItemViewModel? _source;
internal ObservableCollection<VariableItemViewModel> Variables { get; } = [];

public McpConfigDialog() => InitializeComponent();
public McpConfigDialog()
{
InitializeComponent();
Unloaded += OnUnloaded;
}

public McpConfigDialog(McpServerItemViewModel vm)
: this()
Expand All @@ -28,6 +32,12 @@ public McpConfigDialog(McpServerItemViewModel vm)
CheckVariablesVisibility();
}

private void OnUnloaded(object sender, RoutedEventArgs e)
{
VariableRepeater.ItemsSource = null;
Unloaded -= OnUnloaded;
}

private void OnPrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
var name = NameBox.Text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@
HorizontalAlignment="Left"
Text="{ext:Locale Name=Methods}" />
<ScrollViewer Padding="16,0" Style="{StaticResource PageScrollViewerStyle}">
<ItemsRepeater Margin="0,0,0,12" ItemsSource="{x:Bind ViewModel.Functions, Mode=OneWay}">
<ItemsRepeater
x:Name="FunctionRepeater"
Margin="0,0,0,12"
ItemsSource="{x:Bind ViewModel.Functions, Mode=OneWay}">
<ItemsRepeater.ItemTemplate>
<DataTemplate x:DataType="items:AIFunctionItemViewModel">
<local:McpFunctionItemControl ViewModel="{x:Bind}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ protected override void OnControlUnloaded()
{
ViewModel.PropertyChanged += OnViewModelPropertyChanged;
}

FunctionRepeater.ItemsSource = null;
}

private void OnViewModelPropertyChanged(object? sender, PropertyChangedEventArgs e)
Expand Down
2 changes: 1 addition & 1 deletion src/Desktop/RodelAgent.UI/Controls/Draw/DrawSideBody.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
Style="{StaticResource PageScrollViewerStyle}"
Visibility="{x:Bind ViewModel.IsHistoryEmpty, Mode=OneWay, Converter={StaticResource BoolToVisibilityReverseConverter}}">
<Grid Margin="0,12,0,20">
<ItemsRepeater ItemsSource="{x:Bind ViewModel.History}">
<ItemsRepeater x:Name="HistoryRepeater" ItemsSource="{x:Bind ViewModel.History}">
<ItemsRepeater.ItemTemplate>
<DataTemplate x:DataType="items:DrawRecordItemViewModel">
<base:CardControl Command="{x:Bind DisplayCommand}">
Expand Down
3 changes: 3 additions & 0 deletions src/Desktop/RodelAgent.UI/Controls/Draw/DrawSideBody.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ public sealed partial class DrawSideBody : DrawPageControlBase
/// Initializes a new instance of the <see cref="DrawSideBody"/> class.
/// </summary>
public DrawSideBody() => InitializeComponent();

protected override void OnControlUnloaded()
=> HistoryRepeater.ItemsSource = null;
}
11 changes: 8 additions & 3 deletions src/Desktop/RodelAgent.UI/Controls/EmojiPanel.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace RodelAgent.UI.Controls;
/// </summary>
public sealed partial class EmojiPanel : LayoutUserControlBase
{
private readonly ObservableCollection<EmojiItem> _items = new();
private readonly ObservableCollection<EmojiItem> _items = [];

/// <summary>
/// Initializes a new instance of the <see cref="EmojiPanel"/> class.
Expand All @@ -28,14 +28,19 @@ protected override void OnControlLoaded()
{
if (_items.Count == 0)
{
var emojis = EmojiStatics.GetEmojis().OrderBy(p => p.Group).ThenBy(p => p.Unicode);
foreach (var emoji in emojis)
foreach (var emoji in EmojiStatics.GetEmojis().OrderBy(p => p.Group).ThenBy(p => p.Unicode))
{
_items.Add(emoji);
}
}
}

protected override void OnControlUnloaded()
{
EmojiRepeater.ItemsSource = null;
_items.Clear();
}

private void OnEmojiButtonClick(object sender, RoutedEventArgs e)
{
var context = (sender as Button)?.DataContext as EmojiItem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<StackPanel Spacing="8">
<TextBlock HorizontalAlignment="Left" Text="{ext:Locale Name=Link}" />
<ItemsRepeater
x:Name="LinkRepeater"
Margin="-12,0,0,0"
ItemTemplate="{StaticResource LinkItemTemplate}"
ItemsSource="{x:Bind ViewModel.Links}">
Expand All @@ -55,6 +56,7 @@
<StackPanel Spacing="8">
<TextBlock HorizontalAlignment="Left" Text="{ext:Locale Name=OpenSourceRepo}" />
<ItemsRepeater
x:Name="LibraryRepeater"
Margin="-12,0,0,0"
ItemTemplate="{StaticResource LinkItemTemplate}"
ItemsSource="{x:Bind ViewModel.Libraries}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,10 @@ public sealed partial class AboutSettingControl : SettingsPageControlBase
/// Initializes a new instance of the <see cref="AboutSettingControl"/> class.
/// </summary>
public AboutSettingControl() => InitializeComponent();

protected override void OnControlUnloaded()
{
LinkRepeater.ItemsSource = null;
LibraryRepeater.ItemsSource = null;
}
}
6 changes: 1 addition & 5 deletions src/Desktop/RodelAgent.UI/Pages/ChatPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ public sealed partial class ChatPage : ChatPageBase
/// <summary>
/// Initializes a new instance of the <see cref="ChatPage"/> class.
/// </summary>
public ChatPage()
{
InitializeComponent();
NavigationCacheMode = NavigationCacheMode.Required;
}
public ChatPage() => InitializeComponent();

/// <inheritdoc/>
protected override void OnPageLoaded()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ private async void OnWebMessageReceived(CoreWebView2 sender, CoreWebView2WebMess

ReloadWebThemeCommand.Execute(default);
SetInteropResourcesCommand.Execute(default);
if (_currentConversation != null)
{
SetCurrentConversation(_currentConversation);
SetInitialInteropHistoryCommand.Execute(_currentConversation?.History ?? []);
}
}
}
else if (msg.StartsWith("data:", StringComparison.OrdinalIgnoreCase))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@ public void InjectFunc(Func<int>? maxRounds)

public async Task InitializeAsync(WebView2 view)
{
if (_webView is not null)
{
return;
}

if (_tokenTimer is null)
{
_tokenTimer = new DispatcherTimer
Expand All @@ -79,6 +74,7 @@ public async Task InitializeAsync(WebView2 view)
_tokenTimer.Tick += OnTokenTimerTick;
}

_webView?.Close();
_webView = view;
IsWebInitializing = true;
IsWebInitialized = false;
Expand Down
10 changes: 5 additions & 5 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@
<PackageVersion Include="Richasy.AgentKernel.Connectors.ZhiPu" Version="0.0.7-preview6" />
<PackageVersion Include="Richasy.AgentKernel.Core.Mcp" Version="0.0.7-preview6" />
<PackageVersion Include="Richasy.AgentKernel.Definitions" Version="0.0.7-preview6" />
<PackageVersion Include="Richasy.WinUIKernel.AI" Version="0.0.7-preview6" />
<PackageVersion Include="Richasy.WinUIKernel.AI" Version="0.0.8-preview2" />
<PackageVersion Include="RichasyKernel.Abstractions" Version="0.0.1" />
<PackageVersion Include="Serilog" Version="4.2.0" />
<PackageVersion Include="Serilog.Extensions.Logging" Version="9.0.1" />
<PackageVersion Include="Serilog.Sinks.File" Version="7.0.0" />
<PackageVersion Include="SimpleTrayIcon" Version="3.0.2" />
<PackageVersion Include="SQLitePCLRaw.bundle_e_sqlite3" Version="2.1.10" />
<PackageVersion Include="SqlSugarCore" Version="5.1.4.192-preview01" />
<PackageVersion Include="System.Linq.AsyncEnumerable" Version="10.0.0-preview.3.25171.5" />
<PackageVersion Include="SqlSugarCore" Version="5.1.4.194-preview24" />
<PackageVersion Include="System.Linq.AsyncEnumerable" Version="10.0.0-preview.4.25258.110" />
<PackageVersion Include="System.Private.Uri" Version="4.3.2" />
<PackageVersion Include="Tiktoken" Version="2.2.0" />
<PackageVersion Include="Microsoft.Bcl.HashCode" Version="6.0.0" />
Expand All @@ -86,8 +86,8 @@
<PackageVersion Include="Microsoft.EntityFrameworkCore.Abstractions" Version="9.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.2" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.2" />
<PackageVersion Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1742" />
<PackageVersion Include="Microsoft.WindowsAppSDK" Version="1.7.250401001" />
<PackageVersion Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.4188" />
<PackageVersion Include="Microsoft.WindowsAppSDK" Version="1.7.250513003" />
<PackageVersion Include="System.Diagnostics.DiagnosticSource" Version="9.0.0" />
<PackageVersion Include="System.Drawing.Common" Version="9.0.0" />
<PackageVersion Include="System.Linq.Async" Version="6.0.1" />
Expand Down
Loading