Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
e11d290
Merge tag '0.26.0' into develop
intitni Oct 22, 2023
62a6e85
Disable hit test when a chat panel tab is not active
intitni Oct 22, 2023
27ad97c
Update
intitni Oct 30, 2023
a9f3f48
Merge branch 'feature/retrieve-from-active-document' into develop
intitni Oct 30, 2023
ad9c008
Add new scope @sense
intitni Oct 30, 2023
5bdaf24
Update instruction
intitni Oct 30, 2023
ddbfece
Add settings for scopes
intitni Oct 31, 2023
3f25cc5
Adjust UI
intitni Oct 31, 2023
e1f4b54
Update UI
intitni Oct 31, 2023
2b5d950
Update to setup scope according to settings
intitni Oct 31, 2023
f528d9a
Support changing default scopes in chat panel
intitni Oct 31, 2023
956f712
Add Scope enum to represent scopes
intitni Oct 31, 2023
39b387d
Support changing model according to scopes
intitni Oct 31, 2023
d55b05c
Support persisting scopes of chat panel
intitni Oct 31, 2023
5f71a97
Update
intitni Oct 31, 2023
67a9eb0
Merge branch 'feature/search-scope' into develop
intitni Oct 31, 2023
4b34f20
Update
intitni Nov 2, 2023
403a918
Add new logger
intitni Nov 2, 2023
c03ce88
Fix tests
intitni Nov 2, 2023
4158c6b
Add ContextAwarePromptToCodeService
intitni Nov 3, 2023
f47d2d3
Update
intitni Nov 6, 2023
582bdc4
Update
intitni Nov 6, 2023
5848281
Merge branch 'feature/prompt-to-code-with-chat-context-support' into …
intitni Nov 6, 2023
4209f86
Make chat window title bar and traffic light button bigger
intitni Nov 2, 2023
e1cdd69
Merge branch 'feature/adjust-chat-window-title-bar-ui' into develop
intitni Nov 6, 2023
0167734
Update focus code finder to return more info about contexts
intitni Nov 8, 2023
8923f39
Prevent variable declaration being used as code range
intitni Nov 8, 2023
585df56
Support proService clean up
intitni Nov 8, 2023
4740bae
Add keys
intitni Nov 8, 2023
1f3650a
Reset to use old prompt to code service
intitni Nov 8, 2023
fd84744
Update
intitni Nov 8, 2023
4a39591
Add new OpenAI model
intitni Nov 8, 2023
7dc23dc
Merge branch 'feature/add-new-models' into develop
intitni Nov 8, 2023
18a5b34
Adjust implementation of chat panel
intitni Nov 9, 2023
ab97bad
Tweak pin to bottom behavior of chat panel
intitni Nov 9, 2023
4974b20
Merge branch 'feature/chat-panel-improvement' into develop
intitni Nov 9, 2023
8330640
Move context system prompt to right next to the latest message
intitni Nov 9, 2023
6938c9f
Merge branch 'feature/adjust-position-of-context-system-prompt' into …
intitni Nov 9, 2023
309c70f
Track scroll event to disable pin to bottom
intitni Nov 9, 2023
e6940a5
Merge branch 'feature/use-scroll-event-to-disable-pin-to-bottom' into…
intitni Nov 9, 2023
651d29b
Bump Github Copilot to 1.11.4
intitni Nov 9, 2023
1cf2781
Bump Codeium to 1.4.15
intitni Nov 9, 2023
93c5404
Fix a crash that calls dropLast with a negative number
intitni Nov 9, 2023
228b2b2
Update
intitni Nov 9, 2023
ee2aefb
Update
intitni Nov 9, 2023
9b0b4bc
Fix chat panel interfere
intitni Nov 9, 2023
65e603e
Select the first chat tab after restoring
intitni Nov 9, 2023
ab3be0d
Fix that prompt to code can open at launch
intitni Nov 9, 2023
78809ef
Update
intitni Nov 9, 2023
02ae983
Bump version to 0.27.0
intitni Nov 9, 2023
aac6509
Add sense scope to auto completion
intitni Nov 9, 2023
d0910a2
Simplify implementation
intitni Nov 9, 2023
17ce115
Fix that overriding model not overriding max token and min reply token
intitni Nov 9, 2023
bb3d534
Update
intitni Nov 9, 2023
f0b2a24
Update
intitni Nov 9, 2023
e54c85f
Update
intitni Nov 9, 2023
12bc66b
Update
intitni Nov 9, 2023
21985b9
Update appcast.xml
intitni Nov 9, 2023
fa7dc18
Merge branch 'release/0.27.0'
intitni Nov 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add settings for scopes
  • Loading branch information
