Skip to content

Commit e91004b

Browse files
committed
拆分本地修复调试报告开关
新增 EnableLocalRepairDebugReport 设置并持久化。 设置页调试开关改为只控制本地修复失败报告。 修复失败报告生成改用独立开关,不再联动 WebView 调试工具。 更新配置、修复模式和导航壳测试。
1 parent 224893f commit e91004b

10 files changed

Lines changed: 44 additions & 43 deletions

File tree

src/CodexCliPlus.App/MainWindow.EventHandlers.cs

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -450,51 +450,37 @@ private async void SettingsFollowSystemCheckBox_Changed(object sender, RoutedEve
450450
await SetShellThemeAsync(explicitTheme);
451451
}
452452

453-
private async void SettingsDebugToolsCheckBox_Changed(object sender, RoutedEventArgs e)
453+
private async void SettingsLocalRepairDebugReportCheckBox_Changed(object sender, RoutedEventArgs e)
454454
{
455-
if (_suppressDebugToolsChange)
455+
if (_suppressLocalRepairDebugReportChange)
456456
{
457457
return;
458458
}
459459

460-
var enabled = SettingsDebugToolsCheckBox.IsChecked == true;
461-
if (_settings.EnableDebugTools == enabled)
460+
var enabled = SettingsLocalRepairDebugReportCheckBox.IsChecked == true;
461+
if (_settings.EnableLocalRepairDebugReport == enabled)
462462
{
463463
return;
464464
}
465465

466-
var previous = _settings.EnableDebugTools;
467-
_settings.EnableDebugTools = enabled;
468-
ApplyDebugToolsSettings();
466+
var previous = _settings.EnableLocalRepairDebugReport;
467+
_settings.EnableLocalRepairDebugReport = enabled;
469468

470469
try
471470
{
472471
await _appConfigurationService.SaveAsync(_settings);
473-
_notificationService.ShowAuto("调试设置已更新。");
472+
_notificationService.ShowAuto("修复调试报告设置已更新。");
474473
}
475474
catch (Exception exception)
476475
{
477-
_settings.EnableDebugTools = previous;
478-
ApplyDebugToolsSettings();
479-
_suppressDebugToolsChange = true;
480-
SettingsDebugToolsCheckBox.IsChecked = previous;
481-
_suppressDebugToolsChange = false;
482-
_notificationService.ShowManual("调试设置保存失败", exception.Message);
476+
_settings.EnableLocalRepairDebugReport = previous;
477+
_suppressLocalRepairDebugReportChange = true;
478+
SettingsLocalRepairDebugReportCheckBox.IsChecked = previous;
479+
_suppressLocalRepairDebugReportChange = false;
480+
_notificationService.ShowManual("修复调试报告设置保存失败", exception.Message);
483481
}
484482
}
485483

