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
18 changes: 17 additions & 1 deletion .github/workflows/auto-create-release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
22 changes: 6 additions & 16 deletions ExtensionService/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ enum CLSMessageType {
case chatLimitReached
case completionLimitReached
case byokLimitedReached
case monthlyAICreditsLimitReached
case other

var summary: String {
Expand All @@ -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"
}
Expand All @@ -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

Expand All @@ -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)
}
13 changes: 8 additions & 5 deletions Tool/Sources/GitHubCopilotService/Services/QuotaNotifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
11 changes: 10 additions & 1 deletion Tool/Sources/GitHubCopilotService/Services/WarningState.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import Status

public struct WarningAction: Equatable {
public var title: String
Expand Down Expand Up @@ -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
Expand Down
Loading