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.
This commit is contained in:
1 parent
fadd1c2858
commit
fcf5908ff7
5 files changed
+15
-9
No files matched your search
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -63,7 +63,7 @@ export function apply(ctx: Context): void {
|
||||
|---|---|
|
||||
| 区块 | 标题、状态、按钮、说明、附加行、失败信息和提示。区块发起的调用未返回,或 Host 流中断时,按钮不可用。失败时先显示注册方的文案,再显示其诊断项 |
|
||||
| 标题旁标签 | 显示 display 的 `badge`,只出现在已启用插件包的页面或其某一行的页面上,且只在 display 带有标签时显示 |
|
||||
| 开启引导 | 插件包开启后,阶段为 `disconnected` 时打开;“连接”会打开插件包页面,并在 display 给出 `connect` 时启动该操作。阶段确定为其他值后自动关闭 |
|
||||
| 开启引导 | 插件包开启后,阶段为 `disconnected` 时打开;“连接”会打开插件包页面,并在 display 给出 `connect` 时启动该操作。账号检查中或连接中时继续等待,已连接、不可用或服务未运行时自动关闭 |
|
||||
| 提示 | 本浏览器的最新结果,不受插件面板生命周期限制:操作成功的文本,或带警告图标的共用失败文案 |
|
||||
|
||||
### 跟随操作
|
||||
|
||||
@@ -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 (
|
||||
<Modal open={needed} title={title} closeLabel={t('close')} onClose={onDismiss}
|
||||
footer={<>
|
||||
|
||||
@@ -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') =>
|
||||
<ConnectorAccountActivation t={t} phase={phase} title="连接演示" body="插件已开启。" connect="立即连接" onDismiss={onDismiss} onConnect={onConnect} />
|
||||
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', () => {
|
||||
|
||||
Reference in new issue
Block a user