Skip to content

Commit 2950c2a

Browse files
ethanyhouCopilot
andcommitted
refactor: move isSkillsEnabled logic to PreferencesUtils and update usages
Co-authored-by: Copilot <copilot@github.com>
1 parent 0c1088f commit 2950c2a

3 files changed

Lines changed: 24 additions & 19 deletions

File tree

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.osgi.service.event.EventHandler;
2727

2828
import com.microsoft.copilot.eclipse.core.AuthStatusManager;
29-
import com.microsoft.copilot.eclipse.core.Constants;
3029
import com.microsoft.copilot.eclipse.core.CopilotAuthStatusListener;
3130
import com.microsoft.copilot.eclipse.core.CopilotCore;
3231
import com.microsoft.copilot.eclipse.core.FeatureFlags;
@@ -39,7 +38,7 @@
3938
import com.microsoft.copilot.eclipse.core.lsp.protocol.CopilotStatusResult;
4039
import com.microsoft.copilot.eclipse.core.lsp.protocol.TemplateSource;
4140
import com.microsoft.copilot.eclipse.core.utils.WorkspaceUtils;
42-
import com.microsoft.copilot.eclipse.ui.CopilotUi;
41+
import com.microsoft.copilot.eclipse.ui.utils.PreferencesUtils;
4342

4443
/**
4544
* Service for handling slash commands.
@@ -110,7 +109,7 @@ private void initConversationTemplates(IProgressMonitor monitor) {
110109
List<ConversationTemplate> newTemplates = new ArrayList<>();
111110
List<ConversationAgent> newAgents = new ArrayList<>();
112111
Set<String> newCommands = new HashSet<>();
113-
boolean skillsEnabled = isSkillsEnabled();
112+
boolean skillsEnabled = PreferencesUtils.isSkillsEnabled();
114113

115114
// Command: /***
116115
// Pass workspace folders so the language server returns workspace-specific
@@ -172,13 +171,6 @@ private void initConversationTemplates(IProgressMonitor monitor) {
172171
this.allCommands = Set.copyOf(newCommands);
173172
}
174173

175-
private boolean isSkillsEnabled() {
176-
CopilotCore plugin = CopilotCore.getPlugin();
177-
FeatureFlags flags = plugin != null ? plugin.getFeatureFlags() : null;
178-
return CopilotUi.getPlugin().getPreferenceStore().getBoolean(Constants.ENABLE_SKILLS)
179-
&& flags != null && flags.isClientPreviewFeatureEnabled();
180-
}
181-
182174
/**
183175
* Returns templates filtered by the scope appropriate for the given chat mode. In Agent mode only {@code agent-panel}
184176
* scoped templates (including skills) are shown; in Ask mode only {@code chat-panel} scoped templates are shown.

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import com.microsoft.copilot.eclipse.core.utils.WorkspaceUtils;
4242
import com.microsoft.copilot.eclipse.ui.CopilotUi;
4343
import com.microsoft.copilot.eclipse.ui.chat.services.McpExtensionPointManager;
44+
import com.microsoft.copilot.eclipse.ui.utils.PreferencesUtils;
4445

4546
/**
4647
* A class to manage the proxy service for the Copilot Language Server.
@@ -84,7 +85,8 @@ public LanguageServerSettingManager(CopilotLanguageServerConnection conn, IProxy
8485
// agent related settings
8586
getSettings().getGithubSettings().getCopilotSettings().getAgent()
8687
.setAgentMaxRequests(preferenceStore.getInt(Constants.AGENT_MAX_REQUESTS));
87-
getSettings().getGithubSettings().getCopilotSettings().getAgent().setEnableSkills(isSkillsEnabled());
88+
getSettings().getGithubSettings().getCopilotSettings().getAgent()
89+
.setEnableSkills(PreferencesUtils.isSkillsEnabled());
8890

8991
// Set workspace context instructions when it is enabled
9092
if (preferenceStore.getBoolean(Constants.CUSTOM_INSTRUCTIONS_WORKSPACE_ENABLED)) {
@@ -172,7 +174,8 @@ public void propertyChange(PropertyChangeEvent event) {
172174
singleSetting = new CopilotLanguageServerSettings(null, null, null, settings.getGithubSettings());
173175
break;
174176
case Constants.ENABLE_SKILLS:
175-
settings.getGithubSettings().getCopilotSettings().getAgent().setEnableSkills(isSkillsEnabled());
177+
settings.getGithubSettings().getCopilotSettings().getAgent()
178+
.setEnableSkills(PreferencesUtils.isSkillsEnabled());
176179
singleSetting = new CopilotLanguageServerSettings(null, null, null, settings.getGithubSettings());
177180
break;
178181
default:
@@ -522,13 +525,6 @@ public boolean isAutoShowCompletionEnabled() {
522525
return preferenceStore.getBoolean(Constants.AUTO_SHOW_COMPLETION);
523526
}
524527

525-
private boolean isSkillsEnabled() {
526-
CopilotCore plugin = CopilotCore.getPlugin();
527-
FeatureFlags flags = plugin != null ? plugin.getFeatureFlags() : null;
528-
return preferenceStore.getBoolean(Constants.ENABLE_SKILLS) && flags != null
529-
&& flags.isClientPreviewFeatureEnabled();
530-
}
531-
532528
/**
533529
* Enable or disable auto show completions.
534530
*/

com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/utils/PreferencesUtils.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
package com.microsoft.copilot.eclipse.ui.utils;
55

6+
import com.microsoft.copilot.eclipse.core.Constants;
7+
import com.microsoft.copilot.eclipse.core.CopilotCore;
8+
import com.microsoft.copilot.eclipse.core.FeatureFlags;
9+
import com.microsoft.copilot.eclipse.ui.CopilotUi;
610
import com.microsoft.copilot.eclipse.ui.preferences.ByokPreferencePage;
711
import com.microsoft.copilot.eclipse.ui.preferences.ChatPreferencesPage;
812
import com.microsoft.copilot.eclipse.ui.preferences.CompletionsPreferencesPage;
@@ -27,4 +31,17 @@ public static String[] getAllPreferenceIds() {
2731
McpPreferencePage.ID, ByokPreferencePage.ID };
2832
}
2933

34+
/**
35+
* Returns whether the skills feature is enabled. Skills require both the user preference
36+
* {@link Constants#ENABLE_SKILLS} to be set and the client preview feature flag to be enabled.
37+
*
38+
* @return {@code true} if skills are enabled, {@code false} otherwise
39+
*/
40+
public static boolean isSkillsEnabled() {
41+
CopilotCore plugin = CopilotCore.getPlugin();
42+
FeatureFlags flags = plugin != null ? plugin.getFeatureFlags() : null;
43+
return CopilotUi.getPlugin().getPreferenceStore().getBoolean(Constants.ENABLE_SKILLS)
44+
&& flags != null && flags.isClientPreviewFeatureEnabled();
45+
}
46+
3047
}

0 commit comments

Comments
 (0)