This commit is contained in:
Peter Steinberger 2025-06-22 07:01:24 +02:00
parent f6932ca9b5
commit d34f35e660
8 changed files with 41 additions and 33 deletions

View file

@ -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()

View file

@ -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)\"")

View file

@ -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()
}

View file

@ -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"
)

View file

@ -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"
)

View file

@ -59,7 +59,7 @@ final class SystemPermissionManager {
]
private let logger = Logger(
subsystem: Bundle.main.bundleIdentifier ?? "VibeTunnel",
subsystem: "sh.vibetunnel.vibetunnel",
category: "SystemPermissions"
)

View file

@ -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"
)

View file

@ -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 {