From 4aeafe5a1659de2a3b7fc5617a3cdb2fe24c4b04 Mon Sep 17 00:00:00 2001 From: Junyan Qin Date: Mon, 1 Jun 2026 19:25:19 +0800 Subject: [PATCH] fix(web): TDZ crash in add-extension (installIconURL before installInfo) installIconURL was computed above the useState declaration of installInfo, causing "Cannot access 'installInfo' before initialization" (500) on the add-extension page. Move the computation below the state declarations. Co-Authored-By: Claude Opus 4.8 (1M context) --- web/src/app/home/add-extension/page.tsx | 26 ++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/web/src/app/home/add-extension/page.tsx b/web/src/app/home/add-extension/page.tsx index cf20bc6f..42e8d148 100644 --- a/web/src/app/home/add-extension/page.tsx +++ b/web/src/app/home/add-extension/page.tsx @@ -162,19 +162,6 @@ function AddExtensionContent() { : type === 'skill' ? t('market.typeSkill') : t('market.typePlugin'); - - // Marketplace icon URL for the extension being installed, by type. - const buildInstallIconURL = () => { - const cloud = getCloudServiceClientSync(); - const a = installInfo.plugin_author || ''; - const n = installInfo.plugin_name || ''; - if (installExtensionType === 'mcp') - return cloud.getMCPMarketplaceIconURL(a, n); - if (installExtensionType === 'skill') - return cloud.getSkillMarketplaceIconURL(a, n); - return cloud.getPluginIconURL(a, n); - }; - const installIconURL = buildInstallIconURL(); const { addTask, setSelectedTaskId, @@ -191,6 +178,19 @@ function AddExtensionContent() { useState(PluginInstallStatus.ASK_CONFIRM); const [installError, setInstallError] = useState(null); const [installIconFailed, setInstallIconFailed] = useState(false); + + // Marketplace icon URL for the extension being installed, by type. + const installIconURL = (() => { + const cloud = getCloudServiceClientSync(); + const a = installInfo.plugin_author || ''; + const n = installInfo.plugin_name || ''; + if (installExtensionType === 'mcp') + return cloud.getMCPMarketplaceIconURL(a, n); + if (installExtensionType === 'skill') + return cloud.getSkillMarketplaceIconURL(a, n); + return cloud.getPluginIconURL(a, n); + })(); + const [popoverOpen, setPopoverOpen] = useState(false); const [popoverView, setPopoverView] = useState('menu'); const [isDragOver, setIsDragOver] = useState(false);