From 2d5088e58ffbabfa1643d3c9f1827c872b6cebd6 Mon Sep 17 00:00:00 2001 From: LaZzyMan Date: Mon, 9 Mar 2026 11:11:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20Extension=20Managem?= =?UTF-8?q?ent=20=E5=91=BD=E4=BB=A4=E6=8A=A5=E9=94=99=20(=E9=97=AE?= =?UTF-8?q?=E9=A2=98=206)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 listAction 中添加 ExtensionManager 可用性检查 - 当 ExtensionManager 不可用时显示友好的错误提示 - 改进:避免用户遇到静默失败,提供明确的环境不支持信息 --- .../cli/src/ui/commands/extensionsCommand.ts | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/ui/commands/extensionsCommand.ts b/packages/cli/src/ui/commands/extensionsCommand.ts index 99667959b..1824eb4a2 100644 --- a/packages/cli/src/ui/commands/extensionsCommand.ts +++ b/packages/cli/src/ui/commands/extensionsCommand.ts @@ -92,7 +92,28 @@ async function exploreAction(context: CommandContext, args: string) { } } -async function listAction(_context: CommandContext, _args: string) { +async function listAction(context: CommandContext, _args: string) { + const extensionManager = context.services.config?.getExtensionManager(); + + if (!(extensionManager instanceof ExtensionManager)) { + debugLogger.error( + `Cannot ${context.invocation?.name} extensions in this environment`, + ); + + // Show user-friendly error message + context.ui.addItem( + { + type: MessageType.ERROR, + text: t( + 'Extension management is not available in the current environment. ' + + 'This feature may not be supported in your current mode or configuration.', + ), + }, + Date.now(), + ); + return; + } + return { type: 'dialog' as const, dialog: 'extensions_manage' as const,