Skip to content

Commit

Permalink
Merge branch 'release/0.35.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
intitni committed Dec 23, 2024
2 parents 2ab65a5 + de2250c commit dbd4194
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Core/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Tool/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
25 changes: 18 additions & 7 deletions Tool/Sources/AppActivator/AppActivator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -35,19 +37,28 @@ 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)
}
}

static func activatePreviousActiveXcode(delay: TimeInterval = 0.2) {
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ enum GitHubCopilotRequest {

var source: GitHubCopilotChatSource? // inline or panel
var workspaceFolder: String?
var userLanguage: String?
}

let requestBody: RequestBody
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Error> { continuation in
Expand Down
13 changes: 6 additions & 7 deletions Tool/Sources/XcodeInspector/XcodeInspector+TriggerCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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("""
Expand Down
4 changes: 2 additions & 2 deletions Version.xcconfig
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
APP_VERSION = 0.35.2
APP_BUILD = 429
APP_VERSION = 0.35.3
APP_BUILD = 430

0 comments on commit dbd4194

Please sign in to comment.