|
1 | 1 | import ActiveApplicationMonitor |
2 | 2 | import AppKit |
| 3 | +import BuiltinExtension |
3 | 4 | import CodeiumService |
4 | 5 | import CommandHandler |
5 | 6 | import enum CopilotForXcodeKit.SuggestionServiceError |
@@ -218,12 +219,12 @@ struct PseudoCommandHandler: CommandHandler { |
218 | 219 | if now.timeIntervalSince(last) > 60 * 60 { |
219 | 220 | Self.lastTimeCommandFailedToTriggerWithAccessibilityAPI = now |
220 | 221 | toast.toast(content: """ |
221 | | - The app is using a fallback solution to accept suggestions. \ |
222 | | - For better experience, please restart Xcode to re-activate the Copilot \ |
223 | | - menu item. |
224 | | - """, type: .warning) |
| 222 | + The app is using a fallback solution to accept suggestions. \ |
| 223 | + For better experience, please restart Xcode to re-activate the Copilot \ |
| 224 | + menu item. |
| 225 | + """, type: .warning) |
225 | 226 | } |
226 | | - |
| 227 | + |
227 | 228 | throw error |
228 | 229 | } |
229 | 230 | } |
@@ -340,6 +341,24 @@ struct PseudoCommandHandler: CommandHandler { |
340 | 341 | func openChat(forceDetach: Bool, activateThisApp: Bool = true) { |
341 | 342 | switch UserDefaults.shared.value(for: \.openChatMode) { |
342 | 343 | case .chatPanel: |
| 344 | + for ext in BuiltinExtensionManager.shared.extensions { |
| 345 | + guard let tab = ext.chatTabTypes.first(where: { $0.isDefaultChatTabReplacement } ) |
| 346 | + else { continue } |
| 347 | + Task { @MainActor in |
| 348 | + let store = Service.shared.guiController.store |
| 349 | + await store.send( |
| 350 | + .createAndSwitchToChatTabIfNeededMatching( |
| 351 | + check: { $0.name == tab.name }, |
| 352 | + kind: .init(tab.defaultChatBuilder()) |
| 353 | + ) |
| 354 | + ).finish() |
| 355 | + store.send(.openChatPanel( |
| 356 | + forceDetach: forceDetach, |
| 357 | + activateThisApp: activateThisApp |
| 358 | + )) |
| 359 | + } |
| 360 | + return |
| 361 | + } |
343 | 362 | Task { @MainActor in |
344 | 363 | let store = Service.shared.guiController.store |
345 | 364 | await store.send(.createAndSwitchToChatGPTChatTabIfNeeded).finish() |
@@ -395,20 +414,26 @@ struct PseudoCommandHandler: CommandHandler { |
395 | 414 | await openURL(url) |
396 | 415 | } |
397 | 416 | } |
398 | | - case .codeiumChat: |
| 417 | + case let .builtinExtension(extensionIdentifier, tabName): |
| 418 | + guard let ext = BuiltinExtensionManager.shared.extensions |
| 419 | + .first(where: { $0.extensionIdentifier == extensionIdentifier }), |
| 420 | + let tab = ext.chatTabTypes.first(where: { $0.name == tabName }) |
| 421 | + else { return } |
399 | 422 | Task { @MainActor in |
400 | 423 | let store = Service.shared.guiController.store |
401 | 424 | await store.send( |
402 | 425 | .createAndSwitchToChatTabIfNeededMatching( |
403 | | - check: { $0 is CodeiumChatTab }, |
404 | | - kind: .init(CodeiumChatTab.defaultChatBuilder()) |
| 426 | + check: { $0.name == tabName }, |
| 427 | + kind: .init(tab.defaultChatBuilder()) |
405 | 428 | ) |
406 | 429 | ).finish() |
407 | 430 | store.send(.openChatPanel( |
408 | 431 | forceDetach: forceDetach, |
409 | 432 | activateThisApp: activateThisApp |
410 | 433 | )) |
411 | 434 | } |
| 435 | + case let .externalExtension(extensionIdentifier, tabName): |
| 436 | + return |
412 | 437 | } |
413 | 438 | } |
414 | 439 |
|
|
0 commit comments