Skip to content

Commit b11f49e

Browse files
committed
Add scope settings to prompt to code
1 parent 3aba060 commit b11f49e

3 files changed

Lines changed: 50 additions & 5 deletions

File tree

Core/Sources/HostApp/FeatureSettings/ChatSettingsView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ struct ChatSettingsView: View {
290290
},
291291
description: "Experimental. Enable the bot to read the relevant code of the editing file in the project, third party packages and the SDK."
292292
) {
293-
WithFeatureEnabled(\.projectScopeInChat, alignment: .hidden) {
293+
WithFeatureEnabled(\.senseScopeInChat, alignment: .hidden) {
294294
Form {
295295
Toggle(isOn: $settings.enableSenseScopeByDefaultInChatContext) {
296296
Text("Enable by default")

Core/Sources/HostApp/FeatureSettings/PromptToCodeSettingsView.swift

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
import Preferences
12
import SharedUIComponents
23
import SwiftUI
34

5+
#if canImport(ProHostApp)
6+
import ProHostApp
7+
#endif
8+
49
struct PromptToCodeSettingsView: View {
510
final class Settings: ObservableObject {
611
@AppStorage(\.hideCommonPrecedingSpacesInSuggestion)
@@ -99,13 +104,49 @@ struct PromptToCodeSettingsView: View {
99104
Text("pt")
100105
}.disabled(true)
101106
}
107+
108+
ScopeForm()
102109
}
103110
}
104-
}
111+
112+
struct ScopeForm: View {
113+
class Settings: ObservableObject {
114+
@AppStorage(\.enableSenseScopeByDefaultInPromptToCode)
115+
var enableSenseScopeByDefaultInPromptToCode: Bool
116+
init() {}
117+
}
118+
119+
@StateObject var settings = Settings()
120+
121+
var body: some View {
122+
SettingsDivider("Scopes")
123+
124+
VStack {
125+
#if canImport(ProHostApp)
126+
127+
SubSection(
128+
title: WithFeatureEnabled(\.senseScopeInChat, alignment: .trailing) {
129+
Text("Sense Scope (Experimental)")
130+
},
131+
description: "Experimental. Enable the bot to read the relevant code of the editing file in the project, third party packages and the SDK."
132+
) {
133+
WithFeatureEnabled(\.projectScopeInChat, alignment: .hidden) {
134+
Form {
135+
Toggle(isOn: $settings.enableSenseScopeByDefaultInPromptToCode) {
136+
Text("Enable by default")
137+
}
138+
}
139+
}
140+
}
105141

106-
struct PromptToCodeSettingsView_Previews: PreviewProvider {
107-
static var previews: some View {
108-
PromptToCodeSettingsView()
142+
#endif
143+
}
144+
}
109145
}
110146
}
111147

148+
#Preview {
149+
PromptToCodeSettingsView()
150+
.padding()
151+
}
152+

Tool/Sources/Preferences/Keys.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,10 @@ public extension UserDefaultPreferenceKeys {
277277
var promptToCodeEmbeddingModelId: PreferenceKey<String> {
278278
.init(defaultValue: "", key: "PromptToCodeEmbeddingModelId")
279279
}
280+
281+
var enableSenseScopeByDefaultInPromptToCode: PreferenceKey<Bool> {
282+
.init(defaultValue: false, key: "EnableSenseScopeByDefaultInPromptToCode")
283+
}
280284
}
281285

282286
// MARK: - Suggestion

0 commit comments

Comments
 (0)