diff --git a/Core/Package.swift b/Core/Package.swift index f1862ae5..3934bbbc 100644 --- a/Core/Package.swift +++ b/Core/Package.swift @@ -39,13 +39,13 @@ let package = Package( .package(path: "../Tool"), .package(path: "../ChatPlugins"), .package(url: "https://github.com/apple/swift-async-algorithms", from: "1.0.0"), - .package(url: "https://github.com/gonzalezreal/swift-markdown-ui", from: "2.1.0"), + .package(url: "https://github.com/gonzalezreal/swift-markdown-ui", from: "2.4.1"), .package(url: "https://github.com/sparkle-project/Sparkle", from: "2.0.0"), .package(url: "https://github.com/pointfreeco/swift-parsing", from: "0.12.1"), .package(url: "https://github.com/pointfreeco/swift-dependencies", from: "1.0.0"), .package( url: "https://github.com/pointfreeco/swift-composable-architecture", - exact: "1.15.0" + exact: "1.16.1" ), // quick hack to support custom UserDefaults // https://github.com/sindresorhus/KeyboardShortcuts diff --git a/Tool/Package.swift b/Tool/Package.swift index 915ddb17..b5f93686 100644 --- a/Tool/Package.swift +++ b/Tool/Package.swift @@ -72,7 +72,7 @@ let package = Package( .package(url: "https://github.com/intitni/Highlightr", branch: "master"), .package( url: "https://github.com/pointfreeco/swift-composable-architecture", - exact: "1.15.0" + exact: "1.16.1" ), .package(url: "https://github.com/apple/swift-syntax.git", from: "600.0.0"), .package(url: "https://github.com/GottaGetSwifty/CodableWrappers", from: "2.0.7"), diff --git a/Tool/Sources/AppActivator/AppActivator.swift b/Tool/Sources/AppActivator/AppActivator.swift index dfd20482..8d31b32c 100644 --- a/Tool/Sources/AppActivator/AppActivator.swift +++ b/Tool/Sources/AppActivator/AppActivator.swift @@ -16,9 +16,11 @@ public extension NSWorkspace { if activated { return } // Fallback solution - - let axApplication = AXUIElementCreateApplication(ProcessInfo.processInfo.processIdentifier) - axApplication.isFrontmost = true + + let axApplication = AXUIElementCreateApplication( + ProcessInfo.processInfo.processIdentifier + ) + activateAppElement(axApplication) // // let appleScript = """ // tell application "System Events" @@ -35,8 +37,7 @@ public extension NSWorkspace { guard let app = await XcodeInspector.shared.safe.previousActiveApplication else { return } try await Task.sleep(nanoseconds: UInt64(delay * 1_000_000_000)) - app.appElement.isFrontmost = true -// _ = app.activate() + activateApp(app) } } @@ -44,10 +45,20 @@ public extension NSWorkspace { Task { @MainActor in guard let app = await XcodeInspector.shared.safe.latestActiveXcode else { return } try await Task.sleep(nanoseconds: UInt64(delay * 1_000_000_000)) - app.appElement.isFrontmost = true -// _ = app.activate() + activateApp(app) + } + } + + static func activateApp(_ app: AppInstanceInspector) { + // we prefer `.activate()` because it only brings the active window to the front + if !app.activate() { + activateAppElement(app.appElement) } } + + static func activateAppElement(_ appElement: AXUIElement) { + appElement.isFrontmost = true + } } struct ActivateThisAppDependencyKey: DependencyKey { diff --git a/Tool/Sources/GitHubCopilotService/LanguageServer/GitHubCopilotRequest.swift b/Tool/Sources/GitHubCopilotService/LanguageServer/GitHubCopilotRequest.swift index 1cbbf546..87219683 100644 --- a/Tool/Sources/GitHubCopilotService/LanguageServer/GitHubCopilotRequest.swift +++ b/Tool/Sources/GitHubCopilotService/LanguageServer/GitHubCopilotRequest.swift @@ -376,6 +376,7 @@ enum GitHubCopilotRequest { var source: GitHubCopilotChatSource? // inline or panel var workspaceFolder: String? + var userLanguage: String? } let requestBody: RequestBody diff --git a/Tool/Sources/GitHubCopilotService/Services/GitHubCopilotChatService.swift b/Tool/Sources/GitHubCopilotService/Services/GitHubCopilotChatService.swift index 459b259a..1534b961 100644 --- a/Tool/Sources/GitHubCopilotService/Services/GitHubCopilotChatService.swift +++ b/Tool/Sources/GitHubCopilotService/Services/GitHubCopilotChatService.swift @@ -43,7 +43,14 @@ public final class GitHubCopilotChatService: BuiltinExtensionChatServiceType { capabilities: .init(allSkills: false, skills: []), doc: doc, source: .panel, - workspaceFolder: workspace.projectURL.path + workspaceFolder: workspace.projectURL.path, + userLanguage: { + let language = UserDefaults.shared.value(for: \.chatGPTLanguage) + if language.isEmpty { + return "Auto Detected" + } + return language + }() )) let stream = AsyncThrowingStream { continuation in diff --git a/Tool/Sources/XcodeInspector/XcodeInspector+TriggerCommand.swift b/Tool/Sources/XcodeInspector/XcodeInspector+TriggerCommand.swift index 1005fe12..a7abe69a 100644 --- a/Tool/Sources/XcodeInspector/XcodeInspector+TriggerCommand.swift +++ b/Tool/Sources/XcodeInspector/XcodeInspector+TriggerCommand.swift @@ -30,13 +30,12 @@ public extension AppInstanceInspector { guard path.count >= 2 else { throw cantRunCommand("Path too short.") } if activateApp { - appElement.isFrontmost = true -// if !runningApplication.activate() { -// Logger.service.error(""" -// Trigger menu item \(sourcePath): \ -// Xcode not activated. -// """) -// } + if !runningApplication.isActive { + // we prefer `.activate()` because it only brings the active window to the front + if !activate() { + appElement.isFrontmost = true + } + } } else { if !runningApplication.isActive { Logger.service.error(""" diff --git a/Version.xcconfig b/Version.xcconfig index 149df3ac..98ceb482 100644 --- a/Version.xcconfig +++ b/Version.xcconfig @@ -1,2 +1,2 @@ -APP_VERSION = 0.35.2 -APP_BUILD = 429 +APP_VERSION = 0.35.3 +APP_BUILD = 430