Skip to content

Commit

Permalink
Merge branch 'release/0.33.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
intitni committed Jun 17, 2024
2 parents b006fa8 + de452b5 commit 4d83f2b
Show file tree
Hide file tree
Showing 60 changed files with 1,550 additions and 473 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# IDE
.idea

# Created by
https://www.toptal.com/developers/gitignore/api/xcode,macos,swift,swiftpackagemanager
# Edit at
Expand Down
9 changes: 7 additions & 2 deletions CommunicationBridge/main.swift
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import AppKit
import Foundation

class AppDelegate: NSObject, NSApplicationDelegate {}

let bundleIdentifierBase = Bundle(url: Bundle.main.bundleURL.appendingPathComponent(
"CopilotForXcodeExtensionService.app"
))?.object(forInfoDictionaryKey: "BUNDLE_IDENTIFIER_BASE") as? String ?? "com.intii.CopilotForXcode"

let serviceIdentifier = bundleIdentifierBase + ".CommunicationBridge"

let appDelegate = AppDelegate()
let delegate = ServiceDelegate()
let listener = NSXPCListener(machServiceName: serviceIdentifier)
listener.delegate = delegate
listener.resume()
RunLoop.main.run()
let app = NSApplication.shared
app.delegate = appDelegate
app.run()

