Skip to content

Commit 481f6d9

Browse files
duzitongCopilot
andcommitted
fix: isolate per-folder exception in mode picker for multi-project workspaces
In McpPreferencePage.getWorkspaceNameForMode(), the entire workspace-folder loop was wrapped in one try-catch. If any project had a non-file:// URI (e.g. EFS-backed sftp://, ecf:// or other custom linked resources), Paths.get(URI.create(...)) would throw and the catch would return '' for ALL custom modes — hiding them from the mode picker dropdown. Move the Paths.get() call into a per-folder inner try-catch so one bad URI only skips that folder; the loop continues for the rest. Also add INFO/WARN diagnostic logs so future issues can be diagnosed from workspace.log without a debugger. Fixes: #180 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 63b3c1b commit 481f6d9

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/McpPreferencePage.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -970,8 +970,8 @@ private void loadModeOptions() {
970970
for (CustomChatMode mode : customModes) {
971971
String workspaceName = getWorkspaceNameForMode(mode);
972972
if (workspaceName.isEmpty()) {
973-
CopilotCore.LOGGER.info("Workspace name is empty for custom agent: " + mode.getDisplayName()
974-
+ " (ID: " + mode.getId() + ")");
973+
CopilotCore.LOGGER.info("Workspace name is empty for custom agent: "
974+
+ mode.getDisplayName() + " (ID: " + mode.getId() + ")");
975975
continue;
976976
}
977977
options.add(workspaceName + ": " + mode.getDisplayName());
@@ -1086,14 +1086,18 @@ private String getWorkspaceNameForMode(CustomChatMode mode) {
10861086
List<WorkspaceFolder> workspaceFolders = WorkspaceUtils.listWorkspaceFolders();
10871087
if (workspaceFolders != null) {
10881088
for (WorkspaceFolder folder : workspaceFolders) {
1089-
Path folderPath = Paths.get(java.net.URI.create(folder.getUri()));
1090-
if (modePath.startsWith(folderPath)) {
1091-
return folder.getName();
1089+
try {
1090+
Path folderPath = Paths.get(java.net.URI.create(folder.getUri()));
1091+
if (modePath.startsWith(folderPath)) {
1092+
return folder.getName();
1093+
}
1094+
} catch (Exception folderEx) {
1095+
CopilotCore.LOGGER.error("Failed to process folder uri=" + folder.getUri(), folderEx);
10921096
}
10931097
}
10941098
}
10951099
} catch (Exception e) {
1096-
CopilotCore.LOGGER.error("Failed to get workspace name for mode", e);
1100+
CopilotCore.LOGGER.error("Failed to get workspace name for mode id=" + mode.getId(), e);
10971101
}
10981102
return "";
10991103
}

0 commit comments

Comments
 (0)