Skip to content

Commit b2bcfc7

Browse files
committed
Add settings for GitHub Copilot chat
1 parent 4fdb4e5 commit b2bcfc7

File tree

3 files changed

+45
-32
lines changed

3 files changed

+45
-32
lines changed

Core/Sources/ChatGPTChatTab/ChatContextMenu.swift

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,19 @@ struct ChatContextMenu: View {
7070

7171
@ViewBuilder
7272
var chatModel: some View {
73+
let allModels = chatModels + [.init(
74+
id: "com.github.copilot",
75+
name: "GitHub Copilot (poc)",
76+
format: .openAI,
77+
info: .init()
78+
)]
79+
7380
Menu("Chat Model") {
7481
Button(action: {
7582
store.send(.chatModelIdOverrideSelected(nil))
7683
}) {
7784
HStack {
78-
if let defaultModel = chatModels
85+
if let defaultModel = allModels
7986
.first(where: { $0.id == defaultChatModelId })
8087
{
8188
Text("Default (\(defaultModel.name))")
@@ -88,7 +95,7 @@ struct ChatContextMenu: View {
8895
}
8996
}
9097

91-
if let id = store.chatModelIdOverride, !chatModels.map(\.id).contains(id) {
98+
if let id = store.chatModelIdOverride, !allModels.map(\.id).contains(id) {
9299
Button(action: {
93100
store.send(.chatModelIdOverrideSelected(nil))
94101
}) {
@@ -101,7 +108,7 @@ struct ChatContextMenu: View {
101108

102109
Divider()
103110

104-
ForEach(chatModels, id: \.id) { model in
111+
ForEach(allModels, id: \.id) { model in
105112
Button(action: {
106113
store.send(.chatModelIdOverrideSelected(model.id))
107114
}) {
@@ -152,26 +159,26 @@ struct ChatContextMenu: View {
152159
@ViewBuilder
153160
var defaultScopes: some View {
154161
Menu("Default Scopes") {
162+
Button(action: {
163+
store.send(.resetDefaultScopesButtonTapped)
164+
}) {
165+
Text("Reset Default Scopes")
166+
}
167+
168+
Divider()
169+
170+
ForEach(ChatService.Scope.allCases, id: \.rawValue) { value in
155171
Button(action: {
156-
store.send(.resetDefaultScopesButtonTapped)
172+
store.send(.toggleScope(value))
157173
}) {
158-
Text("Reset Default Scopes")
159-
}
160-
161-
Divider()
162-
163-
ForEach(ChatService.Scope.allCases, id: \.rawValue) { value in
164-
Button(action: {
165-
store.send(.toggleScope(value))
166-
}) {
167-
HStack {
168-
Text("@" + value.rawValue)
169-
if store.defaultScopes.contains(value) {
170-
Image(systemName: "checkmark")
171-
}
174+
HStack {
175+
Text("@" + value.rawValue)
176+
if store.defaultScopes.contains(value) {
177+
Image(systemName: "checkmark")
172178
}
173179
}
174180
}
181+
}
175182
}
176183
}
177184

Core/Sources/HostApp/AccountSettings/GitHubCopilotView.swift

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ struct GitHubCopilotView: View {
2020
@AppStorage(\.gitHubCopilotProxyPassword) var gitHubCopilotProxyPassword
2121
@AppStorage(\.gitHubCopilotUseStrictSSL) var gitHubCopilotUseStrictSSL
2222
@AppStorage(\.gitHubCopilotEnterpriseURI) var gitHubCopilotEnterpriseURI
23+
@AppStorage(\.gitHubCopilotPretendIDEToBeVSCode) var pretendIDEToBeVSCode
2324
@AppStorage(\.disableGitHubCopilotSettingsAutoRefreshOnAppear)
2425
var disableGitHubCopilotSettingsAutoRefreshOnAppear
2526
@AppStorage(\.gitHubCopilotLoadKeyChainCertificates)
@@ -263,15 +264,16 @@ struct GitHubCopilotView: View {
263264
.opacity(isRunningAction ? 0.8 : 1)
264265
.disabled(isRunningAction)
265266

266-
Button("Refresh Configuration for Enterprise and Proxy") {
267+
Button("Refresh configurations") {
267268
refreshConfiguration()
268269
}
269270
}
270271

271272
SettingsDivider("Advanced")
272273

273274
Form {
274-
Toggle("Verbose Log", isOn: $settings.gitHubCopilotVerboseLog)
275+
Toggle("Verbose log", isOn: $settings.gitHubCopilotVerboseLog)
276+
Toggle("Pretend IDE to be VSCode", isOn: $settings.pretendIDEToBeVSCode)
275277
}
276278

277279
SettingsDivider("Enterprise")
@@ -281,7 +283,7 @@ struct GitHubCopilotView: View {
281283
text: $settings.gitHubCopilotEnterpriseURI,
282284
prompt: Text("Leave it blank if non is available.")
283285
) {
284-
Text("Auth Provider URL")
286+
Text("Auth provider URL")
285287
}
286288
}
287289

@@ -292,18 +294,18 @@ struct GitHubCopilotView: View {
292294
text: $settings.gitHubCopilotProxyHost,
293295
prompt: Text("xxx.xxx.xxx.xxx, leave it blank to disable proxy.")
294296
) {
295-
Text("Proxy Host")
297+
Text("Proxy host")
296298
}
297299
TextField(text: $settings.gitHubCopilotProxyPort, prompt: Text("80")) {
298-
Text("Proxy Port")
300+
Text("Proxy port")
299301
}
300302
TextField(text: $settings.gitHubCopilotProxyUsername) {
301-
Text("Proxy Username")
303+
Text("Proxy username")
302304
}
303305
SecureField(text: $settings.gitHubCopilotProxyPassword) {
304-
Text("Proxy Password")
306+
Text("Proxy password")
305307
}
306-
Toggle("Proxy Strict SSL", isOn: $settings.gitHubCopilotUseStrictSSL)
308+
Toggle("Proxy strict SSL", isOn: $settings.gitHubCopilotUseStrictSSL)
307309
}
308310
}
309311
Spacer()

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,21 @@ struct ChatSettingsGeneralSectionView: View {
100100
"Chat model",
101101
selection: $settings.defaultChatFeatureChatModelId
102102
) {
103-
if !settings.chatModels
104-
.contains(where: { $0.id == settings.defaultChatFeatureChatModelId })
105-
{
103+
let allModels = settings.chatModels + [.init(
104+
id: "com.github.copilot",
105+
name: "GitHub Copilot (poc)",
106+
format: .openAI,
107+
info: .init()
108+
)]
109+
110+
if !allModels.contains(where: { $0.id == settings.defaultChatFeatureChatModelId }) {
106111
Text(
107-
(settings.chatModels.first?.name).map { "\($0) (Default)" }
108-
?? "No model found"
112+
(allModels.first?.name).map { "\($0) (Default)" } ?? "No model found"
109113
)
110114
.tag(settings.defaultChatFeatureChatModelId)
111115
}
112116

113-
ForEach(settings.chatModels, id: \.id) { chatModel in
117+
ForEach(allModels, id: \.id) { chatModel in
114118
Text(chatModel.name).tag(chatModel.id)
115119
}
116120
}

0 commit comments

Comments
 (0)