Skip to content

Commit 1acbedc

Browse files
committed
Refactor profile management and update settings handling in UI
1 parent 0a475db commit 1acbedc

File tree

7 files changed

+159
-146
lines changed

7 files changed

+159
-146
lines changed

Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22
<PropertyGroup>
33
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
4-
<Version>0.1.4.0</Version>
4+
<Version>0.1.5.0</Version>
55
<AssemblyVersion>$(Version)</AssemblyVersion>
66
<FileVersion>$(Version)</FileVersion>
77
<InformationalVersion>$(Version)</InformationalVersion>

SemanticCode.sln.DotSettings.user

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
22
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AAvaloniaXamlLoader_002Ecs_002Fl_003AC_0021_003FUsers_003Ftoken_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fedf80116cb66406a9794be4ad469395814a00_003F67_003F72f2efdc_003FAvaloniaXamlLoader_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
3+
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AClrPropertyInfo_002Ecs_002Fl_003AC_0021_003FUsers_003Ftoken_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F9c60568d0b54415dad3590c4497304461f9000_003Fc6_003F25c9038e_003FClrPropertyInfo_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
4+
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AExceptionDispatchInfo_002Ecs_002Fl_003AC_0021_003FUsers_003Ftoken_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F96cdc0cbcc484f48a653f0bd0ba43069f04918_003Fe8_003F4bb1170b_003FExceptionDispatchInfo_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
5+
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIDisposable_002Ecs_002Fl_003AC_0021_003FUsers_003Ftoken_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F96cdc0cbcc484f48a653f0bd0ba43069f04918_003F64_003F65730341_003FIDisposable_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
36
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ANavigationView_002Eproperties_002Ecs_002Fl_003AC_0021_003FUsers_003Ftoken_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FSourcesCache_003F8d78d280f056b9a0e3eab34add17e11f4177cea9b9f692f38f54b8cbc195dc85_003FNavigationView_002Eproperties_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
47
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AReactiveObject_002Ecs_002Fl_003AC_0021_003FUsers_003Ftoken_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FSourcesCache_003Fd06f96fa1816853b6b141e4e445f8117486b5f410e66dec683383a9bcce758_003FReactiveObject_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
5-
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASymbol_002Ecs_002Fl_003AC_0021_003FUsers_003Ftoken_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F860d38664572484ebf4032dba43bddb7341a00_003F85_003Fc6ba96c4_003FSymbol_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>
8+
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASymbol_002Ecs_002Fl_003AC_0021_003FUsers_003Ftoken_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F860d38664572484ebf4032dba43bddb7341a00_003F85_003Fc6ba96c4_003FSymbol_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
9+
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ASynchronizationContextTaskScheduler_002Ecs_002Fl_003AC_0021_003FUsers_003Ftoken_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F96cdc0cbcc484f48a653f0bd0ba43069f04918_003F54_003Faace4664_003FSynchronizationContextTaskScheduler_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
10+
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATask_00601_002Ecs_002Fl_003AC_0021_003FUsers_003Ftoken_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F96cdc0cbcc484f48a653f0bd0ba43069f04918_003F88_003Faa4b39a0_003FTask_00601_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>

SemanticCode/Pages/ClaudeCodeSettingsView.axaml

Lines changed: 12 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:vm="clr-namespace:SemanticCode.ViewModels"
6-
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
76
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
87
x:Class="SemanticCode.Pages.ClaudeCodeSettingsView"
98
x:DataType="vm:ClaudeCodeSettingsViewModel">
@@ -25,7 +24,6 @@
2524
HorizontalAlignment="Center"/>
2625
</StackPanel>
2726