intitni committed Oct 31, 2023
commit ddbfece996bf2068e142470ea6f180d5fa6f91e2
217 changes: 205 additions & 12 deletions Core/Sources/HostApp/FeatureSettings/ChatSettingsView.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import Preferences
import SharedUIComponents
import SwiftUI

#if canImport(ProHostApp)
import ProHostApp
#endif

struct ChatSettingsView: View {
class Settings: ObservableObject {
static let availableLocalizedLocales = Locale.availableLocalizedLocales
Expand All @@ -11,8 +16,6 @@ struct ChatSettingsView: View {
@AppStorage(\.chatCodeFontSize) var chatCodeFontSize
@AppStorage(\.maxFocusedCodeLineCount)
var maxFocusedCodeLineCount
@AppStorage(\.useCodeScopeByDefaultInChatContext)
var useCodeScopeByDefaultInChatContext
@AppStorage(\.defaultChatFeatureChatModelId) var defaultChatFeatureChatModelId
@AppStorage(\.defaultChatSystemPrompt) var defaultChatSystemPrompt
@AppStorage(\.chatSearchPluginMaxIterations) var chatSearchPluginMaxIterations
Expand All @@ -32,12 +35,13 @@ struct ChatSettingsView: View {
var body: some View {
VStack {
chatSettingsForm
Divider()
SettingsDivider("UI")
uiForm
Divider()
SettingsDivider("Context")
contextForm
Divider()
SettingsDivider("Plugin")
pluginForm
ScopeForm()
}
}

Expand Down Expand Up @@ -160,7 +164,7 @@ struct ChatSettingsView: View {

Text("pt")
}

Toggle(isOn: $settings.wrapCodeInCodeBlock) {
Text("Wrap code in code block")
}
Expand All @@ -170,10 +174,6 @@ struct ChatSettingsView: View {
@ViewBuilder
var contextForm: some View {
Form {
Toggle(isOn: $settings.useCodeScopeByDefaultInChatContext) {
Text("Use @code scope by default in chat context.")
}

HStack {
TextField(text: .init(get: {
"\(Int(settings.maxFocusedCodeLineCount))"
Expand Down Expand Up @@ -235,13 +235,206 @@ struct ChatSettingsView: View {
)
}
}

struct ScopeForm: View {
class Settings: ObservableObject {
@AppStorage(\.enableFileScopeByDefaultInChatContext)
var enableFileScopeByDefaultInChatContext: Bool
@AppStorage(\.enableCodeScopeByDefaultInChatContext)
var enableCodeScopeByDefaultInChatContext: Bool
@AppStorage(\.enableSenseScopeByDefaultInChatContext)
var enableSenseScopeByDefaultInChatContext: Bool
@AppStorage(\.enableProjectScopeByDefaultInChatContext)
var enableProjectScopeByDefaultInChatContext: Bool
@AppStorage(\.enableWebScopeByDefaultInChatContext)
var enableWebScopeByDefaultInChatContext: Bool
@AppStorage(\.preferredChatModelIdForSenseScope)
var preferredChatModelIdForSenseScope: String
@AppStorage(\.preferredChatModelIdForProjectScope)
var preferredChatModelIdForProjectScope: String
@AppStorage(\.preferredChatModelIdForWebScope)
var preferredChatModelIdForWebScope: String
@AppStorage(\.chatModels) var chatModels

init() {}
}

@StateObject var settings = Settings()

var body: some View {
VStack {
Scope(
title: Text("File Scope"),
description: "Enable the bot to read the metadata of the editing file."
) {
Form {
Toggle(isOn: $settings.enableFileScopeByDefaultInChatContext) {
Text("Enable @file scope by default in chat context.")
}
}
}

Scope(
title: Text("Code Scope"),
description: "Enable the bot to read the code and metadata in the editing file."
) {
Form {
Toggle(isOn: $settings.enableCodeScopeByDefaultInChatContext) {
Text("Enable @code scope by default in chat context.")
}
}
}

#if canImport(ProHostApp)

Scope(
title: WithFeatureEnabled(\.projectScopeInChat) { Text("Sense Scope") },
description: "Experimental. Enable the bot to read the relevant code of the editing file in the project, third party packages and the SDK."
) {
WithFeatureEnabled(\.projectScopeInChat, alignment: .hidden) {
Form {
Toggle(isOn: $settings.enableSenseScopeByDefaultInChatContext) {
Text("Enable @sense scope by default in chat context.")
}

Picker(
"Preferred Chat Model",
selection: $settings.preferredChatModelIdForSenseScope
) {
Text("None").tag("")

if !settings.chatModels
.contains(where: {
$0.id == settings.preferredChatModelIdForSenseScope
}),
!settings.preferredChatModelIdForSenseScope.isEmpty
{
Text(
(settings.chatModels.first?.name).map { "\($0) (Default)" }
?? "No Model Found"
)
.tag(settings.preferredChatModelIdForSenseScope)
}

ForEach(settings.chatModels, id: \.id) { chatModel in
Text(chatModel.name).tag(chatModel.id)
}
}
}
}
.padding(.top, 20)
}

Scope(
title: WithFeatureEnabled(\.projectScopeInChat) { Text("Project Scope") },
description: "Experimental. Enable the bot to search code symbols in the project, third party packages and the SDK."
) {
WithFeatureEnabled(\.projectScopeInChat, alignment: .hidden) {
Form {
Toggle(isOn: $settings.enableProjectScopeByDefaultInChatContext) {
Text("Enable @project scope by default in chat context.")
}

Picker(
"Preferred Chat Model",
selection: $settings.preferredChatModelIdForProjectScope
) {
Text("None").tag("")

if !settings.chatModels
.contains(where: {
$0.id == settings.preferredChatModelIdForProjectScope
}),
!settings.preferredChatModelIdForProjectScope.isEmpty
{
Text(
(settings.chatModels.first?.name).map { "\($0) (Default)" }
?? "No Model Found"
)
.tag(settings.preferredChatModelIdForProjectScope)
}

ForEach(settings.chatModels, id: \.id) { chatModel in
Text(chatModel.name).tag(chatModel.id)
}
}
}
}
}

#endif

Scope(
title: Text("Web Scope"),
description: "Allow the bot to search on Bing or read a web page."
) {
Form {
Toggle(isOn: $settings.enableWebScopeByDefaultInChatContext) {
Text("Enable @web scope by default in chat context.")
}

Picker(
"Preferred Chat Model",
selection: $settings.preferredChatModelIdForWebScope
) {
Text("None").tag("")

if !settings.chatModels
.contains(where: {
$0.id == settings.preferredChatModelIdForWebScope
}),
!settings.preferredChatModelIdForWebScope.isEmpty
{
Text(
(settings.chatModels.first?.name).map { "\($0) (Default)" }
?? "No Model Found"
)
.tag(settings.preferredChatModelIdForWebScope)
}

ForEach(settings.chatModels, id: \.id) { chatModel in
Text(chatModel.name).tag(chatModel.id)
}
}
}
}
}
}

struct Scope<Title: View, Content: View>: View {
let title: Title
let description: String
let content: () -> Content

var body: some View {
SettingsDivider(title)
VStack {
Text(description)
.multilineTextAlignment(.center)
.foregroundStyle(.secondary)
.padding(8)
.background {
RoundedRectangle(cornerRadius: 8)
.fill(Color.secondary.opacity(0.1))
}
.frame(maxWidth: 500)
Form {
content()
}
}
}
}
}
}

// MARK: - Preview

struct ChatSettingsView_Previews: PreviewProvider {
static var previews: some View {
#Preview {
ScrollView {
ChatSettingsView()
.padding()
}
.frame(height: 800)
.environment(\.overrideFeatureFlag, \.never)
}

2 changes: 1 addition & 1 deletion Pro
Submodule Pro updated from 7fe0d0 to e6d0ca
44 changes: 38 additions & 6 deletions Tool/Sources/Preferences/Keys.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public struct UserDefaultPreferenceKeys {
defaultValue: false,
key: "HideCircularWidget"
)

public let showHideWidgetShortcutGlobally = PreferenceKey(
defaultValue: false,
key: "ShowHideWidgetShortcutGlobally"
Expand Down Expand Up @@ -269,11 +269,11 @@ public extension UserDefaultPreferenceKeys {
var promptToCodeGenerateDescriptionInUserPreferredLanguage: PreferenceKey<Bool> {
.init(defaultValue: true, key: "PromptToCodeGenerateDescriptionInUserPreferredLanguage")
}

var promptToCodeChatModelId: PreferenceKey<String> {
.init(defaultValue: "", key: "PromptToCodeChatModelId")
}

var promptToCodeEmbeddingModelId: PreferenceKey<String> {
.init(defaultValue: "", key: "PromptToCodeEmbeddingModelId")
}
Expand Down Expand Up @@ -366,7 +366,7 @@ public extension UserDefaultPreferenceKeys {
.init(defaultValue: 100, key: "MaxEmbeddableFileInChatContextLineCount")
}

var useCodeScopeByDefaultInChatContext: PreferenceKey<Bool> {
var useCodeScopeByDefaultInChatContext: DeprecatedPreferenceKey<Bool> {
.init(defaultValue: true, key: "UseSelectionScopeByDefaultInChatContext")
}

Expand All @@ -389,10 +389,42 @@ public extension UserDefaultPreferenceKeys {
var chatSearchPluginMaxIterations: PreferenceKey<Int> {
.init(defaultValue: 3, key: "ChatSearchPluginMaxIterations")
}

var wrapCodeInChatCodeBlock: PreferenceKey<Bool> {
.init(defaultValue: true, key: "WrapCodeInChatCodeBlock")
}

var enableFileScopeByDefaultInChatContext: PreferenceKey<Bool> {
.init(defaultValue: true, key: "EnableFileScopeByDefaultInChatContext")
}

var enableCodeScopeByDefaultInChatContext: PreferenceKey<Bool> {
.init(defaultValue: true, key: "UseSelectionScopeByDefaultInChatContext")
}

var enableSenseScopeByDefaultInChatContext: PreferenceKey<Bool> {
.init(defaultValue: false, key: "EnableSenseScopeByDefaultInChatContext")
}

var enableProjectScopeByDefaultInChatContext: PreferenceKey<Bool> {
.init(defaultValue: false, key: "EnableProjectScopeByDefaultInChatContext")
}

var enableWebScopeByDefaultInChatContext: PreferenceKey<Bool> {
.init(defaultValue: false, key: "EnableWebScopeByDefaultInChatContext")
}

var preferredChatModelIdForSenseScope: PreferenceKey<String> {
.init(defaultValue: "", key: "PreferredChatModelIdForSenseScope")
}

var preferredChatModelIdForProjectScope: PreferenceKey<String> {
.init(defaultValue: "", key: "PreferredChatModelIdForProjectScope")
}

var preferredChatModelIdForWebScope: PreferenceKey<String> {
.init(defaultValue: "", key: "PreferredChatModelIdForWebScope")
}
}

// MARK: - Bing Search
Expand Down Expand Up @@ -508,7 +540,7 @@ public extension UserDefaultPreferenceKeys {
key: "FeatureFlag-DisableGitHubCopilotSettingsAutoRefreshOnAppear"
)
}

var disableEnhancedWorkspace: FeatureFlag {
.init(
defaultValue: false,
Expand Down
42 changes: 42 additions & 0 deletions Tool/Sources/SharedUIComponents/SettingsDivider.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import SwiftUI

public struct SettingsDivider<Title: View>: View {
let title: Title?

public init(_ title: Title) {
self.title = title
}

public var body: some View {
if let title {
HStack {
VStack {
Divider()
}
title
.foregroundStyle(.secondary)
.font(.subheadline)
.zIndex(2)
VStack {
Divider()
}
}
.padding(.vertical, 8)
} else {
Divider()
.padding(.vertical, 8)
}
}
}

extension SettingsDivider where Title == Text {
public init(_ title: String) {
self.title = Text(title)
}
}

extension SettingsDivider where Title == EmptyView {
public init() {
self.title = nil
}
}