Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions clients/macos/vellum-assistant/Ambient/AmbientAXCapture.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ enum AmbientAXCapture {
log.debug("No focused window for \(appName, privacy: .public)")
return nil
}
let windowElement = windowRef as! AXUIElement
guard let windowElement = windowRef as? AXUIElement else { return nil }
let windowTitle = getStringAttribute(windowElement, kAXTitleAttribute as CFString) ?? "Untitled"

// Get focused element
var focusedRef: CFTypeRef?
var focusedElement: (role: String, label: String?)?
if AXUIElementCopyAttributeValue(appElement, kAXFocusedUIElementAttribute as CFString, &focusedRef) == .success,
let focused = focusedRef {
let fe = focused as! AXUIElement
let focused = focusedRef,
let fe = focused as? AXUIElement {
let role = getStringAttribute(fe, kAXRoleAttribute as CFString) ?? "unknown"
let label = getStringAttribute(fe, kAXTitleAttribute as CFString)
?? getStringAttribute(fe, kAXDescriptionAttribute as CFString)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ final class AccessibilityTreeEnumerator: AccessibilityTreeProviding {
}
return nil
}
let windowElement = windowRef as! AXUIElement
guard let windowElement = windowRef as? AXUIElement else { return nil }

let windowTitle = getStringAttribute(windowElement, kAXTitleAttribute as CFString) ?? "Untitled"

Expand Down Expand Up @@ -207,7 +207,7 @@ final class AccessibilityTreeEnumerator: AccessibilityTreeProviding {
log.debug("enumerateAppByPID: no focused window for \(appName, privacy: .public) (pid \(pid)): AXError \(result.rawValue)")
return nil
}
let windowElement = windowRef as! AXUIElement
guard let windowElement = windowRef as? AXUIElement else { return nil }

let windowTitle = getStringAttribute(windowElement, kAXTitleAttribute as CFString) ?? "Untitled"
let appName = NSRunningApplication(processIdentifier: pid)?.localizedName ?? "Unknown"
Expand Down Expand Up @@ -424,12 +424,11 @@ final class AccessibilityTreeEnumerator: AccessibilityTreeProviding {
var point = CGPoint.zero
var size = CGSize.zero

// Extract values from AXValue refs (force cast is safe here since we validated success above)
if let posRef = positionValue {
AXValueGetValue(posRef as! AXValue, .cgPoint, &point)
if let posRef = positionValue, let posVal = posRef as? AXValue {
AXValueGetValue(posVal, .cgPoint, &point)
}
if let sizeRef = sizeValue {
AXValueGetValue(sizeRef as! AXValue, .cgSize, &size)
if let sizeRef = sizeValue, let sizeVal = sizeRef as? AXValue {
AXValueGetValue(sizeVal, .cgSize, &size)
}

return CGRect(origin: point, size: size)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ struct DictationContextCapture {
log.debug("Could not get focused window — AX permission may be missing")
return ""
}
let window = windowRef as! AXUIElement
guard let window = windowRef as? AXUIElement else { return "" }
return axStringAttribute(window, kAXTitleAttribute as CFString) ?? ""
}

Expand All @@ -100,7 +100,7 @@ struct DictationContextCapture {
log.debug("Could not get focused UI element")
return (nil, false)
}
let focused = focusedRef as! AXUIElement
guard let focused = focusedRef as? AXUIElement else { return (nil, false) }

// Selected text
let selectedText = axStringAttribute(focused, kAXSelectedTextAttribute as CFString)
Expand Down
Loading