28-
<!-- Profile Management -->
2927
<Border Background="{DynamicResource CardBackgroundFillColorDefaultBrush}"
3028
BorderBrush="{DynamicResource CardStrokeColorDefaultBrush}"
3129
BorderThickness="1"
@@ -35,18 +33,17 @@
3533
<TextBlock Text="配置档案管理"
3634
FontWeight="Bold"
3735
FontSize="18"/>
38-
39-
<!-- Current Profile Selection -->
4036
<StackPanel Spacing="8">
4137
<TextBlock Text="当前配置档案"
4238
FontWeight="SemiBold"/>
4339
<Grid ColumnDefinitions="*,Auto">
4440
<ComboBox Grid.Column="0"
4541
ItemsSource="{Binding Profiles}"
46-
SelectedItem="{Binding SelectedProfile}">
42+
SelectedItem="{Binding SelectedProfile}"
43+
PointerPressed="ComboBox_OnPointerPressed">
4744
<ComboBox.ItemTemplate>
4845
<DataTemplate>
49-
<StackPanel Spacing="4">
46+
<StackPanel Spacing="4" Background="Transparent">
5047
<TextBlock Text="{Binding Name}" FontWeight="SemiBold"/>
5148
<TextBlock Text="{Binding Description}" Opacity="0.7" FontSize="12"/>
5249
<StackPanel Orientation="Horizontal" Spacing="8">
@@ -81,12 +78,11 @@
8178
Command="{Binding DeleteProfileCommand}"/>
8279
</StackPanel>
8380

84-
<!-- Create New Profile -->
8581
<Separator Height="1" Margin="0,8,0,8"/>
8682
<StackPanel Spacing="12">
8783
<TextBlock Text="创建新配置档案"
8884
FontWeight="SemiBold"/>
89-
<Grid RowDefinitions="Auto,Auto,Auto" ColumnDefinitions="*,*">
85+
<Grid RowDefinitions="Auto,Auto,Auto" ColumnDefinitions="*,*,*,*">
9086
<TextBlock Grid.Row="0" Grid.Column="0" Text="档案名称"/>
9187
<TextBox Grid.Row="1" Grid.Column="0"
9288
Text="{Binding NewProfileName}"
@@ -97,7 +93,7 @@
9793
Text="{Binding NewProfileDescription}"
9894
Watermark="输入档案描述" Margin="8,0,0,0"/>
9995

100-
<Button Grid.Row="2" Grid.ColumnSpan="2"
96+
<Button Grid.Row="2" Grid.ColumnSpan="2" Grid.Column="2"
10197
Content="创建档案"
10298
Command="{Binding CreateProfileCommand}"
10399
HorizontalAlignment="Center"
@@ -144,7 +140,7 @@
144140
FontSize="13"/>
145141
<TextBox Text="{Binding ApiKey}"
146142
PasswordChar="*"
147-
Watermark="sk-ant-xxxxx"/>
143+
Watermark="sk-ant"/>
148144
</StackPanel>
149145

150146
<!-- Base URL -->
@@ -154,17 +150,8 @@
154150
<TextBlock Text="API 基础 URL 地址"
155151
Opacity="0.7"
156152
FontSize="13"/>
157-
<Grid RowDefinitions="Auto,Auto">
158-
<ComboBox Grid.Row="0"
159-
ItemsSource="{Binding AvailableBaseUrls}"
160-
SelectedItem="{Binding BaseUrl}"
161-
SelectionChanged="BaseUrlComboBox_SelectionChanged"
162-
Name="BaseUrlComboBox"/>
163-
<TextBox Grid.Row="1"
164-
Text="{Binding BaseUrl}"
165-
Margin="0,4,0,0"
166-
Watermark="或直接输入自定义URL"/>
167-
</Grid>
153+
<TextBox Text="{Binding BaseUrl}"
154+
Watermark="输入 API 基础 URL 地址"/>
168155
</StackPanel>
169156

170157
<!-- Main Model -->
@@ -174,17 +161,8 @@
174161
<TextBlock Text="主要会话模型(用于复杂推理)"
175162
Opacity="0.7"
176163
FontSize="13"/>
177-
<Grid RowDefinitions="Auto,Auto">
178-
<ComboBox Grid.Row="0"
179-
ItemsSource="{Binding AvailableModels}"
180-
SelectedItem="{Binding SelectedModel}"
181-
SelectionChanged="ModelComboBox_SelectionChanged"
182-
Name="ModelComboBox"/>
183-
<TextBox Grid.Row="1"
184-
Text="{Binding SelectedModel}"
185-
Margin="0,4,0,0"
186-
Watermark="或直接输入自定义模型名称"/>
187-
</Grid>
164+
<TextBox Text="{Binding SelectedModel}"
165+
Watermark="输入模型名称"/>
188166
</StackPanel>
189167

190168
<!-- Small Fast Model -->
@@ -194,17 +172,8 @@
194172
<TextBlock Text="后台快速模型(用于工具调用和辅助任务)"
195173
Opacity="0.7"
196174
FontSize="13"/>
197-
<Grid RowDefinitions="Auto,Auto">
198-
<ComboBox Grid.Row="0"
199-
ItemsSource="{Binding AvailableSmallFastModels}"
200-
SelectedItem="{Binding SelectedSmallFastModel}"
201-
SelectionChanged="SmallFastModelComboBox_SelectionChanged"
202-
Name="SmallFastModelComboBox"/>
203-
<TextBox Grid.Row="1"
204-
Text="{Binding SelectedSmallFastModel}"
205-
Margin="0,4,0,0"
206-
Watermark="或直接输入自定义快速模型名称"/>
207-
</Grid>
175+
<TextBox Text="{Binding SelectedSmallFastModel}"
176+
Watermark="输入快速模型名称"/>
208177
</StackPanel>
209178
</StackPanel>
210179

SemanticCode/Pages/ClaudeCodeSettingsView.axaml.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Avalonia.Controls;
2+
using Avalonia.Input;
23
using Avalonia.Interactivity;
34

45
namespace SemanticCode.Pages;
@@ -24,4 +25,12 @@ private void SmallFastModelComboBox_SelectionChanged(object? sender, SelectionCh
2425
{
2526
// ComboBox selection is already handled by binding
2627
}
28+
29+
private void ComboBox_OnPointerPressed(object? sender, PointerPressedEventArgs e)
30+
{
31+
if (sender is ComboBox comboBox)
32+
{
33+
comboBox.IsDropDownOpen = !comboBox.IsDropDownOpen;
34+
}
35+
}
2736
}

SemanticCode/SemanticCode.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<TargetFramework>net10.0</TargetFramework>
44
<Nullable>enable</Nullable>
5-
<LangVersion>latest</LangVersion>
5+
<LangVersion>preview</LangVersion>
66
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
77
</PropertyGroup>
88

@@ -14,7 +14,6 @@
1414
<PackageReference Include="Avalonia"/>
1515
<PackageReference Include="Avalonia.Themes.Fluent"/>
1616
<PackageReference Include="Avalonia.Fonts.Inter"/>
17-
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
1817
<PackageReference Include="Avalonia.Diagnostics">
1918
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
2019
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>

SemanticCode/Services/ClaudeCodeProfileService.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,17 +264,21 @@ public static async Task<bool> SetDefaultProfileAsync(string profileName)
264264
return false;
265265
}
266266

267+
// Load the profile's settings
268+
var profileData = await LoadProfileAsync(profileName);
269+
270+
// Copy the profile settings to the main settings.json file
271+
await ClaudeCodeSettingsService.SaveSettingsAsync(profileData.Settings);
272+
267273
foreach (var p in manager.Profiles)
268274
{
269275
p.IsDefault = false;
270276
}
271277

272278
profile.IsDefault = true;
273279

274-
if (manager.CurrentProfile == "default")
275-
{
276-
manager.CurrentProfile = profileName;
277-
}
280+
// Set this profile as current
281+
manager.CurrentProfile = profileName;
278282

279283
await SaveProfileManagerAsync(manager);
280284
return true;

0 commit comments

Comments
 (0)