Skip to content

Commit

Permalink
Release 0.31.0
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Feb 12, 2025
1 parent c933346 commit 1dd4c21
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
9 changes: 7 additions & 2 deletions Tool/Sources/AXNotificationStream/AXNotificationStream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public final class AXNotificationStream: AsyncSequence {
)
var pendingRegistrationNames = Set(notificationNames)
var retry = 0
var shouldLogAXDisabledEvent: Bool = true
while !pendingRegistrationNames.isEmpty, retry < 100 {
guard let self else { return }
retry += 1
Expand All @@ -125,14 +126,18 @@ public final class AXNotificationStream: AsyncSequence {
}
switch e {
case .success:
shouldLogAXDisabledEvent = true
pendingRegistrationNames.remove(name)
await Status.shared.updateAXStatus(.granted)
case .actionUnsupported:
Logger.service.error("AXObserver: Action unsupported: \(name)")
pendingRegistrationNames.remove(name)
case .apiDisabled:
Logger.service
.error("AXObserver: Accessibility API disabled, will try again later")
if shouldLogAXDisabledEvent { // Avoid keeping log AX disabled too many times
shouldLogAXDisabledEvent = false
Logger.service
.error("AXObserver: Accessibility API disabled, will try again later")
}
retry -= 1
await Status.shared.updateAXStatus(.notGranted)
case .invalidUIElement:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ public final class BuiltinExtensionTelemetryServiceProvider<

public func sendError(_ request: TelemetryExceptionRequest) async throws {
guard let telemetryService else {
Logger.service.error("Builtin telemetry service not found.")
print("Builtin telemetry service not found.")
throw BuiltinExtensionTelemetryServiceNotFoundError()
}
guard let workspaceInfo = await activeWorkspace() else {
Logger.service.error("Builtin active workspace info not found.")
print("Builtin active workspace info not found.")
throw BuiltinExtensionActiveWorkspaceInfoNotFoundError()
}

Expand Down
25 changes: 25 additions & 0 deletions Tool/Sources/XcodeInspector/XcodeInspector+TriggerCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,33 @@ public extension XcodeAppInstanceInspector {
func triggerCopilotCommand(name: String, activateXcode: Bool = true) async throws {
let bundleName = Bundle.main
.object(forInfoDictionaryKey: "EXTENSION_BUNDLE_NAME") as! String

guard await isBundleEnabled(bundleName: bundleName) else {
print("Bundle \(bundleName) is not enabled")
return
}

try await triggerMenuItem(path: ["Editor", bundleName, name], activateApp: activateXcode)
}

private func isBundleEnabled(bundleName: String) async -> Bool {
let app = AXUIElementCreateApplication(runningApplication.processIdentifier)

guard let menuBar = app.menuBar,
let editorMenu = menuBar.child(title: "Editor") else {
return false
}

if let bundleMenuItem = editorMenu.child(title: bundleName, role: "AXMenuItem") {
var enabled: CFTypeRef?
let error = AXUIElementCopyAttributeValue(bundleMenuItem, kAXEnabledAttribute as CFString, &enabled)
if error == .success, let isEnabled = enabled as? Bool {
return isEnabled
}
}

return false
}
}

public extension AppInstanceInspector {
Expand Down

0 comments on commit 1dd4c21

Please sign in to comment.