Skip to content

Commit d55b05c

Browse files
committed
Support persisting scopes of chat panel
1 parent 39b387d commit d55b05c

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

Core/Sources/ChatGPTChatTab/ChatGPTChatTab.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import ChatContextCollector
12
import ChatService
23
import ChatTab
4+
import CodableWrappers
35
import Combine
46
import ComposableArchitecture
57
import Foundation
@@ -21,6 +23,7 @@ public class ChatGPTChatTab: ChatTab {
2123
var configuration: OverridingChatGPTConfiguration.Overriding
2224
var systemPrompt: String
2325
var extraSystemPrompt: String
26+
var defaultScopes: Set<ChatContext.Scope>?
2427
}
2528

2629
struct Builder: ChatTabBuilder {
@@ -65,7 +68,8 @@ public class ChatGPTChatTab: ChatTab {
6568
history: await service.memory.history,
6669
configuration: service.configuration.overriding,
6770
systemPrompt: service.systemPrompt,
68-
extraSystemPrompt: service.extraSystemPrompt
71+
extraSystemPrompt: service.extraSystemPrompt,
72+
defaultScopes: service.defaultScopes
6973
)
7074
return (try? JSONEncoder().encode(state)) ?? Data()
7175
}
@@ -79,6 +83,9 @@ public class ChatGPTChatTab: ChatTab {
7983
tab.service.configuration.overriding = state.configuration
8084
tab.service.mutateSystemPrompt(state.systemPrompt)
8185
tab.service.mutateExtraSystemPrompt(state.extraSystemPrompt)
86+
if let scopes = state.defaultScopes {
87+
tab.service.defaultScopes = scopes
88+
}
8289
await tab.service.memory.mutateHistory { history in
8390
history = state.history
8491
}

Tool/Sources/ChatContextCollector/ChatContextCollector.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import OpenAIService
33
import Parsing
44

55
public struct ChatContext {
6-
public enum Scope: String, Equatable, CaseIterable {
6+
public enum Scope: String, Equatable, CaseIterable, Codable {
77
case file
88
case code
99
case sense

0 commit comments

Comments
 (0)