@@ -11,7 +11,7 @@ public protocol BuiltinExtension: CopilotForXcodeExtensionCapability {
1111 var extensionIdentifier : String { get }
1212
1313 /// All chat builders provided by this extension.
14- var chatTabTypes : [ any ChatTab . Type ] { get }
14+ var chatTabTypes : [ any CustomChatTab ] { get }
1515
1616 /// It's usually called when the app is about to quit,
1717 /// you should clean up all the resources here.
@@ -22,7 +22,7 @@ public protocol BuiltinExtension: CopilotForXcodeExtensionCapability {
2222
2323public extension BuiltinExtension {
2424 var suggestionServiceId : BuiltInSuggestionFeatureProvider ? { nil }
25- var chatTabTypes : [ any ChatTab . Type ] { [ ] }
25+ var chatTabTypes : [ any CustomChatTab ] { [ ] }
2626}
2727
2828// MAKR: - ChatService
@@ -42,7 +42,7 @@ public protocol BuiltinExtensionChatServiceType: ChatServiceType {
4242public struct RetrievedContent {
4343 public var document : ChatMessage . Reference
4444 public var priority : Int
45-
45+
4646 public init ( document: ChatMessage . Reference , priority: Int ) {
4747 self . document = document
4848 self . priority = priority
@@ -63,3 +63,29 @@ public enum ChatServiceMemoryMutation: Codable {
6363 case streamIntoMessage( id: String , role: Message . Role ? , text: String ? )
6464}
6565
66+ public protocol CustomChatTab {
67+ var name : String { get }
68+ var isDefaultChatTabReplacement : Bool { get }
69+ var canHandleOpenChatCommand : Bool { get }
70+ func chatBuilders( ) -> [ ChatTabBuilder ]
71+ func defaultChatBuilder( ) -> ChatTabBuilder
72+ func restore( from data: Data ) async throws -> any ChatTabBuilder
73+ }
74+
75+ public struct TypedCustomChatTab : CustomChatTab {
76+ public let type : ChatTab . Type
77+
78+ public init ( of type: ChatTab . Type ) {
79+ self . type = type
80+ }
81+
82+ public var name : String { type. name }
83+ public var isDefaultChatTabReplacement : Bool { type. isDefaultChatTabReplacement }
84+ public var canHandleOpenChatCommand : Bool { type. canHandleOpenChatCommand }
85+ public func chatBuilders( ) -> [ ChatTabBuilder ] { type. chatBuilders ( ) }
86+ public func defaultChatBuilder( ) -> ChatTabBuilder { type. defaultChatBuilder ( ) }
87+ public func restore( from data: Data ) async throws -> any ChatTabBuilder {
88+ try await type. restore ( from: data)
89+ }
90+ }
91+
0 commit comments