Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions Core/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ let package = Package(
extension [Target.Dependency] {
func pro(_ targetNames: [String]) -> [Target.Dependency] {
if isProIncluded() {
// include the pro package
return self + targetNames.map { Target.Dependency.product(name: $0, package: "Pro") }
}
return self
Expand All @@ -391,6 +392,7 @@ extension [Target.Dependency] {
extension [Package.Dependency] {
var pro: [Package.Dependency] {
if isProIncluded() {
// include the pro package
return self + [.package(path: "../Pro")]
}
return self
Expand Down
7 changes: 2 additions & 5 deletions Core/Sources/GitHubCopilotService/GitHubCopilotService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ public class GitHubCopilotBaseService {
self.projectRootURL = projectRootURL
let (server, localServer) = try {
let urls = try GitHubCopilotBaseService.createFoldersIfNeeded()
var userEnvPath = ProcessInfo.processInfo.userEnvironment["PATH"] ?? ""
if userEnvPath.isEmpty {
userEnvPath = "/usr/bin:/usr/local/bin" // fallback
}
let executionParams: Process.ExecutionParameters
let runner = UserDefaults.shared.value(for: \.runNodeWith)

Expand All @@ -95,7 +91,7 @@ public class GitHubCopilotBaseService {
)
}()
case .shell:
let shell = ProcessInfo.processInfo.userEnvironment["SHELL"] ?? "/bin/bash"
let shell = ProcessInfo.processInfo.shellExecutablePath
let nodePath = UserDefaults.shared.value(for: \.nodePath)
let command = [
nodePath.isEmpty ? "node" : nodePath,
Expand All @@ -111,6 +107,7 @@ public class GitHubCopilotBaseService {
)
}()
case .env:
let userEnvPath = "/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
executionParams = {
let nodePath = UserDefaults.shared.value(for: \.nodePath)
return Process.ExecutionParameters(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,13 @@ struct GUI: ReducerProtocol {
Reduce { state, action in
switch action {
case .start:
#if canImport(ChatTabPersistent)
return .run { send in
#if canImport(ChatTabPersistent)
await send(.persistent(.restoreChatTabs))
#endif
}
#else
return .none
#endif

case let .openChatPanel(forceDetach):
return .run { send in
Expand Down
10 changes: 9 additions & 1 deletion Core/Sources/Service/Service.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Foundation
#if canImport(KeyBindingManager)
import KeyBindingManager
#endif
import Workspace

@globalActor public enum ServiceActor {
Expand All @@ -24,10 +26,13 @@ public final class Service {
public let guiController = GraphicalUserInterfaceController()
public let realtimeSuggestionController = RealtimeSuggestionController()
public let scheduledCleaner: ScheduledCleaner
#if canImport(KeyBindingManager)
let keyBindingManager: KeyBindingManager
#endif

private init() {
scheduledCleaner = .init(workspacePool: workspacePool, guiController: guiController)
#if canImport(KeyBindingManager)
keyBindingManager = .init(
workspacePool: workspacePool,
acceptSuggestion: {
Expand All @@ -36,14 +41,17 @@ public final class Service {
}
}
)
#endif
}

@MainActor
public func start() {
scheduledCleaner.start()
realtimeSuggestionController.start()
guiController.start()
#if canImport(KeyBindingManager)
keyBindingManager.start()
#endif
DependencyUpdater().update()
}
}
Expand Down
22 changes: 11 additions & 11 deletions Core/Tests/ServiceTests/FilespaceSuggestionInvalidationTests.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Foundation
import SuggestionModel
import Workspace
import XCTest

@testable import Workspace
@testable import Service

class FilespaceSuggestionInvalidationTests: XCTestCase {
Expand Down Expand Up @@ -33,7 +33,7 @@ class FilespaceSuggestionInvalidationTests: XCTestCase {
cursorPosition: .init(line: 1, character: 4)
)
XCTAssertTrue(isValid)
let suggestion = await filespace.presentingSuggestion
let suggestion = filespace.presentingSuggestion
XCTAssertNotNil(suggestion)
}

Expand All @@ -47,7 +47,7 @@ class FilespaceSuggestionInvalidationTests: XCTestCase {
cursorPosition: .init(line: 1, character: 4)
)
XCTAssertTrue(isValid)
let suggestion = await filespace.presentingSuggestion
let suggestion = filespace.presentingSuggestion
XCTAssertNotNil(suggestion)
}

Expand All @@ -61,7 +61,7 @@ class FilespaceSuggestionInvalidationTests: XCTestCase {
cursorPosition: .init(line: 2, character: 0)
)
XCTAssertFalse(isValid)
let suggestion = await filespace.presentingSuggestion
let suggestion = filespace.presentingSuggestion
XCTAssertNil(suggestion)
}

Expand All @@ -75,7 +75,7 @@ class FilespaceSuggestionInvalidationTests: XCTestCase {
cursorPosition: .init(line: 100, character: 4)
)
XCTAssertFalse(isValid)
let suggestion = await filespace.presentingSuggestion
let suggestion = filespace.presentingSuggestion
XCTAssertNil(suggestion)
}

Expand All @@ -89,7 +89,7 @@ class FilespaceSuggestionInvalidationTests: XCTestCase {
cursorPosition: .init(line: 1, character: 4)
)
XCTAssertFalse(isValid)
let suggestion = await filespace.presentingSuggestion
let suggestion = filespace.presentingSuggestion
XCTAssertNil(suggestion)
}

Expand All @@ -103,7 +103,7 @@ class FilespaceSuggestionInvalidationTests: XCTestCase {
cursorPosition: .init(line: 1, character: 100)
)
XCTAssertFalse(isValid)
let suggestion = await filespace.presentingSuggestion
let suggestion = filespace.presentingSuggestion
XCTAssertNil(suggestion)
}

Expand All @@ -117,7 +117,7 @@ class FilespaceSuggestionInvalidationTests: XCTestCase {
cursorPosition: .init(line: 1, character: 9)
)
XCTAssertFalse(isValid)
let suggestion = await filespace.presentingSuggestion
let suggestion = filespace.presentingSuggestion
XCTAssertNil(suggestion)
}

Expand All @@ -132,7 +132,7 @@ class FilespaceSuggestionInvalidationTests: XCTestCase {
cursorPosition: .init(line: 1, character: 9)
)
XCTAssertFalse(isValid)
let suggestion = await filespace.presentingSuggestion
let suggestion = filespace.presentingSuggestion
XCTAssertNil(suggestion)
}

Expand All @@ -146,7 +146,7 @@ class FilespaceSuggestionInvalidationTests: XCTestCase {
cursorPosition: .init(line: 1, character: 9)
)
XCTAssertTrue(isValid)
let suggestion = await filespace.presentingSuggestion
let suggestion = filespace.presentingSuggestion
XCTAssertNotNil(suggestion)
}

Expand All @@ -161,7 +161,7 @@ class FilespaceSuggestionInvalidationTests: XCTestCase {
cursorPosition: .init(line: 1, character: 4)
)
XCTAssertFalse(isValid)
let suggestion = await filespace.presentingSuggestion
let suggestion = filespace.presentingSuggestion
XCTAssertNil(suggestion)
}
}
Expand Down
1 change: 1 addition & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Most of the logics are implemented inside the package `Core` and `Tool`.

1. Update the xcconfig files, launchAgent.plist, and Tool/Configs/Configurations.swift.
2. Build or archive the Copilot for Xcode target.
3. If Xcode complains that the pro package doesn't exist, please remove the package from the project, and update the last function in Core/Package.swift to return false.

## Testing Extension

Expand Down
2 changes: 1 addition & 1 deletion Tool/Sources/Workspace/Filespace.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public final class Filespace {
public let fileURL: URL
public private(set) lazy var language: String = languageIdentifierFromFileURL(fileURL).rawValue
public var codeMetadata: FilespaceCodeMetadata = .init()
public private(set) var suggestions: [CodeSuggestion] = [] {
public internal(set) var suggestions: [CodeSuggestion] = [] {
didSet { refreshUpdateTime() }
}

Expand Down