Skip to content

Commit 982a44d

Browse files
committed
Add GitHub Copilot chat (poc) to scope preferred models
1 parent 2d62073 commit 982a44d

1 file changed

Lines changed: 30 additions & 9 deletions

File tree

Core/Sources/HostApp/FeatureSettings/Chat/ChatSettingsScopeSectionView.swift

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,27 +96,34 @@ struct ChatSettingsScopeSectionView: View {
9696
Toggle(isOn: $settings.enableSenseScopeByDefaultInChatContext) {
9797
Text("Enable by default")
9898
}
99+
100+
let allModels = settings.chatModels + [.init(
101+
id: "com.github.copilot",
102+
name: "GitHub Copilot (poc)",
103+
format: .openAI,
104+
info: .init()
105+
)]
99106

100107
Picker(
101108
"Preferred chat model",
102109
selection: $settings.preferredChatModelIdForSenseScope
103110
) {
104111
Text("Use the default model").tag("")
105112

106-
if !settings.chatModels
113+
if !allModels
107114
.contains(where: {
108115
$0.id == settings.preferredChatModelIdForSenseScope
109116
}),
110117
!settings.preferredChatModelIdForSenseScope.isEmpty
111118
{
112119
Text(
113-
(settings.chatModels.first?.name).map { "\($0) (Default)" }
120+
(allModels.first?.name).map { "\($0) (Default)" }
114121
?? "No model found"
115122
)
116123
.tag(settings.preferredChatModelIdForSenseScope)
117124
}
118125

119-
ForEach(settings.chatModels, id: \.id) { chatModel in
126+
ForEach(allModels, id: \.id) { chatModel in
120127
Text(chatModel.name).tag(chatModel.id)
121128
}
122129
}
@@ -151,27 +158,34 @@ struct ChatSettingsScopeSectionView: View {
151158
Toggle(isOn: $settings.enableProjectScopeByDefaultInChatContext) {
152159
Text("Enable by default")
153160
}
161+
162+
let allModels = settings.chatModels + [.init(
163+
id: "com.github.copilot",
164+
name: "GitHub Copilot (poc)",
165+
format: .openAI,
166+
info: .init()
167+
)]
154168

155169
Picker(
156170
"Preferred chat model",
157171
selection: $settings.preferredChatModelIdForProjectScope
158172
) {
159173
Text("Use the default model").tag("")
160174

161-
if !settings.chatModels
175+
if !allModels
162176
.contains(where: {
163177
$0.id == settings.preferredChatModelIdForProjectScope
164178
}),
165179
!settings.preferredChatModelIdForProjectScope.isEmpty
166180
{
167181
Text(
168-
(settings.chatModels.first?.name).map { "\($0) (Default)" }
182+
(allModels.first?.name).map { "\($0) (Default)" }
169183
?? "No Model Found"
170184
)
171185
.tag(settings.preferredChatModelIdForProjectScope)
172186
}
173187

174-
ForEach(settings.chatModels, id: \.id) { chatModel in
188+
ForEach(allModels, id: \.id) { chatModel in
175189
Text(chatModel.name).tag(chatModel.id)
176190
}
177191
}
@@ -188,27 +202,34 @@ struct ChatSettingsScopeSectionView: View {
188202
Toggle(isOn: $settings.enableWebScopeByDefaultInChatContext) {
189203
Text("Enable @web scope by default in chat context.")
190204
}
205+
206+
let allModels = settings.chatModels + [.init(
207+
id: "com.github.copilot",
208+
name: "GitHub Copilot (poc)",
209+
format: .openAI,
210+
info: .init()
211+
)]
191212

192213
Picker(
193214
"Preferred chat model",
194215
selection: $settings.preferredChatModelIdForWebScope
195216
) {
196217
Text("Use the default model").tag("")
197218

198-
if !settings.chatModels
219+
if !allModels
199220
.contains(where: {
200221
$0.id == settings.preferredChatModelIdForWebScope
201222
}),
202223
!settings.preferredChatModelIdForWebScope.isEmpty
203224
{
204225
Text(
205-
(settings.chatModels.first?.name).map { "\($0) (Default)" }
226+
(allModels.first?.name).map { "\($0) (Default)" }
206227
?? "No model found"
207228
)
208229
.tag(settings.preferredChatModelIdForWebScope)
209230
}
210231

211-
ForEach(settings.chatModels, id: \.id) { chatModel in
232+
ForEach(allModels, id: \.id) { chatModel in
212233
Text(chatModel.name).tag(chatModel.id)
213234
}
214235
}

0 commit comments

Comments
 (0)