Skip to content

Commit 01a6f16

Browse files
committed
Merge tag '0.30.3' into develop
2 parents aabd765 + e7324cc commit 01a6f16

11 files changed

Lines changed: 97 additions & 60 deletions

File tree

Core/Sources/HostApp/AccountSettings/ChatModelManagement/ChatModelEditView.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ struct ChatModelEditView: View {
216216
@ViewBuilder
217217
var openAI: some View {
218218
baseURLTextField(prompt: Text("https://api.openai.com")) {
219-
Text("/v1/chat/completion")
219+
Text("/v1/chat/completions")
220220
}
221221
apiKeyNamePicker
222222

@@ -294,11 +294,11 @@ struct ChatModelEditView: View {
294294
baseURLTextField(
295295
title: "",
296296
prompt: viewStore.state
297-
? Text("https://api.openai.com/v1/chat/completion")
297+
? Text("https://api.openai.com/v1/chat/completions")
298298
: Text("https://api.openai.com")
299299
) {
300300
if !viewStore.state {
301-
Text("/v1/chat/completion")
301+
Text("/v1/chat/completions")
302302
}
303303
}
304304
}

Core/Sources/SuggestionWidget/FeatureReducers/WidgetFeature.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,10 @@ public struct WidgetFeature: ReducerProtocol {
238238

239239
case .observeActiveApplicationChange:
240240
return .run { send in
241-
let stream = AsyncStream<NSRunningApplication> { continuation in
241+
let stream = AsyncStream<AppInstanceInspector> { continuation in
242242
let cancellable = xcodeInspector.$activeApplication.sink { newValue in
243243
guard let newValue else { return }
244-
continuation.yield(newValue.runningApplication)
244+
continuation.yield(newValue)
245245
}
246246
continuation.onTermination = { _ in
247247
cancellable.cancel()
@@ -293,7 +293,7 @@ public struct WidgetFeature: ReducerProtocol {
293293
guard let activeXcode = xcodeInspector.activeXcode else { continue }
294294
guard await windows.fullscreenDetector.isOnActiveSpace else { continue }
295295
let app = AXUIElementCreateApplication(
296-
activeXcode.runningApplication.processIdentifier
296+
activeXcode.processIdentifier
297297
)
298298
if let _ = app.focusedWindow {
299299
await windows.orderFront()
@@ -538,7 +538,7 @@ public struct WidgetFeature: ReducerProtocol {
538538
let task = Task { @MainActor in
539539
if let activeApp, activeApp.isXcode {
540540
let application = AXUIElementCreateApplication(
541-
activeApp.runningApplication.processIdentifier
541+
activeApp.processIdentifier
542542
)
543543
/// We need this to hide the windows when Xcode is minimized.
544544
let noFocus = application.focusedWindow == nil

ExtensionService/AppDelegate+Menu.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ extension AppDelegate: NSMenuDelegate {
164164

165165
for xcode in inspector.xcodes {
166166
let item = NSMenuItem(
167-
title: "Xcode \(xcode.runningApplication.processIdentifier)",
167+
title: "Xcode \(xcode.processIdentifier)",
168168
action: nil,
169169
keyEquivalent: ""
170170
)

Pro

Submodule Pro updated from 576da60 to 4059899

Tool/Sources/AppActivator/AppActivator.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ public extension NSWorkspace {
3131
Task { @MainActor in
3232
guard let app = XcodeInspector.shared.previousActiveApplication else { return }
3333
try await Task.sleep(nanoseconds: UInt64(delay * 1_000_000_000))
34-
app.runningApplication.activate()
34+
app.activate()
3535
}
3636
}
3737

3838
static func activatePreviousActiveXcode(delay: TimeInterval = 0.2) {
3939
Task { @MainActor in
4040
guard let app = XcodeInspector.shared.latestActiveXcode else { return }
4141
try await Task.sleep(nanoseconds: UInt64(delay * 1_000_000_000))
42-
app.runningApplication.activate()
42+
app.activate()
4343
}
4444
}
4545
}
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
import Foundation
22

3+
private var teamIDPrefix: String {
4+
Bundle.main.infoDictionary?["TEAM_ID_PREFIX"] as? String ?? ""
5+
}
6+
7+
private var bundleIdentifierBase: String {
8+
Bundle.main.infoDictionary?["BUNDLE_IDENTIFIER_BASE"] as? String ?? ""
9+
}
10+
311
public var userDefaultSuiteName: String {
4-
"5YKZ4Y3DAW.group.com.intii.CopilotForXcode"
12+
"\(teamIDPrefix)group.\(bundleIdentifierBase)"
513
}
614

715
public var keychainAccessGroup: String {
8-
#if DEBUG
9-
return "5YKZ4Y3DAW.dev.com.intii.CopilotForXcode.Shared"
10-
#else
11-
return "5YKZ4Y3DAW.com.intii.CopilotForXcode.Shared"
12-
#endif
16+
return "\(teamIDPrefix)\(bundleIdentifierBase).Shared"
1317
}
1418

1519
public var keychainService: String {
16-
#if DEBUG
17-
return "dev.com.intii.CopilotForXcode"
18-
#else
19-
return "com.intii.CopilotForXcode"
20-
#endif
20+
return bundleIdentifierBase
2121
}
2222

Tool/Sources/XcodeInspector/AppInstanceInspector.swift

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,43 @@ import AppKit
22
import Foundation
33

44
public class AppInstanceInspector: ObservableObject {
5+
let runningApplication: NSRunningApplication
6+
public let processIdentifier: pid_t
7+
public let bundleURL: URL?
8+
public let bundleIdentifier: String?
9+
510
public var appElement: AXUIElement {
6-
AXUIElementCreateApplication(runningApplication.processIdentifier)
11+
return AXUIElementCreateApplication(runningApplication.processIdentifier)
12+
}
13+
14+
public var isTerminated: Bool {
15+
return runningApplication.isTerminated
16+
}
17+
18+
public var isActive: Bool {
19+
guard !runningApplication.isTerminated else { return false }
20+
return runningApplication.isActive
21+
}
22+
23+
public var isXcode: Bool {
24+
guard !runningApplication.isTerminated else { return false }
25+
return runningApplication.isXcode
26+
}
27+
28+
public var isExtensionService: Bool {
29+
guard !runningApplication.isTerminated else { return false }
30+
return runningApplication.isCopilotForXcodeExtensionService
31+
}
32+
33+
public func activate() -> Bool {
34+
return runningApplication.activate()
735
}
8-
public let runningApplication: NSRunningApplication
9-
public var isActive: Bool { runningApplication.isActive }
10-
public var isXcode: Bool { runningApplication.isXcode }
11-
public var isExtensionService: Bool { runningApplication.isCopilotForXcodeExtensionService }
1236

1337
init(runningApplication: NSRunningApplication) {
1438
self.runningApplication = runningApplication
39+
processIdentifier = runningApplication.processIdentifier
40+
bundleURL = runningApplication.bundleURL
41+
bundleIdentifier = runningApplication.bundleIdentifier
1542
}
1643
}
1744

Tool/Sources/XcodeInspector/Apps/XcodeAppInstanceInspector.swift

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -162,34 +162,32 @@ public final class XcodeAppInstanceInspector: AppInstanceInspector {
162162
)
163163
focusedWindow = window
164164

165-
// should find a better solution to do this thread safe
166-
Task { @MainActor in
167-
focusedWindowObservations.forEach { $0.cancel() }
168-
focusedWindowObservations.removeAll()
169-
170-
documentURL = window.documentURL
171-
workspaceURL = window.workspaceURL
172-
projectRootURL = window.projectRootURL
173-
174-
window.$documentURL
175-
.filter { $0 != .init(fileURLWithPath: "/") }
176-
.receive(on: DispatchQueue.main)
177-
.sink { [weak self] url in
178-
self?.documentURL = url
179-
}.store(in: &focusedWindowObservations)
180-
window.$workspaceURL
181-
.filter { $0 != .init(fileURLWithPath: "/") }
182-
.receive(on: DispatchQueue.main)
183-
.sink { [weak self] url in
184-
self?.workspaceURL = url
185-
}.store(in: &focusedWindowObservations)
186-
window.$projectRootURL
187-
.filter { $0 != .init(fileURLWithPath: "/") }
188-
.receive(on: DispatchQueue.main)
189-
.sink { [weak self] url in
190-
self?.projectRootURL = url
191-
}.store(in: &focusedWindowObservations)
192-
}
165+
focusedWindowObservations.forEach { $0.cancel() }
166+
focusedWindowObservations.removeAll()
167+
168+
documentURL = window.documentURL
169+
workspaceURL = window.workspaceURL
170+
projectRootURL = window.projectRootURL
171+
172+
window.$documentURL
173+
.filter { $0 != .init(fileURLWithPath: "/") }
174+
.receive(on: DispatchQueue.main)
175+
.sink { [weak self] url in
176+
self?.documentURL = url
177+
}.store(in: &focusedWindowObservations)
178+
window.$workspaceURL
179+
.filter { $0 != .init(fileURLWithPath: "/") }
180+
.receive(on: DispatchQueue.main)
181+
.sink { [weak self] url in
182+
self?.workspaceURL = url
183+
}.store(in: &focusedWindowObservations)
184+
window.$projectRootURL
185+
.filter { $0 != .init(fileURLWithPath: "/") }
186+
.receive(on: DispatchQueue.main)
187+
.sink { [weak self] url in
188+
self?.projectRootURL = url
189+
}.store(in: &focusedWindowObservations)
190+
193191
} else {
194192
let window = XcodeWindowInspector(uiElement: window)
195193
focusedWindow = window

Tool/Sources/XcodeInspector/XcodeInspector.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public final class XcodeInspector: ObservableObject {
122122
appChangeObservations.forEach { $0.cancel() }
123123
appChangeObservations.removeAll()
124124

125-
let appChangeTask = Task { [weak self] in
125+
let appChangeTask = Task(priority: .utility) { [weak self] in
126126
guard let self else { return }
127127
if let activeXcode {
128128
await setActiveXcode(activeXcode)
@@ -140,7 +140,7 @@ public final class XcodeInspector: ObservableObject {
140140
else { continue }
141141
if app.isXcode {
142142
if let existed = xcodes.first(where: {
143-
$0.runningApplication.processIdentifier == app.processIdentifier
143+
$0.processIdentifier == app.processIdentifier && !$0.isTerminated
144144
}) {
145145
await MainActor.run {
146146
self.setActiveXcode(existed)
@@ -175,7 +175,7 @@ public final class XcodeInspector: ObservableObject {
175175
let processIdentifier = app.processIdentifier
176176
await MainActor.run {
177177
self.xcodes.removeAll {
178-
$0.runningApplication.processIdentifier == processIdentifier
178+
$0.processIdentifier == processIdentifier || $0.isTerminated
179179
}
180180
if self.latestActiveXcode?.runningApplication
181181
.processIdentifier == processIdentifier

Version.xcconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
APP_VERSION = 0.30.2
2-
APP_BUILD = 314
1+
APP_VERSION = 0.30.3
2+
APP_BUILD = 316
33

0 commit comments

Comments
 (0)