Pre-release 0.38.129 · davido7-sudo/CopilotForXcode@e7fd64d · GitHub
Skip to content

Commit e7fd64d

Browse files
committed
Pre-release 0.38.129
1 parent d1f7de3 commit e7fd64d

28 files changed

Lines changed: 820 additions & 334 deletions

‎Core/Sources/ChatService/ChatService.swift‎

Lines changed: 0 additions & 28 deletions

‎Core/Sources/ConversationTab/ChatPanel.swift‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ struct ChatPanelInputArea: View {
499499
var focusedField: FocusState<Chat.State.Field?>.Binding
500500
@State var cancellable = Set<AnyCancellable>()
501501
@State private var isFilePickerPresented = false
502-
@State private var allFiles: [FileReference] = []
502+
@State private var allFiles: [FileReference]? = nil
503503
@State private var filteredTemplates: [ChatTemplate] = []
504504
@State private var filteredAgent: [ChatAgent] = []
505505
@State private var showingTemplates = false
@@ -528,7 +528,7 @@ struct ChatPanelInputArea: View {
528528
}
529529
)
530530
.onAppear() {
531-
allFiles = ContextUtils.getFilesInActiveWorkspace(workspaceURL: chat.workspaceURL)
531+
allFiles = ContextUtils.getFilesFromWorkspaceIndex(workspaceURL: chat.workspaceURL)
532532
}
533533
}
534534

‎Core/Sources/ConversationTab/ContextUtils.swift‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ import SystemUtils
77

88
public struct ContextUtils {
99

10+
public static func getFilesFromWorkspaceIndex(workspaceURL: URL?) -> [FileReference]? {
11+
guard let workspaceURL = workspaceURL else { return [] }
12+
return WorkspaceFileIndex.shared.getFiles(for: workspaceURL)
13+
}
14+
1015
public static func getFilesInActiveWorkspace(workspaceURL: URL?) -> [FileReference] {
1116
if let workspaceURL = workspaceURL, let info = WorkspaceFile.getWorkspaceInfo(workspaceURL: workspaceURL) {
1217
return WorkspaceFile.getFilesInActiveWorkspace(workspaceURL: info.workspaceURL, workspaceRootURL: info.projectURL)

‎Core/Sources/ConversationTab/FilePicker.swift‎

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import SwiftUI
55
import SystemUtils
66

77
public struct FilePicker: View {
8-
@Binding var allFiles: [FileReference]
8+
@Binding var allFiles: [FileReference]?
99
let workspaceURL: URL?
1010
var onSubmit: (_ file: FileReference) -> Void
1111
var onExit: () -> Void
@@ -14,20 +14,21 @@ public struct FilePicker: View {
1414
@State private var selectedId: Int = 0
1515
@State private var localMonitor: Any? = nil
1616

17-
private var filteredFiles: [FileReference] {
17+
private var filteredFiles: [FileReference]? {
1818
if searchText.isEmpty {
1919
return allFiles
2020
}
2121

22-
return allFiles.filter { doc in
22+
return allFiles?.filter { doc in
2323
(doc.fileName ?? doc.url.lastPathComponent) .localizedCaseInsensitiveContains(searchText)
2424
}
2525
}
2626

2727
private static let defaultEmptyStateText = "No results found."
28+
private static let isIndexingStateText = "Indexing files, try later..."
2829

2930
private var emptyStateAttributedString: AttributedString? {
30-
var message = FilePicker.defaultEmptyStateText
31+
var message = allFiles == nil ? FilePicker.isIndexingStateText : FilePicker.defaultEmptyStateText
3132
if let workspaceURL = workspaceURL {
3233
let status = FileUtils.checkFileReadability(at: workspaceURL.path)
3334
if let errorMessage = status.errorMessage(using: ContextUtils.workspaceReadabilityErrorMessageProvider) {
@@ -89,25 +90,25 @@ public struct FilePicker: View {
8990
ScrollViewReader { proxy in
9091
ScrollView {
9192
LazyVStack(alignment: .leading, spacing: 4) {
92-
ForEach(Array(filteredFiles.enumerated()), id: \.element) { index, doc in
93-
FileRowView(doc: doc, id: index, selectedId: $selectedId)
94-
.contentShape(Rectangle())
95-
.onTapGesture {
96-
onSubmit(doc)
97-
selectedId = index
98-
isSearchBarFocused = true
99-
}
100-
.id(index)
101-
}
102-
103-
if filteredFiles.isEmpty {
93+
if allFiles == nil || filteredFiles?.isEmpty == true {
10494
emptyStateView
10595
.foregroundColor(.secondary)
10696
.padding(.leading, 4)
10797
.padding(.vertical, 4)
98+
} else {
99+
ForEach(Array((filteredFiles ?? []).enumerated()), id: \.element) { index, doc in
100+
FileRowView(doc: doc, id: index, selectedId: $selectedId)
101+
.contentShape(Rectangle())
102+
.onTapGesture {
103+
onSubmit(doc)
104+
selectedId = index
105+
isSearchBarFocused = true
106+
}
107+
.id(index)
108+
}
108109
}
109110
}
110-
.id(filteredFiles.hashValue)
111+
.id(filteredFiles?.hashValue)
111112
}
112113
.frame(maxHeight: 200)
113114
.padding(.horizontal, 4)
@@ -158,16 +159,14 @@ public struct FilePicker: View {
158159
}
159160

160161
private func moveSelection(up: Bool, proxy: ScrollViewProxy) {
161-
let files = filteredFiles
162-
guard !files.isEmpty else { return }
162+
guard let files = filteredFiles, !files.isEmpty else { return }
163163
let nextId = selectedId + (up ? -1 : 1)
164164
selectedId = max(0, min(nextId, files.count - 1))
165165
proxy.scrollTo(selectedId, anchor: .bottom)
166166
}
167167

168168
private func handleEnter() {
169-
let files = filteredFiles
170-
guard !files.isEmpty && selectedId < files.count else { return }
169+
guard let files = filteredFiles, !files.isEmpty && selectedId < files.count else { return }
171170
onSubmit(files[selectedId])
172171
}
173172
}
@@ -192,9 +191,13 @@ struct FileRowView: View {
192191
Text(doc.fileName ?? doc.url.lastPathComponent)
193192
.font(.body)
194193
.hoverPrimaryForeground(isHovered: selectedId == id)
194+
.lineLimit(1)
195+
.truncationMode(.middle)
195196
Text(doc.relativePath ?? doc.url.path)
196197
.font(.caption)
197198
.foregroundColor(.secondary)
199+
.lineLimit(1)
200+
.truncationMode(.middle)
198201
}
199202

200203
Spacer()
@@ -206,7 +209,7 @@ struct FileRowView: View {
206209
.onHover(perform: { hovering in
207210
isHovered = hovering
208211
})
209-
.transition(.move(edge: .bottom))
212+
.help(doc.relativePath ?? doc.url.path)
210213
}
211214
}
212215
}

‎Core/Sources/GitHubCopilotViewModel/GitHubCopilotViewModel.swift‎

Lines changed: 184 additions & 4 deletions

0 commit comments

Comments
 (0)