From 828b0796fda7ddd9851ee29cf135ac91157c65e0 Mon Sep 17 00:00:00 2001 From: Amiya_desi <771087882@qq.com> Date: Fri, 5 Jun 2026 14:57:33 +0800 Subject: [PATCH] fix(provider): show terminal launch feedback immediately Opening provider terminals can block until the spawned CLI exits, so waiting for the backend command before showing feedback makes the UI look unresponsive. Show an immediate localized opening toast after directory selection, then replace it with the existing success toast once the backend returns. The opening toast id is now tracked so failure handling can dismiss it before showing terminalOpenFailed. That keeps the failure path to one clear error message instead of leaving an 'Opening terminal...' toast beside the error. Constraint: Keep this PR limited to frontend feedback and i18n. Rejected: Only show terminalOpened after openTerminal resolves | on some terminal launch paths that message appears only after the terminal closes. Confidence: high Scope-risk: narrow Tested: node .\\node_modules\\typescript\\bin\\tsc --noEmit Tested: node .\\node_modules\\prettier\\bin\\prettier.cjs --check src/**/*.{js,jsx,ts,tsx,css,json} Tested: git diff --check Not-tested: Manual terminal launch across OS terminal apps Co-authored-by: OmX --- src/App.tsx | 11 +++++++++++ src/i18n/locales/en.json | 1 + src/i18n/locales/ja.json | 1 + src/i18n/locales/zh-TW.json | 1 + src/i18n/locales/zh.json | 1 + 5 files changed, 15 insertions(+) diff --git a/src/App.tsx b/src/App.tsx index 966e48a6ff..b2fb38c1de 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -773,12 +773,19 @@ function App() { }; const handleOpenTerminal = async (provider: Provider) => { + let openingToastId: string | number | undefined; + try { const selectedDir = await settingsApi.pickDirectory(); if (!selectedDir) { return; } + openingToastId = toast.info( + t("provider.terminalOpening", { + defaultValue: "正在打开终端...", + }), + ); await providersApi.openTerminal(provider.id, activeApp, { cwd: selectedDir, }); @@ -786,9 +793,13 @@ function App() { t("provider.terminalOpened", { defaultValue: "终端已打开", }), + { id: openingToastId }, ); } catch (error) { console.error("[App] Failed to open terminal", error); + if (openingToastId !== undefined) { + toast.dismiss(openingToastId); + } const errorMessage = extractErrorMessage(error); toast.error( t("provider.terminalOpenFailed", { diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index af0a09d4e2..4a68ce4695 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -145,6 +145,7 @@ "managedByHermes": "Hermes Managed", "managedByHermesHint": "Defined in Hermes' providers: dict. Edit or remove it via Hermes Web UI.", "openTerminal": "Open Terminal", + "terminalOpening": "Opening terminal...", "terminalOpened": "Terminal opened", "terminalOpenFailed": "Failed to open terminal", "name": "Provider Name", diff --git a/src/i18n/locales/ja.json b/src/i18n/locales/ja.json index 45d2556ae2..1a1e6b9ace 100644 --- a/src/i18n/locales/ja.json +++ b/src/i18n/locales/ja.json @@ -145,6 +145,7 @@ "managedByHermes": "Hermes 管理", "managedByHermesHint": "Hermes の providers: dict で定義されています。Hermes Web UI で編集または削除してください。", "openTerminal": "ターミナルを開く", + "terminalOpening": "ターミナルを開いています...", "terminalOpened": "ターミナルを開きました", "terminalOpenFailed": "ターミナルを開けませんでした", "name": "プロバイダー名", diff --git a/src/i18n/locales/zh-TW.json b/src/i18n/locales/zh-TW.json index 5e0e908cc9..031d630656 100644 --- a/src/i18n/locales/zh-TW.json +++ b/src/i18n/locales/zh-TW.json @@ -145,6 +145,7 @@ "managedByHermes": "Hermes 託管", "managedByHermesHint": "該專案定義於 Hermes 的 providers: dict,請在 Hermes Web UI 中編輯或刪除。", "openTerminal": "開啟終端機", + "terminalOpening": "正在開啟終端機...", "terminalOpened": "終端機已開啟", "terminalOpenFailed": "開啟終端機失敗", "name": "供應商名稱", diff --git a/src/i18n/locales/zh.json b/src/i18n/locales/zh.json index 3eaabcaa17..cfa7b7a1af 100644 --- a/src/i18n/locales/zh.json +++ b/src/i18n/locales/zh.json @@ -145,6 +145,7 @@ "managedByHermes": "Hermes 托管", "managedByHermesHint": "该条目定义在 Hermes 的 providers: dict,请在 Hermes Web UI 中编辑或删除。", "openTerminal": "打开终端", + "terminalOpening": "正在打开终端...", "terminalOpened": "终端已打开", "terminalOpenFailed": "打开终端失败", "name": "供应商名称",