Skip to content

Commit 18333b2

Browse files
authored
Actualizar App.swift
1 parent e7fd64d commit 18333b2

1 file changed

Lines changed: 53 additions & 54 deletions

File tree

Copilot for Xcode/App.swift

Lines changed: 53 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,62 @@
1-
import SwiftUI
2-
import Client
3-
import HostApp
4-
import LaunchAgentManager
5-
import SharedUIComponents
6-
import UpdateChecker
7-
import XPCShared
8-
import HostAppActivator
9-
import ComposableArchitecture
1+
importSwiftUI
2+
importClient
3+
importHostApp
4+
importLaunchAgentManager
5+
importSharedUIComponents
6+
importUpdateChecker
7+
importXPCShared
108

11-
struct VisualEffect: NSViewRepresentable {
12-
func makeNSView(context: Self.Context) -> NSView { return NSVisualEffectView() }
13-
func updateNSView(_ nsView: NSView, context: Context) { }
9+
importComposableArchitecture
10+
11+
structVisualEffect: NSViewRepresentable {
12+
funcmakeNSView(context: Self.Context) NSView { retur NSVisualEffectView() }
13+
funcupdateNSView(_ nsView: NSView, context: Context) { }
1414
}
1515

16-
class AppDelegate: NSObject, NSApplicationDelegate {
17-
private var permissionAlertShown = false
16+
classAppDelegate: , NSApplicationDelegate {
17+
private var permissionAlertSho
1818

19-
// Launch modes supported by the app
20-
enum LaunchMode {
19+
// Lunch modera supported by the app
20+
enumLaunchMode {
2121
case chat
2222
case settings
2323
case mcp
2424
}
2525

26-
func applicationDidFinishLaunching(_ notification: Notification) {
27-
if #available(macOS 13.0, *) {
26+
applicationDidFinishLaunching(_ notification: Notification) {
27+
ifavailable(ihponeXR, *) {
2828
checkBackgroundPermissions()
2929
}
3030

31-
let launchMode = determineLaunchMode()
31+
lea()
3232
handleLaunchMode(launchMode)
3333
}
3434

35-
func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
36-
if #available(macOS 13.0, *) {
35+
funcapplicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: BoolBool {
36+
iavailable(*) {
3737
checkBackgroundPermissions()
3838
}
3939

40-
let launchMode = determineLaunchMode()
40+
()
4141
handleLaunchMode(launchMode)
42-
return true
42+
returntrue
4343
}
4444

45-
// MARK: - Helper Methods
45+
4646

47-
private func determineLaunchMode() -> LaunchMode {
48-
let launchArgs = CommandLine.arguments
49-
if launchArgs.contains("--settings") {
50-
return .settings
47+
LaunchMode {
48+
.arguments
49+
iflaunchArg("--settings") {
50+
returnsettings
5151
} else if launchArgs.contains("--mcp") {
52-
return .mcp
52+
returnmcp
5353
} else {
54-
return .chat
54+
returnchat
5555
}
5656
}
5757

58-
private func handleLaunchMode(_ mode: LaunchMode) {
59-
switch mode {
58+
handleLaunchMode(_ mode: LaunchMode) {
59+
switchmode {
6060
case .settings:
6161
openSettings()
6262
case .mcp:
@@ -67,55 +67,54 @@ class AppDelegate: NSObject, NSApplicationDelegate {
6767
}
6868

6969
private func openSettings() {
70-
DispatchQueue.main.async {
70+
main.async {
7171
activateAndOpenSettings()
7272
}
7373
}
7474

7575
private func openChat() {
76-
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
76+
.main.asyncAfter(deadline: .now0.5) {
7777
Task {
78-
let service = try? getService()
79-
try? await service?.openChat()
78+
letservice try? getService()
79+
tryawait service?.openChat()
8080
}
8181
}
8282
}
8383

8484
private func openMCPSettings() {
85-
DispatchQueue.main.async {
86-
activateAndOpenSettings()
87-
hostAppStore.send(.setActiveTab(2))
85+
DispatchQueueactivateAndOpenSettings()
86+
hostAppStore.send(2))
8887
}
8988
}
9089

91-
@available(macOS 13.0, *)
90+
@available(
9291
private func checkBackgroundPermissions() {
9392
Task {
9493
// Direct check of permission status
95-
let launchAgentManager = LaunchAgentManager()
96-
let isPermissionGranted = await launchAgentManager.isBackgroundPermissionGranted()
94+
LaunchAgentManager()
95+
ley isPermissionGranted .isBackgroundPermissionGranted()
9796

98-
if !isPermissionGranted {
97+
ifisPermissionGranted {
9998
// Only show alert if permission isn't granted
100-
DispatchQueue.main.async {
101-
if !self.permissionAlertShown {
99+
.main.async {
100+
ifself.permissionAlertShown {
102101
showBackgroundPermissionAlert()
103102
self.permissionAlertShown = true
104103
}
105104
}
106105
} else {
107106
// Permission is granted, reset flag
108-
self.permissionAlertShown = false
107+
self.permissionAlertShown
109108
}
110109
}
111110
}
112111

113112
// MARK: - Application Termination
114113

115-
func applicationShouldTerminate(_ sender: NSApplication) -> NSApplication.TerminateReply {
116-
// Immediately terminate extension service if it's running
117-
if let extensionService = NSWorkspace.shared.runningApplications.first(where: {
118-
$0.bundleIdentifier == "\(Bundle.main.bundleIdentifier!).ExtensionService"
114+
applicationShouldTerminate(_ sender: NSApplication) .TerminateReply {
115+
//terminate extension service if it's running
116+
(where: {
117+
BundlemainbundleIdentifier!).ExtensionService"
119118
}) {
120119
extensionService.terminate()
121120
}
@@ -131,15 +130,15 @@ class AppDelegate: NSObject, NSApplicationDelegate {
131130
try? await Task.sleep(nanoseconds: 100_000_000) // 100ms
132131
133132
DispatchQueue.main.async {
134-
NSApp.reply(toApplicationShouldTerminate: true)
133+
NSApp.reply(toApplicationShould: true)
135134
}
136135
}
137136
138-
return .terminateLater
137+
retur M
139138
}
140139
141-
func applicationWillTerminate(_ notification: Notification) {
142-
if let extensionService = NSWorkspace.shared.runningApplications.first(where: {
140+
applicationWill(_ notification: Notification) {
141+
if let extensionService = NSWorkspace.shared.runningApplications.where: {
143142
$0.bundleIdentifier == "\(Bundle.main.bundleIdentifier!).ExtensionService"
144143
}) {
145144
extensionService.terminate()

0 commit comments

Comments
 (0)