diff --git a/.github/workflows/auto-create-release-pr.yml b/.github/workflows/auto-create-release-pr.yml index 02aa4566..dc6995b0 100644 --- a/.github/workflows/auto-create-release-pr.yml +++ b/.github/workflows/auto-create-release-pr.yml @@ -45,7 +45,23 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - gh pr checks "${{ github.ref_name }}" --watch + for i in $(seq 1 60); do + other_checks=$(gh pr checks "${{ github.ref_name }}" | grep -v "create-pr" || true) + if echo "$other_checks" | grep -wq "fail"; then + echo "Required checks failed." + exit 1 + fi + if [ -z "$other_checks" ]; then + echo "No other checks found yet, waiting..." + elif ! echo "$other_checks" | grep -wq "pending"; then + echo "All required checks passed." + exit 0 + fi + echo "Waiting for checks..." + sleep 10 + done + echo "Timed out waiting for required checks." + exit 1 - name: Merge pull request env: diff --git a/ExtensionService/AppDelegate.swift b/ExtensionService/AppDelegate.swift index 5b88200c..fcbad9d6 100644 --- a/ExtensionService/AppDelegate.swift +++ b/ExtensionService/AppDelegate.swift @@ -516,6 +516,7 @@ enum CLSMessageType { case chatLimitReached case completionLimitReached case byokLimitedReached + case monthlyAICreditsLimitReached case other var summary: String { @@ -526,6 +527,8 @@ enum CLSMessageType { return "Monthly Completion Limit Reached" case .byokLimitedReached: return "BYOK Limit Reached" + case .monthlyAICreditsLimitReached: + return "Monthly AI Credits Limit Reached" case .other: return "CLS Error" } @@ -537,14 +540,6 @@ struct CLSMessage { let detail: String } -func extractDateFromCLSMessage(_ message: String) -> String? { - let pattern = #"until (\d{1,2}/\d{1,2}/\d{4}, \d{1,2}:\d{2}:\d{2} [AP]M)"# - if let range = message.range(of: pattern, options: .regularExpression) { - return String(message[range].dropFirst(6)) - } - return nil -} - func getCLSMessageSummary(_ message: String) -> CLSMessage { let messageType: CLSMessageType @@ -555,16 +550,11 @@ func getCLSMessageSummary(_ message: String) -> CLSMessage { messageType = .completionLimitReached } else if message.contains("BYOK") { messageType = .byokLimitedReached + } else if message.contains("You've used your monthly AI Credits") { + messageType = .monthlyAICreditsLimitReached } else { messageType = .other } - let detail: String - if let date = extractDateFromCLSMessage(message) { - detail = "Visit GitHub to check your usage and upgrade to Copilot Pro or wait until \(date) for your limit to reset." - } else { - detail = message - } - - return CLSMessage(summary: messageType.summary, detail: detail) + return CLSMessage(summary: messageType.summary, detail: message) } diff --git a/Tool/Sources/GitHubCopilotService/Services/QuotaNotifier.swift b/Tool/Sources/GitHubCopilotService/Services/QuotaNotifier.swift index ef505545..a526e979 100644 --- a/Tool/Sources/GitHubCopilotService/Services/QuotaNotifier.swift +++ b/Tool/Sources/GitHubCopilotService/Services/QuotaNotifier.swift @@ -179,11 +179,14 @@ public class QuotaNotifierImpl: NSObject, QuotaNotifier { Task { @MainActor in let quotaInfo = await Status.shared.getQuotaInfo() let actions = buildWarningActions(params: params, quotaInfo: quotaInfo) - WarningStateManager.shared.setWarning(WarningContent( - message: params.message, - severity: params.severity, - actions: actions - )) + let isCompletionsWarning = params.message.localizedCaseInsensitiveContains("completions") + if !isCompletionsWarning { + WarningStateManager.shared.setWarning(WarningContent( + message: params.message, + severity: params.severity, + actions: actions + )) + } await NotificationCenterCoordinator.shared.setupIfNeeded() self.registerCategoriesIfNeeded() await sendAppleNotification(params, categoryID: notificationCategoryID(for: actions)) diff --git a/Tool/Sources/GitHubCopilotService/Services/WarningState.swift b/Tool/Sources/GitHubCopilotService/Services/WarningState.swift index e6fb8ede..ef5577e3 100644 --- a/Tool/Sources/GitHubCopilotService/Services/WarningState.swift +++ b/Tool/Sources/GitHubCopilotService/Services/WarningState.swift @@ -1,4 +1,5 @@ import Foundation +import Status public struct WarningAction: Equatable { public var title: String @@ -27,7 +28,15 @@ public class WarningStateManager: ObservableObject { @Published public var currentWarning: WarningContent? - private init() {} + private init() { + DistributedNotificationCenter.default().addObserver( + forName: .authStatusDidChange, + object: nil, + queue: .main + ) { [weak self] _ in + self?.dismissWarning() + } + } public func setWarning(_ warning: WarningContent) { DispatchQueue.main.async { [weak self] in