486-
private void ApplyDebugToolsSettings()
487-
{
488-
if (!_webViewConfigured || ManagementWebView.CoreWebView2 is null)
489-
{
490-
return;
491-
}
492-
493-
var enabled = _settings.EnableDebugTools;
494-
ManagementWebView.CoreWebView2.Settings.AreDevToolsEnabled = enabled;
495-
ManagementWebView.CoreWebView2.Settings.AreDefaultContextMenusEnabled = enabled;
496-
}
497-
498484
private void SettingsOpenMainRepoButton_Click(object sender, RoutedEventArgs e)
499485
{
500486
OpenExternal("https://github.com/router-for-me/CLIProxyAPI");

src/CodexCliPlus.App/MainWindow.ShellSettingsPresentation.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,9 @@ CancellationToken cancellationToken
273273
private void UpdateSettingsOverlayBaseline()
274274
{
275275
UpdateShellThemePresentation(CreateShellThemeSnapshot(_settings.ThemeMode, 0));
276-
_suppressDebugToolsChange = true;
277-
SettingsDebugToolsCheckBox.IsChecked = _settings.EnableDebugTools;
278-
_suppressDebugToolsChange = false;
276+
_suppressLocalRepairDebugReportChange = true;
277+
SettingsLocalRepairDebugReportCheckBox.IsChecked = _settings.EnableLocalRepairDebugReport;
278+
_suppressLocalRepairDebugReportChange = false;
279279
SetSettingsUpdateStatus($"当前版本 {CurrentApplicationVersion}");
280280
}
281281

src/CodexCliPlus.App/MainWindow.WebViewHost.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,7 @@ private LocalDependencyRepairResult AttachLocalDependencyRepairDebugReportIfNeed
12431243
LocalDependencyRepairProgress? lastProgress
12441244
)
12451245
{
1246-
if (result.Succeeded || !_settings.EnableDebugTools)
1246+
if (result.Succeeded || !_settings.EnableLocalRepairDebugReport)
12471247
{
12481248
return result;
12491249
}

src/CodexCliPlus.App/MainWindow.xaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,19 +1418,19 @@
14181418
Foreground="{DynamicResource PrimaryTextBrush}"
14191419
/>
14201420
<TextBlock
1421-
Text="修复失败时在桌面生成可交给 Codex 的诊断报告,并启用内置网页调试工具"
1421+
Text="修复失败时在桌面生成可交给 Codex 的诊断报告和修复指南"
14221422
Margin="0,10,0,12"
14231423
FontSize="13"
14241424
Foreground="{DynamicResource SecondaryTextBrush}"
14251425
TextWrapping="Wrap"
14261426
/>
14271427
<CheckBox
1428-
x:Name="SettingsDebugToolsCheckBox"
1428+
x:Name="SettingsLocalRepairDebugReportCheckBox"
14291429
VerticalAlignment="Center"
1430-
Checked="SettingsDebugToolsCheckBox_Changed"
1431-
Unchecked="SettingsDebugToolsCheckBox_Changed"
1432-
AutomationProperties.AutomationId="SettingsDebugToolsCheckBox"
1433-
Content="启用调试模式"
1430+
Checked="SettingsLocalRepairDebugReportCheckBox_Changed"
1431+
Unchecked="SettingsLocalRepairDebugReportCheckBox_Changed"
1432+
AutomationProperties.AutomationId="SettingsLocalRepairDebugReportCheckBox"
1433+
Content="启用修复调试报告"
14341434
/>
14351435
</StackPanel>
14361436
</Border>

src/CodexCliPlus.App/MainWindow.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ WindowState WindowState
162162
private bool _isInitializing;
163163
private bool _webViewConfigured;
164164
private bool _settingsOverlayOpen;
165-
private bool _suppressDebugToolsChange;
165+
private bool _suppressLocalRepairDebugReportChange;
166166
private bool _isShellBrandDockClosing;
167167
private bool _isAuthenticationCompactWindowMode;
168168
private bool _initialPresentationRevealed;

src/CodexCliPlus.Core/Models/AppSettings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public sealed class AppSettings
3333

3434
public bool EnableDebugTools { get; set; }
3535

36+
public bool EnableLocalRepairDebugReport { get; set; }
37+
3638
public string? LastRepositoryPath { get; set; }
3739

3840
public bool SecurityKeyOnboardingCompleted { get; set; }

src/CodexCliPlus.Infrastructure/Configuration/JsonAppConfigurationService.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,8 @@ private sealed class PersistedAppSettings
333333

334334
public bool EnableDebugTools { get; init; }
335335

336+
public bool EnableLocalRepairDebugReport { get; init; }
337+
336338
public string? LastRepositoryPath { get; init; }
337339

338340
public bool? SecurityKeyOnboardingCompleted { get; init; }
@@ -361,6 +363,7 @@ public AppSettings ToModel()
361363
ThemeMode = ThemeMode,
362364
MinimumLogLevel = MinimumLogLevel,
363365
EnableDebugTools = EnableDebugTools,
366+
EnableLocalRepairDebugReport = EnableLocalRepairDebugReport,
364367
LastRepositoryPath = LastRepositoryPath,
365368
SecurityKeyOnboardingCompleted = SecurityKeyOnboardingCompleted ?? true,
366369
LastSeenApplicationVersion = string.IsNullOrWhiteSpace(LastSeenApplicationVersion)
@@ -411,6 +414,7 @@ public static PersistedAppSettings FromModel(AppSettings settings)
411414
ThemeMode = settings.ThemeMode,
412415
MinimumLogLevel = settings.MinimumLogLevel,
413416
EnableDebugTools = settings.EnableDebugTools,
417+
EnableLocalRepairDebugReport = settings.EnableLocalRepairDebugReport,
414418
LastRepositoryPath = settings.LastRepositoryPath,
415419
SecurityKeyOnboardingCompleted = settings.SecurityKeyOnboardingCompleted,
416420
LastSeenApplicationVersion = string.IsNullOrWhiteSpace(

tests/CodexCliPlus.Tests/AppRepairModeTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public void DesktopRepairRequestCatchesRepairFlowFailuresAndPostsResult()
121121
source,
122122
StringComparison.Ordinal
123123
);
124-
Assert.Contains("_settings.EnableDebugTools", source, StringComparison.Ordinal);
124+
Assert.Contains("_settings.EnableLocalRepairDebugReport", source, StringComparison.Ordinal);
125125
Assert.Contains("DebugReportPath", source, StringComparison.Ordinal);
126126
Assert.Contains(
127127
"_changeBroadcastService.Broadcast(\"local-environment\")",

tests/CodexCliPlus.Tests/Configuration/JsonDesktopConfigurationServiceTests.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public async Task SaveAndLoadAsyncStoresManagementKeyOutsideDesktopJson()
3232
ThemeMode = AppThemeMode.Dark,
3333
MinimumLogLevel = AppLogLevel.Warning,
3434
EnableDebugTools = true,
35+
EnableLocalRepairDebugReport = true,
3536
LastRepositoryPath = @"C:\repo",
3637
SecurityKeyOnboardingCompleted = true,
3738
LastSeenApplicationVersion = "1.2.3",
@@ -50,6 +51,7 @@ public async Task SaveAndLoadAsyncStoresManagementKeyOutsideDesktopJson()
5051
Assert.Equal(AppThemeMode.Dark, actual.ThemeMode);
5152
Assert.Equal(AppLogLevel.Warning, actual.MinimumLogLevel);
5253
Assert.True(actual.EnableDebugTools);
54+
Assert.True(actual.EnableLocalRepairDebugReport);
5355
Assert.Equal(@"C:\repo", actual.LastRepositoryPath);
5456
Assert.True(actual.SecurityKeyOnboardingCompleted);
5557
Assert.Equal("1.2.3", actual.LastSeenApplicationVersion);
@@ -59,6 +61,7 @@ public async Task SaveAndLoadAsyncStoresManagementKeyOutsideDesktopJson()
5961
Assert.Contains("managementKeyReference", persistedJson, StringComparison.Ordinal);
6062
Assert.Contains("\"rememberPassword\": true", persistedJson, StringComparison.Ordinal);
6163
Assert.Contains("\"autoLogin\": false", persistedJson, StringComparison.Ordinal);
64+
Assert.Contains("\"enableLocalRepairDebugReport\": true", persistedJson, StringComparison.Ordinal);
6265
Assert.DoesNotContain("rememberManagementKey", persistedJson, StringComparison.Ordinal);
6366
Assert.Contains(
6467
"\"securityKeyOnboardingCompleted\": true",
@@ -133,6 +136,7 @@ public async Task SaveAndLoadAsyncPreservesShellAndUpdatePreferences()
133136
ThemeMode = AppThemeMode.White,
134137
MinimumLogLevel = AppLogLevel.Error,
135138
EnableDebugTools = true,
139+
EnableLocalRepairDebugReport = true,
136140
};
137141

138142
await service.SaveAsync(expected);
@@ -146,6 +150,7 @@ public async Task SaveAndLoadAsyncPreservesShellAndUpdatePreferences()
146150
Assert.Equal(AppThemeMode.White, actual.ThemeMode);
147151
Assert.Equal(AppLogLevel.Error, actual.MinimumLogLevel);
148152
Assert.True(actual.EnableDebugTools);
153+
Assert.True(actual.EnableLocalRepairDebugReport);
149154
}
150155

151156
[Fact]

tests/CodexCliPlus.Tests/UI/NavigationShellTests.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -527,19 +527,23 @@ public void MainWindowHostsSingleWebViewAndTrayMenuContract()
527527
);
528528
Assert.DoesNotContain("SettingsWindow_Deactivated", hostSource, StringComparison.Ordinal);
529529
Assert.Contains("x:Name=\"SettingsFollowSystemCheckBox\"", xaml, StringComparison.Ordinal);
530-
Assert.Contains("x:Name=\"SettingsDebugToolsCheckBox\"", xaml, StringComparison.Ordinal);
531-
Assert.Contains("Content=\"启用调试模式\"", xaml, StringComparison.Ordinal);
532530
Assert.Contains(
533-
"SettingsDebugToolsCheckBox.IsChecked = _settings.EnableDebugTools",
531+
"x:Name=\"SettingsLocalRepairDebugReportCheckBox\"",
532+
xaml,
533+
StringComparison.Ordinal
534+
);
535+
Assert.Contains("Content=\"启用修复调试报告\"", xaml, StringComparison.Ordinal);
536+
Assert.Contains(
537+
"SettingsLocalRepairDebugReportCheckBox.IsChecked = _settings.EnableLocalRepairDebugReport",
534538
hostSource,
535539
StringComparison.Ordinal
536540
);
537541
Assert.Contains(
538-
"_settings.EnableDebugTools = enabled",
542+
"_settings.EnableLocalRepairDebugReport = enabled",
539543
hostSource,
540544
StringComparison.Ordinal
541545
);
542-
Assert.Contains("ApplyDebugToolsSettings", hostSource, StringComparison.Ordinal);
546+
Assert.DoesNotContain("ApplyDebugToolsSettings", hostSource, StringComparison.Ordinal);
543547
Assert.Contains("CornerRadius=\"18,18,0,0\"", xaml, StringComparison.Ordinal);
544548
Assert.DoesNotContain(
545549
"x:Name=\"SettingsOverlayCloseButton\"",

0 commit comments

Comments
 (0)