fix: 修复 Extension Management 命令报错 (问题 6)

- 在 listAction 中添加 ExtensionManager 可用性检查
- 当 ExtensionManager 不可用时显示友好的错误提示
- 改进:避免用户遇到静默失败,提供明确的环境不支持信息
This commit is contained in:
LaZzyMan 2026-03-09 11:11:18 +08:00
parent 4dfaa12e16
commit 2d5088e58f

View file

@ -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,