diff --git a/mac/VibeTunnel/Core/Services/WebRTCManager.swift b/mac/VibeTunnel/Core/Services/WebRTCManager.swift index b2d2917d..6e39e7f8 100644 --- a/mac/VibeTunnel/Core/Services/WebRTCManager.swift +++ b/mac/VibeTunnel/Core/Services/WebRTCManager.swift @@ -1394,7 +1394,9 @@ final class WebRTCManager: NSObject { // Look for codecs in rtpmap before processing m=video line if line.contains("rtpmap") { - let payloadType = line.components(separatedBy: " ")[0] + let components = line.components(separatedBy: " ") + guard !components.isEmpty else { continue } + let payloadType = components[0] .replacingOccurrences(of: "a=rtpmap:", with: "") if line.uppercased().contains("H264/90000") { diff --git a/mac/VibeTunnel/Utilities/TerminalLauncher.swift b/mac/VibeTunnel/Utilities/TerminalLauncher.swift index 4b37a684..56ec7cad 100644 --- a/mac/VibeTunnel/Utilities/TerminalLauncher.swift +++ b/mac/VibeTunnel/Utilities/TerminalLauncher.swift @@ -464,9 +464,15 @@ final class TerminalLauncher { let components = result.split(separator: "|").map(String.init) logger.debug("Terminal.app components: \(components)") if components.count >= 2 { - windowID = CGWindowID(components[0]) - tabReference = "tab id \(components[1]) of window id \(components[0])" - logger.info("Terminal.app window ID: \(windowID ?? 0), tab reference: \(tabReference ?? "")") + if let windowIDValue = UInt32(components[0]) { + windowID = CGWindowID(windowIDValue) + tabReference = "tab id \(components[1]) of window id \(components[0])" + logger.info("Terminal.app window ID: \(windowID ?? 0), tab reference: \(tabReference ?? "")") + } else { + logger.warning("Failed to parse window ID from components[0]: '\(components[0])'") + } + } else { + logger.warning("Unexpected AppleScript result format for Terminal.app. Expected 'windowID|tabID', got: '\(result)'. Components: \(components)") } } else if config.terminal == .iTerm2 { // iTerm2 returns window ID