Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat - support edit/create local files outside of workspace#248

Open
xinyi-gong wants to merge 1 commit into
mainfrom
tori/local-file-edit
Open

feat - support edit/create local files outside of workspace#248
xinyi-gong wants to merge 1 commit into
mainfrom
tori/local-file-edit

Conversation

@xinyi-gong
Copy link
Copy Markdown
Member

Summary

  • Add support for create_file and edit_file tool when the target is an absolute local file path outside the Eclipse workspace.
  • Track local file changes in the file change summary bar alongside workspace files.
  • Support local file View Diff, Keep, and Undo flows, including empty-baseline diffs for newly created files.
  • Preserve existing workspace-file behavior by resolving Eclipse IFile resources before falling back to local filesystem paths.
  • Add focused unit coverage for local create/edit paths and a SWTBot markdown test plan for the user-visible local file flows.

@xinyi-gong xinyi-gong marked this pull request as ready for review May 22, 2026 01:55
Copilot AI review requested due to automatic review settings May 22, 2026 01:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for tracking and reviewing create_file / insert_edit_into_file operations targeting absolute local filesystem paths outside the Eclipse workspace, integrating them into the existing “file change summary bar” UX and diff/keep/undo flows.

Changes:

  • Introduces a ChangedFile abstraction so the summary bar can track both workspace IFile and external Path targets.
  • Extends Create/Edit file tools and the compare-editor plumbing to support local files (including empty-baseline diffs for newly created files).
  • Adds/updates unit tests and documents a SWTBot test plan for the user-visible local-file flows.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/WorkingSetBar.java Updates summary bar UI to render and route actions for ChangedFile (workspace + local).
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/tools/WorkingSetHandler.java Extends handler contract with Path overloads for keep/undo/view-diff.
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/tools/FileToolService.java Switches change tracking to ChangedFile, adds routing for local keep/undo/diff and “created then edited” behavior.
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/tools/FileToolBase.java Adds local-file caches and compare editor handling (Path-keyed) alongside existing workspace support.
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/tools/EditFileTool.java Adds local-path resolution + local edit/write/undo/diff behavior.
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/tools/EditableLocalFileCompareInput.java New compare input to represent editable local-file content within Compare UI.
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/tools/CreateFileTool.java Adds local file creation + local diff/undo support; adjusts baseline caching for create flows.
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/tools/ChangedFile.java New model type representing either a workspace IFile or external local Path.
com.microsoft.copilot.eclipse.ui.test/src/com/microsoft/copilot/eclipse/ui/chat/WorkingSetBarTest.java Updates UI unit tests to use ChangedFile for summary bar rendering scenarios.
com.microsoft.copilot.eclipse.ui.test/src/com/microsoft/copilot/eclipse/ui/chat/tools/EditFileToolTest.java Adds focused unit coverage for external local-file edit and undo/baseline behavior.
com.microsoft.copilot.eclipse.ui.test/src/com/microsoft/copilot/eclipse/ui/chat/tools/CreateFileToolTest.java Adds focused unit coverage for external local-file create and undo behavior.
com.microsoft.copilot.eclipse.swtbot.test/test-plans/file-system/local-file-edit-and-create-tools.md Adds a SWTBot-oriented manual test plan for local file edit/create UX flows.

Comment on lines 220 to 223
@Override
public void onKeepChange(IFile file) {
closeCompareEditor(file);
}
Comment on lines +225 to 233
/**
* Handles the action of keeping changes to a local file.
*
* @param file the local file to keep changes for
*/
@Override
public void onUndoAllChanges(List<IFile> files) throws CoreException {
for (IFile file : files) {
onUndoChange(file);
}
public void onKeepChange(Path file) {
closeCompareEditor(file);
}
Comment on lines 235 to 241
@@ -176,11 +240,43 @@ public void onUndoChange(IFile file) throws CoreException {
closeCompareEditor(file);
}
Comment on lines +249 to +254
@Override
public void onUndoChange(Path file) throws IOException {
Path normalizedPath = normalizeLocalPath(file);
Files.deleteIfExists(normalizedPath);
closeCompareEditor(normalizedPath);
}
Comment on lines +108 to +118
private LanguageModelToolResult createFile(String filePath, String content) {
IFile file = FileUtils.getFileFromPath(filePath, false);

if (file != null && file.getProject().exists()) {
return createWorkspaceFile(file, filePath, content);
}

Path localPath = getLocalFilePath(filePath);
if (localPath != null) {
return createLocalFile(localPath, content);
}
Comment on lines +146 to +160
private LanguageModelToolResult[] editFile(String filePath, String code) {
IFile file = FileUtils.getFileFromPath(filePath, true);

if (file != null && file.exists()) {
return editWorkspaceFile(file, code);
}

Path localPath = getLocalFilePath(filePath);
if (localPath != null && Files.isRegularFile(localPath, LinkOption.NOFOLLOW_LINKS)) {
return editLocalFile(localPath, code);
}

return new LanguageModelToolResult[] {
new LanguageModelToolResult("The file path provided does not exist. Please check the path and try again.",
ToolInvocationStatus.error) };
Comment on lines 348 to 359
// TODO: Should share a same instance with ReferencedFile
WorkbenchLabelProvider labelProvider = new WorkbenchLabelProvider();
fileRows = new LinkedList<>();
for (IFile file : filesMap.keySet()) {
for (ChangedFile file : filesMap.keySet()) {
if (file == null) {
continue;
}

Image image = labelProvider.getImage(file);
Image image = file.isWorkspaceFile() ? labelProvider.getImage(file.getWorkspaceFile())
: PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FILE);
fileRows.add(new FileRow(contentArea, SWT.NONE, image, file));
}
Comment on lines 525 to 533
/**
* Creates a map of mock files with the specified count.
*/
private Map<IFile, FileChangeProperty> createMockFilesMap(int count, boolean isHandled) {
Map<IFile, FileChangeProperty> filesMap = new LinkedHashMap<>();
private Map<ChangedFile, FileChangeProperty> createMockFilesMap(int count, boolean isHandled) {
Map<ChangedFile, FileChangeProperty> filesMap = new LinkedHashMap<>();
for (int i = 0; i < count; i++) {
IFile mockFile = createMockFile("TestFile" + i + ".java");
filesMap.put(mockFile, new FileChangeProperty(FileChangeType.Created));
filesMap.put(ChangedFile.workspace(mockFile), new FileChangeProperty(FileChangeType.Created));
}
Comment on lines +132 to +136
Map<String, Object> input = new HashMap<>();
input.put("filePath", filePath);
input.put("code", code);
input.put("explanation", "test edit");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants