From fcf5908ff7cf1fe748e92c6c5d60bde69eb6246d Mon Sep 17 00:00:00 2001 From: gengruilin Date: Sun, 8 Nov 2026 04:36:33 +0800 Subject: [PATCH] fix(connector-account): keep the activation prompt while the account is connecting An MCP server switched on connects before it reports that it needs authorization, so the prompt now waits while the account is checking or connecting and dismisses itself only once the account is connected, unavailable, or not running. --- packages/client/ui-connector-account/README.i18n.yaml | 4 ++-- packages/client/ui-connector-account/README.md | 2 +- packages/client/ui-connector-account/README.zh.md | 2 +- .../ui-connector-account/src/client/components.tsx | 7 ++++--- .../tests/components.client.spec.tsx | 9 +++++++-- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/packages/client/ui-connector-account/README.i18n.yaml b/packages/client/ui-connector-account/README.i18n.yaml index 347d021162..010f9d34c4 100644 --- a/packages/client/ui-connector-account/README.i18n.yaml +++ b/packages/client/ui-connector-account/README.i18n.yaml @@ -21,8 +21,8 @@ en: e618281ea7721daf zh: a5d5f5e307ea3435 /deepseek-ai-dsh-client-ui-connector-account/use-this-package/present-the-section: - en: 73ca134d685b5872 - zh: 05b929fd28dc955e + en: 4ed05fa030f31fed + zh: 4d9597b68959be93 /deepseek-ai-dsh-client-ui-connector-account/use-this-package/following-operations: en: a9e64f316efcac3e zh: d059d31b65573bf5 diff --git a/packages/client/ui-connector-account/README.md b/packages/client/ui-connector-account/README.md index 1013fb4f48..a8c6386a7b 100644 --- a/packages/client/ui-connector-account/README.md +++ b/packages/client/ui-connector-account/README.md @@ -63,7 +63,7 @@ The registrant imports the registry's types with `import type` from the package |---|---| | Section | Title, status, buttons, detail, notes, failure, and hint. Buttons are disabled while a call the section made is pending or the Host stream is down. A failure shows the registrant's text, then its diagnostic items | | Title tag | The display's `badge`, shown only on the enabled bundle's page or one of its row pages, and only while the display has one | -| Activation prompt | Open while the phase is `disconnected` after the bundle is switched on; Connect opens the bundle page and starts the display's `connect` operation, if it names one. It dismisses itself once the phase settles elsewhere | +| Activation prompt | Open while the phase is `disconnected` after the bundle is switched on; Connect opens the bundle page and starts the display's `connect` operation, if it names one. It waits while the account is checking or connecting and dismisses itself once the account is connected, unavailable, or not running | | Notice | The latest outcome in this browser, outside the Plugins panel's lifetime: the operation's success text, or the shared failure copy with a warning icon | ### Following operations diff --git a/packages/client/ui-connector-account/README.zh.md b/packages/client/ui-connector-account/README.zh.md index a32ed876b2..2de3b35071 100644 --- a/packages/client/ui-connector-account/README.zh.md +++ b/packages/client/ui-connector-account/README.zh.md @@ -63,7 +63,7 @@ export function apply(ctx: Context): void { |---|---| | 区块 | 标题、状态、按钮、说明、附加行、失败信息和提示。区块发起的调用未返回,或 Host 流中断时,按钮不可用。失败时先显示注册方的文案,再显示其诊断项 | | 标题旁标签 | 显示 display 的 `badge`,只出现在已启用插件包的页面或其某一行的页面上,且只在 display 带有标签时显示 | -| 开启引导 | 插件包开启后,阶段为 `disconnected` 时打开;“连接”会打开插件包页面,并在 display 给出 `connect` 时启动该操作。阶段确定为其他值后自动关闭 | +| 开启引导 | 插件包开启后,阶段为 `disconnected` 时打开;“连接”会打开插件包页面,并在 display 给出 `connect` 时启动该操作。账号检查中或连接中时继续等待,已连接、不可用或服务未运行时自动关闭 | | 提示 | 本浏览器的最新结果,不受插件面板生命周期限制:操作成功的文本,或带警告图标的共用失败文案 | ### 跟随操作 diff --git a/packages/client/ui-connector-account/src/client/components.tsx b/packages/client/ui-connector-account/src/client/components.tsx index 93bc807582..9d115051cd 100644 --- a/packages/client/ui-connector-account/src/client/components.tsx +++ b/packages/client/ui-connector-account/src/client/components.tsx @@ -194,14 +194,15 @@ export interface ConnectorAccountActivationProps { /** * Guidance after the user switches a bundle on while its account is not connected. * @param props - the phase, the registrant's text, the dismiss and connect callbacks, and the translator. - * @returns a prompt shown while disconnected; it dismisses itself once the phase settles elsewhere. + * @returns a prompt shown while disconnected; it waits while the account is checking or connecting, which may still end + * disconnected, and dismisses itself once the account is connected or unavailable. */ export function ConnectorAccountActivation(props: ConnectorAccountActivationProps): ReactNode { const { t, phase, title, body, connect, onDismiss, onConnect } = props const needed = phase === 'disconnected' useEffect(() => { - if (phase !== 'checking' && !needed) onDismiss() - }, [phase, needed, onDismiss]) + if (phase === 'connected' || phase === 'unavailable' || phase === 'stopped') onDismiss() + }, [phase, onDismiss]) return ( diff --git a/packages/client/ui-connector-account/tests/components.client.spec.tsx b/packages/client/ui-connector-account/tests/components.client.spec.tsx index c84907ffed..df9a0d0e80 100644 --- a/packages/client/ui-connector-account/tests/components.client.spec.tsx +++ b/packages/client/ui-connector-account/tests/components.client.spec.tsx @@ -110,12 +110,14 @@ it('explains a stopped stream with the shared copy and reopens it even while off expect(onRetry).toHaveBeenCalledOnce() }) -it('prompts to connect only while disconnected and steps aside once the phase settles elsewhere', () => { +it('prompts to connect only while disconnected, waits while checking or connecting, and steps aside once settled', () => { const onDismiss = vi.fn() const onConnect = vi.fn() - const prompt = (phase: 'checking' | 'disconnected' | 'connected') => + const prompt = (phase: 'checking' | 'connecting' | 'disconnected' | 'connected' | 'unavailable' | 'stopped') => const { rerender } = render(prompt('checking')) + // An account still connecting after the bundle is switched on may end disconnected. + rerender(prompt('connecting')) expect(screen.queryByRole('dialog')).toBeNull() expect(onDismiss).not.toHaveBeenCalled() rerender(prompt('disconnected')) @@ -127,6 +129,9 @@ it('prompts to connect only while disconnected and steps aside once the phase se expect(onDismiss).toHaveBeenCalledOnce() rerender(prompt('connected')) expect(onDismiss).toHaveBeenCalledTimes(2) + rerender(prompt('unavailable')) + rerender(prompt('stopped')) + expect(onDismiss).toHaveBeenCalledTimes(4) }) it('shows the latest notice with the registrant text or the shared failure copy', () => {