diff --git a/src/core/controller/file/createRuleFile.ts b/src/core/controller/file/createRuleFile.ts index db5b41ef..c1b858e7 100644 --- a/src/core/controller/file/createRuleFile.ts +++ b/src/core/controller/file/createRuleFile.ts @@ -44,12 +44,10 @@ export const createRuleFile: FileMethodHandler = async (controller: Controller, if (fileExists) { const message = `${fileTypeName} file "${request.filename}" already exists.` - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.WARNING, - message, - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.WARNING, + message, + }) // Still open it for editing await handleFileServiceRequest(controller, "openFile", { value: filePath }) } else { @@ -63,12 +61,10 @@ export const createRuleFile: FileMethodHandler = async (controller: Controller, await handleFileServiceRequest(controller, "openFile", { value: filePath }) const message = `Created new ${request.isGlobal ? "global" : "workspace"} ${fileTypeName} file: ${request.filename}` - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.INFORMATION, - message, - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.INFORMATION, + message, + }) } return RuleFile.create({ diff --git a/src/core/controller/file/deleteRuleFile.ts b/src/core/controller/file/deleteRuleFile.ts index a482270e..6b678fd9 100644 --- a/src/core/controller/file/deleteRuleFile.ts +++ b/src/core/controller/file/deleteRuleFile.ts @@ -46,12 +46,10 @@ export const deleteRuleFile: FileMethodHandler = async (controller: Controller, const fileTypeName = request.type === "workflow" ? "workflow" : "rule" const message = `${fileTypeName} file "${fileName}" deleted successfully` - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.INFORMATION, - message, - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.INFORMATION, + message, + }) return RuleFile.create({ filePath: request.rulePath, diff --git a/src/core/controller/index.ts b/src/core/controller/index.ts index 507cfff5..5f5fa59e 100644 --- a/src/core/controller/index.ts +++ b/src/core/controller/index.ts @@ -114,19 +114,15 @@ export class Controller { await updateGlobalState(this.context, "userInfo", undefined) await updateGlobalState(this.context, "apiProvider", "openrouter") await this.postStateToWebview() - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.INFORMATION, - message: "Successfully logged out of Cline", - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.INFORMATION, + message: "Successfully logged out of Cline", + }) } catch (error) { - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.INFORMATION, - message: "Logout failed", - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.INFORMATION, + message: "Logout failed", + }) } } @@ -485,12 +481,10 @@ export class Controller { await this.postStateToWebview() } catch (error) { console.error("Failed to handle auth callback:", error) - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.ERROR, - message: "Failed to log in to Cline", - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.ERROR, + message: "Failed to log in to Cline", + }) // Even on login failure, we preserve any existing tokens // Only clear tokens on explicit logout } @@ -525,12 +519,10 @@ export class Controller { console.error("Failed to fetch MCP marketplace:", error) if (!silent) { const errorMessage = error instanceof Error ? error.message : "Failed to fetch MCP marketplace" - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.ERROR, - message: errorMessage, - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.ERROR, + message: errorMessage, + }) } return undefined } @@ -614,12 +606,10 @@ export class Controller { } catch (error) { console.error("Failed to handle cached MCP marketplace:", error) const errorMessage = error instanceof Error ? error.message : "Failed to handle cached MCP marketplace" - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.ERROR, - message: errorMessage, - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.ERROR, + message: errorMessage, + }) } } @@ -982,24 +972,20 @@ export class Controller { // Check if there's a workspace folder open const cwd = await getCwd() if (!cwd) { - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.ERROR, - message: "No workspace folder open", - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.ERROR, + message: "No workspace folder open", + }) return } // Get the git diff const gitDiff = await getWorkingState(cwd) if (gitDiff === "No changes in working directory") { - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.INFORMATION, - message: "No changes in workspace for commit message", - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.INFORMATION, + message: "No changes in workspace for commit message", + }) return } @@ -1067,58 +1053,46 @@ Commit message:` const repo = api.repositories[0] repo.inputBox.value = commitMessage const message = "Commit message generated and applied" - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.INFORMATION, - message, - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.INFORMATION, + message, + }) } else { const message = "No Git repositories found" - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.ERROR, - message, - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.ERROR, + message, + }) } } else { const message = "Git extension not found" - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.ERROR, - message, - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.ERROR, + message, + }) } } else { const message = "Failed to generate commit message" - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.ERROR, - message, - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.ERROR, + message, + }) } } catch (innerError) { const innerErrorMessage = innerError instanceof Error ? innerError.message : String(innerError) - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.ERROR, - message: `Failed to generate commit message: ${innerErrorMessage}`, - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.ERROR, + message: `Failed to generate commit message: ${innerErrorMessage}`, + }) } }, ) } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error) - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.ERROR, - message: `Failed to generate commit message: ${errorMessage}`, - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.ERROR, + message: `Failed to generate commit message: ${errorMessage}`, + }) } } } diff --git a/src/core/controller/state/resetState.ts b/src/core/controller/state/resetState.ts index c2d21844..8455c5bd 100644 --- a/src/core/controller/state/resetState.ts +++ b/src/core/controller/state/resetState.ts @@ -15,20 +15,16 @@ import { getHostBridgeProvider } from "@/hosts/host-providers" export async function resetState(controller: Controller, request: ResetStateRequest): Promise { try { if (request.global) { - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.INFORMATION, - message: "Resetting global state...", - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.INFORMATION, + message: "Resetting global state...", + }) await resetGlobalState(controller.context) } else { - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.INFORMATION, - message: "Resetting workspace state...", - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.INFORMATION, + message: "Resetting workspace state...", + }) await resetWorkspaceState(controller.context) } @@ -37,12 +33,10 @@ export async function resetState(controller: Controller, request: ResetStateRequ controller.task = undefined } - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.INFORMATION, - message: "State reset", - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.INFORMATION, + message: "State reset", + }) await controller.postStateToWebview() await sendChatButtonClickedEvent(controller.id) @@ -50,12 +44,10 @@ export async function resetState(controller: Controller, request: ResetStateRequ return Empty.create() } catch (error) { console.error("Error resetting state:", error) - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.ERROR, - message: `Failed to reset state: ${error instanceof Error ? error.message : String(error)}`, - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.ERROR, + message: `Failed to reset state: ${error instanceof Error ? error.message : String(error)}`, + }) throw error } } diff --git a/src/core/controller/state/updateDefaultTerminalProfile.ts b/src/core/controller/state/updateDefaultTerminalProfile.ts index 6695de05..a8e24c5c 100644 --- a/src/core/controller/state/updateDefaultTerminalProfile.ts +++ b/src/core/controller/state/updateDefaultTerminalProfile.ts @@ -27,12 +27,10 @@ export async function updateDefaultTerminalProfile( // Show information message if terminals were closed if (closedCount > 0) { const message = `Closed ${closedCount} ${closedCount === 1 ? "terminal" : "terminals"} with different profile.` - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.INFORMATION, - message, - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.INFORMATION, + message, + }) } // Show warning if there are busy terminals that couldn't be closed @@ -40,12 +38,10 @@ export async function updateDefaultTerminalProfile( const message = `${busyTerminals.length} busy ${busyTerminals.length === 1 ? "terminal has" : "terminals have"} a different profile. ` + `Close ${busyTerminals.length === 1 ? "it" : "them"} to use the new profile for all commands.` - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.WARNING, - message, - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.WARNING, + message, + }) } } diff --git a/src/core/controller/task/deleteAllTaskHistory.ts b/src/core/controller/task/deleteAllTaskHistory.ts index 9f85f018..78c019db 100644 --- a/src/core/controller/task/deleteAllTaskHistory.ts +++ b/src/core/controller/task/deleteAllTaskHistory.ts @@ -33,7 +33,7 @@ export async function deleteAllTaskHistory(controller: Controller): Promise setTimeout(resolve, 200)) - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.INFORMATION, - message, - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.INFORMATION, + message, + }) // Record that we've shown the popup for this version. await context.globalState.update("clineLastPopupNotificationVersion", currentVersion) } @@ -413,12 +411,10 @@ export async function activate(context: vscode.ExtensionContext) { // Ensure clipboard is restored even if an error occurs await writeTextToClipboard(tempCopyBuffer) console.error("Error getting terminal contents:", error) - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.ERROR, - message: "Failed to get terminal contents", - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.ERROR, + message: "Failed to get terminal contents", + }) } }), ) @@ -554,12 +550,10 @@ export async function activate(context: vscode.ExtensionContext) { } const selectedText = editor.document.getText(range) if (!selectedText.trim()) { - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.INFORMATION, - message: "Please select some code to explain.", - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.INFORMATION, + message: "Please select some code to explain.", + }) return } const filePath = editor.document.uri.fsPath @@ -581,12 +575,10 @@ export async function activate(context: vscode.ExtensionContext) { } const selectedText = editor.document.getText(range) if (!selectedText.trim()) { - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.INFORMATION, - message: "Please select some code to improve.", - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.INFORMATION, + message: "Please select some code to improve.", + }) return } const filePath = editor.document.uri.fsPath @@ -651,12 +643,10 @@ export async function activate(context: vscode.ExtensionContext) { sendFocusChatInputEvent(clientId) } else { console.error("FocusChatInput: Could not find or activate a Cline webview to focus.") - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.ERROR, - message: "Could not activate Cline view. Please try opening it manually from the Activity Bar.", - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.ERROR, + message: "Could not activate Cline view. Please try opening it manually from the Activity Bar.", + }) } telemetryService.captureButtonClick("command_focusChatInput", activeWebviewProvider?.controller.task?.taskId) }), diff --git a/src/hosts/vscode/hostbridge/window/showMessage.ts b/src/hosts/vscode/hostbridge/window/showMessage.ts index 31c013ab..baab02e3 100644 --- a/src/hosts/vscode/hostbridge/window/showMessage.ts +++ b/src/hosts/vscode/hostbridge/window/showMessage.ts @@ -3,7 +3,7 @@ import { SelectedResponse, ShowMessageRequest, ShowMessageType } from "@/shared/ const DEFAULT_OPTIONS = { modal: false, items: [] } as const -export async function showMessage(request: ShowMessageRequest): Promise { +export async function showMessage(request: ShowMessageRequest): Promise { const { message, type, options } = request const { modal, detail, items } = { ...DEFAULT_OPTIONS, ...options } const option = { modal, detail } diff --git a/src/integrations/git/commit-message-generator.ts b/src/integrations/git/commit-message-generator.ts index fcca9009..5036ec66 100644 --- a/src/integrations/git/commit-message-generator.ts +++ b/src/integrations/git/commit-message-generator.ts @@ -59,12 +59,10 @@ export function extractCommitMessage(aiResponse: string): string { */ export async function copyCommitMessageToClipboard(message: string): Promise { await writeTextToClipboard(message) - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.INFORMATION, - message: "Commit message copied to clipboard", - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.INFORMATION, + message: "Commit message copied to clipboard", + }) } /** @@ -77,18 +75,16 @@ export async function showCommitMessageOptions(message: string): Promise { const editAction = "Edit Message" const selectedAction = ( - await getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.INFORMATION, - message: "Commit message generated", - options: { - modal: false, - detail: message, - items: [copyAction, applyAction, editAction], - }, - }), - ) - )?.selectedOption + await getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.INFORMATION, + message: "Commit message generated", + options: { + modal: false, + detail: message, + items: [copyAction, applyAction, editAction], + }, + }) + ).selectedOption // Handle user dismissing the dialog (selectedAction is undefined) if (!selectedAction) { @@ -120,28 +116,22 @@ async function applyCommitMessageToGitInput(message: string): Promise { if (api && api.repositories.length > 0) { const repo = api.repositories[0] repo.inputBox.value = message - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.INFORMATION, - message: "Commit message applied to Git input", - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.INFORMATION, + message: "Commit message applied to Git input", + }) } else { - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.ERROR, - message: "No Git repositories found", - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.ERROR, + message: "No Git repositories found", + }) await copyCommitMessageToClipboard(message) } } else { - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.ERROR, - message: "Git extension not found", - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.ERROR, + message: "Git extension not found", + }) await copyCommitMessageToClipboard(message) } } @@ -161,10 +151,8 @@ async function editCommitMessage(message: string): Promise { path: document.uri.fsPath, }), ) - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.INFORMATION, - message: "Edit the commit message and copy when ready", - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.INFORMATION, + message: "Edit the commit message and copy when ready", + }) } diff --git a/src/integrations/misc/export-markdown.ts b/src/integrations/misc/export-markdown.ts index a58d2db6..2da3a9d0 100644 --- a/src/integrations/misc/export-markdown.ts +++ b/src/integrations/misc/export-markdown.ts @@ -48,12 +48,10 @@ export async function downloadTask(dateTs: number, conversationHistory: Anthropi }), ) } catch (error) { - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.ERROR, - message: `Failed to save markdown file: ${error instanceof Error ? error.message : String(error)}`, - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.ERROR, + message: `Failed to save markdown file: ${error instanceof Error ? error.message : String(error)}`, + }) } } } diff --git a/src/integrations/misc/open-file.ts b/src/integrations/misc/open-file.ts index 93869aff..e44edc2c 100644 --- a/src/integrations/misc/open-file.ts +++ b/src/integrations/misc/open-file.ts @@ -9,12 +9,10 @@ import { writeFile } from "@utils/fs" export async function openImage(dataUri: string) { const matches = dataUri.match(/^data:image\/([a-zA-Z]+);base64,(.+)$/) if (!matches) { - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.ERROR, - message: "Invalid data URI format", - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.ERROR, + message: "Invalid data URI format", + }) return } const [, format, base64Data] = matches @@ -24,12 +22,10 @@ export async function openImage(dataUri: string) { await writeFile(tempFilePath, new Uint8Array(imageBuffer)) await vscode.commands.executeCommand("vscode.open", vscode.Uri.file(tempFilePath)) } catch (error) { - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.ERROR, - message: `Error opening image: ${error}`, - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.ERROR, + message: `Error opening image: ${error}`, + }) } } diff --git a/src/integrations/misc/process-files.ts b/src/integrations/misc/process-files.ts index 764951de..676daf4c 100644 --- a/src/integrations/misc/process-files.ts +++ b/src/integrations/misc/process-files.ts @@ -46,22 +46,18 @@ export async function selectFiles(imagesAllowed: boolean): Promise<{ images: str const dimensions = sizeOf(uint8Array) // Get dimensions from Uint8Array if (dimensions.width! > 7500 || dimensions.height! > 7500) { console.warn(`Image dimensions exceed 7500px, skipping: ${filePath}`) - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.ERROR, - message: `Image too large: ${path.basename(filePath)} was skipped (dimensions exceed 7500px).`, - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.ERROR, + message: `Image too large: ${path.basename(filePath)} was skipped (dimensions exceed 7500px).`, + }) return null } } catch (error) { console.error(`Error reading file or getting dimensions for ${filePath}:`, error) - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.ERROR, - message: `Could not read dimensions for ${path.basename(filePath)}, skipping.`, - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.ERROR, + message: `Could not read dimensions for ${path.basename(filePath)}, skipping.`, + }) return null } @@ -76,22 +72,18 @@ export async function selectFiles(imagesAllowed: boolean): Promise<{ images: str const stats = await fs.stat(filePath) if (stats.size > 20 * 1000 * 1024) { console.warn(`File too large, skipping: ${filePath}`) - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.ERROR, - message: `File too large: ${path.basename(filePath)} was skipped (size exceeds 20MB).`, - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.ERROR, + message: `File too large: ${path.basename(filePath)} was skipped (size exceeds 20MB).`, + }) return null } } catch (error) { console.error(`Error checking file size for ${filePath}:`, error) - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.ERROR, - message: `Could not check file size for ${path.basename(filePath)}, skipping.`, - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.ERROR, + message: `Could not check file size for ${path.basename(filePath)}, skipping.`, + }) return null } return { type: "file", data: filePath } diff --git a/src/services/mcp/McpHub.ts b/src/services/mcp/McpHub.ts index e14fd7ac..de935de2 100644 --- a/src/services/mcp/McpHub.ts +++ b/src/services/mcp/McpHub.ts @@ -109,24 +109,20 @@ export class McpHub { try { config = JSON.parse(content) } catch (error) { - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.ERROR, - message: "Invalid MCP settings format. Please ensure your settings follow the correct JSON format.", - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.ERROR, + message: "Invalid MCP settings format. Please ensure your settings follow the correct JSON format.", + }) return undefined } // Validate against schema const result = McpSettingsSchema.safeParse(config) if (!result.success) { - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.ERROR, - message: "Invalid MCP settings schema.", - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.ERROR, + message: "Invalid MCP settings schema.", + }) return undefined } @@ -158,12 +154,10 @@ export class McpHub { if (settings) { try { await this.updateServerConnections(settings.mcpServers) - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.INFORMATION, - message: "MCP servers updated", - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.INFORMATION, + message: "MCP servers updated", + }) } catch (error) { console.error("Failed to process MCP settings change:", error) } @@ -413,12 +407,10 @@ export class McpHub { console.log(`[MCP Fallback Notification] ${name}:`, JSON.stringify(notification, null, 2)) // Show in VS Code for visibility - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.INFORMATION, - message: `MCP ${name}: ${notification.method || "unknown"} - ${JSON.stringify(notification.params || {})}`, - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.INFORMATION, + message: `MCP ${name}: ${notification.method || "unknown"} - ${JSON.stringify(notification.params || {})}`, + }) } console.log(`[MCP Debug] Successfully set fallback notification handler for ${name}`) } catch (error) { @@ -671,12 +663,10 @@ export class McpHub { const connection = this.connections.find((conn) => conn.server.name === serverName) const config = connection?.server.config if (config) { - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.INFORMATION, - message: `Restarting ${serverName} MCP server...`, - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.INFORMATION, + message: `Restarting ${serverName} MCP server...`, + }) connection.server.status = "connecting" connection.server.error = "" await this.notifyWebviewOfServerChanges() @@ -685,20 +675,16 @@ export class McpHub { await this.deleteConnection(serverName) // Try to connect again using existing config await this.connectToServer(serverName, JSON.parse(config), "internal") - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.INFORMATION, - message: `${serverName} MCP server connected`, - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.INFORMATION, + message: `${serverName} MCP server connected`, + }) } catch (error) { console.error(`Failed to restart connection for ${serverName}:`, error) - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.ERROR, - message: `Failed to connect to ${serverName} MCP server`, - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.ERROR, + message: `Failed to connect to ${serverName} MCP server`, + }) } } @@ -784,12 +770,10 @@ export class McpHub { if (error instanceof Error) { console.error("Error details:", error.message, error.stack) } - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.ERROR, - message: `Failed to update server state: ${error instanceof Error ? error.message : String(error)}`, - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.ERROR, + message: `Failed to update server state: ${error instanceof Error ? error.message : String(error)}`, + }) throw error } } @@ -946,12 +930,10 @@ export class McpHub { } } catch (error) { console.error("Failed to update autoApprove settings:", error) - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.ERROR, - message: "Failed to update autoApprove settings", - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.ERROR, + message: "Failed to update autoApprove settings", + }) throw error // Re-throw to ensure the error is properly handled } } @@ -1069,12 +1051,10 @@ export class McpHub { if (error instanceof Error) { console.error("Error details:", error.message, error.stack) } - getHostBridgeProvider().windowClient.showMessage( - ShowMessageRequest.create({ - type: ShowMessageType.ERROR, - message: `Failed to update server timeout: ${error instanceof Error ? error.message : String(error)}`, - }), - ) + getHostBridgeProvider().windowClient.showMessage({ + type: ShowMessageType.ERROR, + message: `Failed to update server timeout: ${error instanceof Error ? error.message : String(error)}`, + }) throw error } }