mirror of
https://github.com/samsonjs/vibetunnel.git
synced 2026-04-25 14:57:37 +00:00
adjust distributed message
This commit is contained in:
parent
5c9f9720dc
commit
36735223af
1 changed files with 11 additions and 7 deletions
|
|
@ -391,7 +391,7 @@ final class TerminalLauncher {
|
|||
// MARK: - Distributed Notification Handling
|
||||
|
||||
private func setupNotificationListener() {
|
||||
let notificationName = NSNotification.Name("sh.vibetunnel.vibetunnel.openSession")
|
||||
let notificationName = NSNotification.Name("sh.vibetunnel.vibetunnel.spawn")
|
||||
|
||||
notificationObserver = DistributedNotificationCenter.default().addObserver(
|
||||
forName: notificationName,
|
||||
|
|
@ -400,15 +400,15 @@ final class TerminalLauncher {
|
|||
) { notification in
|
||||
// Extract values immediately to avoid sending notification across boundaries
|
||||
let userInfo = notification.userInfo
|
||||
let workingDirectory = userInfo?["workingDirectory"] as? String
|
||||
let command = userInfo?["command"] as? String
|
||||
let workingDirectory = userInfo?["workingDir"] as? String
|
||||
let commandArray = userInfo?["command"] as? [String]
|
||||
let sessionId = userInfo?["sessionId"] as? String
|
||||
|
||||
Task { @MainActor [weak self] in
|
||||
guard let self = self else { return }
|
||||
self.processOpenSessionRequest(
|
||||
workingDirectory: workingDirectory,
|
||||
command: command,
|
||||
commandArray: commandArray,
|
||||
sessionId: sessionId
|
||||
)
|
||||
}
|
||||
|
|
@ -417,15 +417,19 @@ final class TerminalLauncher {
|
|||
logger.info("Registered for distributed notification: \(notificationName.rawValue)")
|
||||
}
|
||||
|
||||
private func processOpenSessionRequest(workingDirectory: String?, command: String?, sessionId: String?) {
|
||||
private func processOpenSessionRequest(workingDirectory: String?, commandArray: [String]?, sessionId: String?) {
|
||||
guard let workingDirectory = workingDirectory,
|
||||
let command = command,
|
||||
let commandArray = commandArray,
|
||||
!commandArray.isEmpty,
|
||||
let sessionId = sessionId else {
|
||||
logger.error("Invalid notification payload: missing required fields")
|
||||
return
|
||||
}
|
||||
|
||||
logger.info("Received openSession notification - sessionId: \(sessionId), workingDirectory: \(workingDirectory)")
|
||||
// Join command array into a single command string
|
||||
let command = commandArray.joined(separator: " ")
|
||||
|
||||
logger.info("Received spawn notification - sessionId: \(sessionId), workingDirectory: \(workingDirectory), command: \(command)")
|
||||
|
||||
Task {
|
||||
do {
|
||||
|
|
|
|||
Loading…
Reference in a new issue