Skip to content

Commit 3b4c241

Browse files
committed
Merge branch 'release/0.29.0'
2 parents 948449d + 92be6d9 commit 3b4c241

93 files changed

Lines changed: 2469 additions & 1503 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Copilot for Xcode.xcodeproj/project.pbxproj

Lines changed: 15 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
C8216B782980370100AD38C7 /* ReloadLaunchAgent.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8216B772980370100AD38C7 /* ReloadLaunchAgent.swift */; };
2424
C8216B7D2980374300AD38C7 /* ArgumentParser in Frameworks */ = {isa = PBXBuildFile; productRef = C8216B7C2980374300AD38C7 /* ArgumentParser */; };
2525
C8216B802980378300AD38C7 /* Helper in Embed XPCService */ = {isa = PBXBuildFile; fileRef = C8216B70298036EC00AD38C7 /* Helper */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
26+
C828B27F2B1F7B4F00E7612A /* ExtensionPoint.appextensionpoint in Copy Extension Point */ = {isa = PBXBuildFile; fileRef = C828B27D2B1F241500E7612A /* ExtensionPoint.appextensionpoint */; };
2627
C8520301293C4D9000460097 /* Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8520300293C4D9000460097 /* Helpers.swift */; };
2728
C861A6A329E5503F005C41A3 /* PromptToCodeCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = C861A6A229E5503F005C41A3 /* PromptToCodeCommand.swift */; };
2829
C861E6112994F6070056CB02 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C861E6102994F6070056CB02 /* AppDelegate.swift */; };
@@ -90,6 +91,17 @@
9091
);
9192
runOnlyForDeploymentPostprocessing = 1;
9293
};
94+
C828B27E2B1F7B3C00E7612A /* Copy Extension Point */ = {
95+
isa = PBXCopyFilesBuildPhase;
96+
buildActionMask = 2147483647;
97+
dstPath = "$(EXTENSIONS_FOLDER_PATH)";
98+
dstSubfolderSpec = 16;
99+
files = (
100+
C828B27F2B1F7B4F00E7612A /* ExtensionPoint.appextensionpoint in Copy Extension Point */,
101+
);
102+
name = "Copy Extension Point";
103+
runOnlyForDeploymentPostprocessing = 0;
104+
};
93105
C8520306293CF0EF00460097 /* Embed XPCService */ = {
94106
isa = PBXCopyFilesBuildPhase;
95107
buildActionMask = 2147483647;
@@ -163,6 +175,7 @@
163175
C8216B70298036EC00AD38C7 /* Helper */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = Helper; sourceTree = BUILT_PRODUCTS_DIR; };
164176
C8216B72298036EC00AD38C7 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
165177
C8216B772980370100AD38C7 /* ReloadLaunchAgent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReloadLaunchAgent.swift; sourceTree = "<group>"; };
178+
C828B27D2B1F241500E7612A /* ExtensionPoint.appextensionpoint */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = ExtensionPoint.appextensionpoint; sourceTree = "<group>"; };
166179
C82E38492A1F025F00D4EADF /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
167180
C83E5DED2A38CD8C0071506D /* Makefile */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = "<group>"; };
168181
C8520300293C4D9000460097 /* Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Helpers.swift; sourceTree = "<group>"; };
@@ -270,6 +283,7 @@
270283
C81458AD293A009600135263 /* Config.xcconfig */,
271284
C81458AE293A009800135263 /* Config.debug.xcconfig */,
272285
C8CD828229B88006008D044D /* TestPlan.xctestplan */,
286+
C828B27D2B1F241500E7612A /* ExtensionPoint.appextensionpoint */,
273287
C81D181E2A1B509B006C1B70 /* Tool */,
274288
C8189B282938979000C9DCDA /* Core */,
275289
C8189B182938972F00C9DCDA /* Copilot for Xcode */,
@@ -413,8 +427,7 @@
413427
C861E60A2994F6070056CB02 /* Sources */,
414428
C861E60B2994F6070056CB02 /* Frameworks */,
415429
C861E60C2994F6070056CB02 /* Resources */,
416-
C8A3AE572A28852D0046E809 /* Sign Python STD */,
417-
C8A3B1782A2894E10046E809 /* Sign Python Site Packages */,
430+
C828B27E2B1F7B3C00E7612A /* Copy Extension Point */,
418431
);
419432
buildRules = (
420433
);
@@ -505,47 +518,6 @@
505518
};
506519
/* End PBXResourcesBuildPhase section */
507520

