Skip to content

Commit b6bdc31

Browse files
committed
introduce constants for client names and remove wrong ide name for mcp apps support
1 parent a8a28cc commit b6bdc31

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

pkg/github/helper_test.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,16 @@ func createMCPRequest(args any) mcp.CallToolRequest {
291291
}
292292
}
293293

294+
// Well-known MCP client names used in tests.
295+
const (
296+
ClientNameVSCodeInsiders = "Visual Studio Code - Insiders"
297+
ClientNameVSCode = "Visual Studio Code"
298+
)
299+
294300
// createMCPRequestWithSession creates a CallToolRequest with a ServerSession
295-
// that has the given client name in its InitializeParams. This is used to test
296-
// UI capability detection based on ClientInfo.Name.
297-
func createMCPRequestWithSession(t *testing.T, clientName string, args any) mcp.CallToolRequest {
301+
// that has the given client name in its InitializeParams. When withUI is true
302+
// the session advertises MCP Apps UI support via the capability extension.
303+
func createMCPRequestWithSession(t *testing.T, clientName string, withUI bool, args any) mcp.CallToolRequest {
298304
t.Helper()
299305

300306
argsMap, ok := args.(map[string]any)
@@ -307,8 +313,7 @@ func createMCPRequestWithSession(t *testing.T, clientName string, args any) mcp.
307313
srv := mcp.NewServer(&mcp.Implementation{Name: "test"}, nil)
308314

309315
caps := &mcp.ClientCapabilities{}
310-
// If the client is a known UI-supporting client, add the UI extension
311-
if clientName == "Visual Studio Code - Insiders" || clientName == "Visual Studio Code" {
316+
if withUI {
312317
caps.AddExtension("io.modelcontextprotocol/ui", map[string]any{
313318
"mimeTypes": []string{"text/html;profile=mcp-app"},
314319
})

pkg/github/issues_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,7 @@ func Test_IssueWrite_InsidersMode_UIGate(t *testing.T) {
957957
handler := serverTool.Handler(deps)
958958

959959
t.Run("UI client without _ui_submitted returns form message", func(t *testing.T) {
960-
request := createMCPRequestWithSession(t, "Visual Studio Code - Insiders", map[string]any{
960+
request := createMCPRequestWithSession(t, ClientNameVSCodeInsiders, true, map[string]any{
961961
"method": "create",
962962
"owner": "owner",
963963
"repo": "repo",
@@ -971,7 +971,7 @@ func Test_IssueWrite_InsidersMode_UIGate(t *testing.T) {
971971
})
972972

973973
t.Run("UI client with _ui_submitted executes directly", func(t *testing.T) {
974-
request := createMCPRequestWithSession(t, "Visual Studio Code - Insiders", map[string]any{
974+
request := createMCPRequestWithSession(t, ClientNameVSCodeInsiders, true, map[string]any{
975975
"method": "create",
976976
"owner": "owner",
977977
"repo": "repo",

pkg/github/pullrequests_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2185,7 +2185,7 @@ func Test_CreatePullRequest_InsidersMode_UIGate(t *testing.T) {
21852185
handler := serverTool.Handler(deps)
21862186

21872187
t.Run("UI client without _ui_submitted returns form message", func(t *testing.T) {
2188-
request := createMCPRequestWithSession(t, "Visual Studio Code", map[string]any{
2188+
request := createMCPRequestWithSession(t, ClientNameVSCodeInsiders, true, map[string]any{
21892189
"owner": "owner",
21902190
"repo": "repo",
21912191
"title": "Test PR",
@@ -2200,7 +2200,7 @@ func Test_CreatePullRequest_InsidersMode_UIGate(t *testing.T) {
22002200
})
22012201

22022202
t.Run("UI client with _ui_submitted executes directly", func(t *testing.T) {
2203-
request := createMCPRequestWithSession(t, "Visual Studio Code", map[string]any{
2203+
request := createMCPRequestWithSession(t, ClientNameVSCodeInsiders, true, map[string]any{
22042204
"owner": "owner",
22052205
"repo": "repo",
22062206
"title": "Test PR",

0 commit comments

Comments
 (0)