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
1 change: 1 addition & 0 deletions .github/workflows/auto-close-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
"At the moment we are not accepting contributions to the repository.
Feedback for GitHub Copilot for Xcode can be given in the [Copilot community discussions](https://github.com/github/CopilotForXcode/discussions)."
if: ${{ !(startsWith(github.head_ref, 'release/') && github.event.pull_request.head.repo.full_name == github.repository) }}
env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50 changes: 50 additions & 0 deletions .github/workflows/auto-create-release-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Auto-create Release PR

on:
push:
branches:
- 'release/**'

jobs:
create-pr:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4

- name: Create pull request
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
existing_pr_count="$(gh pr list \
--state open \
--base main \
--head "${{ github.ref_name }}" \
--json number \
--jq 'length')"
if [ "${existing_pr_count}" -gt 0 ]; then
echo "Open pull request already exists for branch '${{ github.ref_name }}' into 'main'; skipping creation."
else
gh pr create \
--title "$(git log -1 --pretty=%s)" \
--body "Automated release PR." \
--base main \
--head "${{ github.ref_name }}"
fi
- name: Approve pull request
env:
# PAT stored in github/CopilotForXcode, with write permissions to pull requests
GH_TOKEN: ${{ secrets.XCODE_AUTO_APPROVE }}
run: |
gh pr review --approve "${{ github.ref_name }}"
- name: Auto-merge pull request
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr merge "${{ github.ref_name }}" \
--auto \
--delete-branch
8 changes: 6 additions & 2 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ jobs:
fail-fast: false
matrix:
include:
- language: actions
build-mode: none
- language: javascript-typescript
build-mode: none
- language: python
build-mode: none
- language: swift
Expand All @@ -37,7 +41,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
Expand Down Expand Up @@ -66,6 +70,6 @@ jobs:
CODE_SIGNING_ALLOWED="NO"

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
uses: github/codeql-action/analyze@v4
with:
category: "/language:${{matrix.language}}"
24 changes: 12 additions & 12 deletions Copilot for Xcode.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@
"@executable_path/../Frameworks",
"@executable_path/../../../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.0;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = "$(APP_VERSION)";
PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_IDENTIFIER_BASE).EditorExtension";
PRODUCT_NAME = Copilot;
Expand Down Expand Up @@ -874,7 +874,7 @@
"@executable_path/../Frameworks",
"@executable_path/../../../../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.0;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = "$(APP_VERSION)";
PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_IDENTIFIER_BASE).EditorExtension";
PRODUCT_NAME = Copilot;
Expand Down Expand Up @@ -936,7 +936,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 12.0;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -991,7 +991,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 12.0;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = macosx;
Expand Down Expand Up @@ -1022,7 +1022,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.0;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = "$(APP_VERSION)";
PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_IDENTIFIER_BASE)";
PRODUCT_MODULE_NAME = Copilot_for_Xcode;
Expand Down Expand Up @@ -1056,7 +1056,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.0;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = "$(APP_VERSION)";
PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_IDENTIFIER_BASE)";
PRODUCT_NAME = "$(HOST_APP_NAME)";
Expand All @@ -1072,7 +1072,7 @@
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = VEKTX9H2N7;
ENABLE_HARDENED_RUNTIME = YES;
MACOSX_DEPLOYMENT_TARGET = 12.0;
MACOSX_DEPLOYMENT_TARGET = 13.0;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
Expand All @@ -1087,7 +1087,7 @@
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=macosx*]" = VEKTX9H2N7;
ENABLE_HARDENED_RUNTIME = YES;
MACOSX_DEPLOYMENT_TARGET = 12.0;
MACOSX_DEPLOYMENT_TARGET = 13.0;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -1117,7 +1117,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.0;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = "$(APP_VERSION)";
PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_IDENTIFIER_BASE).ExtensionService";
PRODUCT_NAME = "$(EXTENSION_SERVICE_NAME)";
Expand Down Expand Up @@ -1151,7 +1151,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.0;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = "$(APP_VERSION)";
PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_IDENTIFIER_BASE).ExtensionService";
PRODUCT_NAME = "$(EXTENSION_SERVICE_NAME)";
Expand All @@ -1172,7 +1172,7 @@
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu17;
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MACOSX_DEPLOYMENT_TARGET = 12.0;
MACOSX_DEPLOYMENT_TARGET = 13.0;
PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_IDENTIFIER_BASE).CommunicationBridge";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
Expand All @@ -1193,7 +1193,7 @@
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu17;
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MACOSX_DEPLOYMENT_TARGET = 12.0;
MACOSX_DEPLOYMENT_TARGET = 13.0;
PRODUCT_BUNDLE_IDENTIFIER = "$(BUNDLE_IDENTIFIER_BASE).CommunicationBridge";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
23 changes: 9 additions & 14 deletions Copilot for Xcode/App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,15 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}

func applicationDidFinishLaunching(_ notification: Notification) {
if #available(macOS 13.0, *) {
checkBackgroundPermissions()
}

checkBackgroundPermissions()

let launchMode = determineLaunchMode()
handleLaunchMode(launchMode)
}

func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
if #available(macOS 13.0, *) {
checkBackgroundPermissions()
}

checkBackgroundPermissions()

let launchMode = determineLaunchMode()
handleLaunchMode(launchMode)
return true
Expand Down Expand Up @@ -113,7 +109,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
}

@available(macOS 13.0, *)
private func checkBackgroundPermissions() {
Task {
// Direct check of permission status
Expand All @@ -122,15 +117,17 @@ class AppDelegate: NSObject, NSApplicationDelegate {

if !isPermissionGranted {
// Only show alert if permission isn't granted
DispatchQueue.main.async {
await MainActor.run {
if !self.permissionAlertShown {
showBackgroundPermissionAlert()
self.permissionAlertShown = true
}
}
} else {
// Permission is granted, reset flag
self.permissionAlertShown = false
await MainActor.run {
self.permissionAlertShown = false
}
}
}
}
Expand Down Expand Up @@ -272,10 +269,8 @@ func activateAndOpenSettings() {
if #available(macOS 14.0, *) {
let environment = SettingsEnvironment()
environment.open()
} else if #available(macOS 13.0, *) {
NSApp.sendAction(Selector(("showSettingsWindow:")), to: nil, from: nil)
} else {
NSApp.sendAction(Selector(("showPreferencesWindow:")), to: nil, from: nil)
NSApp.sendAction(Selector(("showSettingsWindow:")), to: nil, from: nil)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Core/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import PackageDescription

let package = Package(
name: "Core",
platforms: [.macOS(.v12)],
platforms: [.macOS(.v13)],
products: [
.library(
name: "Service",
Expand Down
25 changes: 24 additions & 1 deletion Core/Sources/ChatService/ChatService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,14 @@ public final class ChatService: ChatServiceType, ObservableObject {
public var memory: ContextAwareAutoManagedChatMemory
@Published public internal(set) var chatHistory: [ChatMessage] = []
@Published public internal(set) var isReceivingMessage = false
@Published public internal(set) var isSummarizingConversation = false
@Published public internal(set) var fileEditMap: OrderedDictionary<URL, FileEdit> = [:]
@Published public internal(set) var contextSizeInfo: ContextSizeInfo? = nil
public internal(set) var requestType: RequestType? = nil
public private(set) var chatTabInfo: ChatTabInfo
private let conversationProvider: ConversationServiceProvider?
private let conversationProgressHandler: ConversationProgressHandler
private let compressionHandler: CompressionHandler
private let conversationContextHandler: ConversationContextHandler = ConversationContextHandlerImpl.shared
// sync all the files in the workspace to watch for changes.
private let watchedFilesHandler: WatchedFilesHandler = WatchedFilesHandlerImpl.shared
Expand All @@ -85,10 +88,12 @@ public final class ChatService: ChatServiceType, ObservableObject {
init(provider: any ConversationServiceProvider,
memory: ContextAwareAutoManagedChatMemory = ContextAwareAutoManagedChatMemory(),
conversationProgressHandler: ConversationProgressHandler = ConversationProgressHandlerImpl.shared,
compressionHandler: CompressionHandler = CompressionHandlerImpl.shared,
chatTabInfo: ChatTabInfo) {
self.memory = memory
self.conversationProvider = provider
self.conversationProgressHandler = conversationProgressHandler
self.compressionHandler = compressionHandler
self.chatTabInfo = chatTabInfo
memory.chatService = self

Expand Down Expand Up @@ -134,6 +139,19 @@ public final class ChatService: ChatServiceType, ObservableObject {
conversationProgressHandler.onEnd.sink { [weak self] (token, progress) in
self?.handleProgressEnd(token: token, progress: progress)
}.store(in: &cancellables)

compressionHandler.onCompressionStarted.sink { [weak self] compressionConversationId in
guard let self, self.conversationId == compressionConversationId else { return }
self.isSummarizingConversation = true
}.store(in: &cancellables)

compressionHandler.onCompressionCompleted.sink { [weak self] completedNotification in
guard let self, self.conversationId == completedNotification.conversationId else { return }
self.isSummarizingConversation = false
if let contextInfo = completedNotification.contextInfo {
self.contextSizeInfo = contextInfo
}
}.store(in: &cancellables)
}

private func subscribeToConversationContextRequest() {
Expand Down Expand Up @@ -745,7 +763,11 @@ public final class ChatService: ChatServiceType, ObservableObject {
guard let workDownToken = activeRequestId, workDownToken == token else {
return
}


if let contextSize = progress.contextSize {
self.contextSizeInfo = contextSize
}

let id = progress.turnId
var content = ""
var references: [ConversationReference] = []
Expand Down Expand Up @@ -895,6 +917,7 @@ public final class ChatService: ChatServiceType, ObservableObject {
private func resetOngoingRequest(with turnStatus: ChatMessage.TurnStatus = .success) {
activeRequestId = nil
isReceivingMessage = false
isSummarizingConversation = false
requestType = nil

// Clear turn tracking data
Expand Down
Loading
Loading