File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -4,11 +4,13 @@ public final class ActiveApplicationMonitor {
44 static let shared = ActiveApplicationMonitor ( )
55 var latestXcode : NSRunningApplication ? = NSWorkspace . shared. runningApplications
66 . first ( where: \. isXcode)
7+ var previousApp : NSRunningApplication ?
78 var activeApplication = NSWorkspace . shared. runningApplications. first ( where: \. isActive) {
89 didSet {
910 if activeApplication? . isXcode ?? false {
1011 latestXcode = activeApplication
1112 }
13+ previousApp = oldValue
1214 }
1315 }
1416
@@ -35,6 +37,8 @@ public final class ActiveApplicationMonitor {
3537 }
3638
3739 public static var activeApplication : NSRunningApplication ? { shared. activeApplication }
40+
41+ public static var previousActiveApplication : NSRunningApplication ? { shared. previousApp }
3842
3943 public static var activeXcode : NSRunningApplication ? {
4044 if activeApplication? . isXcode ?? false {
@@ -77,3 +81,4 @@ public final class ActiveApplicationMonitor {
7781public extension NSRunningApplication {
7882 var isXcode : Bool { bundleIdentifier == " com.apple.dt.Xcode " }
7983}
84+
Original file line number Diff line number Diff line change 1+ import ActiveApplicationMonitor
12import ChatService
2- import SuggestionModel
3- import GitHubCopilotService
43import Foundation
4+ import GitHubCopilotService
55import OpenAIService
66import PromptToCodeService
7+ import SuggestionModel
78import SuggestionWidget
89
910@ServiceActor
@@ -52,6 +53,9 @@ final class WidgetDataSource {
5253 }
5354 let presenter = PresentInWindowSuggestionPresenter ( )
5455 presenter. closeChatRoom ( fileURL: url)
56+ if let app = ActiveApplicationMonitor . previousActiveApplication, app. isXcode {
57+ app. activate ( )
58+ }
5559 } ,
5660 onSwitchContext: { [ weak self] in
5761 let useGlobalChat = UserDefaults . shared. value ( for: \. useGlobalChat)
@@ -114,6 +118,9 @@ final class WidgetDataSource {
114118 self ? . removePromptToCode ( for: url)
115119 let presenter = PresentInWindowSuggestionPresenter ( )
116120 presenter. closePromptToCode ( fileURL: url)
121+ if let app = ActiveApplicationMonitor . previousActiveApplication, app. isXcode {
122+ app. activate ( )
123+ }
117124 }
118125 )
119126 return PromptToCode ( promptToCodeService: service, provider: provider)
@@ -199,3 +206,4 @@ extension WidgetDataSource: SuggestionWidgetDataSource {
199206 return promptToCodes [ url] ? . provider
200207 }
201208}
209+
You can’t perform that action at this time.
0 commit comments