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
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ NS_ASSUME_NONNULL_BEGIN

@interface LSApplicationWorkspace : NSObject
+(nullable instancetype)defaultWorkspace;
-(void)openURL:(NSURL *)url configuration:(_LSOpenConfiguration *)config completionHandler:(void (^)(BOOL))completion;
-(void)openURL:(NSURL *)url
configuration:(_LSOpenConfiguration *)config
completionHandler:(void (^)(NSDictionary<NSString *, id> * _Nullable result, NSError * _Nullable error))completion;
@end

NS_ASSUME_NONNULL_END
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ extension EnvironmentValues {
#endif

// resolvedTextProvider = OpenSwiftUIResolvedTextProvider.self
// hasSystemOpenURLAction = true
hasSystemOpenURLAction = true

#if os(iOS) || os(visionOS)
// bridgedEnvironmentResolver = UITraitBridgedEnvironmentResolver.self
Expand Down
83 changes: 75 additions & 8 deletions Sources/OpenSwiftUI/Util/OpenSwiftUIGlue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ public import OpenSwiftUICore
@_spiOnly
public import OpenAttributeGraphShims
import COpenSwiftUI
#if os(iOS) || os(visionOS) || os(tvOS)
import UIKit
#elseif os(macOS)
import AppKit
#endif

// MARK: - OpenSwiftUIGlue

Expand Down Expand Up @@ -66,13 +71,79 @@ final public class OpenSwiftUIGlue: CoreGlue {
L.makeLayoutView(root: root, inputs: inputs, body: body)
}

override final public func defaultOpenURLAction(
env: EnvironmentValues
) -> OpenURLAction {
OpenURLAction(isDefault: true) { url, completion in
#if os(iOS) || os(visionOS)
if let scene = env.sceneSession?.scene {
scene.open(
url,
options: nil,
completionHandler: completion
)
} else {
UIApplication.shared.open(
url,
options: [:],
completionHandler: completion
)
}
#elseif os(tvOS)
UIApplication.shared.open(
url,
options: [:],
completionHandler: completion
)
#elseif os(macOS)
// TBA
NSWorkspace.shared.open(
url,
configuration: .init()
) { _, error in
completion(error == nil)
}
#else
_openSwiftUIPlatformUnimplementedWarning()
completion(false)
#endif
}
}

override final public func defaultOpenSensitiveURLAction() -> OpenURLAction {
OpenURLAction(isDefault: true) { url, completion in
#if os(iOS) || os(visionOS)
let configuration = _LSOpenConfiguration()
configuration.isSensitive = true
let selector = Selector(("_currentOpenApplicationEndpoint"))
if let scene = UIApplication.shared.connectedScenes.first,
scene.responds(to: selector),
let endpoint = scene.perform(selector) {
configuration.targetConnectionEndpoint = endpoint.takeUnretainedValue()
}
guard let workspace = LSApplicationWorkspace.default() else {

@augmentcode augmentcode Bot Jul 28, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defaultOpenSensitiveURLAction can exit without calling completion (e.g., when LSApplicationWorkspace.default() is nil, and also in the non-iOS/visionOS #else branch), which can leave callers waiting indefinitely; consider always invoking completion(false) on these paths.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

return
}
workspace.open(
url,
configuration: configuration
) { _, error in
if let error {
Log.internalWarning(
"Failed to open sensitive URL \(url). Error: \(error)"
)
}
completion(error == nil)
}
#else
_openSwiftUIPlatformUnimplementedWarning()
#endif
}
}

// TODO
}

@_spi(ForOpenSwiftUIOnly)
@available(*, unavailable)
extension OpenSwiftUIGlue: Sendable {}

// MARK: - OpenSwiftUIGlue2

@_spi(ForOpenSwiftUIOnly)
Expand Down Expand Up @@ -144,7 +215,3 @@ final public class OpenSwiftUIGlue2: CoreGlue2 {
return attributedString
}
}

@_spi(ForOpenSwiftUIOnly)
@available(*, unavailable)
extension OpenSwiftUIGlue2: Sendable {}
156 changes: 0 additions & 156 deletions Sources/OpenSwiftUI/View/Control/Link/OpenURLActionKey.swift

This file was deleted.

Loading
Loading