Skip to content

Conversation

@mattt
Copy link
Collaborator

@mattt mattt commented Dec 5, 2025

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR relaxes the minimum platform requirements to support macOS 13 (down from 14), along with corresponding downgrades for other Apple platforms. To enable this while preserving OAuth functionality that requires macOS 14+ (due to the @Observable macro), the PR refactors the TokenProvider.oauth enum case from taking a concrete HuggingFaceAuthenticationManager parameter to accepting a generic async closure. A platform-restricted factory method .oauth(manager:) is introduced to provide convenient creation of OAuth token providers on supported platforms.

Key Changes:

  • Downgraded minimum platform versions (macOS 14→13, macCatalyst 14→16, watchOS 10→9, tvOS 17→16)
  • Refactored TokenProvider.oauth case to use async closure pattern instead of direct manager reference
  • Added @available annotations to OAuth-related code to restrict to macOS 14+ platforms

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
Package.swift Lowered minimum platform requirements to support older OS versions
Sources/HuggingFace/Shared/TokenProvider.swift Refactored OAuth enum case to use closure pattern; added factory method with availability restrictions; updated documentation
Sources/HuggingFace/OAuth/HuggingFaceAuthenticationManager.swift Added @available annotations to all OAuth-related types and extensions to restrict to macOS 14+ platforms

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +191 to 194
case .oauth:
fatalError(
"OAuth token provider requires async context. Use getToken() in an async context or switch to a synchronous provider."
)
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

The synchronous getToken() method handles the .oauth case by throwing a fatal error, but there doesn't appear to be an async overload func getToken() async throws -> String? that properly implements the OAuth case by calling the closure. Without the async overload, OAuth functionality will be broken as the closure cannot be invoked from synchronous contexts. You need to add an async version of getToken() that handles .oauth(let getToken): by calling try await getToken().

Copilot uses AI. Check for mistakes.
@mattt mattt merged commit ffd2280 into main Dec 5, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants