feat(plugin-inventory): flat plugin list with a default-open toggle guard
The plugin-list tab rendered one flat list of every Loader entry — no separate "system plugins" section — with each card showing its real enabled state and an enable/disable button (a required plugin shows only a read-only note). The enable/disable guard flipped from default-protect to default-open: only the small REQUIRED_PLUGINS core (entry tree, Remote RPC spine, session/agent spines) is protected from being disabled, so the shipped plugins are actually toggleable. Tests, host READMEs, and the enable-disable agent note track the new grouping and guard. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -34,19 +34,22 @@ patch's `applyEntryPatches` target lookup.
|
||||
|
||||
The Web plugin-list tab (`ui-settings-plugin-inventory`) adds an enable/disable
|
||||
button to each expanded card, wired to the Remote, re-listing after the toggle.
|
||||
The list is grouped: toggleable plugins carry the button in the main list, while
|
||||
the required system plugins sit in a separate collapsible "system plugins"
|
||||
section with no controls.
|
||||
The tab renders one flat list of every entry: each card shows the real current
|
||||
state, a toggleable plugin carries an enable or disable button (so a
|
||||
bundle-default disabled plugin can be re-enabled), and a required plugin shows
|
||||
only a read-only note.
|
||||
|
||||
**Guard:** every entry carries a `protected` flag. Disabling a plugin that
|
||||
another plugin injects breaks the dependent, and enabling one whose service is
|
||||
unavailable fails the boot (both surfaced as `dsh-tool-ralph: pending (waiting
|
||||
for service: workflowEngine)` after a bad toggle). So `setEnabled` refuses to
|
||||
**disable** a required plugin, and after **enabling** a plugin it verifies the
|
||||
fiber became active (reverting a dependency-missing enable). The plugin-list tab
|
||||
groups by current state: disabled plugins sit in the main list with an enable
|
||||
button, while enabled plugins sit in a collapsible system section (a user-added
|
||||
enabled plugin keeps a disable toggle, a required one shows none).
|
||||
**Guard:** every entry carries a `protected` flag. The guard is default-open:
|
||||
only the small `REQUIRED_PLUGINS` set in `src/required.ts` (the entry tree, the
|
||||
Remote RPC spine, the session and agent spines) is protected. Disabling a
|
||||
plugin that another plugin injects breaks the dependent, and enabling one whose
|
||||
service is unavailable fails the boot (both surfaced as
|
||||
`dsh-tool-ralph: pending (waiting for service: workflowEngine)` after a bad
|
||||
toggle). So `setEnabled` refuses to **disable** a required plugin, and after
|
||||
**enabling** a plugin it verifies the fiber became active (reverting a
|
||||
dependency-missing enable). The plugin-list tab renders one flat list: a
|
||||
toggleable plugin carries an enable or disable button from its real state,
|
||||
while a required plugin shows only a read-only note.
|
||||
|
||||
## Persistence caveat
|
||||
|
||||
|
||||
@@ -26,15 +26,17 @@ Web UI 的插件列表是只读的:它展示 Loader 的条目和生命周期
|
||||
(`include:<rowId>`);两者不同,只有裸 id 能命中 patch 的 `applyEntryPatches` 目标查找。
|
||||
|
||||
Web 插件列表 tab(`ui-settings-plugin-inventory`)在每张展开卡片的详情区加启用/停用按钮,
|
||||
绑定该 Remote,切换后重新拉取列表。列表分组:可切换插件在主列表带按钮,必需的系统插件
|
||||
放在一个可折叠的"系统插件"区,无任何开关。
|
||||
绑定该 Remote,切换后重新拉取列表。该 tab 渲染单一扁平列表,包含所有条目:每张卡片显示真实
|
||||
当前状态,可切换插件带"启用"或"停用"按钮(所以 bundle 默认禁用的插件也能重新启用),
|
||||
必需插件只显示只读说明。
|
||||
|
||||
**门卫:** 每条条目带 `protected` 标记。停用一个被其他插件注入的插件会破坏依赖者,
|
||||
启用一个服务不可用的插件会导致启动失败(坏切换后都会表现为
|
||||
`dsh-tool-ralph: pending (waiting for service: workflowEngine)`)。所以 `setEnabled`
|
||||
拒绝**停用**必需插件;**启用**后校验 fiber 变为 active(依赖缺失的启用会回滚)。
|
||||
插件列表 tab 按当前状态分组:已停用插件在主列表带"启用"按钮,已启用插件放在可折叠的
|
||||
"系统插件"区(用户自加的已启用插件保留"停用"按钮,必需插件无任何开关)。
|
||||
**门卫:** 每条条目带 `protected` 标记。守卫默认开放:只有 `src/required.ts` 中
|
||||
`REQUIRED_PLUGINS` 这个小型集合(入口树、Remote RPC 主干、session 与 agent 主干)受保护。
|
||||
停用一个被其他插件注入的插件会破坏依赖者,启用一个服务不可用的插件会导致启动失败
|
||||
(坏切换后都会表现为 `dsh-tool-ralph: pending (waiting for service: workflowEngine)`)。
|
||||
所以 `setEnabled` 拒绝**停用**必需插件;**启用**后校验 fiber 变为 active(依赖缺失的
|
||||
启用会回滚)。插件列表 tab 渲染单一扁平列表:可切换插件按真实状态带"启用"或"停用"按钮,
|
||||
必需插件只显示只读说明。
|
||||
|
||||
## 持久化注意
|
||||
|
||||
|
||||
-22
@@ -289,25 +289,3 @@
|
||||
opacity: 0.7;
|
||||
font-size: 0.85em;
|
||||
}
|
||||
|
||||
.systemSection {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.systemHeading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
width: 100%;
|
||||
padding: 0.5rem 0;
|
||||
font-weight: 600;
|
||||
background: none;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.systemCount {
|
||||
font-weight: 400;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
+5
-28
@@ -70,7 +70,6 @@ export function PluginInventorySettingsTab({ list, setEnabled, t }: PluginInvent
|
||||
const [expanded, setExpanded] = useState<PluginInventoryEntry['entryId'] | null>(null)
|
||||
const [state, setState] = useState<ViewState>({ status: 'loading' })
|
||||
const [busy, setBusy] = useState<PluginInventoryEntry['entryId'] | null>(null)
|
||||
const [systemOpen, setSystemOpen] = useState(true)
|
||||
|
||||
useEffect(() => {
|
||||
let current = true
|
||||
@@ -98,11 +97,9 @@ export function PluginInventorySettingsTab({ list, setEnabled, t }: PluginInvent
|
||||
: [],
|
||||
[normalizedQuery, state],
|
||||
)
|
||||
// Disabled plugins sit in the main list with an enable toggle so they can be
|
||||
// re-enabled; enabled plugins are grouped into a collapsible system section
|
||||
// (a user-added enabled plugin still carries a disable toggle).
|
||||
const userEntries = filteredEntries.filter(entry => !entry.enabled)
|
||||
const systemEntries = filteredEntries.filter(entry => entry.enabled)
|
||||
// One flat list carries every plugin: each shows its real state with an
|
||||
// enable or disable button, while a required plugin shows only the required
|
||||
// note (it cannot be toggled).
|
||||
|
||||
useEffect(() => {
|
||||
if (expanded !== null && !filteredEntries.some(entry => entry.entryId === expanded)) {
|
||||
@@ -230,31 +227,11 @@ export function PluginInventorySettingsTab({ list, setEnabled, t }: PluginInvent
|
||||
{state.snapshot.entries.length > 0 && filteredEntries.length === 0
|
||||
? <p className={css.status}>{t('emptySearch')}</p>
|
||||
: null}
|
||||
{userEntries.length > 0 ? (
|
||||
{filteredEntries.length > 0 ? (
|
||||
<ul className={css.cards}>
|
||||
{userEntries.map(card)}
|
||||
{filteredEntries.map(card)}
|
||||
</ul>
|
||||
) : null}
|
||||
{systemEntries.length > 0 ? (
|
||||
<section className={css.systemSection} aria-labelledby={`${catalogId}-system-heading`}>
|
||||
<button
|
||||
className={css.systemHeading}
|
||||
type="button"
|
||||
id={`${catalogId}-system-heading`}
|
||||
aria-expanded={systemOpen}
|
||||
onClick={() => { setSystemOpen(current => !current) }}
|
||||
>
|
||||
<span>{t('systemPlugins')}</span>
|
||||
<span className={css.systemCount}>{systemEntries.length}</span>
|
||||
<IconChevronDownOutline14 className={css.chevron} size={12} aria-hidden="true" />
|
||||
</button>
|
||||
{systemOpen ? (
|
||||
<ul className={css.cards}>
|
||||
{systemEntries.map(card)}
|
||||
</ul>
|
||||
) : null}
|
||||
</section>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
@@ -24,7 +24,6 @@ export const zh = {
|
||||
disable: '停用',
|
||||
toggling: '切换中…',
|
||||
required: '应用必需插件,不可切换',
|
||||
systemPlugins: '系统插件',
|
||||
} satisfies Record<string, string>
|
||||
|
||||
/** Plugin inventory locale key union. */
|
||||
@@ -54,5 +53,4 @@ export const en = {
|
||||
disable: 'Disable',
|
||||
toggling: 'Toggling…',
|
||||
required: 'Required by the app; cannot be toggled',
|
||||
systemPlugins: 'System plugins',
|
||||
} satisfies Record<PluginInventoryLocaleKey, string>
|
||||
|
||||
@@ -78,6 +78,35 @@ describe('PluginInventorySettingsTab', () => {
|
||||
expect(screen.queryByText(en.unobserved)).toBeNull()
|
||||
})
|
||||
|
||||
it('renders every plugin in one flat list, toggling by state and guarding required plugins', async () => {
|
||||
const grouped = {
|
||||
entries: [
|
||||
{ entryId: 'recog', moduleName: '@deepseek-ai/dsh-image-recognition', enabled: true, protected: false, fiberPhase: 'active' },
|
||||
{ entryId: 'recog-http', moduleName: '@deepseek-ai/dsh-image-recognition-http', enabled: false, protected: false, fiberPhase: null },
|
||||
{ entryId: 'hmr', moduleName: '@deepseek-ai/cordis-plugin-hmr', enabled: true, protected: true, fiberPhase: 'active' },
|
||||
],
|
||||
} as unknown as Snapshot
|
||||
render(<PluginInventorySettingsTab {...props(async () => grouped)} />)
|
||||
|
||||
// No separate system section: all three entries share one flat list.
|
||||
expect(screen.queryByText('System plugins')).toBeNull()
|
||||
expect((await screen.findByRole('searchbox', { name: en.search })).getAttribute('aria-label')).toBeTruthy()
|
||||
expect(screen.getAllByRole('listitem')).toHaveLength(3)
|
||||
|
||||
// A toggleable enabled plugin carries a disable button.
|
||||
fireEvent.click(screen.getByRole('button', { name: 'image-recognition, Mounted, Enabled' }))
|
||||
expect(screen.getByRole('button', { name: en.disable })).toBeTruthy()
|
||||
|
||||
// A toggleable disabled plugin carries an enable button.
|
||||
fireEvent.click(screen.getByRole('button', { name: 'image-recognition-http, Disabled' }))
|
||||
expect(screen.getByRole('button', { name: en.enable })).toBeTruthy()
|
||||
|
||||
// A required plugin shows the required note, never a toggle.
|
||||
fireEvent.click(screen.getByRole('button', { name: 'hmr, Mounted, Enabled' }))
|
||||
expect(screen.getByText(en.required)).toBeTruthy()
|
||||
expect(screen.queryByRole('button', { name: en.disable })).toBeNull()
|
||||
})
|
||||
|
||||
it('filters by module name or Loader entry id', async () => {
|
||||
render(<PluginInventorySettingsTab {...props(async () => SNAPSHOT)} />)
|
||||
const search = await screen.findByRole('searchbox', { name: en.search })
|
||||
|
||||
@@ -6,7 +6,7 @@ Host projection of the current Cordis Loader tree with per-plugin enable/disable
|
||||
|
||||
The phase is `pending`, `loading`, `active`, `failed`, or `unloading`; it is `null` when the entry has no live root Fiber. The snapshot is intentionally point-in-time: Loader remains the sole lifecycle authority, while this package owns no cache, history, provenance model, or event stream. `setEnabled` toggles one entry live through `ctx.loader.update` and persists an explicit `disabled` override into the profile's user patch layer so the choice survives a restart (a bundle-default disable needs the `disabled: false` override to stick).
|
||||
|
||||
Every entry carries a `protected` flag. The guard is default-protect: every shipped plugin is required by the application (disabling one that another plugin injects breaks the dependent; enabling one whose service is unavailable fails the boot), so `setEnabled` refuses them and the UI hides the toggle. Only plugins a deployment adds through an opt-in bundle (`USER_TOGGLEABLE_PLUGINS` in `src/required.ts`) are toggleable. The Web plugin-list tab groups the inventory by current state: disabled plugins sit in the main list with an enable button (so they can be re-enabled), while enabled plugins sit in a collapsible "system plugins" section — a user-added enabled plugin keeps a disable toggle, a required one shows none. Its public payload types live under `./types`, and Typert generates the Host and Client Remote artifacts exposed by `./typert` and `./remote`.
|
||||
Every entry carries a `protected` flag. The guard is default-open: every plugin is toggleable unless its module name is in the small `REQUIRED_PLUGINS` set in `src/required.ts` — the load-bearing core (the entry tree, the Remote RPC spine, the session and agent spines) that must never be disabled. `setEnabled` refuses to disable a required plugin and, after enabling, verifies the fiber becomes active (reverting a dependency-missing enable). The Web plugin-list tab renders one flat list of every entry: each shows its real enabled state, a toggleable plugin carries an enable or disable button (so a bundle-default-disabled plugin can be re-enabled), and a required plugin shows only a read-only note. Its public payload types live under `./types`, and Typert generates the Host and Client Remote artifacts exposed by `./typert` and `./remote`.
|
||||
|
||||
The service is Remote-only and deliberately declares no same-process Cordis `Context` merge. Client packages consume it through the explicit [`api-remotes`](../../api/remotes/README.md) assembly rather than importing the Host implementation.
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
阶段为 `pending`、`loading`、`active`、`failed` 或 `unloading`;条目没有存活的根 Fiber 时则为 `null`。该快照刻意只表示调用当下:Loader 仍是唯一的生命周期权威,本包不拥有缓存、历史、来源模型或事件流。`setEnabled` 通过 `ctx.loader.update` 实时切换单条条目,并把显式 `disabled` 覆盖写进 profile 的用户补丁层,使选择在重启后保留(bundle 默认禁用的行需要 `disabled: false` 覆盖才能保持启用)。
|
||||
|
||||
每条条目带 `protected` 标记。守卫默认保护:所有随包插件都是应用必需(停用一个被其他插件注入的插件会破坏依赖者;启用一个服务不可用的插件会导致启动失败),所以 `setEnabled` 拒绝它们、UI 隐藏开关。只有部署通过 opt-in bundle 添加的插件(`src/required.ts` 的 `USER_TOGGLEABLE_PLUGINS`)可切换。Web 插件列表 tab 按当前状态分组:已停用插件在主列表带"启用"按钮(可重新启用),已启用插件放在可折叠的"系统插件"区——用户自加的已启用插件仍保留"停用"按钮,必需插件则无任何开关。公开 payload 类型位于 `./types`,Typert 生成由 `./typert` 与 `./remote` 导出的 Host 和 Client Remote 产物。
|
||||
每条条目带 `protected` 标记。守卫默认开放:除 `src/required.ts` 中 `REQUIRED_PLUGINS` 这个小型集合(入口树、Remote RPC 主干、session 与 agent 主干等必须保留的核心)外,所有插件都可切换。`setEnabled` 拒绝停用必需插件;启用后会校验 fiber 变为 active(依赖缺失的启用会回滚)。Web 插件列表 tab 渲染单一扁平列表,包含所有条目:每项按真实启用状态显示,可切换插件带"启用"或"停用"按钮(这样 bundle 默认禁用的插件也能重新启用),必需插件只显示只读说明。公开 payload 类型位于 `./types`,Typert 生成由 `./typert` 与 `./remote` 导出的 Host 和 Client Remote 产物。
|
||||
|
||||
该服务仅供 Remote 使用,刻意不声明同进程 Cordis `Context` merge。Client 包通过显式的 [`api-remotes`](../../api/remotes/README.md) 组合消费它,而不导入 Host 实现。
|
||||
|
||||
|
||||
@@ -1,30 +1,31 @@
|
||||
/**
|
||||
* Which Loader plugins the running application requires and must not be toggled.
|
||||
*
|
||||
* The guard is a default-protect rule: every shipped/known plugin is required by
|
||||
* the application, so toggling it can tear the process down — disabling a plugin
|
||||
* that another plugin injects breaks the dependent, and enabling one whose
|
||||
* service is unavailable fails the boot. Only plugins a deployment explicitly
|
||||
* adds through an opt-in bundle (the "user/extra" plugins) are safe to enable or
|
||||
* disable. Add every new opt-in bundle's plugin module names to
|
||||
* {@link USER_TOGGLEABLE_PLUGINS}.
|
||||
* The guard is default-open: every plugin is toggleable unless it is explicitly
|
||||
* listed as required. Only the few load-bearing core plugins that other plugins
|
||||
* inject and whose disable would tear the process or the management surface
|
||||
* down are surfaced as `protected`. Add a module name to
|
||||
* {@link REQUIRED_PLUGINS} when a plugin must never be disabled.
|
||||
* @module @deepseek-ai/dsh-plugin-inventory/required
|
||||
*/
|
||||
|
||||
/**
|
||||
* Plugin module names a deployment may enable or disable. Every other module is
|
||||
* required by the application and surfaced as `protected`. Extend this set when
|
||||
* a new opt-in bundle adds plugins the UI should let the user toggle.
|
||||
* Plugin module names that are required by the application and must not be
|
||||
* toggled. Everything else is toggleable. Keep this to the true core: the entry
|
||||
* tree, the Remote RPC spine every Remote depends on, and the session/agent
|
||||
* spines. `cordis:required` is a test seam for the unit tests.
|
||||
*/
|
||||
const USER_TOGGLEABLE_PLUGINS = new Set([
|
||||
'@deepseek-ai/dsh-image-recognition',
|
||||
'@deepseek-ai/dsh-image-recognition-http',
|
||||
'@deepseek-ai/dsh-tool-image-recognition',
|
||||
// Test seam: a `cordis:` builtin the unit tests use as a toggleable entry.
|
||||
'cordis:user-toggleable',
|
||||
const REQUIRED_PLUGINS = new Set([
|
||||
'@deepseek-ai/cordis-plugin-loader',
|
||||
'@deepseek-ai/dsh-typert-registry',
|
||||
'@deepseek-ai/dsh-typert-loader',
|
||||
'@deepseek-ai/dsh-session',
|
||||
'@deepseek-ai/dsh-agent',
|
||||
// Test seam: a `cordis:` builtin the unit tests use as a required entry.
|
||||
'cordis:required',
|
||||
])
|
||||
|
||||
/** Whether a Loader module is required by the application and must not be toggled. */
|
||||
export function isRequiredPlugin(moduleName: string): boolean {
|
||||
return !USER_TOGGLEABLE_PLUGINS.has(moduleName)
|
||||
return REQUIRED_PLUGINS.has(moduleName)
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ async function harness(): Promise<{
|
||||
ctx.loader.builtins.pending = pendingPlugin
|
||||
// `cordis:` builtins the toggle tests create; they resolve without a package install.
|
||||
ctx.loader.builtins['user-toggleable'] = activePlugin
|
||||
ctx.loader.builtins['host-webserver'] = activePlugin
|
||||
ctx.loader.builtins['required'] = activePlugin
|
||||
await ctx.plugin(PluginInventoryGateway)
|
||||
const inventory = ctx.get('pluginInventory') as PluginInventoryGateway
|
||||
return { ctx, inventory }
|
||||
@@ -63,7 +63,7 @@ describe('PluginInventoryGateway', () => {
|
||||
|
||||
it('setEnabled refuses a required plugin', async () => {
|
||||
const { ctx, inventory } = await harness()
|
||||
const id = await ctx.loader.create({ name: 'cordis:host-webserver' }) as PluginEntryId
|
||||
const id = await ctx.loader.create({ name: 'cordis:required' }) as PluginEntryId
|
||||
expect(inventory.list().entries.find(entry => entry.entryId === id)?.protected).toBe(true)
|
||||
await expect(inventory.setEnabled(id, false)).rejects.toThrow(/required by the application/)
|
||||
expect(inventory.list().entries.find(entry => entry.entryId === id)?.enabled).toBe(true)
|
||||
@@ -86,21 +86,21 @@ describe('PluginInventoryGateway', () => {
|
||||
entryId: activeId,
|
||||
moduleName: 'cordis:active',
|
||||
enabled: true,
|
||||
protected: true,
|
||||
protected: false,
|
||||
fiberPhase: 'active',
|
||||
},
|
||||
{
|
||||
entryId: pendingId,
|
||||
moduleName: 'cordis:pending',
|
||||
enabled: true,
|
||||
protected: true,
|
||||
protected: false,
|
||||
fiberPhase: 'pending',
|
||||
},
|
||||
{
|
||||
entryId: disabledId,
|
||||
moduleName: 'cordis:not-installed',
|
||||
enabled: false,
|
||||
protected: true,
|
||||
protected: false,
|
||||
fiberPhase: null,
|
||||
},
|
||||
]))
|
||||
@@ -110,7 +110,7 @@ describe('PluginInventoryGateway', () => {
|
||||
entryId: activeId,
|
||||
moduleName: 'cordis:active',
|
||||
enabled: false,
|
||||
protected: true,
|
||||
protected: false,
|
||||
fiberPhase: null,
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user