Skip to content

Commit

Permalink
Merge branch 'release/0.29.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
intitni committed Jan 9, 2024
2 parents 948449d + 92be6d9 commit 3b4c241
Show file tree
Hide file tree
Showing 93 changed files with 2,469 additions and 1,503 deletions.
58 changes: 15 additions & 43 deletions Copilot for Xcode.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
C8216B782980370100AD38C7 /* ReloadLaunchAgent.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8216B772980370100AD38C7 /* ReloadLaunchAgent.swift */; };
C8216B7D2980374300AD38C7 /* ArgumentParser in Frameworks */ = {isa = PBXBuildFile; productRef = C8216B7C2980374300AD38C7 /* ArgumentParser */; };
C8216B802980378300AD38C7 /* Helper in Embed XPCService */ = {isa = PBXBuildFile; fileRef = C8216B70298036EC00AD38C7 /* Helper */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
C828B27F2B1F7B4F00E7612A /* ExtensionPoint.appextensionpoint in Copy Extension Point */ = {isa = PBXBuildFile; fileRef = C828B27D2B1F241500E7612A /* ExtensionPoint.appextensionpoint */; };
C8520301293C4D9000460097 /* Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8520300293C4D9000460097 /* Helpers.swift */; };
C861A6A329E5503F005C41A3 /* PromptToCodeCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = C861A6A229E5503F005C41A3 /* PromptToCodeCommand.swift */; };
C861E6112994F6070056CB02 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C861E6102994F6070056CB02 /* AppDelegate.swift */; };
Expand Down Expand Up @@ -90,6 +91,17 @@
);
runOnlyForDeploymentPostprocessing = 1;
};
C828B27E2B1F7B3C00E7612A /* Copy Extension Point */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "$(EXTENSIONS_FOLDER_PATH)";
dstSubfolderSpec = 16;
files = (
C828B27F2B1F7B4F00E7612A /* ExtensionPoint.appextensionpoint in Copy Extension Point */,
);
name = "Copy Extension Point";
runOnlyForDeploymentPostprocessing = 0;
};
C8520306293CF0EF00460097 /* Embed XPCService */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -163,6 +175,7 @@
C8216B70298036EC00AD38C7 /* Helper */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = Helper; sourceTree = BUILT_PRODUCTS_DIR; };
C8216B72298036EC00AD38C7 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
C8216B772980370100AD38C7 /* ReloadLaunchAgent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReloadLaunchAgent.swift; sourceTree = "<group>"; };
C828B27D2B1F241500E7612A /* ExtensionPoint.appextensionpoint */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = ExtensionPoint.appextensionpoint; sourceTree = "<group>"; };
C82E38492A1F025F00D4EADF /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
C83E5DED2A38CD8C0071506D /* Makefile */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = "<group>"; };
C8520300293C4D9000460097 /* Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Helpers.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -270,6 +283,7 @@
C81458AD293A009600135263 /* Config.xcconfig */,
C81458AE293A009800135263 /* Config.debug.xcconfig */,
C8CD828229B88006008D044D /* TestPlan.xctestplan */,
C828B27D2B1F241500E7612A /* ExtensionPoint.appextensionpoint */,
C81D181E2A1B509B006C1B70 /* Tool */,
C8189B282938979000C9DCDA /* Core */,
C8189B182938972F00C9DCDA /* Copilot for Xcode */,
Expand Down Expand Up @@ -413,8 +427,7 @@
C861E60A2994F6070056CB02 /* Sources */,
C861E60B2994F6070056CB02 /* Frameworks */,
C861E60C2994F6070056CB02 /* Resources */,
C8A3AE572A28852D0046E809 /* Sign Python STD */,
C8A3B1782A2894E10046E809 /* Sign Python Site Packages */,
C828B27E2B1F7B3C00E7612A /* Copy Extension Point */,
);
buildRules = (
);
Expand Down Expand Up @@ -505,47 +518,6 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
C8A3AE572A28852D0046E809 /* Sign Python STD */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 8;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Sign Python STD";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 1;
shellPath = /bin/sh;
shellScript = "#set -e\n#echo \"Signing as $EXPANDED_CODE_SIGN_IDENTITY_NAME ($EXPANDED_CODE_SIGN_IDENTITY)\"\n#find \"$CODESIGNING_FOLDER_PATH/Contents/Resources/python-stdlib/lib-dynload\" -name \"*.so\" -exec /usr/bin/codesign --force --sign \"$EXPANDED_CODE_SIGN_IDENTITY\" -o runtime --timestamp=none --preserve-metadata=identifier,entitlements,flags --generate-entitlement-der {} \\;\n";
};
C8A3B1782A2894E10046E809 /* Sign Python Site Packages */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 8;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Sign Python Site Packages";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 1;
shellPath = /bin/sh;
shellScript = "#set -e\n#echo \"Signing as $EXPANDED_CODE_SIGN_IDENTITY_NAME ($EXPANDED_CODE_SIGN_IDENTITY)\"\n#find \"$CODESIGNING_FOLDER_PATH/Contents/Resources/site-packages\" -type f \\( -name \"*.so\" -o -name \"*.dylib\" \\) -exec /usr/bin/codesign --force --sign \"$EXPANDED_CODE_SIGN_IDENTITY\" -o runtime --timestamp=none --preserve-metadata=identifier,entitlements,flags --generate-entitlement-der {} \\;\n";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
C81458882939EFDC00135263 /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand Down
21 changes: 16 additions & 5 deletions Core/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ let package = Package(
name: "Client",
dependencies: [
.product(name: "XPCShared", package: "Tool"),
.product(name: "SuggestionService", package: "Tool"),
.product(name: "SuggestionProvider", package: "Tool"),
.product(name: "SuggestionModel", package: "Tool"),
.product(name: "Logger", package: "Tool"),
.product(name: "Preferences", package: "Tool"),
Expand All @@ -119,12 +119,13 @@ let package = Package(
name: "Service",
dependencies: [
"SuggestionWidget",
"SuggestionService",
"ChatService",
"PromptToCodeService",
"ServiceUpdateMigration",
"ChatGPTChatTab",
.product(name: "XPCShared", package: "Tool"),
.product(name: "SuggestionService", package: "Tool"),
.product(name: "SuggestionProvider", package: "Tool"),
.product(name: "Workspace", package: "Tool"),
.product(name: "UserDefaultsObserver", package: "Tool"),
.product(name: "AppMonitoring", package: "Tool"),
Expand All @@ -149,7 +150,7 @@ let package = Package(
"Client",
"SuggestionInjector",
.product(name: "XPCShared", package: "Tool"),
.product(name: "SuggestionService", package: "Tool"),
.product(name: "SuggestionProvider", package: "Tool"),
.product(name: "SuggestionModel", package: "Tool"),
.product(name: "Environment", package: "Tool"),
.product(name: "Preferences", package: "Tool"),
Expand All @@ -164,7 +165,7 @@ let package = Package(
"Client",
"LaunchAgentManager",
"PlusFeatureFlag",
.product(name: "SuggestionService", package: "Tool"),
.product(name: "SuggestionProvider", package: "Tool"),
.product(name: "Toast", package: "Tool"),
.product(name: "SharedUIComponents", package: "Tool"),
.product(name: "SuggestionModel", package: "Tool"),
Expand All @@ -180,6 +181,15 @@ let package = Package(

// MARK: - Suggestion Service

.target(
name: "SuggestionService",
dependencies: [
.product(name: "SuggestionModel", package: "Tool"),
.product(name: "SuggestionProvider", package: "Tool")
].pro([
"ProExtension",
])
),
.target(
name: "SuggestionInjector",
dependencies: [.product(name: "SuggestionModel", package: "Tool")]
Expand Down Expand Up @@ -263,6 +273,7 @@ let package = Package(
dependencies: [
"PromptToCodeService",
"ChatGPTChatTab",
.product(name: "Toast", package: "Tool"),
.product(name: "UserDefaultsObserver", package: "Tool"),
.product(name: "SharedUIComponents", package: "Tool"),
.product(name: "AppMonitoring", package: "Tool"),
Expand Down Expand Up @@ -290,7 +301,7 @@ let package = Package(
.target(
name: "ServiceUpdateMigration",
dependencies: [
.product(name: "SuggestionService", package: "Tool"),
.product(name: "SuggestionProvider", package: "Tool"),
.product(name: "Preferences", package: "Tool"),
.product(name: "Keychain", package: "Tool"),
]
Expand Down
13 changes: 13 additions & 0 deletions Core/Sources/ChatGPTChatTab/Chat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ struct Chat: ReducerProtocol {
case binding(BindingAction<State>)

case appear
case refresh
case sendButtonTapped
case returnButtonTapped
case stopRespondingButtonTapped
Expand Down Expand Up @@ -132,6 +133,12 @@ struct Chat: ReducerProtocol {
await send(.systemPromptChanged)
await send(.extraSystemPromptChanged)
await send(.focusOnTextField)
await send(.refresh)
}

case .refresh:
return .run { send in
await send(.chatMenu(.refresh))
}

case .sendButtonTapped:
Expand Down Expand Up @@ -376,6 +383,7 @@ struct ChatMenu: ReducerProtocol {

enum Action: Equatable {
case appear
case refresh
case resetPromptButtonTapped
case temperatureOverrideSelected(Double?)
case chatModelIdOverrideSelected(String?)
Expand All @@ -390,6 +398,11 @@ struct ChatMenu: ReducerProtocol {
Reduce { state, action in
switch action {
case .appear:
return .run {
await $0(.refresh)
}

case .refresh:
state.temperatureOverride = service.configuration.overriding.temperature
state.chatModelIdOverride = service.configuration.overriding.modelId
return .none
Expand Down
6 changes: 5 additions & 1 deletion Core/Sources/ChatGPTChatTab/ChatGPTChatTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public class ChatGPTChatTab: ChatTab {
await tab.service.memory.mutateHistory { history in
history = state.history
}
tab.viewStore.send(.refresh)
}
return builder
}
Expand Down Expand Up @@ -140,7 +141,10 @@ public class ChatGPTChatTab: ChatTab {
}
}.store(in: &cancellable)

viewStore.publisher.removeDuplicates().sink { [weak self] _ in
viewStore.publisher.removeDuplicates().debounce(
for: .milliseconds(500),
scheduler: DispatchQueue.main
).sink { [weak self] _ in
Task { @MainActor [weak self] in
self?.chatTabViewStore.send(.tabContentUpdated)
}
Expand Down
42 changes: 33 additions & 9 deletions Core/Sources/Client/AsyncXPCService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public struct AsyncXPCService {
}
}
}

public func getXPCServiceAccessibilityPermission() async throws -> Bool {
try await withXPCServiceConnected(connection: connection) {
service, continuation in
Expand Down Expand Up @@ -85,7 +85,7 @@ public struct AsyncXPCService {
{ $0.getRealtimeSuggestedCode }
)
}

public func getPromptToCodeAcceptedCode(editorContent: EditorContent) async throws
-> UpdatedContent?
{
Expand Down Expand Up @@ -144,7 +144,7 @@ public struct AsyncXPCService {
{ service in { service.customCommand(id: id, editorContent: $0, withReply: $1) } }
)
}

public func postNotification(name: String) async throws {
try await withXPCServiceConnected(connection: connection) {
service, continuation in
Expand All @@ -153,17 +153,41 @@ public struct AsyncXPCService {
}
}
}

public func performAction(name: String, arguments: String) async throws -> String {
try await withXPCServiceConnected(connection: connection) {
service, continuation in
service.performAction(name: name, arguments: arguments) {
continuation.resume($0)

public func send<M: ExtensionServiceRequestType>(
requestBody: M
) async throws -> M.ResponseBody {
try await withXPCServiceConnected(connection: connection) { service, continuation in
do {
let requestBodyData = try JSONEncoder().encode(requestBody)
service.send(endpoint: M.endpoint, requestBody: requestBodyData) { data, error in
if let error {
continuation.reject(error)
} else {
do {
guard let data = data else {
continuation.reject(NoDataError())
return
}
let responseBody = try JSONDecoder().decode(
M.ResponseBody.self,
from: data
)
continuation.resume(responseBody)
} catch {
continuation.reject(error)
}
}
}
} catch {
continuation.reject(error)
}
}
}
}

struct NoDataError: Error {}

struct AutoFinishContinuation<T> {
var continuation: AsyncThrowingStream<T, Error>.Continuation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,26 @@ struct ChatModelEdit: ReducerProtocol {
return .none

case .checkSuggestedMaxTokens:
guard state.format == .openAI,
let knownModel = ChatGPTModel(rawValue: state.modelName)
else {
switch state.format {
case .openAI:
if let knownModel = ChatGPTModel(rawValue: state.modelName) {
state.suggestedMaxTokens = knownModel.maxToken
} else {
state.suggestedMaxTokens = nil
}
return .none
case .googleAI:
if let knownModel = GoogleGenerativeAIModel(rawValue: state.modelName) {
state.suggestedMaxTokens = knownModel.maxToken
} else {
state.suggestedMaxTokens = nil
}
return .none
default:
state.suggestedMaxTokens = nil
return .none
}
state.suggestedMaxTokens = knownModel.maxToken
return .none


case .apiKeySelection:
return .none

Expand Down Expand Up @@ -175,7 +186,12 @@ extension ChatModel {
apiKeyName: state.apiKeyName,
baseURL: state.baseURL.trimmingCharacters(in: .whitespacesAndNewlines),
maxTokens: state.maxTokens,
supportsFunctionCalling: state.supportsFunctionCalling,
supportsFunctionCalling: {
if case .googleAI = state.format {
return false
}
return state.supportsFunctionCalling
}(),
modelName: state.modelName.trimmingCharacters(in: .whitespacesAndNewlines)
)
)
Expand Down
Loading

0 comments on commit 3b4c241

Please sign in to comment.