Skip to content

Commit 65dc134

Browse files
committed
Pre-release 0.41.136
1 parent 1339ef7 commit 65dc134

File tree

63 files changed

+1816
-211
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1816
-211
lines changed

Core/Sources/ChatService/ChatService.swift

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public final class ChatService: ChatServiceType, ObservableObject {
9090
@Published public internal(set) var isReceivingMessage = false
9191
@Published public internal(set) var fileEditMap: OrderedDictionary<URL, FileEdit> = [:]
9292
public internal(set) var requestType: RequestType? = nil
93-
public let chatTabInfo: ChatTabInfo
93+
public private(set) var chatTabInfo: ChatTabInfo
9494
private let conversationProvider: ConversationServiceProvider?
9595
private let conversationProgressHandler: ConversationProgressHandler
9696
private let conversationContextHandler: ConversationContextHandler = ConversationContextHandlerImpl.shared
@@ -131,6 +131,11 @@ public final class ChatService: ChatServiceType, ObservableObject {
131131
// Memory will be deallocated automatically
132132
}
133133

134+
public func updateChatTabInfo(_ tabInfo: ChatTabInfo) {
135+
// Only isSelected need to be updated
136+
chatTabInfo.isSelected = tabInfo.isSelected
137+
}
138+
134139
private func subscribeToNotifications() {
135140
memory.observeHistoryChange { [weak self] in
136141
Task { [weak self] in
@@ -643,7 +648,7 @@ public final class ChatService: ChatServiceType, ObservableObject {
643648
return URL(fileURLWithPath: chatTabInfo.workspacePath)
644649
}
645650

646-
private func getProjectRootURL() async throws -> URL? {
651+
public func getProjectRootURL() -> URL? {
647652
guard let workspaceURL = getWorkspaceURL() else { return nil }
648653
return WorkspaceXcodeWindowInspector.extractProjectURL(
649654
workspaceURL: workspaceURL,
@@ -989,8 +994,6 @@ public final class SharedChatService {
989994
}
990995

991996
public func loadChatTemplates() async -> [ChatTemplate]? {
992-
guard self.chatTemplates == nil else { return self.chatTemplates }
993-
994997
do {
995998
if let templates = (try await conversationProvider?.templates()) {
996999
self.chatTemplates = templates
@@ -1163,7 +1166,7 @@ extension ChatService {
11631166
)
11641167
await memory.appendMessage(initialBotMessage)
11651168

1166-
guard let projectRootURL = try await getProjectRootURL()
1169+
guard let projectRootURL = getProjectRootURL()
11671170
else {
11681171
let round = CodeReviewRound.fromError(turnId: turnId, error: "Invalid git repository.")
11691172
await appendCodeReviewRound(round)

Core/Sources/ChatService/Skills/CurrentEditorSkill.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,27 @@ public class CurrentEditorSkill: ConversationSkill {
3636

3737
public func resolveSkill(request: ConversationContextRequest, completion: JSONRPCResponseHandler){
3838
let uri: String? = self.currentFile.url.absoluteString
39-
var selection: JSONValue?
39+
let response: JSONValue
4040

4141
if let fileSelection = currentFile.selection {
4242
let start = fileSelection.start
4343
let end = fileSelection.end
44-
selection = .hash([
45-
"start": .hash(["line": .number(Double(start.line)), "character": .number(Double(start.character))]),
46-
"end": .hash(["line": .number(Double(end.line)), "character": .number(Double(end.character))])
44+
response = .hash([
45+
"uri": .string(uri ?? ""),
46+
"selection": .hash([
47+
"start": .hash(["line": .number(Double(start.line)), "character": .number(Double(start.character))]),
48+
"end": .hash(["line": .number(Double(end.line)), "character": .number(Double(end.character))])
49+
])
4750
])
51+
} else {
52+
// No text selection - only include file URI without selection metadata
53+
response = .hash(["uri": .string(uri ?? "")])
4854
}
4955

5056
completion(
5157
AnyJSONRPCResponse(
5258
id: request.id,
53-
result: JSONValue.array([
54-
JSONValue.hash([
55-
"uri" : .string(uri ?? ""),
56-
"selection": selection ?? .null
57-
]),
58-
JSONValue.null
59-
]))
59+
result: JSONValue.array([response, JSONValue.null]))
6060
)
6161
}
6262
}

0 commit comments

Comments
 (0)