fix(macos): allow disabling launchd job when switching to remote mode

Previously, GatewayLaunchAgentManager.set() returned early for ANY launchd change
in remote mode. This prevented the launchd job from being unloaded when switching
from local to remote mode, causing a crash-loop as the job kept trying to bind
to port 18789 (which the SSH tunnel was using).

Now only 'enable' is blocked in remote mode; 'disable' (uninstall) proceeds
normally so the job is properly unloaded.

Fixes #2354
This commit is contained in:
Kenny Lee 2026-01-26 11:49:41 -08:00
parent 9f7e74c0d8
commit 58be73e179

View File

@ -51,8 +51,10 @@ enum GatewayLaunchAgentManager {
static func set(enabled: Bool, bundlePath: String, port: Int) async -> String? {
_ = bundlePath
guard !CommandResolver.connectionModeIsRemote() else {
self.logger.info("launchd change skipped (remote mode)")
// In remote mode, never enable the local gateway, but still allow disabling it
// so switching from localremote properly unloads the launchd job.
if enabled, CommandResolver.connectionModeIsRemote() {
self.logger.info("launchd enable skipped (remote mode)")
return nil
}
if enabled, self.isLaunchAgentWriteDisabled() {