12 changes: 12 additions & 0 deletions Copilot for Xcode.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,7 @@
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = "$(APP_BUILD)";
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = 5YKZ4Y3DAW;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = EditorExtension/Info.plist;
Expand Down Expand Up @@ -800,6 +801,7 @@
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = "$(APP_BUILD)";
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = 5YKZ4Y3DAW;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = EditorExtension/Info.plist;
Expand Down Expand Up @@ -854,9 +856,11 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
Expand Down Expand Up @@ -915,9 +919,11 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand Down Expand Up @@ -945,6 +951,7 @@
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = "$(APP_BUILD)";
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"Copilot for Xcode/Preview Content\"";
DEVELOPMENT_TEAM = 5YKZ4Y3DAW;
ENABLE_HARDENED_RUNTIME = YES;
Expand Down Expand Up @@ -977,6 +984,7 @@
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = "$(APP_BUILD)";
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"Copilot for Xcode/Preview Content\"";
DEVELOPMENT_TEAM = 5YKZ4Y3DAW;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -1002,6 +1010,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = 5YKZ4Y3DAW;
ENABLE_HARDENED_RUNTIME = YES;
MACOSX_DEPLOYMENT_TARGET = 12.0;
Expand All @@ -1015,6 +1024,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = 5YKZ4Y3DAW;
ENABLE_HARDENED_RUNTIME = YES;
MACOSX_DEPLOYMENT_TARGET = 12.0;
Expand All @@ -1033,6 +1043,7 @@
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = "$(APP_BUILD)";
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = 5YKZ4Y3DAW;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
Expand Down Expand Up @@ -1065,6 +1076,7 @@
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = "$(APP_BUILD)";
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = 5YKZ4Y3DAW;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1410"
LastUpgradeVersion = "1520"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1410"
LastUpgradeVersion = "1520"
wasCreatedForAppExtension = "YES"
version = "2.0">
<BuildAction
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1420"
LastUpgradeVersion = "1520"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
55 changes: 41 additions & 14 deletions Copilot for Xcode.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
"version" : "1.0.2"
}
},
{
"identity" : "generative-ai-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/google/generative-ai-swift",
"state" : {
"revision" : "f4a88085d5a6c1108f5a1aead83d19d02df8328d",
"version" : "0.4.9"
}
},
{
"identity" : "glob",
"kind" : "remoteSourceControl",
Expand Down Expand Up @@ -54,6 +63,15 @@
"version" : "0.6.0"
}
},
{
"identity" : "keyboardshortcuts",
"kind" : "remoteSourceControl",
"location" : "https://github.com/intitni/KeyboardShortcuts",
"state" : {
"branch" : "main",
"revision" : "65fb410b0c6d3ed96623b460bab31ffce5f48b4d"
}
},
{
"identity" : "languageclient",
"kind" : "remoteSourceControl",
Expand Down Expand Up @@ -99,6 +117,24 @@
"version" : "2.4.2"
}
},
{
"identity" : "sttextkitplus",
"kind" : "remoteSourceControl",
"location" : "https://github.com/krzyzanowskim/STTextKitPlus",
"state" : {
"revision" : "a57a2081e364c71b11e521ed8800481e8da300ac",
"version" : "0.1.0"
}
},
{
"identity" : "sttextview",
"kind" : "remoteSourceControl",
"location" : "https://github.com/krzyzanowskim/STTextView",
"state" : {
"revision" : "e9e54718b882115db69ec1e17ac1bec844906cd9",
"version" : "0.9.0"
}
},
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
Expand Down Expand Up @@ -203,8 +239,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-syntax.git",
"state" : {
"branch" : "main",
"revision" : "aa3b1e187c9cc568f9d1abc47feb11f6b044d284"
"revision" : "6ad4ea24b01559dde0773e3d091f1b9e36175036",
"version" : "509.0.2"
}
},
{
Expand All @@ -219,10 +255,10 @@
{
"identity" : "swifttreesitter",
"kind" : "remoteSourceControl",
"location" : "https://github.com/ChimeHQ/SwiftTreeSitter",
"location" : "https://github.com/intitni/SwiftTreeSitter.git",
"state" : {
"revision" : "df25a52f72ebc5b50ae20d26d1363793408bb28b",
"version" : "0.7.1"
"branch" : "main",
"revision" : "fd499bfafcccfae12a1a579dc922d8418025a35d"
}
},
{
Expand Down Expand Up @@ -252,15 +288,6 @@
"revision" : "1b54ef0b5efddddf393b45e173788499cc572048"
}
},
{
"identity" : "tree-sitter-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/alex-pinkus/tree-sitter-swift",
"state" : {
"branch" : "with-generated-files",
"revision" : "eda05af7ac41adb4eb19c346883c0fa32fe3bdd8"
}
},
{
"identity" : "usearch",
"kind" : "remoteSourceControl",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1410"
LastUpgradeVersion = "1520"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1410"
LastUpgradeVersion = "1520"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
20 changes: 20 additions & 0 deletions Core/Sources/ChatGPTChatTab/Chat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ struct Chat {
var isReceivingMessage = false
var chatMenu = ChatMenu.State()
var focusedField: Field?
var isEnabled = true
var isPinnedToBottom = true

enum Field: String, Hashable {
case textField
Expand All @@ -77,13 +79,16 @@ struct Chat {

case appear
case refresh
case setIsEnabled(Bool)
case sendButtonTapped
case returnButtonTapped
case stopRespondingButtonTapped
case clearButtonTap
case deleteMessageButtonTapped(MessageID)
case resendMessageButtonTapped(MessageID)
case setAsExtraPromptButtonTapped(MessageID)
case manuallyScrolledUp
case scrollToBottomButtonTapped
case focusOnTextField
case referenceClicked(DisplayedChatMessage.Reference)

Expand Down Expand Up @@ -143,6 +148,10 @@ struct Chat {
await send(.chatMenu(.refresh))
}

case let .setIsEnabled(isEnabled):
state.isEnabled = isEnabled
return .none

case .sendButtonTapped:
guard !state.typedMessage.isEmpty else { return .none }
let message = state.typedMessage
Expand Down Expand Up @@ -204,6 +213,14 @@ struct Chat {
await openURL(url)
}
}

case .manuallyScrolledUp:
state.isPinnedToBottom = false
return .none

case .scrollToBottomButtonTapped:
state.isPinnedToBottom = true
return .none

case .focusOnTextField:
state.focusedField = .textField
Expand Down Expand Up @@ -365,6 +382,9 @@ struct Chat {

case .isReceivingMessageChanged:
state.isReceivingMessage = service.isReceivingMessage
if service.isReceivingMessage {
state.isPinnedToBottom = true
}
return .none

case .systemPromptChanged:
Expand Down
11 changes: 6 additions & 5 deletions Core/Sources/ChatGPTChatTab/ChatGPTChatTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ public class ChatGPTChatTab: ChatTab {
return (try? JSONEncoder().encode(state)) ?? Data()
}

public static func restore(
from data: Data,
externalDependency: Void
) async throws -> any ChatTabBuilder {
public static func restore(from data: Data) async throws -> any ChatTabBuilder {
let state = try JSONDecoder().decode(RestorableState.self, from: data)
let builder = Builder(title: "Chat") { @MainActor tab in
tab.service.configuration.overriding = state.configuration
Expand All @@ -96,7 +93,7 @@ public class ChatGPTChatTab: ChatTab {
return builder
}

public static func chatBuilders(externalDependency: Void) -> [ChatTabBuilder] {
public static func chatBuilders() -> [ChatTabBuilder] {
let customCommands = UserDefaults.shared.value(for: \.customCommands).compactMap {
command in
if case .customChat = command.feature {
Expand All @@ -107,6 +104,10 @@ public class ChatGPTChatTab: ChatTab {

return [Builder(title: "New Chat", customCommand: nil)] + customCommands
}

public static func defaultBuilder() -> ChatTabBuilder {
Builder(title: "New Chat", customCommand: nil)
}

@MainActor
public init(service: ChatService = .init(), store: StoreOf<ChatTabItem>) {
Expand Down
Loading

0 comments on commit 4d83f2b

Please sign in to comment.