refactor(runtime): remove redundant mode guard

This commit is contained in:
Qiu Yuzhou
2026-10-17 17:44:09 +08:00
parent 74a2e0695e
commit 5fc5ddf1cb
3 changed files with 2 additions and 4 deletions
@@ -248,7 +248,7 @@ final class ProxyControlWorkflow: ObservableObject {
return republish()
}
/// 切换代理模式:可用性与 no-op 语义由控制器既有入口裁定;
/// 切换代理模式:no-op 语义由控制器既有入口裁定;
/// 完成后整体重发布。持久化失败保留旧模式,失败以 typed fact 呈现。
@discardableResult
func setProxyMode(_ mode: ProxyMode) async -> ProxyControlSnapshot {
@@ -5,7 +5,6 @@ extension ProxyRuntimeController {
/// and global) also deploy and verify the ACL runtime even when system proxy
/// is off, because manually connected SOCKS and HTTP clients use the same ACL.
func setProxyMode(_ mode: ProxyMode) async {
guard ProxyMode.availableModes.contains(mode) else { return }
guard mode != proxyMode else { return }
await transitionMode(mode, ruleDefaultAction: settings.ruleDefaultAction)
}
@@ -3,8 +3,7 @@ import XCTest
@testable import ShadowsocksX_NG2
/// Domain mode availability is the single policy shared by the menu and
/// runtime mode entry points.
/// Built-in modes keep a stable selector order and project local proxy settings.
final class ProxyModeAvailabilityTests: XCTestCase {
func testBuiltInModesAreAlwaysAvailableInProductOrder() {
XCTAssertEqual(