508-
/* Begin PBXShellScriptBuildPhase section */
509-
C8A3AE572A28852D0046E809 /* Sign Python STD */ = {
510-
isa = PBXShellScriptBuildPhase;
511-
alwaysOutOfDate = 1;
512-
buildActionMask = 8;
513-
files = (
514-
);
515-
inputFileListPaths = (
516-
);
517-
inputPaths = (
518-
);
519-
name = "Sign Python STD";
520-
outputFileListPaths = (
521-
);
522-
outputPaths = (
523-
);
524-
runOnlyForDeploymentPostprocessing = 1;
525-
shellPath = /bin/sh;
526-
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";
527-
};
528-
C8A3B1782A2894E10046E809 /* Sign Python Site Packages */ = {
529-
isa = PBXShellScriptBuildPhase;
530-
alwaysOutOfDate = 1;
531-
buildActionMask = 8;
532-
files = (
533-
);
534-
inputFileListPaths = (
535-
);
536-
inputPaths = (
537-
);
538-
name = "Sign Python Site Packages";
539-
outputFileListPaths = (
540-
);
541-
outputPaths = (
542-
);
543-
runOnlyForDeploymentPostprocessing = 1;
544-
shellPath = /bin/sh;
545-
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";
546-
};
547-
/* End PBXShellScriptBuildPhase section */
548-
549521
/* Begin PBXSourcesBuildPhase section */
550522
C81458882939EFDC00135263 /* Sources */ = {
551523
isa = PBXSourcesBuildPhase;

Core/Package.swift

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ let package = Package(
109109
name: "Client",
110110
dependencies: [
111111
.product(name: "XPCShared", package: "Tool"),
112-
.product(name: "SuggestionService", package: "Tool"),
112+
.product(name: "SuggestionProvider", package: "Tool"),
113113
.product(name: "SuggestionModel", package: "Tool"),
114114
.product(name: "Logger", package: "Tool"),
115115
.product(name: "Preferences", package: "Tool"),
@@ -119,12 +119,13 @@ let package = Package(
119119
name: "Service",
120120
dependencies: [
121121
"SuggestionWidget",
122+
"SuggestionService",
122123
"ChatService",
123124
"PromptToCodeService",
124125
"ServiceUpdateMigration",
125126
"ChatGPTChatTab",
126127
.product(name: "XPCShared", package: "Tool"),
127-
.product(name: "SuggestionService", package: "Tool"),
128+
.product(name: "SuggestionProvider", package: "Tool"),
128129
.product(name: "Workspace", package: "Tool"),
129130
.product(name: "UserDefaultsObserver", package: "Tool"),
130131
.product(name: "AppMonitoring", package: "Tool"),
@@ -149,7 +150,7 @@ let package = Package(
149150
"Client",
150151
"SuggestionInjector",
151152
.product(name: "XPCShared", package: "Tool"),
152-
.product(name: "SuggestionService", package: "Tool"),
153+
.product(name: "SuggestionProvider", package: "Tool"),
153154
.product(name: "SuggestionModel", package: "Tool"),
154155
.product(name: "Environment", package: "Tool"),
155156
.product(name: "Preferences", package: "Tool"),
@@ -164,7 +165,7 @@ let package = Package(
164165
"Client",
165166
"LaunchAgentManager",
166167
"PlusFeatureFlag",
167-
.product(name: "SuggestionService", package: "Tool"),
168+
.product(name: "SuggestionProvider", package: "Tool"),
168169
.product(name: "Toast", package: "Tool"),
169170
.product(name: "SharedUIComponents", package: "Tool"),
170171
.product(name: "SuggestionModel", package: "Tool"),
@@ -180,6 +181,15 @@ let package = Package(
180181

181182
// MARK: - Suggestion Service
182183

184+
.target(
185+
name: "SuggestionService",
186+
dependencies: [
187+
.product(name: "SuggestionModel", package: "Tool"),
188+
.product(name: "SuggestionProvider", package: "Tool")
189+
].pro([
190+
"ProExtension",
191+
])
192+
),
183193
.target(
184194
name: "SuggestionInjector",
185195
dependencies: [.product(name: "SuggestionModel", package: "Tool")]
@@ -263,6 +273,7 @@ let package = Package(
263273
dependencies: [
264274
"PromptToCodeService",
265275
"ChatGPTChatTab",
276+
.product(name: "Toast", package: "Tool"),
266277
.product(name: "UserDefaultsObserver", package: "Tool"),
267278
.product(name: "SharedUIComponents", package: "Tool"),
268279
.product(name: "AppMonitoring", package: "Tool"),
@@ -290,7 +301,7 @@ let package = Package(
290301
.target(
291302
name: "ServiceUpdateMigration",
292303
dependencies: [
293-
.product(name: "SuggestionService", package: "Tool"),
304+
.product(name: "SuggestionProvider", package: "Tool"),
294305
.product(name: "Preferences", package: "Tool"),
295306
.product(name: "Keychain", package: "Tool"),
296307
]

Core/Sources/ChatGPTChatTab/Chat.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ struct Chat: ReducerProtocol {
7474
case binding(BindingAction<State>)
7575

7676
case appear
77+
case refresh
7778
case sendButtonTapped
7879
case returnButtonTapped
7980
case stopRespondingButtonTapped
@@ -132,6 +133,12 @@ struct Chat: ReducerProtocol {
132133
await send(.systemPromptChanged)
133134
await send(.extraSystemPromptChanged)
134135
await send(.focusOnTextField)
136+
await send(.refresh)
137+
}
138+
139+
case .refresh:
140+
return .run { send in
141+
await send(.chatMenu(.refresh))
135142
}
136143

137144
case .sendButtonTapped:
@@ -376,6 +383,7 @@ struct ChatMenu: ReducerProtocol {
376383

377384
enum Action: Equatable {
378385
case appear
386+
case refresh
379387
case resetPromptButtonTapped
380388
case temperatureOverrideSelected(Double?)
381389
case chatModelIdOverrideSelected(String?)
@@ -390,6 +398,11 @@ struct ChatMenu: ReducerProtocol {
390398
Reduce { state, action in
391399
switch action {
392400
case .appear:
401+
return .run {
402+
await $0(.refresh)
403+
}
404+
405+
case .refresh:
393406
state.temperatureOverride = service.configuration.overriding.temperature
394407
state.chatModelIdOverride = service.configuration.overriding.modelId
395408
return .none

Core/Sources/ChatGPTChatTab/ChatGPTChatTab.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public class ChatGPTChatTab: ChatTab {
8989
await tab.service.memory.mutateHistory { history in
9090
history = state.history
9191
}
92+
tab.viewStore.send(.refresh)
9293
}
9394
return builder
9495
}
@@ -140,7 +141,10 @@ public class ChatGPTChatTab: ChatTab {
140141
}
141142
}.store(in: &cancellable)
142143

143-
viewStore.publisher.removeDuplicates().sink { [weak self] _ in
144+
viewStore.publisher.removeDuplicates().debounce(
145+
for: .milliseconds(500),
146+
scheduler: DispatchQueue.main
147+
).sink { [weak self] _ in
144148
Task { @MainActor [weak self] in
145149
self?.chatTabViewStore.send(.tabContentUpdated)
146150
}

Core/Sources/Client/AsyncXPCService.swift

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public struct AsyncXPCService {
2020
}
2121
}
2222
}
23-
23+
2424
public func getXPCServiceAccessibilityPermission() async throws -> Bool {
2525
try await withXPCServiceConnected(connection: connection) {
2626
service, continuation in
@@ -85,7 +85,7 @@ public struct AsyncXPCService {
8585
{ $0.getRealtimeSuggestedCode }
8686
)
8787
}
88-
88+
8989
public func getPromptToCodeAcceptedCode(editorContent: EditorContent) async throws
9090
-> UpdatedContent?
9191
{
@@ -144,7 +144,7 @@ public struct AsyncXPCService {
144144
{ service in { service.customCommand(id: id, editorContent: $0, withReply: $1) } }
145145
)
146146
}
147-
147+
148148
public func postNotification(name: String) async throws {
149149
try await withXPCServiceConnected(connection: connection) {
150150
service, continuation in
@@ -153,17 +153,41 @@ public struct AsyncXPCService {
153153
}
154154
}
155155
}
156-
157-
public func performAction(name: String, arguments: String) async throws -> String {
158-
try await withXPCServiceConnected(connection: connection) {
159-
service, continuation in
160-
service.performAction(name: name, arguments: arguments) {
161-
continuation.resume($0)
156+
157+
public func send<M: ExtensionServiceRequestType>(
158+
requestBody: M
159+
) async throws -> M.ResponseBody {
160+
try await withXPCServiceConnected(connection: connection) { service, continuation in
161+
do {
162+
let requestBodyData = try JSONEncoder().encode(requestBody)
163+
service.send(endpoint: M.endpoint, requestBody: requestBodyData) { data, error in
164+
if let error {
165+
continuation.reject(error)
166+
} else {
167+
do {
168+
guard let data = data else {
169+
continuation.reject(NoDataError())
170+
return
171+
}
172+
let responseBody = try JSONDecoder().decode(
173+
M.ResponseBody.self,
174+
from: data
175+
)
176+
continuation.resume(responseBody)
177+
} catch {
178+
continuation.reject(error)
179+
}
180+
}
181+
}
182+
} catch {
183+
continuation.reject(error)
162184
}
163185
}
164186
}
165187
}
166188

189+
struct NoDataError: Error {}
190+
167191
struct AutoFinishContinuation<T> {
168192
var continuation: AsyncThrowingStream<T, Error>.Continuation
169193

Core/Sources/HostApp/AccountSettings/ChatModelManagement/ChatModelEdit.swift

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,26 @@ struct ChatModelEdit: ReducerProtocol {
114114
return .none
115115

116116
case .checkSuggestedMaxTokens:
117-
guard state.format == .openAI,
118-
let knownModel = ChatGPTModel(rawValue: state.modelName)
119-
else {
117+
switch state.format {
118+
case .openAI:
119+
if let knownModel = ChatGPTModel(rawValue: state.modelName) {
120+
state.suggestedMaxTokens = knownModel.maxToken
121+
} else {
122+
state.suggestedMaxTokens = nil
123+
}
124+
return .none
125+
case .googleAI:
126+
if let knownModel = GoogleGenerativeAIModel(rawValue: state.modelName) {
127+
state.suggestedMaxTokens = knownModel.maxToken
128+
} else {
129+
state.suggestedMaxTokens = nil
130+
}
131+
return .none
132+
default:
120133
state.suggestedMaxTokens = nil
121134
return .none
122135
}
123-
state.suggestedMaxTokens = knownModel.maxToken
124-
return .none
125-
136+
126137
case .apiKeySelection:
127138
return .none
128139

@@ -175,7 +186,12 @@ extension ChatModel {
175186
apiKeyName: state.apiKeyName,
176187
baseURL: state.baseURL.trimmingCharacters(in: .whitespacesAndNewlines),
177188
maxTokens: state.maxTokens,
178-
supportsFunctionCalling: state.supportsFunctionCalling,
189+
supportsFunctionCalling: {
190+
if case .googleAI = state.format {
191+
return false
192+
}
193+
return state.supportsFunctionCalling
194+
}(),
179195
modelName: state.modelName.trimmingCharacters(in: .whitespacesAndNewlines)
180196
)
181197
)

0 commit comments

Comments
 (0)