Merge pull request #6644 from deepseek-harness/turtle/discover-back-and-upgrade-0e7147938262

fix(plugin-manager): return to Discover from a bundle page opened there
This commit is contained in:
Turtle authored and GitHub committed 2026-10-20 14:09:05 +08:00
commit f8eafdc554
8 files changed
+59 -17

No files matched your search

@@ -36,8 +36,8 @@
en: 54d7666c630da471
zh: d7ded257d0fd5559
/deepseek-ai-dsh-client-ui-plugin-manager/use-this-package/page-tabs:
en: 25451392e1118869
zh: 8ba84f8fdbb47b3f
en: 1de4fe390871d0da
zh: 1723ae12ccbe3697
/deepseek-ai-dsh-client-ui-plugin-manager/understand-the-implementation:
en: 203168fc87e939bd
zh: 72d0ccd2c54f3f44
+1 -1
View File
@@ -108,7 +108,7 @@ A row's page exists only while a `plugins.row.config` entry names the row, so a
### Page tabs
Another plugin adds a tab after the page's own **Installed** tab by registering into the `plugins.tab` list slot; the entry's `label` names the tab and `order` places it. The tabs appear under the page header once one entry exists and are hidden on a bundle's, row's, or official plugin's page; the selected tab survives leaving **Plugins**, and a tab whose entry leaves falls back to **Installed**. The page renders the selected entry in place of its groups and hides its own refresh and add buttons there. The owner props carry `install({ spec, registry?, title, version })` and `openPackage(name)`. `install` is for a version the person already confirmed in the tab: the install dialog opens at its check screen, without the spec form, names the plugin with `title` and `version` above the spec, which it shows in smaller monospace text, keeps that name on the progress and result screens, with the installed version once done, asks `registry` first for that install only and never remembers it, and offers **Retry** after a refusal; a hidden installation reopens instead. `openPackage` switches to **Installed** and opens the bundle's page when that tab lists it; a bundle the page leaves out, such as a built-in profile bundle, leaves the Installed list open. A confirmed install offers no GitHub mirror recovery, since that recovery reopens the spec form, and its back button cancels a running install. [`ui-plugin-market`](../ui-plugin-market/README.md) contributes the **Discover** tab here.
Another plugin adds a tab after the page's own **Installed** tab by registering into the `plugins.tab` list slot; the entry's `label` names the tab and `order` places it. The tabs appear under the page header once one entry exists and are hidden on a bundle's, row's, or official plugin's page; the selected tab survives leaving **Plugins**, and a tab whose entry leaves falls back to **Installed**. The page renders the selected entry in place of its groups and hides its own refresh and add buttons there. The owner props carry `install({ spec, registry?, title, version })` and `openPackage(name)`. `install` is for a version the person already confirmed in the tab: the install dialog opens at its check screen, without the spec form, names the plugin with `title` and `version` above the spec, which it shows in smaller monospace text, keeps that name on the progress and result screens, with the installed version once done, asks `registry` first for that install only and never remembers it, and offers **Retry** after a refusal; a hidden installation reopens instead. `openPackage` switches to **Installed** and opens the bundle's page when that tab lists it, and that page's back button returns to the tab that opened it; a bundle the page leaves out, such as a built-in profile bundle, leaves the Installed list open. A confirmed install offers no GitHub mirror recovery, since that recovery reopens the spec form, and its back button cancels a running install. [`ui-plugin-market`](../ui-plugin-market/README.md) contributes the **Discover** tab here.
-----
@@ -108,7 +108,7 @@ ctx.slots.inject('plugins.detail.section', () => ctx.slots.register({
### 页面标签页
其他插件向 `plugins.tab` 列表 slot 注册条目,即可在页面自带的**已安装**标签页之后添加一个标签页;条目的 `label` 为标签页命名,`order` 决定其位置。至少存在一个条目时,标签页显示在页头下方;在组合包、行或官方插件的页面上隐藏。离开**插件**后,所选标签页保持不变;所选标签页的条目被移除时,回到**已安装**。页面渲染所选条目以代替自身的分组,并在此时隐藏自身的刷新和添加按钮。owner props 提供 `install({ spec, registry?, title, version })` 和 `openPackage(name)`。`install` 用于用户已在标签页中确认的版本:安装对话框在检查界面打开,不显示 spec 表单,在以较小等宽字显示的 spec 上方用 `title` 和 `version` 标明插件,并在进度和结果界面保持该名称,完成后显示已安装的版本;只在这一次安装中首先使用 `registry`,且从不记住它;被拒绝后提供**重试**;如果有隐藏中的安装任务,则改为重新打开该任务。`openPackage` 切换到**已安装**,并在该标签页列出该组合包时打开其页面;页面不列出的组合包(例如内置 profile 组合包)只打开「已安装」列表。已确认的安装不提供 GitHub 镜像恢复,因为该恢复会重新打开 spec 表单;其返回按钮用于取消正在进行的安装。[`ui-plugin-market`](../ui-plugin-market/README.zh.md) 在这里贡献**发现**标签页。
其他插件向 `plugins.tab` 列表 slot 注册条目,即可在页面自带的**已安装**标签页之后添加一个标签页;条目的 `label` 为标签页命名,`order` 决定其位置。至少存在一个条目时,标签页显示在页头下方;在组合包、行或官方插件的页面上隐藏。离开**插件**后,所选标签页保持不变;所选标签页的条目被移除时,回到**已安装**。页面渲染所选条目以代替自身的分组,并在此时隐藏自身的刷新和添加按钮。owner props 提供 `install({ spec, registry?, title, version })` 和 `openPackage(name)`。`install` 用于用户已在标签页中确认的版本:安装对话框在检查界面打开,不显示 spec 表单,在以较小等宽字显示的 spec 上方用 `title` 和 `version` 标明插件,并在进度和结果界面保持该名称,完成后显示已安装的版本;只在这一次安装中首先使用 `registry`,且从不记住它;被拒绝后提供**重试**;如果有隐藏中的安装任务,则改为重新打开该任务。`openPackage` 切换到**已安装**,并在该标签页列出该组合包时打开其页面,该页面的返回按钮回到打开它的标签页;页面不列出的组合包(例如内置 profile 组合包)只打开「已安装」列表。已确认的安装不提供 GitHub 镜像恢复,因为该恢复会重新打开 spec 表单;其返回按钮用于取消正在进行的安装。[`ui-plugin-market`](../ui-plugin-market/README.zh.md) 在这里贡献**发现**标签页。
-----
@@ -1578,6 +1578,9 @@ export function PluginManagerPage(props: PluginManagerPageProps): ReactNode {
const showsMainList = showsCards && !showsMoreList
const installedCards = onInstalled && showsCards
const openPkgInMore = openPkg !== undefined && openPkg.official && detailFromMore
const returnTab = view.kind === 'package' || view.kind === 'row' ? view.returnTab : undefined
const backToMore = openPkgInMore && returnTab === undefined
const pkgOrigin = returnTab !== undefined ? { returnTab } : backToMore ? { from: 'more' as const } : {}
// The Installed tab's panel, whatever it currently shows; the More list is not a tab panel.
const installedPanel = tabs.length === 0 || showsMoreList
? {}
@@ -1589,7 +1592,7 @@ export function PluginManagerPage(props: PluginManagerPageProps): ReactNode {
}
const configure = (pkg: PackageView): RowConfigure => ({
has: row => ledger.rows.has(rowConfigKey(pkg.name, row.rowId)),
open: (row) => { setView({ kind: 'row', name: pkg.name, rowId: row.rowId, ...openPkgInMore ? { from: 'more' } : {} }) },
open: (row) => { setView({ kind: 'row', name: pkg.name, rowId: row.rowId, ...pkgOrigin }) },
})
const updates = updatesNote(mine, state.versions, t)
const updatePkg = state.update === null ? undefined : state.packages.find(pkg => pkg.name === state.update?.packageName)
@@ -1684,7 +1687,7 @@ export function PluginManagerPage(props: PluginManagerPageProps): ReactNode {
<div role="tabpanel" id={`${tabsId}-${tab}-panel`} aria-labelledby={`${tabsId}-${tab}`} className={css.tabPanel}>
{renderSlot('plugins.tab', {
install: props.installFrom,
openPackage: (name) => { setTab(INSTALLED_TAB); setView({ kind: 'package', name }) },
openPackage: (name) => { setTab(INSTALLED_TAB); setView({ kind: 'package', name, returnTab: tab }) },
}, { only: tab })}
</div>
)
@@ -1737,7 +1740,7 @@ export function PluginManagerPage(props: PluginManagerPageProps): ReactNode {
t={t}
resolveText={resolveText}
renderSlot={renderSlot}
onBack={() => { setView({ kind: 'package', name: openPkg.name, ...openPkgInMore ? { from: 'more' } : {} }) }}
onBack={() => { setView({ kind: 'package', name: openPkg.name, ...pkgOrigin }) }}
/>
)
: null}
@@ -1752,13 +1755,16 @@ export function PluginManagerPage(props: PluginManagerPageProps): ReactNode {
configured={ledger.bundles.has(openPkg.name)}
configure={configure(openPkg)}
renderSlot={renderSlot}
inMore={openPkgInMore}
inMore={backToMore}
detail={(
<BundleDetailSection name={openPkg.name} version={openPkg.version} fromNpm={openPkg.availability === 'missing'}
language={language} details={bundleDetails} t={t}
load={props.loadDetail} retry={props.retryDetail} image={props.detailImage} />
)}
onBack={() => { setView({ kind: openPkgInMore ? 'more' : 'list' }) }}
onBack={() => {
if (returnTab !== undefined) setTab(returnTab)
setView({ kind: backToMore ? 'more' : 'list' })
}}
onSetEnabled={(enabled) => { props.setEnabled(openPkg.name, enabled) }}
onUninstall={() => { props.uninstall(openPkg.name) }}
onUpdate={() => { props.update(openPkg.name) }}
@@ -1,13 +1,16 @@
/** Plugin page selection shared by the page and cross-plugin navigation. */
import { defineStore, type EngineStoreHandle } from '@deepseek-ai/dsh-client-store'
/** The main or additional plugin list, or one bundle, official item, or bundle row of the Installed tab. */
/**
* The main or additional plugin list, or one bundle, official item, or bundle row of the Installed tab. A bundle or row
* opened from a contributed tab names it in `returnTab`, and the bundle page's back returns to that tab's list.
*/
type View =
| { readonly kind: 'list' }
| { readonly kind: 'more' }
| { readonly kind: 'package'; readonly name: string; readonly from?: 'more' }
| { readonly kind: 'package'; readonly name: string; readonly from?: 'more'; readonly returnTab?: string }
| { readonly kind: 'item'; readonly id: string }
| { readonly kind: 'row'; readonly name: string; readonly rowId: string; readonly from?: 'more' }
| { readonly kind: 'row'; readonly name: string; readonly rowId: string; readonly from?: 'more'; readonly returnTab?: string }
/** `installed` is the page's own tab; any other value is the id of a `plugins.tab` entry. */
type NavigationState = { view: View; tab: string }
@@ -100,7 +100,7 @@ export interface PluginTabProps {
*/
readonly install: (target: PluginTabInstall) => void
/**
* Switch to the Installed tab and open a bundle's page.
* Switch to the Installed tab and open a bundle's page, whose back button returns to the calling tab.
* @param packageName - npm package name of the bundle.
*/
readonly openPackage: (packageName: string) => void
@@ -249,10 +249,14 @@ describe('PluginManagerPage', () => {
fireEvent.click(screen.getByRole('button', { name: 'Discover install' }))
expect(actions.installFrom).toHaveBeenCalledWith({ spec: '[email protected]', registry: 'https://r.example/', title: 'Alpha', version: '1.0.0' })
fireEvent.click(screen.getByRole('button', { name: 'Discover open' }))
expect(navigation.getSnapshot()).toEqual({ tab: 'installed', view: { kind: 'package', name: 'dsh-better-sidebar' } })
expect(navigation.getSnapshot()).toEqual({ tab: 'installed', view: { kind: 'package', name: 'dsh-better-sidebar', returnTab: 'discover' } })
expect(document.querySelector('[data-plugin-detail="dsh-better-sidebar"]')).not.toBeNull()
// A detail page hides the tabs; a contributed tab that leaves the ledger falls back to Installed.
// A detail page hides the tabs; its back button returns to the tab that opened it.
expect(screen.queryByRole('tablist')).toBeNull()
fireEvent.click(screen.getByRole('button', { name: en.backToList }))
expect(navigation.getSnapshot()).toEqual({ tab: 'discover', view: { kind: 'list' } })
expect(screen.getByRole('tab', { name: 'Discover' }).getAttribute('aria-selected')).toBe('true')
// A contributed tab that leaves the ledger falls back to Installed.
act(() => { navigation.actions.setView({ kind: 'list' }); navigation.actions.setTab('discover') })
setTabs([])
expect(document.querySelector('[data-plugin-group="bundles"]')).not.toBeNull()
@@ -273,7 +277,7 @@ describe('PluginManagerPage', () => {
expect(screen.getByRole('tabpanel', { name: 'Discover' })).toBeTruthy()
})
it('keeps the Installed tab panel through loading and the More list out of the tabs', () => {
it('keeps the Installed tab panel through loading and the More list out of the tabs, and returns a More plugin opened from Discover to Discover', () => {
const worktree = '@deepseek-ai/dsh-experimental-tool-worktree'
const { navigation, set } = renderTab({ status: 'loading', packages: [] }, {}, {
'plugins.tab:discover': (_view, owner) => (
@@ -292,10 +296,39 @@ describe('PluginManagerPage', () => {
fireEvent.click(screen.getByRole('tab', { name: 'Discover' }))
fireEvent.click(screen.getByRole('button', { name: 'Discover open' }))
expect(document.querySelector(`[data-plugin-detail="${worktree}"]`)).not.toBeNull()
// An official plugin of the More list opened from Discover returns to Discover, not to the More list.
fireEvent.click(screen.getByRole('button', { name: en.backToList }))
expect(navigation.getSnapshot()).toEqual({ tab: 'discover', view: { kind: 'list' } })
fireEvent.click(screen.getByRole('tab', { name: en.installedTab }))
act(() => { navigation.actions.setView({ kind: 'more' }) })
fireEvent.click(screen.getByRole('button', { name: en.openDetail.replace('{name}', worktree) }))
fireEvent.click(screen.getByRole('button', { name: en.backToPackage.replace('{name}', en.moreTitle) }))
expect(screen.getByRole('heading', { name: en.moreTitle, level: 1 })).toBeTruthy()
})
it('keeps the opening tab through a row page opened from a bundle page', () => {
const { navigation, setTabs } = renderTab({ packages: [pkg({ rows: [row()] })] }, { rows: new Set(['dsh-better-sidebar#sidebar']) }, {
'plugins.tab:discover': (_view, owner) => (
<button type="button" onClick={() => { (owner as PluginTabProps).openPackage('dsh-better-sidebar') }}>Discover open</button>
),
'plugins.row.config:dsh-better-sidebar#sidebar': view => view === 'summary' ? 'Config summary' : <form aria-label="row settings" />,
}, {}, [{ id: 'discover', label: 'Discover' }])
fireEvent.click(screen.getByRole('tab', { name: 'Discover' }))
fireEvent.click(screen.getByRole('button', { name: 'Discover open' }))
fireEvent.click(screen.getByRole('button', { name: en.configureRow.replace('{name}', 'dsh-better-sidebar') }))
expect(navigation.getSnapshot().view).toEqual({ kind: 'row', name: 'dsh-better-sidebar', rowId: 'sidebar', returnTab: 'discover' })
fireEvent.click(screen.getByRole('button', { name: en.backToPackage.replace('{name}', 'dsh-better-sidebar') }))
expect(navigation.getSnapshot().view).toEqual({ kind: 'package', name: 'dsh-better-sidebar', returnTab: 'discover' })
fireEvent.click(screen.getByRole('button', { name: en.backToList }))
expect(navigation.getSnapshot()).toEqual({ tab: 'discover', view: { kind: 'list' } })
// A calling tab that left the ledger while the page was open falls back to Installed.
fireEvent.click(screen.getByRole('button', { name: 'Discover open' }))
setTabs([])
fireEvent.click(screen.getByRole('button', { name: en.backToList }))
expect(navigation.getSnapshot().tab).toBe('installed')
expect(document.querySelector('[data-plugin-group="bundles"]')).not.toBeNull()
})
it('shows a confirmed version by name above its spec, as a check and a refusal with retry, without the spec form or another registry', () => {
const confirmed: InstallState = { ...IDLE_INSTALL, open: true, spec: '[email protected]', confirmed: { title: 'Alpha', version: '1.0.0' }, registries: REGISTRIES }
const { actions, set } = renderTab({ install: { ...confirmed, phase: 'checking' } })
@@ -2617,7 +2617,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
},
],
ownerProps: [
'/** Owner props of a page tab another plugin contributes, such as Discover. */\nexport interface PluginTabProps {\n /**\n * Install an exact version the person already confirmed: the page\'s install dialog opens at its check and progress\n * screens, without the spec form, and names the plugin and version above the spec.\n * @param target - the spec, optional registry, and display text.\n */\n readonly install: (target: PluginTabInstall) => void\n /**\n * Switch to the Installed tab and open a bundle\'s page.\n * @param packageName - npm package name of the bundle.\n */\n readonly openPackage: (packageName: string) => void\n}',
'/** Owner props of a page tab another plugin contributes, such as Discover. */\nexport interface PluginTabProps {\n /**\n * Install an exact version the person already confirmed: the page\'s install dialog opens at its check and progress\n * screens, without the spec form, and names the plugin and version above the spec.\n * @param target - the spec, optional registry, and display text.\n */\n readonly install: (target: PluginTabInstall) => void\n /**\n * Switch to the Installed tab and open a bundle\'s page, whose back button returns to the calling tab.\n * @param packageName - npm package name of the bundle.\n */\n readonly openPackage: (packageName: string) => void\n}',
],
ownerPropsReferences: [
'PluginTabInstall',