Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,42 @@ public static List<IProject> listTopLevelProjectsWithGitRepository() {
}

/**
* List all top level projects as workspace folders in the current workspace.
* List all top level projects as workspace folders in the current workspace, including the workspace root.
*/
public static List<WorkspaceFolder> listWorkspaceFolders() {
List<IProject> projects = WorkspaceUtils.listTopLevelProjects();

List<WorkspaceFolder> folders = new ArrayList<>();
java.util.Set<String> seenUris = new java.util.HashSet<>();

// Add workspace root first so it can be searched for root-level prompt files and skills
try {
URI workspaceRootUri = ResourcesPlugin.getWorkspace().getRoot().getLocationURI();
if (workspaceRootUri != null) {
String rootUriString = workspaceRootUri.toASCIIString();
WorkspaceFolder rootFolder = new WorkspaceFolder();
rootFolder.setUri(rootUriString);
rootFolder.setName("workspace-root");
folders.add(rootFolder);
seenUris.add(rootUriString);
}
} catch (Exception e) {
// If we can't get workspace root URI, continue with projects only
}
Comment on lines +94 to +106

// Add top-level projects (avoiding duplicates)
for (IProject project : projects) {
URI uri = project.getLocationURI();
if (uri != null) {
WorkspaceFolder folder = new WorkspaceFolder();
folder.setUri(uri.toASCIIString());
folder.setName(project.getName());
folders.add(folder);
String uriString = uri.toASCIIString();
// Avoid adding the same URI twice (project might be at workspace root in some configurations)
if (!seenUris.contains(uriString)) {
WorkspaceFolder folder = new WorkspaceFolder();
folder.setUri(uriString);
folder.setName(project.getName());
folders.add(folder);
seenUris.add(uriString);
}
}
}
return folders;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.e4.core.services.events.IEventBroker;
import org.eclipse.lsp4e.LSPEclipseUtils;
import org.eclipse.lsp4j.WorkspaceFolder;
import org.eclipse.ui.PlatformUI;
import org.osgi.service.event.EventHandler;
Expand All @@ -38,6 +37,7 @@
import com.microsoft.copilot.eclipse.core.lsp.protocol.CopilotScope;
import com.microsoft.copilot.eclipse.core.lsp.protocol.CopilotStatusResult;
import com.microsoft.copilot.eclipse.core.lsp.protocol.TemplateSource;
import com.microsoft.copilot.eclipse.core.utils.WorkspaceUtils;
import com.microsoft.copilot.eclipse.ui.utils.PreferencesUtils;

/**
Expand Down Expand Up @@ -115,7 +115,17 @@ private void initConversationTemplates(IProgressMonitor monitor) {
// Pass workspace folders so the language server returns workspace-specific
// prompt files (.prompt.md) and skills (SKILL.md) alongside built-in templates.
try {
List<WorkspaceFolder> workspaceFolders = LSPEclipseUtils.getWorkspaceFolders();
List<WorkspaceFolder> workspaceFolders = WorkspaceUtils.listWorkspaceFolders();
// Log workspace folders for debugging prompt/skill discovery
if (!workspaceFolders.isEmpty()) {
StringBuilder folderLog = new StringBuilder("Discovering prompts and skills from workspace folders: ");
for (WorkspaceFolder folder : workspaceFolders) {
folderLog.append("[").append(folder.getName()).append(": ").append(folder.getUri()).append("] ");
}
CopilotCore.LOGGER.info(folderLog.toString());
} else {
CopilotCore.LOGGER.info("No workspace folders available for prompt and skill discovery");
}
Comment on lines +118 to +128
ConversationTemplate[] rawTemplates = this.lsConnection.listConversationTemplates(workspaceFolders).get();
if (monitor.isCanceled()) {
return;
Expand Down