Skip to content

Refresh conversation templates dynamically on workspace project changes - #431

Open
Daniel Belina (dmbelina) wants to merge 1 commit into
microsoft:mainfrom
dmbelina:workspace-detect
Open

Refresh conversation templates dynamically on workspace project changes#431
Daniel Belina (dmbelina) wants to merge 1 commit into
microsoft:mainfrom
dmbelina:workspace-detect

Conversation

@dmbelina

@dmbelina Daniel Belina (dmbelina) commented Aug 28, 2026

Copy link
Copy Markdown

Currently, when Eclipse starts with an empty workspace (or when projects are imported, opened, closed, or deleted during a session), conversation templates, including slash commands (/), custom prompts, and skills, do not update until Eclipse is completely restarted.

This change adds tracking so conversation templates refresh automatically upon workspace changes.

Root Cause

  1. ChatCompletionService used LSPEclipseUtils.getWorkspaceFolders(), which holds a stale startup snapshot from LSP4E.
  2. ChatCompletionService had no IResourceChangeListener for workspace project changes.

Changes

  • Replaced LSPEclipseUtils.getWorkspaceFolders() with WorkspaceUtils.listWorkspaceFolders().
  • Added an IResourceChangeListener in ChatCompletionService to refresh conversation templates on IProject changes (POST_CHANGE).
  • Unregistered the listener in dispose().

Testing

  1. Started Eclipse with an empty workspace.
  2. Imported a project
  3. Verified my skills appeared in Chat's / completion list without restarting.

Note: There is also an upstream language server issue where conversation/templates skips global skills when workspaceFolders is empty; this fix ensures that as soon as a project is opened, templates refresh immediately. For reference that issue is here: github/copilot-language-server-release#51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Eclipse UI-side chat completion/template refresh logic so slash commands, custom prompts, and skills refresh automatically as workspace projects are added/opened/closed/removed—without requiring an Eclipse restart.

Changes:

  • Switched workspace-folder resolution from LSP4E’s startup snapshot (LSPEclipseUtils.getWorkspaceFolders()) to WorkspaceUtils.listWorkspaceFolders() for up-to-date project state.
  • Added an IResourceChangeListener to trigger template refresh on workspace project changes, and unregistered it on dispose().
Suppressed comments (1)

com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/services/ChatCompletionService.java:254

  • The IllegalStateException during listener removal is swallowed silently. Logging an info-level message helps diagnose unexpected shutdown/dispose ordering issues where the listener might not be removed as intended.
      } catch (IllegalStateException e) {
        // Workspace may not be available during shutdown
      }

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +92 to +103
private boolean hasProjectChanges(IResourceDelta delta) {
if (delta == null) {
return false;
}
// If the delta is at the root level, check each child
for (IResourceDelta child : delta.getAffectedChildren()) {
if (child.getResource() instanceof IProject) {
return true;
}
}
return delta.getResource() instanceof IProject;
}
Comment on lines +86 to +88
} catch (IllegalStateException e) {
// Workspace may not be available in standalone headless unit test environments
}
@dmbelina

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree [company="IBM"]

@dmbelina

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="IBM"

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