Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
437105f
Merge tag '0.31.3' into develop
intitni Mar 29, 2024
c407edd
Add suggestion service configuration
intitni Mar 4, 2024
998d413
Update
intitni Mar 21, 2024
7e358e5
Update
intitni Mar 21, 2024
9db5e00
Udate
intitni Mar 27, 2024
d2cd089
Bump version of Swift async algorithms
intitni Apr 2, 2024
c374beb
Update
intitni Apr 2, 2024
c410167
Update
intitni Apr 2, 2024
d0924ae
Merge branch 'feature/passing-relevant-snippets-to-suggestion-service…
intitni Apr 2, 2024
5b88887
Disable snippets from opened file when not needed
intitni Apr 2, 2024
d16d1c7
Pass scenario to highlighter
intitni Apr 3, 2024
d5caace
Support storing codable object in UserDefaults
intitni Apr 4, 2024
6447b3c
Add preference keys for theme
intitni Apr 4, 2024
adaac4f
Apply theme to UI components
intitni Apr 4, 2024
5ca085c
Tweak the behavior of theme change in chat
intitni Apr 4, 2024
1c4f3fe
Merge branch 'feature/xcode-theme' into develop
intitni Apr 4, 2024
7118062
Update
intitni Apr 4, 2024
a77ee20
Update
intitni Apr 4, 2024
efed398
Merge tag '0.32.0.beta' into develop
intitni Apr 4, 2024
2b70557
Display the error description of a language server error in the host app
intitni Apr 5, 2024
7d16b3c
Merge branch 'feature/display-github-copilot-error-in-host-app' into …
intitni Apr 5, 2024
e9b9cd2
Fix typo
intitni Apr 5, 2024
71ce6d5
Lower minimum debounce
intitni Apr 5, 2024
f315e0b
Merge tag 'use-cloudflare-domain-name-for-validation' into develop
intitni Apr 7, 2024
8e11ca2
Add preference keys for fonts
intitni Apr 7, 2024
e9525da
Add font picker
intitni Apr 7, 2024
b8433c1
Support changing code font of suggestion, chat and prompt to code
intitni Apr 7, 2024
abcaaec
Add terminal font preference key
intitni Apr 7, 2024
cef6d05
Merge branch 'feature/font-picker' into develop
intitni Apr 7, 2024
bead740
Merge tag 'fix-auto-check-update-toggle-not-updating' into develop
intitni Apr 7, 2024
d891b79
Update
intitni Apr 7, 2024
40fcb26
Support changing base URL of Google Generative AI
intitni Apr 8, 2024
e02a1f5
Fix endpoint of Google Generative AI
intitni Apr 8, 2024
3e7c947
Merge branch 'feature/google-generative-ai-custom-baseurl' into develop
intitni Apr 8, 2024
d4fb901
Move refreshUpdateTime calls to Workspace
intitni Apr 10, 2024
e6e6eeb
Rename to lastUpdateTime
intitni Apr 10, 2024
44ab963
Make lastUpdateTime publicly readable
intitni Apr 10, 2024
133b659
Support getting int value from AXUIElement
intitni Apr 10, 2024
f873f33
Update
intitni Apr 10, 2024
40c1a1e
Add CloseIdleTabsCommand
intitni Apr 10, 2024
37fde45
Add settings for closing idle tabs
intitni Apr 10, 2024
0b10b54
Update
intitni Apr 10, 2024
630646e
Merge branch 'feature/auto-close-tabs' into develop
intitni Apr 10, 2024
58bb038
Fix default value
intitni Apr 10, 2024
f6c6488
Update to also use title changed event to detect file change
intitni Apr 10, 2024
e17ce5a
Allow all file types to have a filespace
intitni Apr 10, 2024
1eed5bb
Move filespace creation on editor change to Service
intitni Apr 10, 2024
a3f6695
Merge tag '0.32.0.beta.2' into develop
intitni Apr 11, 2024
5fa427e
Fix bugs in idle tab closing
intitni Apr 11, 2024
75f5b0f
Update idle tab closing
intitni Apr 11, 2024
6249d12
Update UI
intitni Apr 14, 2024
47086c6
Support setting Google AI api version
intitni Apr 14, 2024
374194a
Add new OpenAI models
intitni Apr 14, 2024
e49b703
Update idle tab closing
intitni Apr 15, 2024
548d8e3
Update
intitni Apr 15, 2024
a904b59
Bump version
intitni Apr 11, 2024
5627c03
Update appcast.xml
intitni Apr 15, 2024
a8c1bd0
Merge branch 'release/0.32.0'
intitni Apr 15, 2024
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
6 changes: 5 additions & 1 deletion Copilot for Xcode.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
C89E75C32A46FB32000DD64F /* AppDelegate+Menu.swift in Sources */ = {isa = PBXBuildFile; fileRef = C89E75C22A46FB32000DD64F /* AppDelegate+Menu.swift */; };
C8C8B60929AFA35F00034BEE /* CopilotForXcodeExtensionService.app in Embed XPCService */ = {isa = PBXBuildFile; fileRef = C861E60E2994F6070056CB02 /* CopilotForXcodeExtensionService.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
C8DCF00029CE11D500FDDDD7 /* ChatWithSelection.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8DCEFFF29CE11D500FDDDD7 /* ChatWithSelection.swift */; };
C8DD9CB12BC673F80036641C /* CloseIdleTabsCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8DD9CB02BC673F80036641C /* CloseIdleTabsCommand.swift */; };
C8F1032B2A7A39D700D28F4F /* launchAgent.plist in Copy Launch Agent */ = {isa = PBXBuildFile; fileRef = C8F103292A7A365000D28F4F /* launchAgent.plist */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -197,6 +198,7 @@
C89E75C22A46FB32000DD64F /* AppDelegate+Menu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AppDelegate+Menu.swift"; sourceTree = "<group>"; };
C8CD828229B88006008D044D /* TestPlan.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = TestPlan.xctestplan; sourceTree = "<group>"; };
C8DCEFFF29CE11D500FDDDD7 /* ChatWithSelection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatWithSelection.swift; sourceTree = "<group>"; };
C8DD9CB02BC673F80036641C /* CloseIdleTabsCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CloseIdleTabsCommand.swift; sourceTree = "<group>"; };
C8F103292A7A365000D28F4F /* launchAgent.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = launchAgent.plist; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -264,6 +266,7 @@
C800DBB0294C624D00B04CAC /* PrefetchSuggestionsCommand.swift */,
C8758E6F29F04BFF00D29C1C /* CustomCommand.swift */,
C8DCEFFF29CE11D500FDDDD7 /* ChatWithSelection.swift */,
C8DD9CB02BC673F80036641C /* CloseIdleTabsCommand.swift */,
C861A6A229E5503F005C41A3 /* PromptToCodeCommand.swift */,
C81458972939EFDC00135263 /* Info.plist */,
C81458982939EFDC00135263 /* EditorExtension.entitlements */,
Expand Down Expand Up @@ -448,7 +451,7 @@
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1420;
LastSwiftUpdateCheck = 1520;
LastUpgradeCheck = 1410;
TargetAttributes = {
C814588B2939EFDC00135263 = {
Expand Down Expand Up @@ -525,6 +528,7 @@
files = (
C8DCF00029CE11D500FDDDD7 /* ChatWithSelection.swift in Sources */,
C81458942939EFDC00135263 /* SourceEditorExtension.swift in Sources */,
C8DD9CB12BC673F80036641C /* CloseIdleTabsCommand.swift in Sources */,
C8758E7029F04BFF00D29C1C /* CustomCommand.swift in Sources */,
C8758E7229F04CF100D29C1C /* SeparatorCommand.swift in Sources */,
C861A6A329E5503F005C41A3 /* PromptToCodeCommand.swift in Sources */,
Expand Down
6 changes: 4 additions & 2 deletions Core/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ let package = Package(
],
dependencies: [
.package(path: "../Tool"),
.package(url: "https://github.com/apple/swift-async-algorithms", from: "0.1.0"),
.package(url: "https://github.com/apple/swift-async-algorithms", from: "1.0.0"),
.package(url: "https://github.com/gonzalezreal/swift-markdown-ui", from: "2.1.0"),
.package(url: "https://github.com/sparkle-project/Sparkle", from: "2.0.0"),
.package(url: "https://github.com/pointfreeco/swift-parsing", from: "0.12.1"),
Expand All @@ -113,7 +113,9 @@ let package = Package(
.product(name: "SuggestionModel", package: "Tool"),
.product(name: "Logger", package: "Tool"),
.product(name: "Preferences", package: "Tool"),
]
].pro([
"ProClient",
])
),
.target(
name: "Service",
Expand Down
11 changes: 7 additions & 4 deletions Core/Sources/ChatGPTChatTab/ChatPanel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -533,19 +533,22 @@ struct ChatPanel_EmptyChat_Preview: PreviewProvider {

struct ChatCodeSyntaxHighlighter: CodeSyntaxHighlighter {
let brightMode: Bool
let fontSize: Double
let font: NSFont
let colorChange: Color?

init(brightMode: Bool, fontSize: Double) {
init(brightMode: Bool, font: NSFont, colorChange: Color?) {
self.brightMode = brightMode
self.fontSize = fontSize
self.font = font
self.colorChange = colorChange
}

func highlightCode(_ content: String, language: String?) -> Text {
let content = highlightedCodeBlock(
code: content,
language: language ?? "",
scenario: "chat",
brightMode: brightMode,
fontSize: fontSize
font: font
)
return Text(AttributedString(content))
}
Expand Down
100 changes: 92 additions & 8 deletions Core/Sources/ChatGPTChatTab/Styles.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,17 @@ extension View {
.padding(.top, 14)
}

func codeBlockStyle(_ configuration: CodeBlockConfiguration) -> some View {
background(Color(nsColor: .textBackgroundColor).opacity(0.7))
func codeBlockStyle(
_ configuration: CodeBlockConfiguration,
backgroundColor: Color,
labelColor: Color
) -> some View {
background(backgroundColor)
.clipShape(RoundedRectangle(cornerRadius: 6))
.overlay(alignment: .top) {
HStack(alignment: .center) {
Text(configuration.language ?? "code")
.foregroundStyle(.tertiary)
.foregroundStyle(labelColor)
.font(.callout)
.padding(.leading, 8)
.lineLimit(1)
Expand All @@ -63,12 +67,76 @@ extension View {
}
}
}
.overlay {
RoundedRectangle(cornerRadius: 6).stroke(Color.primary.opacity(0.05), lineWidth: 1)
}
.markdownMargin(top: 4, bottom: 16)
}
}

struct ThemedMarkdownText: View {
@AppStorage(\.syncChatCodeHighlightTheme) var syncCodeHighlightTheme
@AppStorage(\.codeForegroundColorLight) var codeForegroundColorLight
@AppStorage(\.codeBackgroundColorLight) var codeBackgroundColorLight
@AppStorage(\.codeForegroundColorDark) var codeForegroundColorDark
@AppStorage(\.codeBackgroundColorDark) var codeBackgroundColorDark
@AppStorage(\.chatFontSize) var chatFontSize
@AppStorage(\.chatCodeFont) var chatCodeFont
@Environment(\.colorScheme) var colorScheme

let text: String

init(_ text: String) {
self.text = text
}

var body: some View {
Markdown(text)
.textSelection(.enabled)
.markdownTheme(.custom(
fontSize: chatFontSize,
codeBlockBackgroundColor: {
if syncCodeHighlightTheme {
if colorScheme == .light, let color = codeBackgroundColorLight.value {
return color.swiftUIColor
} else if let color = codeBackgroundColorDark.value {
return color.swiftUIColor
}
}

return Color(nsColor: .textBackgroundColor).opacity(0.7)
}(),
codeBlockLabelColor: {
if syncCodeHighlightTheme {
if colorScheme == .light,
let color = codeForegroundColorLight.value
{
return color.swiftUIColor.opacity(0.5)
} else if let color = codeForegroundColorDark.value {
return color.swiftUIColor.opacity(0.5)
}
}
return Color.secondary.opacity(0.7)
}()
))
.markdownCodeSyntaxHighlighter(
ChatCodeSyntaxHighlighter(
brightMode: colorScheme != .dark,
font: chatCodeFont.value.nsFont,
colorChange: colorScheme == .dark
? codeForegroundColorDark.value?.swiftUIColor
: codeForegroundColorLight.value?.swiftUIColor
)
)
}
}

extension MarkdownUI.Theme {
static func custom(fontSize: Double) -> MarkdownUI.Theme {
static func custom(
fontSize: Double,
codeBlockBackgroundColor: Color,
codeBlockLabelColor: Color
) -> MarkdownUI.Theme {
.gitHub.text {
ForegroundColor(.primary)
BackgroundColor(Color.clear)
Expand All @@ -80,14 +148,22 @@ extension MarkdownUI.Theme {
if wrapCode {
configuration.label
.codeBlockLabelStyle()
.codeBlockStyle(configuration)
.codeBlockStyle(
configuration,
backgroundColor: codeBlockBackgroundColor,
labelColor: codeBlockLabelColor
)
} else {
ScrollView(.horizontal) {
configuration.label
.codeBlockLabelStyle()
}
.workaroundForVerticalScrollingBugInMacOS()
.codeBlockStyle(configuration)
.codeBlockStyle(
configuration,
backgroundColor: codeBlockBackgroundColor,
labelColor: codeBlockLabelColor
)
}
}
}
Expand All @@ -109,14 +185,22 @@ extension MarkdownUI.Theme {
if wrapCode {
configuration.label
.codeBlockLabelStyle()
.codeBlockStyle(configuration)
.codeBlockStyle(
configuration,
backgroundColor: Color(nsColor: .textBackgroundColor).opacity(0.7),
labelColor: Color.secondary.opacity(0.7)
)
} else {
ScrollView(.horizontal) {
configuration.label
.codeBlockLabelStyle()
}
.workaroundForVerticalScrollingBugInMacOS()
.codeBlockStyle(configuration)
.codeBlockStyle(
configuration,
backgroundColor: Color(nsColor: .textBackgroundColor).opacity(0.7),
labelColor: Color.secondary.opacity(0.7)
)
}
}
.table { configuration in
Expand Down
12 changes: 1 addition & 11 deletions Core/Sources/ChatGPTChatTab/Views/BotMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ struct BotMessage: View {
let references: [DisplayedChatMessage.Reference]
let chat: StoreOf<Chat>
@Environment(\.colorScheme) var colorScheme
@AppStorage(\.chatFontSize) var chatFontSize
@AppStorage(\.chatCodeFontSize) var chatCodeFontSize

@State var isReferencesPresented = false
@State var isReferencesHovered = false
Expand Down Expand Up @@ -45,15 +43,7 @@ struct BotMessage: View {
}
}

Markdown(text)
.textSelection(.enabled)
.markdownTheme(.custom(fontSize: chatFontSize))
.markdownCodeSyntaxHighlighter(
ChatCodeSyntaxHighlighter(
brightMode: colorScheme != .dark,
fontSize: chatCodeFontSize
)
)
ThemedMarkdownText(text)
}
.frame(alignment: .trailing)
.padding()
Expand Down
12 changes: 1 addition & 11 deletions Core/Sources/ChatGPTChatTab/Views/UserMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,9 @@ struct UserMessage: View {
let text: String
let chat: StoreOf<Chat>
@Environment(\.colorScheme) var colorScheme
@AppStorage(\.chatFontSize) var chatFontSize
@AppStorage(\.chatCodeFontSize) var chatCodeFontSize

var body: some View {
Markdown(text)
.textSelection(.enabled)
.markdownTheme(.custom(fontSize: chatFontSize))
.markdownCodeSyntaxHighlighter(
ChatCodeSyntaxHighlighter(
brightMode: colorScheme != .dark,
fontSize: chatCodeFontSize
)
)
ThemedMarkdownText(text)
.frame(alignment: .leading)
.padding()
.background {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import AIModel
import Toast
import ComposableArchitecture
import Dependencies
import Keychain
import OpenAIService
import Preferences
import SwiftUI
import Toast

struct ChatModelEdit: ReducerProtocol {
struct State: Equatable, Identifiable {
Expand All @@ -16,6 +16,7 @@ struct ChatModelEdit: ReducerProtocol {
@BindingState var supportsFunctionCalling: Bool = true
@BindingState var modelName: String = ""
@BindingState var ollamaKeepAlive: String = ""
@BindingState var apiVersion: String = ""
var apiKeyName: String { apiKeySelection.apiKeyName }
var baseURL: String { baseURLSelection.baseURL }
var isFullURL: Bool { baseURLSelection.isFullURL }
Expand Down Expand Up @@ -47,6 +48,7 @@ struct ChatModelEdit: ReducerProtocol {
toast($0, $1, "ChatModelEdit")
}
}

@Dependency(\.apiKeyKeychain) var keychain

var body: some ReducerProtocol<State, Action> {
Expand Down Expand Up @@ -77,19 +79,7 @@ struct ChatModelEdit: ReducerProtocol {
case .testButtonClicked:
guard !state.isTesting else { return .none }
state.isTesting = true
let model = ChatModel(
id: state.id,
name: state.name,
format: state.format,
info: .init(
apiKeyName: state.apiKeyName,
baseURL: state.baseURL,
isFullURL: state.isFullURL,
maxTokens: state.maxTokens,
supportsFunctionCalling: state.supportsFunctionCalling,
modelName: state.modelName
)
)
let model = ChatModel(state: state)
return .run { send in
do {
let service = ChatGPTService(
Expand Down Expand Up @@ -194,6 +184,7 @@ extension ChatModelEdit.State {
supportsFunctionCalling: model.info.supportsFunctionCalling,
modelName: model.info.modelName,
ollamaKeepAlive: model.info.ollamaInfo.keepAlive,
apiVersion: model.info.googleGenerativeAIInfo.apiVersion,
apiKeySelection: .init(
apiKeyName: model.info.apiKeyName,
apiKeyManagement: .init(availableAPIKeyNames: [model.info.apiKeyName])
Expand Down Expand Up @@ -223,7 +214,8 @@ extension ChatModel {
}
}(),
modelName: state.modelName.trimmingCharacters(in: .whitespacesAndNewlines),
ollamaInfo: .init(keepAlive: state.ollamaKeepAlive)
ollamaInfo: .init(keepAlive: state.ollamaKeepAlive),
googleGenerativeAIInfo: .init(apiVersion: state.apiVersion)
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,10 @@ struct ChatModelEditView: View {

@ViewBuilder
var googleAI: some View {
baseURLTextField(prompt: Text("https://generativelanguage.googleapis.com")) {
Text("/v1")
}

apiKeyNamePicker

WithViewStore(
Expand All @@ -353,6 +357,10 @@ struct ChatModelEditView: View {
}

maxTokensTextField

WithViewStore(store, removeDuplicates: { $0.apiVersion == $1.apiVersion }) { viewStore in
TextField("API Version", text: viewStore.$apiVersion, prompt: Text("v1"))
}
}

@ViewBuilder
Expand Down Expand Up @@ -392,7 +400,7 @@ struct ChatModelEditView: View {
baseURLTextField(prompt: Text("https://api.anthropic.com")) {
Text("/v1/messages")
}

apiKeyNamePicker

WithViewStore(
Expand Down Expand Up @@ -421,7 +429,7 @@ struct ChatModelEditView: View {
.frame(width: 20)
}
}

maxTokensTextField

VStack(alignment: .leading, spacing: 8) {
Expand Down
Loading