Skip to content

Commit 37ec23e

Browse files
committed
Add BrowserChatTab
1 parent 891b161 commit 37ec23e

File tree

15 files changed

+67
-12
lines changed

15 files changed

+67
-12
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "Pro"]
2+
path = Pro
3+
url = git@github.com:intitni/CopilotForXcodePro.git

Copilot for Xcode.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@
162162
C861E61F2994F6390056CB02 /* ServiceDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServiceDelegate.swift; sourceTree = "<group>"; };
163163
C8758E6F29F04BFF00D29C1C /* CustomCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomCommand.swift; sourceTree = "<group>"; };
164164
C8758E7129F04CF100D29C1C /* SeparatorCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeparatorCommand.swift; sourceTree = "<group>"; };
165+
C87903302A5D2E6400FE6F42 /* Pro */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = Pro; sourceTree = "<group>"; };
165166
C87B03A3293B24AB00C77EAE /* Copilot-for-Xcode-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = "Copilot-for-Xcode-Info.plist"; sourceTree = SOURCE_ROOT; };
166167
C87B03A4293B261200C77EAE /* AcceptSuggestionCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AcceptSuggestionCommand.swift; sourceTree = "<group>"; };
167168
C87B03A6293B261900C77EAE /* RejectSuggestionCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RejectSuggestionCommand.swift; sourceTree = "<group>"; };
@@ -257,6 +258,7 @@
257258
C83E3F3E2A38C66D0071506D /* Python */,
258259
C81D181E2A1B509B006C1B70 /* Tool */,
259260
C8189B282938979000C9DCDA /* Core */,
261+
C87903302A5D2E6400FE6F42 /* Pro */,
260262
C8189B182938972F00C9DCDA /* Copilot for Xcode */,
261263
C81458922939EFDC00135263 /* EditorExtension */,
262264
C8216B71298036EC00AD38C7 /* Helper */,

Core/Package.swift

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ let package = Package(
5656
url: "https://github.com/pointfreeco/swift-composable-architecture",
5757
from: "0.55.0"
5858
),
59-
],
59+
].pro,
6060
targets: [
6161
// MARK: - Main
6262

@@ -88,7 +88,8 @@ let package = Package(
8888
"PromptToCodeService",
8989
"ServiceUpdateMigration",
9090
"UserDefaultsObserver",
91-
"ChatTab",
91+
"ChatGPTChatTab",
92+
.product(name: "ChatTab", package: "Tool"),
9293
.product(name: "Logger", package: "Tool"),
9394
.product(name: "OpenAIService", package: "Tool"),
9495
.product(name: "Preferences", package: "Tool"),
@@ -223,12 +224,13 @@ let package = Package(
223224
),
224225

225226
.target(
226-
name: "ChatTab",
227+
name: "ChatGPTChatTab",
227228
dependencies: [
228229
"SharedUIComponents",
229230
"ChatService",
230231
.product(name: "OpenAIService", package: "Tool"),
231232
.product(name: "Logger", package: "Tool"),
233+
.product(name: "ChatTab", package: "Tool"),
232234
.product(name: "MarkdownUI", package: "swift-markdown-ui"),
233235
]
234236
),
@@ -248,13 +250,14 @@ let package = Package(
248250
.target(
249251
name: "SuggestionWidget",
250252
dependencies: [
251-
"ChatTab",
253+
"ChatGPTChatTab",
252254
"ActiveApplicationMonitor",
253255
"AXNotificationStream",
254256
"Environment",
255257
"UserDefaultsObserver",
256258
"XcodeInspector",
257259
"SharedUIComponents",
260+
.product(name: "ChatTab", package: "Tool"),
258261
.product(name: "Logger", package: "Tool"),
259262
.product(name: "AsyncAlgorithms", package: "swift-async-algorithms"),
260263
.product(name: "MarkdownUI", package: "swift-markdown-ui"),
@@ -391,3 +394,34 @@ let package = Package(
391394
]
392395
)
393396

397+
// MARK: - Pro
398+
399+
extension [Target.Dependency] {
400+
func pro(_ targetNames: [String]) -> [Target.Dependency] {
401+
if isProIncluded() {
402+
return self + targetNames.map { Target.Dependency.product(name: $0, package: "Pro") }
403+
}
404+
return self
405+
}
406+
}
407+
408+
extension [Package.Dependency] {
409+
var pro: [Package.Dependency] {
410+
if isProIncluded() {
411+
return self + [.package(path: "../Pro")]
412+
}
413+
return self
414+
}
415+
}
416+
417+
import Foundation
418+
419+
func isProIncluded(file: StaticString = #file) -> Bool {
420+
let filePath = "\(file)"
421+
let url = URL(fileURLWithPath: filePath)
422+
.deletingLastPathComponent()
423+
.deletingLastPathComponent()
424+
.appendingPathComponent("Pro/Package.swift")
425+
return FileManager.default.fileExists(atPath: url.path)
426+
}
427+

Core/Sources/ChatTab/ChatGPT/ChatGPTChatTab.swift renamed to Core/Sources/ChatGPTChatTab/ChatGPTChatTab.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import ChatService
2+
import ChatTab
23
import Combine
34
import Foundation
45
import SwiftUI
@@ -17,7 +18,7 @@ public class ChatGPTChatTab: ChatTab {
1718
self.service = service
1819
provider = .init(service: service)
1920
super.init(id: "Chat-" + provider.id.uuidString, title: "Chat")
20-
21+
2122
provider.$history.sink { [weak self] _ in
2223
if let title = self?.provider.title {
2324
self?.title = title
File renamed without changes.
File renamed without changes.

Core/Sources/Service/GUI/GraphicalUserInterfaceController.swift.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import AppKit
2+
import ChatGPTChatTab
23
import ChatTab
34
import ComposableArchitecture
45
import Environment

Core/Sources/Service/GUI/WidgetDataSource.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import ActiveApplicationMonitor
22
import ChatService
3-
import ChatTab
43
import ComposableArchitecture
54
import Foundation
65
import GitHubCopilotService

Core/Sources/SuggestionWidget/ChatWindowView.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import ActiveApplicationMonitor
22
import AppKit
3+
import ChatGPTChatTab
34
import ChatTab
45
import ComposableArchitecture
56
import SwiftUI
@@ -31,9 +32,9 @@ struct ChatWindowView: View {
3132
.fill(.tertiary)
3233
.frame(width: 120, height: 4)
3334
.frame(height: 16)
34-
35+
3536
Divider()
36-
37+
3738
ChatTabBar(store: store)
3839
.frame(height: 26)
3940

@@ -50,7 +51,7 @@ struct ChatWindowView: View {
5051
}
5152
.opacity(0)
5253
.keyboardShortcut("M", modifiers: [.command])
53-
54+
5455
Button(action: {
5556
viewStore.send(.closeActiveTabClicked)
5657
}) {

0 commit comments

Comments
 (0)