Skip to content

Commit f31eb0a

Browse files
authored
fix: skip inline agent mode for chat view chat mode selector. (#1603)
1 parent 7a60318 commit f31eb0a

3 files changed

Lines changed: 91 additions & 1 deletion

File tree

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package com.microsoft.copilot.eclipse.core.chat.service;
2+
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
import static org.junit.jupiter.api.Assertions.assertNotNull;
5+
import static org.mockito.ArgumentMatchers.any;
6+
import static org.mockito.Mockito.when;
7+
8+
import java.lang.reflect.Field;
9+
import java.util.List;
10+
import java.util.concurrent.CompletableFuture;
11+
12+
import org.junit.jupiter.api.BeforeEach;
13+
import org.junit.jupiter.api.Test;
14+
import org.junit.jupiter.api.extension.ExtendWith;
15+
import org.mockito.Mock;
16+
import org.mockito.junit.jupiter.MockitoExtension;
17+
18+
import com.microsoft.copilot.eclipse.core.CopilotCore;
19+
import com.microsoft.copilot.eclipse.core.chat.BuiltInChatMode;
20+
import com.microsoft.copilot.eclipse.core.lsp.CopilotLanguageServerConnection;
21+
import com.microsoft.copilot.eclipse.core.lsp.protocol.ConversationMode;
22+
import com.microsoft.copilot.eclipse.core.lsp.protocol.ConversationModesParams;
23+
24+
@ExtendWith(MockitoExtension.class)
25+
class BuiltInChatModeServiceTests {
26+
27+
@Mock
28+
private CopilotLanguageServerConnection mockConnection;
29+
30+
private BuiltInChatModeService builtInChatModeService;
31+
32+
@BeforeEach
33+
void setUp() throws Exception {
34+
builtInChatModeService = new BuiltInChatModeService();
35+
36+
CopilotCore plugin = new CopilotCore();
37+
Field languageServerField = CopilotCore.class.getDeclaredField("copilotLanguageServer");
38+
languageServerField.setAccessible(true);
39+
languageServerField.set(plugin, mockConnection);
40+
}
41+
42+
@Test
43+
void testLoadBuiltInModes_inlineAgentSkippedFromAgentModes() {
44+
ConversationMode agentMode = createBuiltInMode("Agent", "Agent", "Agent",
45+
"Advanced agent mode with access to tools and capabilities");
46+
ConversationMode inlineAgentMode = createBuiltInMode("InlineAgent", "Agent", "InlineAgent",
47+
"Agent mode with a restricted tool set for inline editing");
48+
49+
when(mockConnection.listConversationModes(any(ConversationModesParams.class)))
50+
.thenReturn(CompletableFuture.completedFuture(new ConversationMode[] { agentMode, inlineAgentMode }));
51+
52+
List<BuiltInChatMode> builtInModes = builtInChatModeService.loadBuiltInModes().join();
53+
54+
assertEquals(1, builtInModes.size());
55+
56+
BuiltInChatMode builtInMode = builtInModes.get(0);
57+
assertNotNull(builtInMode);
58+
assertEquals("Agent", builtInMode.getId());
59+
assertEquals("Agent", builtInMode.getDisplayName());
60+
assertEquals("Agent", builtInMode.getKind());
61+
}
62+
63+
private ConversationMode createBuiltInMode(String id, String name, String kind, String description) {
64+
ConversationMode mode = new ConversationMode();
65+
mode.setId(id);
66+
mode.setName(name);
67+
mode.setKind(kind);
68+
mode.setBuiltIn(true);
69+
mode.setDescription(description);
70+
return mode;
71+
}
72+
}

com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/chat/BuiltInChatMode.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ public class BuiltInChatMode extends BaseChatMode {
2525
public static final String PLAN_MODE_NAME = "Plan";
2626
public static final String DEBUGGER_MODE_NAME = "Debugger";
2727

28+
// Built-in mode kinds
29+
public static final String INLINE_AGENT_KIND = "InlineAgent";
30+
31+
private final String kind;
32+
2833
/**
2934
* Constructor that creates a BuiltInChatMode from a ConversationMode.
3035
*
@@ -33,6 +38,16 @@ public class BuiltInChatMode extends BaseChatMode {
3338
public BuiltInChatMode(ConversationMode mode) {
3439
super(mode.getId(), mode.getName(), mode.getDescription(),
3540
mode.getCustomTools(), mode.getModel(), mode.getHandOffs());
41+
this.kind = mode.getKind();
42+
}
43+
44+
/**
45+
* Get the kind of this built-in mode.
46+
*
47+
* @return the mode kind (e.g., "Ask", "Agent", "InlineAgent")
48+
*/
49+
public String getKind() {
50+
return kind;
3651
}
3752

3853
/**

com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/chat/service/BuiltInChatModeService.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ public CompletableFuture<List<BuiltInChatMode>> loadBuiltInModes() {
4141
if (mode == null || !mode.isBuiltIn()) {
4242
continue;
4343
}
44-
44+
// Exclude InlineAgent kind — it is not a user-facing chat mode
45+
if (BuiltInChatMode.INLINE_AGENT_KIND.equalsIgnoreCase(mode.getKind())) {
46+
continue;
47+
}
4548
// Filter to only allowed built-in modes by name (case-insensitive)
4649
if (ALLOWED_BUILTIN_NAMES.stream().anyMatch(name -> name.equalsIgnoreCase(mode.getName()))) {
4750
BuiltInChatMode builtIn = convertToBuiltInChatMode(mode);

0 commit comments

Comments
 (0)