mirror of
https://github.com/samsonjs/vibetunnel.git
synced 2026-04-27 15:17:38 +00:00
cleanup
This commit is contained in:
parent
f6932ca9b5
commit
d34f35e660
8 changed files with 41 additions and 33 deletions
|
|
@ -16,7 +16,7 @@ final class DockIconManager: NSObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
private var windowsObservation: NSKeyValueObservation?
|
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() {
|
override private init() {
|
||||||
super.init()
|
super.init()
|
||||||
|
|
|
||||||
|
|
@ -65,15 +65,14 @@ final class BunServer {
|
||||||
// Verify binary exists and is executable
|
// Verify binary exists and is executable
|
||||||
var isDirectory: ObjCBool = false
|
var isDirectory: ObjCBool = false
|
||||||
let fileExists = FileManager.default.fileExists(atPath: binaryPath, isDirectory: &isDirectory)
|
let fileExists = FileManager.default.fileExists(atPath: binaryPath, isDirectory: &isDirectory)
|
||||||
logger.info("vibetunnel binary exists: \(fileExists), is directory: \(isDirectory.boolValue)")
|
|
||||||
|
|
||||||
if fileExists && !isDirectory.boolValue {
|
if fileExists && !isDirectory.boolValue {
|
||||||
let attributes = try FileManager.default.attributesOfItem(atPath: binaryPath)
|
let attributes = try FileManager.default.attributesOfItem(atPath: binaryPath)
|
||||||
if let permissions = attributes[.posixPermissions] as? NSNumber {
|
if let permissions = attributes[.posixPermissions] as? NSNumber,
|
||||||
logger.info("vibetunnel binary permissions: \(String(permissions.intValue, radix: 8))")
|
let fileSize = attributes[.size] as? NSNumber {
|
||||||
}
|
logger
|
||||||
if let fileSize = attributes[.size] as? NSNumber {
|
.info(
|
||||||
logger.info("vibetunnel binary size: \(fileSize.intValue) bytes")
|
"vibetunnel binary size: \(fileSize.intValue) bytes, permissions: \(String(permissions.intValue, radix: 8))"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
} else if !fileExists {
|
} else if !fileExists {
|
||||||
logger.error("vibetunnel binary NOT FOUND at: \(binaryPath)")
|
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)")
|
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
|
// Build the vibetunnel command with all arguments
|
||||||
var vibetunnelArgs = "--port \(port)"
|
var vibetunnelArgs = "--port \(port)"
|
||||||
|
|
||||||
|
|
@ -119,13 +115,7 @@ final class BunServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create wrapper to run vibetunnel
|
// Create wrapper to run vibetunnel
|
||||||
let vibetunnelCommand = """
|
let vibetunnelCommand = "exec \(binaryPath) \(vibetunnelArgs)"
|
||||||
# Run vibetunnel directly
|
|
||||||
exec "\(binaryPath)" \(vibetunnelArgs)
|
|
||||||
"""
|
|
||||||
|
|
||||||
// Note: cleanup-startup is not supported by the current server implementation
|
|
||||||
|
|
||||||
process.arguments = ["-l", "-c", vibetunnelCommand]
|
process.arguments = ["-l", "-c", vibetunnelCommand]
|
||||||
|
|
||||||
logger.info("Executing command: /bin/zsh -l -c \"\(vibetunnelCommand)\"")
|
logger.info("Executing command: /bin/zsh -l -c \"\(vibetunnelCommand)\"")
|
||||||
|
|
|
||||||
|
|
@ -201,10 +201,10 @@ class ServerManager {
|
||||||
defer { isRestarting = false }
|
defer { isRestarting = false }
|
||||||
|
|
||||||
await stop()
|
await stop()
|
||||||
|
|
||||||
// Add a brief delay to ensure the port is released by the OS
|
// Add a brief delay to ensure the port is released by the OS
|
||||||
try? await Task.sleep(for: .milliseconds(500))
|
try? await Task.sleep(for: .milliseconds(500))
|
||||||
|
|
||||||
await start()
|
await start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,12 @@ public final class SparkleUpdaterManager: NSObject, SPUUpdaterDelegate {
|
||||||
fileprivate var updaterController: SPUStandardUpdaterController?
|
fileprivate var updaterController: SPUStandardUpdaterController?
|
||||||
private(set) var userDriverDelegate: SparkleUserDriverDelegate?
|
private(set) var userDriverDelegate: SparkleUserDriverDelegate?
|
||||||
private let logger = os.Logger(
|
private let logger = os.Logger(
|
||||||
subsystem: Bundle.main.bundleIdentifier ?? "VibeTunnel",
|
subsystem: "sh.vibetunnel.vibetunnel",
|
||||||
category: "SparkleUpdater"
|
category: "SparkleUpdater"
|
||||||
)
|
)
|
||||||
|
|
||||||
private nonisolated static let staticLogger = os.Logger(
|
private nonisolated static let staticLogger = os.Logger(
|
||||||
subsystem: Bundle.main.bundleIdentifier ?? "VibeTunnel",
|
subsystem: "sh.vibetunnel.vibetunnel",
|
||||||
category: "SparkleUpdater"
|
category: "SparkleUpdater"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import UserNotifications
|
||||||
@MainActor
|
@MainActor
|
||||||
final class SparkleUserDriverDelegate: NSObject, @preconcurrency SPUStandardUserDriverDelegate {
|
final class SparkleUserDriverDelegate: NSObject, @preconcurrency SPUStandardUserDriverDelegate {
|
||||||
private let logger = os.Logger(
|
private let logger = os.Logger(
|
||||||
subsystem: Bundle.main.bundleIdentifier ?? "VibeTunnel",
|
subsystem: "sh.vibetunnel.vibetunnel",
|
||||||
category: "SparkleUserDriver"
|
category: "SparkleUserDriver"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ final class SystemPermissionManager {
|
||||||
]
|
]
|
||||||
|
|
||||||
private let logger = Logger(
|
private let logger = Logger(
|
||||||
subsystem: Bundle.main.bundleIdentifier ?? "VibeTunnel",
|
subsystem: "sh.vibetunnel.vibetunnel",
|
||||||
category: "SystemPermissions"
|
category: "SystemPermissions"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ final class WindowTracker {
|
||||||
static let shared = WindowTracker()
|
static let shared = WindowTracker()
|
||||||
|
|
||||||
private let logger = Logger(
|
private let logger = Logger(
|
||||||
subsystem: Bundle.main.bundleIdentifier ?? "VibeTunnel",
|
subsystem: "sh.vibetunnel.vibetunnel",
|
||||||
category: "WindowTracker"
|
category: "WindowTracker"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -306,13 +306,10 @@ enum TerminalLauncherError: LocalizedError {
|
||||||
@MainActor
|
@MainActor
|
||||||
final class TerminalLauncher {
|
final class TerminalLauncher {
|
||||||
static let shared = TerminalLauncher()
|
static let shared = TerminalLauncher()
|
||||||
|
|
||||||
private let logger = Logger(subsystem: "sh.vibetunnel.VibeTunnel", category: "TerminalLauncher")
|
private let logger = Logger(subsystem: "sh.vibetunnel.VibeTunnel", category: "TerminalLauncher")
|
||||||
|
|
||||||
private init() {
|
private init() {
|
||||||
logger.info("TerminalLauncher initializing...")
|
|
||||||
performFirstRunAutoDetection()
|
performFirstRunAutoDetection()
|
||||||
logger.info("TerminalLauncher initialized successfully")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func launchCommand(_ command: String) throws {
|
func launchCommand(_ command: String) throws {
|
||||||
|
|
@ -615,7 +612,12 @@ final class TerminalLauncher {
|
||||||
// For Bun server, use fwd to create sessions
|
// For Bun server, use fwd to create sessions
|
||||||
logger.info("Using Bun server session creation via fwd")
|
logger.info("Using Bun server session creation via fwd")
|
||||||
let bunPath = findBunExecutable()
|
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"
|
let fullCommand = "cd \"\(escapedWorkingDir)\" && \(bunCommand) && exit"
|
||||||
|
|
||||||
// Get the preferred terminal or fallback
|
// Get the preferred terminal or fallback
|
||||||
|
|
@ -680,12 +682,22 @@ final class TerminalLauncher {
|
||||||
fullCommand = "cd \"\(escapedDir)\" && \(bunCommand) && exit"
|
fullCommand = "cd \"\(escapedDir)\" && \(bunCommand) && exit"
|
||||||
} else {
|
} else {
|
||||||
// Fallback if format is different
|
// 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"
|
fullCommand = "cd \"\(escapedDir)\" && \(bunCommand) && exit"
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Command is just the user command
|
// 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"
|
fullCommand = "cd \"\(escapedDir)\" && \(bunCommand) && exit"
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -752,10 +764,16 @@ final class TerminalLauncher {
|
||||||
return "echo 'VibeTunnel: Bun executable not found in app bundle'; false"
|
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
|
// Bun executable has fwd command built-in
|
||||||
logger.info("Using Bun executable for session creation")
|
logger.info("Using Bun executable for session creation")
|
||||||
if let sessionId = sessionId {
|
if let sessionId {
|
||||||
// Pass the pre-generated session ID to fwd
|
// Pass the pre-generated session ID to fwd
|
||||||
return "\"\(bunPath)\" fwd --session-id \(sessionId) \(userCommand)"
|
return "\"\(bunPath)\" fwd --session-id \(sessionId) \(userCommand)"
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue