diff --git a/mac/VibeTunnel/Core/Managers/DockIconManager.swift b/mac/VibeTunnel/Core/Managers/DockIconManager.swift index 542aa33d..e52c2fc8 100644 --- a/mac/VibeTunnel/Core/Managers/DockIconManager.swift +++ b/mac/VibeTunnel/Core/Managers/DockIconManager.swift @@ -16,7 +16,7 @@ final class DockIconManager: NSObject { } private var windowsObservation: NSKeyValueObservation? - private let logger = Logger(subsystem: Bundle.main.bundleIdentifier ?? "VibeTunnel", category: "DockIconManager") + private let logger = Logger(subsystem: "sh.vibetunnel.vibetunnel", category: "DockIconManager") override private init() { super.init() diff --git a/mac/VibeTunnel/Core/Services/BunServer.swift b/mac/VibeTunnel/Core/Services/BunServer.swift index 607f8838..b5c6f993 100644 --- a/mac/VibeTunnel/Core/Services/BunServer.swift +++ b/mac/VibeTunnel/Core/Services/BunServer.swift @@ -65,15 +65,14 @@ final class BunServer { // Verify binary exists and is executable var isDirectory: ObjCBool = false let fileExists = FileManager.default.fileExists(atPath: binaryPath, isDirectory: &isDirectory) - logger.info("vibetunnel binary exists: \(fileExists), is directory: \(isDirectory.boolValue)") - if fileExists && !isDirectory.boolValue { let attributes = try FileManager.default.attributesOfItem(atPath: binaryPath) - if let permissions = attributes[.posixPermissions] as? NSNumber { - logger.info("vibetunnel binary permissions: \(String(permissions.intValue, radix: 8))") - } - if let fileSize = attributes[.size] as? NSNumber { - logger.info("vibetunnel binary size: \(fileSize.intValue) bytes") + if let permissions = attributes[.posixPermissions] as? NSNumber, + let fileSize = attributes[.size] as? NSNumber { + logger + .info( + "vibetunnel binary size: \(fileSize.intValue) bytes, permissions: \(String(permissions.intValue, radix: 8))" + ) } } else if !fileExists { logger.error("vibetunnel binary NOT FOUND at: \(binaryPath)") @@ -99,9 +98,6 @@ final class BunServer { logger.error("Web directory not found at expected location: \(staticPath)") } - // Build command to run vibetunnel through login shell - // Note: The current server implementation doesn't support bind address configuration - // Build the vibetunnel command with all arguments var vibetunnelArgs = "--port \(port)" @@ -119,13 +115,7 @@ final class BunServer { } // Create wrapper to run vibetunnel - let vibetunnelCommand = """ - # Run vibetunnel directly - exec "\(binaryPath)" \(vibetunnelArgs) - """ - - // Note: cleanup-startup is not supported by the current server implementation - + let vibetunnelCommand = "exec \(binaryPath) \(vibetunnelArgs)" process.arguments = ["-l", "-c", vibetunnelCommand] logger.info("Executing command: /bin/zsh -l -c \"\(vibetunnelCommand)\"") diff --git a/mac/VibeTunnel/Core/Services/ServerManager.swift b/mac/VibeTunnel/Core/Services/ServerManager.swift index 97e7a95e..ebb78d7b 100644 --- a/mac/VibeTunnel/Core/Services/ServerManager.swift +++ b/mac/VibeTunnel/Core/Services/ServerManager.swift @@ -201,10 +201,10 @@ class ServerManager { defer { isRestarting = false } await stop() - + // Add a brief delay to ensure the port is released by the OS try? await Task.sleep(for: .milliseconds(500)) - + await start() } diff --git a/mac/VibeTunnel/Core/Services/SparkleUpdaterManager.swift b/mac/VibeTunnel/Core/Services/SparkleUpdaterManager.swift index 3cade1dd..05966255 100644 --- a/mac/VibeTunnel/Core/Services/SparkleUpdaterManager.swift +++ b/mac/VibeTunnel/Core/Services/SparkleUpdaterManager.swift @@ -17,12 +17,12 @@ public final class SparkleUpdaterManager: NSObject, SPUUpdaterDelegate { fileprivate var updaterController: SPUStandardUpdaterController? private(set) var userDriverDelegate: SparkleUserDriverDelegate? private let logger = os.Logger( - subsystem: Bundle.main.bundleIdentifier ?? "VibeTunnel", + subsystem: "sh.vibetunnel.vibetunnel", category: "SparkleUpdater" ) private nonisolated static let staticLogger = os.Logger( - subsystem: Bundle.main.bundleIdentifier ?? "VibeTunnel", + subsystem: "sh.vibetunnel.vibetunnel", category: "SparkleUpdater" ) diff --git a/mac/VibeTunnel/Core/Services/SparkleUserDriverDelegate.swift b/mac/VibeTunnel/Core/Services/SparkleUserDriverDelegate.swift index adb9f659..b5a5c0cb 100644 --- a/mac/VibeTunnel/Core/Services/SparkleUserDriverDelegate.swift +++ b/mac/VibeTunnel/Core/Services/SparkleUserDriverDelegate.swift @@ -9,7 +9,7 @@ import UserNotifications @MainActor final class SparkleUserDriverDelegate: NSObject, @preconcurrency SPUStandardUserDriverDelegate { private let logger = os.Logger( - subsystem: Bundle.main.bundleIdentifier ?? "VibeTunnel", + subsystem: "sh.vibetunnel.vibetunnel", category: "SparkleUserDriver" ) diff --git a/mac/VibeTunnel/Core/Services/SystemPermissionManager.swift b/mac/VibeTunnel/Core/Services/SystemPermissionManager.swift index b6063f81..38ed3b54 100644 --- a/mac/VibeTunnel/Core/Services/SystemPermissionManager.swift +++ b/mac/VibeTunnel/Core/Services/SystemPermissionManager.swift @@ -59,7 +59,7 @@ final class SystemPermissionManager { ] private let logger = Logger( - subsystem: Bundle.main.bundleIdentifier ?? "VibeTunnel", + subsystem: "sh.vibetunnel.vibetunnel", category: "SystemPermissions" ) diff --git a/mac/VibeTunnel/Core/Services/WindowTracker.swift b/mac/VibeTunnel/Core/Services/WindowTracker.swift index 6ae3d142..940bc224 100644 --- a/mac/VibeTunnel/Core/Services/WindowTracker.swift +++ b/mac/VibeTunnel/Core/Services/WindowTracker.swift @@ -14,7 +14,7 @@ final class WindowTracker { static let shared = WindowTracker() private let logger = Logger( - subsystem: Bundle.main.bundleIdentifier ?? "VibeTunnel", + subsystem: "sh.vibetunnel.vibetunnel", category: "WindowTracker" ) diff --git a/mac/VibeTunnel/Utilities/TerminalLauncher.swift b/mac/VibeTunnel/Utilities/TerminalLauncher.swift index a1a9cadc..9b6c0f7d 100644 --- a/mac/VibeTunnel/Utilities/TerminalLauncher.swift +++ b/mac/VibeTunnel/Utilities/TerminalLauncher.swift @@ -306,13 +306,10 @@ enum TerminalLauncherError: LocalizedError { @MainActor final class TerminalLauncher { static let shared = TerminalLauncher() - private let logger = Logger(subsystem: "sh.vibetunnel.VibeTunnel", category: "TerminalLauncher") private init() { - logger.info("TerminalLauncher initializing...") performFirstRunAutoDetection() - logger.info("TerminalLauncher initialized successfully") } func launchCommand(_ command: String) throws { @@ -615,7 +612,12 @@ final class TerminalLauncher { // For Bun server, use fwd to create sessions logger.info("Using Bun server session creation via fwd") let bunPath = findBunExecutable() - let bunCommand = buildBunCommand(bunPath: bunPath, userCommand: command, workingDir: escapedWorkingDir, sessionId: sessionId) + let bunCommand = buildBunCommand( + bunPath: bunPath, + userCommand: command, + workingDir: escapedWorkingDir, + sessionId: sessionId + ) let fullCommand = "cd \"\(escapedWorkingDir)\" && \(bunCommand) && exit" // Get the preferred terminal or fallback @@ -680,12 +682,22 @@ final class TerminalLauncher { fullCommand = "cd \"\(escapedDir)\" && \(bunCommand) && exit" } else { // Fallback if format is different - let bunCommand = buildBunCommand(bunPath: bunPath, userCommand: command, workingDir: escapedDir, sessionId: sessionId) + let bunCommand = buildBunCommand( + bunPath: bunPath, + userCommand: command, + workingDir: escapedDir, + sessionId: sessionId + ) fullCommand = "cd \"\(escapedDir)\" && \(bunCommand) && exit" } } else { // Command is just the user command - let bunCommand = buildBunCommand(bunPath: bunPath, userCommand: command, workingDir: escapedDir, sessionId: sessionId) + let bunCommand = buildBunCommand( + bunPath: bunPath, + userCommand: command, + workingDir: escapedDir, + sessionId: sessionId + ) fullCommand = "cd \"\(escapedDir)\" && \(bunCommand) && exit" } } else { @@ -752,10 +764,16 @@ final class TerminalLauncher { return "echo 'VibeTunnel: Bun executable not found in app bundle'; false" } - private func buildBunCommand(bunPath: String, userCommand: String, workingDir: String, sessionId: String? = nil) -> String { + private func buildBunCommand( + bunPath: String, + userCommand: String, + workingDir: String, + sessionId: String? = nil + ) + -> String { // Bun executable has fwd command built-in logger.info("Using Bun executable for session creation") - if let sessionId = sessionId { + if let sessionId { // Pass the pre-generated session ID to fwd return "\"\(bunPath)\" fwd --session-id \(sessionId) \(userCommand)" } else {