From f4903eac7eaee7507fdca2793e6099ca636aa653 Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 2 Dec 2024 20:54:45 +0800 Subject: [PATCH 1/4] fix: update version of swift-markdown-ui and TCA to fix compile error of swift 6 --- Core/Package.swift | 4 ++-- Tool/Package.swift | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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"), From cb94ad2f5c853ba1feac987ea98446f6f5e6d769 Mon Sep 17 00:00:00 2001 From: Shx Guo Date: Sun, 22 Dec 2024 17:59:53 +0800 Subject: [PATCH 2/4] Fix that activate app brings all windows to front --- Tool/Sources/AppActivator/AppActivator.swift | 25 +++++++++++++------ .../XcodeInspector+TriggerCommand.swift | 13 +++++----- 2 files changed, 24 insertions(+), 14 deletions(-) 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/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(""" From 43ba6fdd8dca34aabc6c7e71e579856cb863a84f Mon Sep 17 00:00:00 2001 From: Shx Guo Date: Mon, 23 Dec 2024 02:17:02 +0800 Subject: [PATCH 3/4] Support setting language to GitHub Copilot chat --- .../LanguageServer/GitHubCopilotRequest.swift | 1 + .../Services/GitHubCopilotChatService.swift | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) 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 From de2250cf2fc35fc13ba6c756e5a2a588208fa42d Mon Sep 17 00:00:00 2001 From: Shx Guo Date: Mon, 23 Dec 2024 15:31:20 +0800 Subject: [PATCH 4/4] Bump version --- Version.xcconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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