mirror of
https://github.com/samsonjs/vibetunnel.git
synced 2026-04-27 15:17:38 +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
|
// MARK: - Distributed Notification Handling
|
||||||
|
|
||||||
private func setupNotificationListener() {
|
private func setupNotificationListener() {
|
||||||
let notificationName = NSNotification.Name("sh.vibetunnel.vibetunnel.openSession")
|
let notificationName = NSNotification.Name("sh.vibetunnel.vibetunnel.spawn")
|
||||||
|
|
||||||
notificationObserver = DistributedNotificationCenter.default().addObserver(
|
notificationObserver = DistributedNotificationCenter.default().addObserver(
|
||||||
forName: notificationName,
|
forName: notificationName,
|
||||||
|
|
@ -400,15 +400,15 @@ final class TerminalLauncher {
|
||||||
) { notification in
|
) { notification in
|
||||||
// Extract values immediately to avoid sending notification across boundaries
|
// Extract values immediately to avoid sending notification across boundaries
|
||||||
let userInfo = notification.userInfo
|
let userInfo = notification.userInfo
|
||||||
let workingDirectory = userInfo?["workingDirectory"] as? String
|
let workingDirectory = userInfo?["workingDir"] as? String
|
||||||
let command = userInfo?["command"] as? String
|
let commandArray = userInfo?["command"] as? [String]
|
||||||
let sessionId = userInfo?["sessionId"] as? String
|
let sessionId = userInfo?["sessionId"] as? String
|
||||||
|
|
||||||
Task { @MainActor [weak self] in
|
Task { @MainActor [weak self] in
|
||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
self.processOpenSessionRequest(
|
self.processOpenSessionRequest(
|
||||||
workingDirectory: workingDirectory,
|
workingDirectory: workingDirectory,
|
||||||
command: command,
|
commandArray: commandArray,
|
||||||
sessionId: sessionId
|
sessionId: sessionId
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -417,15 +417,19 @@ final class TerminalLauncher {
|
||||||
logger.info("Registered for distributed notification: \(notificationName.rawValue)")
|
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,
|
guard let workingDirectory = workingDirectory,
|
||||||
let command = command,
|
let commandArray = commandArray,
|
||||||
|
!commandArray.isEmpty,
|
||||||
let sessionId = sessionId else {
|
let sessionId = sessionId else {
|
||||||
logger.error("Invalid notification payload: missing required fields")
|
logger.error("Invalid notification payload: missing required fields")
|
||||||
return
|
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 {
|
Task {
|
||||||
do {
|
do {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue