File tree Expand file tree Collapse file tree 4 files changed +36
-4
lines changed
Expand file tree Collapse file tree 4 files changed +36
-4
lines changed Original file line number Diff line number Diff line change 1+ import ActiveApplicationMonitor
12import Combine
23import PromptToCodeService
34import SuggestionWidget
@@ -58,6 +59,9 @@ extension PromptToCodeProvider {
5859 Task { @ServiceActor in
5960 let handler = PseudoCommandHandler ( )
6061 await handler. acceptSuggestion ( )
62+ if let app = ActiveApplicationMonitor . previousActiveApplication, app. isXcode {
63+ app. activate ( )
64+ }
6165 }
6266 }
6367
@@ -74,3 +78,4 @@ extension PromptToCodeProvider {
7478 }
7579 }
7680}
81+
Original file line number Diff line number Diff line change @@ -173,12 +173,22 @@ extension WidgetDataSource: SuggestionWidgetDataSource {
173173 Task { @ServiceActor in
174174 let handler = PseudoCommandHandler ( )
175175 await handler. rejectSuggestions ( )
176+ if let app = ActiveApplicationMonitor . previousActiveApplication,
177+ app. isXcode
178+ {
179+ app. activate ( )
180+ }
176181 }
177182 } ,
178183 onAcceptSuggestionTapped: {
179184 Task { @ServiceActor in
180185 let handler = PseudoCommandHandler ( )
181186 await handler. acceptSuggestion ( )
187+ if let app = ActiveApplicationMonitor . previousActiveApplication,
188+ app. isXcode
189+ {
190+ app. activate ( )
191+ }
182192 }
183193 }
184194 )
Original file line number Diff line number Diff line change 1+ import ActiveApplicationMonitor
12import AppKit
23import SwiftUI
34
@@ -9,7 +10,7 @@ final class ChatWindowViewModel: ObservableObject {
910 @Published var colorScheme : ColorScheme
1011 @Published var isPanelDisplayed = false
1112 @Published var chatPanelInASeparateWindow = false
12-
13+
1314 public init ( chat: ChatProvider ? = nil , colorScheme: ColorScheme = . dark) {
1415 self . chat = chat
1516 self . colorScheme = colorScheme
@@ -26,6 +27,11 @@ struct ChatWindowView: View {
2627 . background {
2728 Button ( action: {
2829 viewModel. isPanelDisplayed = false
30+ if let app = ActiveApplicationMonitor . previousActiveApplication,
31+ app. isXcode
32+ {
33+ app. activate ( )
34+ }
2935 } ) {
3036 EmptyView ( )
3137 }
@@ -38,3 +44,4 @@ struct ChatWindowView: View {
3844 . preferredColorScheme ( viewModel. colorScheme)
3945 }
4046}
47+
Original file line number Diff line number Diff line change 1+ import ActiveApplicationMonitor
12import Environment
23import Preferences
34import SuggestionModel
@@ -26,15 +27,24 @@ struct WidgetView: View {
2627 Circle ( ) . fill ( isHovering ? . white. opacity ( 0.8 ) : . white. opacity ( 0.3 ) )
2728 . onTapGesture {
2829 withAnimation ( . easeInOut( duration: 0.2 ) ) {
29- let isDisplayed = {
30+ let wasDisplayed = {
3031 if panelViewModel. isPanelDisplayed,
3132 panelViewModel. content != nil { return true }
3233 if chatWindowViewModel. isPanelDisplayed,
3334 chatWindowViewModel. chat != nil { return true }
3435 return false
3536 } ( )
36- panelViewModel. isPanelDisplayed = !isDisplayed
37- chatWindowViewModel. isPanelDisplayed = !isDisplayed
37+ panelViewModel. isPanelDisplayed = !wasDisplayed
38+ chatWindowViewModel. isPanelDisplayed = !wasDisplayed
39+ let isDisplayed = !wasDisplayed
40+
41+ if !isDisplayed {
42+ if let app = ActiveApplicationMonitor . previousActiveApplication,
43+ app. isXcode
44+ {
45+ app. activate ( )
46+ }
47+ }
3848 }
3949 }
4050 . overlay {
You can’t perform that action at this time.
0 commit comments