You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to add files to Chat via the attachment picker, files that should be available aren't and files that should not be available are. It seems that when in an Xcode workspace, the Chat file picker simply scans directories that are adjacent to the workspace and makes all files available even if the adjacent directories and subdirectories are not in the workspace.
Versions
Copilot for Xcode: 0.31.0
Xcode: 16
macOS: 5.2
Steps to reproduce
Bug 1. Too Greedy
Create a Demo directory in file system
Create a Projects directory inside Demo Demo/Projects
Create ProjectA in Projects Demo/Projects/ProjectA
Create ProjectB in Projects Demo/Projects/ProjectB
Save ProjectA as a Workspace in the Projects directory Demo/Projects/ProjectA.xcworkspace
Open ProjectA.xcworkspace
Open Chat Window Attach Context Picker
Results: ProjectB files are available to attach to Chat, they shouldn't be.
Bug 2. Too limited
Create a Packages directory in demo Demo/Packages
Create a PackageA in the Packages Demo/Packages/PackageA
Edit the package as a local dependecy within the workspace
Open Chat Window Attach Context Picker
Results: All project files are available, but only the focused package file is available. We cant add other files from the package.
The issue seems be be in ContextUtils.getFilesInActiveWorkspace() which makes no use of the workspaceURL :
publicstaticfunc getFilesInActiveWorkspace()->[FileReference]{guardlet workspaceURL =XcodeInspector.shared.realtimeActiveWorkspaceURL,let projectURL =XcodeInspector.shared.realtimeActiveProjectURL else{return[]}do{letfileManager=FileManager.default
letenumerator= fileManager.enumerator(
at: projectURL,
includingPropertiesForKeys:[.isRegularFileKey,.isDirectoryKey],
options:[.skipsHiddenFiles])varfiles:[FileReference]=[]whilelet fileURL = enumerator?.nextObject()as?URL{
// Skip items matching the specified pattern
ifmatchesPatterns(fileURL, patterns: skipPatterns){
enumerator?.skipDescendants()continue}letresourceValues=try fileURL.resourceValues(forKeys:[.isRegularFileKey,.isDirectoryKey])
// Handle directories if needed
if resourceValues.isDirectory ==true{continue}guard resourceValues.isRegularFile ==trueelse{continue}if supportedFileExtensions.contains(fileURL.pathExtension.lowercased())==false{continue}letrelativePath= fileURL.path.replacingOccurrences(of: projectURL.path, with:"")letfileName= fileURL.lastPathComponent
letfile=FileReference(url: fileURL,
relativePath: relativePath,
fileName: fileName)
files.append(file)}return files
}catch{Logger.client.error("Failed to get files in workspace: \(error)")return[]}}
The text was updated successfully, but these errors were encountered:
When trying to add files to Chat via the attachment picker, files that should be available aren't and files that should not be available are. It seems that when in an Xcode workspace, the Chat file picker simply scans directories that are adjacent to the workspace and makes all files available even if the adjacent directories and subdirectories are not in the workspace.
Versions
Steps to reproduce
Bug 1. Too Greedy
Demo/Projects
Demo/Projects/ProjectA
Demo/Projects/ProjectB
Demo/Projects/ProjectA.xcworkspace
ProjectA.xcworkspace
Bug 2. Too limited
Demo/Packages
Demo/Packages/PackageA
The issue seems be be in
ContextUtils.getFilesInActiveWorkspace()
which makes no use of theworkspaceURL
:The text was updated successfully, but these errors were encountered: