Skip to content

DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.

feat(config): show built-in plugins in a collapsible group

hairyf0ca04abac696
diff --git a/src/i18n/locales/en-US.json b/src/i18n/locales/en-US.json
index 17716a46..ba836d10 100644
--- a/src/i18n/locales/en-US.json
+++ b/src/i18n/locales/en-US.json
@@ -235,6 +235,7 @@
"plugins.uninstall": "Uninstall",
"plugins.upgrade": "Upgrade",
"plugins.builtin": "Built-in",
+ "plugins.builtin_title": "Built-in plugins ({{count}})",
"plugins.preset": "Preset",
"plugins.abnormal_tooltip": "This plugin is running abnormally. Click to view details.",
"plugins.abnormal_desc": "Plugin {{name}} is abnormal and may be corrupted or incompatible with the current environment.",
diff --git a/src/i18n/locales/zh-CN.json b/src/i18n/locales/zh-CN.json
index 2b272c15..d576fb36 100644
--- a/src/i18n/locales/zh-CN.json
+++ b/src/i18n/locales/zh-CN.json
@@ -235,6 +235,7 @@
"plugins.uninstall": "卸载",
"plugins.upgrade": "升级",
"plugins.builtin": "内置",
+ "plugins.builtin_title": "内置插件({{count}})",
"plugins.preset": "预设",
"plugins.abnormal_tooltip": "此插件运行异常,点击查看详情。",
"plugins.abnormal_desc": "插件 {{name}} 运行异常,可能已损坏或与当前环境不兼容。",
diff --git a/src/ui/config/plugin.tsx b/src/ui/config/plugin.tsx
index cce2b87f..ca7c8b9b 100644
--- a/src/ui/config/plugin.tsx
+++ b/src/ui/config/plugin.tsx
@@ -1,11 +1,11 @@
import type { DshPlugin } from '@/types'
-import { CircleExclamation } from '@gravity-ui/icons'
+import { ChevronRight, CircleExclamation } from '@gravity-ui/icons'
import { Button, Chip, Label, Spinner, Tooltip } from '@heroui/react'
import { useOverlay } from '@overlastic/react'
-import { useMount } from '@reause/core'
+import { useMount, useToggle } from '@reause/core'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { invoke } from '@tauri-apps/api/core'
-import { useState } from 'react'
+import { Fragment, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { If } from 'react-if-lite'
import { tv } from 'tailwind-variants'
@@ -72,12 +72,18 @@ export function ConfigPlugin() {
useMount(refreshUpdates)
useListen<DshPlugin[]>('dsh-plugins-updated', refreshUpdates)
- // 内置插件由启动自愈自动安装与维护,不进入本面板:这里只列出用户可管理
- // (升级/禁用/卸载)的插件,避免必装项混进可卸载清单。
- const plugins = (pluginList ?? []).filter(plugin => !plugin.internal)
const loading = isLoading
const error = pluginError ? String(pluginError) : ''
+ /** 「内置插件」分组是否展开:默认折叠,内置插件由启动自愈维护,不作为常规可管理项 */
+ const [showInternal, toggleShowInternal] = useToggle()
+ // 内置插件(internal)随包分发、由启动自愈安装与维护,排到列表末尾并收进默认折叠的
+ // 分组:与可升级/可卸载的插件并列只会让用户把它们当作普通插件。它们仍可升级
+ // (切换核心版本后内置包可能落后),但不提供卸载/禁用/快照入口。
+ const plugins = pluginList ?? []
+ const internalPlugins = plugins.filter(plugin => plugin.internal)
+ const displayPlugins = [...plugins.filter(plugin => !plugin.internal), ...internalPlugins]
+
const [dialogHolder, openDialog] = useOverlay(Modal, { type: 'holder' })
/** 行内操作进行中状态:id + 操作类型(update/remove/disable/enable/snapshot/restore/delete-snapshot),保证单例运行 */
@@ -427,172 +433,195 @@ export function ConfigPlugin() {
)}
>
<div className="flex flex-col gap-4">
- {plugins.map(plugin => (
- <Item
- key={plugin.id}
- left={(
- <div className="min-w-0">
- <div className="flex min-w-0 items-center gap-1">
- <If cond={plugin.error != null}>
- <Tooltip delay={0}>
- <Button
- isIconOnly
- size="sm"
- variant="ghost"
- className="size-6 shrink-0 rounded-md text-danger"
- aria-label={t('plugins.abnormal_tooltip')}
- >
- <CircleExclamation />
- </Button>
- <Tooltip.Content className="max-w-[320px]">
- <div className="space-y-1">
- <p className="text-xs font-medium">
- {t('plugins.abnormal_desc', { name: plugin.name })}
- </p>
- <p className="whitespace-pre-wrap break-all font-mono text-[11px] opacity-80">
- {plugin.error?.message}
- </p>
- </div>
- </Tooltip.Content>
- </Tooltip>
- </If>
- <Label className="min-w-0 truncate text-sm font-medium text-ink">
- {plugin.name}
- </Label>
- <If cond={plugin.version !== ''}>
- <code className="shrink-0 rounded bg-default px-1.5 py-0.5 font-mono text-[10px] text-muted">
- {plugin.version}
- </code>
+ {displayPlugins.map(plugin => (
+ <Fragment key={plugin.id}>
+ {/* 「内置插件」分组头:默认折叠,点标题展开/收起。内置插件由启动自愈维护,
+ 与可升级/可卸载的插件并列只会让用户误当作普通插件 */}
+ <If cond={plugin === internalPlugins[0]}>
+ <button
+ type="button"
+ className="flex items-center gap-1 px-1 pt-2 text-left text-xs font-medium text-muted"
+ aria-expanded={showInternal}
+ onClick={() => toggleShowInternal()}
+ >
+ <ChevronRight className={showInternal ? 'size-3.5 rotate-90' : 'size-3.5'} />
+ {t('plugins.builtin_title', { count: internalPlugins.length })}
+ </button>
+ </If>
+ <Item
+ key={plugin.id}
+ className={plugin.internal && !showInternal ? 'hidden' : undefined}
+ left={(
+ <div className="min-w-0">
+ <div className="flex min-w-0 items-center gap-1">
+ <If cond={plugin.error != null}>
+ <Tooltip delay={0}>
+ <Button
+ isIconOnly
+ size="sm"
+ variant="ghost"
+ className="size-6 shrink-0 rounded-md text-danger"
+ aria-label={t('plugins.abnormal_tooltip')}
+ >
+ <CircleExclamation />
+ </Button>
+ <Tooltip.Content className="max-w-[320px]">
+ <div className="space-y-1">
+ <p className="text-xs font-medium">
+ {t('plugins.abnormal_desc', { name: plugin.name })}
+ </p>
+ <p className="whitespace-pre-wrap break-all font-mono text-[11px] opacity-80">
+ {plugin.error?.message}
+ </p>
+ </div>
+ </Tooltip.Content>
+ </Tooltip>
+ </If>
+ <Label className="min-w-0 truncate text-sm font-medium text-ink">
+ {plugin.name}
+ </Label>
+ <If cond={plugin.version !== ''}>
+ <code className="shrink-0 rounded bg-default px-1.5 py-0.5 font-mono text-[10px] text-muted">
+ {plugin.version}
+ </code>
+ </If>
+ <If cond={!plugin.internal && plugin.recommended}>
+ <Chip size="sm" variant="soft" color="success" className="shrink-0 font-medium">
+ {t('plugins.preset')}
+ </Chip>
+ </If>
+ <If cond={plugin.disabled}>
+ <Chip size="sm" variant="soft" color="default">
+ {t('plugins.disabled_badge')}
+ </Chip>
+ </If>
+ {/* 配置覆盖禁用:展示在 cordis.patch.yml 中被显式禁用的真实状态
+ (内置插件同样标注,issue #399:Scheduler/Pet 行此前只有「内置」) */}
+ <If cond={plugin.patchDisabled}>
+ <Chip size="sm" variant="soft" color="warning">
+ {t('plugins.patch_disabled_badge')}
+ </Chip>
+ </If>
+ <If cond={plugin.internal}>
+ <code className="shrink-0 rounded bg-default px-1.5 py-0.5 font-mono text-[10px] text-muted">
+ {t('plugins.builtin')}
+ </code>
+ </If>
+ </div>
+ <If cond={plugin.description !== ''}>
+ <TextEllipsis lineClamp={2} className="text-xs text-muted">
+ {plugin.description}
+ </TextEllipsis>
</If>
- <If cond={plugin.recommended}>
- <Chip size="sm" variant="soft" color="success" className="shrink-0 font-medium">
- {t('plugins.preset')}
+ </div>
+ )}
+ right={(
+ <>
+ {/* 升级入口仅在确有更新(updateAvailable)或插件异常(error,修复入口)时显示;
+ 与文档 P1「对 dshmarket 点击升级」一致,且不会常驻——up-to-date 插件不显示升级按钮 */}
+ <If cond={plugin.updateAvailable || plugin.error != null}>
+ <Chip
+ className={actionChip({ busy: !!busy })}
+ variant="primary"
+ color="accent"
+ size="sm"
+ onClick={() => onUpgrade(plugin.id)}
+ >
+ <span className="flex items-center gap-1">
+ <If cond={busy?.id === plugin.id && busy.action === 'update'} then={<Spinner size="sm" color="current" />} />
+ {t('plugins.upgrade')}
+ <If cond={plugin.latestVersion != null && plugin.error == null}>
+ <span className="font-mono text-[10px] opacity-80 max-w-[80px] truncate">
+ {plugin.latestVersion && plugin.latestVersion.length >= 40 ? `${plugin.latestVersion.slice(0, 8)}…` : plugin.latestVersion}
+ </span>
+ </If>
+ </span>
</Chip>
</If>
- <If cond={plugin.disabled}>
- <Chip size="sm" variant="soft" color="default">
- {t('plugins.disabled_badge')}
+ {/* 启用入口:配置覆盖禁用(含内置插件)或桌面禁用清单 → 可启用。
+ 配置覆盖禁用时点击会先弹确认框,确认后后端才移除该覆盖 */}
+ <If cond={plugin.patchDisabled || (!plugin.internal && plugin.disabled)}>
+ <Chip
+ className={actionChip({ busy: !!busy })}
+ variant="primary"
+ color="accent"
+ size="sm"
+ onClick={() => onEnable(plugin.id, plugin.patchDisabled)}
+ >
+ <span className="flex items-center gap-1">
+ <If cond={busy?.id === plugin.id && busy.action === 'enable'} then={<Spinner size="sm" color="current" />} />
+ {t('plugins.enable')}
+ </span>
</Chip>
</If>
- {/* 配置覆盖禁用:展示在 cordis.patch.yml 中被显式禁用的真实状态
- (内置插件同样标注,issue #399:Scheduler/Pet 行此前只有「内置」) */}
- <If cond={plugin.patchDisabled}>
- <Chip size="sm" variant="soft" color="warning">
- {t('plugins.patch_disabled_badge')}
+ <If cond={!plugin.internal && !plugin.patchDisabled && !plugin.disabled}>
+ <Chip
+ className={actionChip({ busy: !!busy })}
+ size="sm"
+ onClick={() => onDisable(plugin.id)}
+ >
+ <span className="flex items-center gap-1">
+ <If cond={busy?.id === plugin.id && busy.action === 'disable'} then={<Spinner size="sm" color="current" />} />
+ {t('plugins.disable')}
+ </span>
</Chip>
</If>
- </div>
- <If cond={plugin.description !== ''}>
- <TextEllipsis lineClamp={2} className="text-xs text-muted">
- {plugin.description}
- </TextEllipsis>
- </If>
- </div>
- )}
- right={(
- <>
- {/* 升级入口仅在确有更新(updateAvailable)或插件异常(error,修复入口)时显示;
- 与文档 P1「对 dshmarket 点击升级」一致,且不会常驻——up-to-date 插件不显示升级按钮 */}
- <If cond={plugin.updateAvailable || plugin.error != null}>
- <Chip
- className={actionChip({ busy: !!busy })}
- variant="primary"
- color="accent"
- size="sm"
- onClick={() => onUpgrade(plugin.id)}
- >
- <span className="flex items-center gap-1">
- <If cond={busy?.id === plugin.id && busy.action === 'update'} then={<Spinner size="sm" color="current" />} />
- {t('plugins.upgrade')}
- <If cond={plugin.latestVersion != null && plugin.error == null}>
- <span className="font-mono text-[10px] opacity-80 max-w-[80px] truncate">
- {plugin.latestVersion && plugin.latestVersion.length >= 40 ? `${plugin.latestVersion.slice(0, 8)}…` : plugin.latestVersion}
+ <If cond={!plugin.internal}>
+ {/* 单插件快照:快照始终可用(已存在时覆盖确认);还原/删除快照仅在
+ 存在快照时显示。还原会停服务,还原后 toast 提示重启(issue #303) */}
+ <Chip
+ className={actionChip({ busy: !!busy })}
+ variant="primary"
+ color="accent"
+ size="sm"
+ onClick={() => onSnapshot(plugin.id, plugin.name, plugin.hasSnapshot)}
+ >
+ <span className="flex items-center gap-1">
+ <If cond={busy?.id === plugin.id && busy.action === 'snapshot'} then={<Spinner size="sm" color="current" />} />
+ {t('plugins.snapshot')}
+ </span>
+ </Chip>
+ <If cond={plugin.hasSnapshot}>
+ <Chip
+ className={actionChip({ busy: !!busy })}
+ variant="primary"
+ color="accent"
+ size="sm"
+ onClick={() => onRestore(plugin.id, plugin.name)}
+ >
+ <span className="flex items-center gap-1">
+ <If cond={busy?.id === plugin.id && busy.action === 'restore'} then={<Spinner size="sm" color="current" />} />
+ {t('plugins.restore')}
</span>
- </If>
- </span>
- </Chip>
- </If>
- {/* 启用入口:配置覆盖禁用(含内置插件)或桌面禁用清单 → 可启用。
- 配置覆盖禁用时点击会先弹确认框,确认后后端才移除该覆盖 */}
- <If cond={plugin.patchDisabled || plugin.disabled}>
- <Chip
- className={actionChip({ busy: !!busy })}
- variant="primary"
- color="accent"
- size="sm"
- onClick={() => onEnable(plugin.id, plugin.patchDisabled)}
- >
- <span className="flex items-center gap-1">
- <If cond={busy?.id === plugin.id && busy.action === 'enable'} then={<Spinner size="sm" color="current" />} />
- {t('plugins.enable')}
- </span>
- </Chip>
- </If>
- <If cond={!plugin.patchDisabled && !plugin.disabled}>
- <Chip
- className={actionChip({ busy: !!busy })}
- size="sm"
- onClick={() => onDisable(plugin.id)}
- >
- <span className="flex items-center gap-1">
- <If cond={busy?.id === plugin.id && busy.action === 'disable'} then={<Spinner size="sm" color="current" />} />
- {t('plugins.disable')}
- </span>
- </Chip>
- </If>
- {/* 单插件快照:快照始终可用(已存在时覆盖确认);还原/删除快照仅在
- 存在快照时显示。还原会停服务,还原后 toast 提示重启(issue #303) */}
- <Chip
- className={actionChip({ busy: !!busy })}
- variant="primary"
- color="accent"
- size="sm"
- onClick={() => onSnapshot(plugin.id, plugin.name, plugin.hasSnapshot)}
- >
- <span className="flex items-center gap-1">
- <If cond={busy?.id === plugin.id && busy.action === 'snapshot'} then={<Spinner size="sm" color="current" />} />
- {t('plugins.snapshot')}
- </span>
- </Chip>
- <If cond={plugin.hasSnapshot}>
- <Chip
- className={actionChip({ busy: !!busy })}
- variant="primary"
- color="accent"
- size="sm"
- onClick={() => onRestore(plugin.id, plugin.name)}
- >
- <span className="flex items-center gap-1">
- <If cond={busy?.id === plugin.id && busy.action === 'restore'} then={<Spinner size="sm" color="current" />} />
- {t('plugins.restore')}
- </span>
- </Chip>
- <Chip
- className={actionChip({ busy: !!busy })}
- size="sm"
- onClick={() => onDeleteSnapshot(plugin.id, plugin.name)}
- >
- <span className="flex items-center gap-1">
- <If cond={busy?.id === plugin.id && busy.action === 'delete-snapshot'} then={<Spinner size="sm" color="current" />} />
- {t('plugins.delete_snapshot')}
- </span>
- </Chip>
- </If>
- <Chip
- className={actionChip({ busy: !!busy })}
- variant="primary"
- color="danger"
- size="sm"
- onClick={() => onRemove(plugin.id, plugin.name)}
- >
- <span className="flex items-center gap-1">
- <If cond={busy?.id === plugin.id && busy.action === 'remove'} then={<Spinner size="sm" color="current" />} />
- {t('plugins.uninstall')}
- </span>
- </Chip>
- </>
- )}
- />
+ </Chip>
+ <Chip
+ className={actionChip({ busy: !!busy })}
+ size="sm"
+ onClick={() => onDeleteSnapshot(plugin.id, plugin.name)}
+ >
+ <span className="flex items-center gap-1">
+ <If cond={busy?.id === plugin.id && busy.action === 'delete-snapshot'} then={<Spinner size="sm" color="current" />} />
+ {t('plugins.delete_snapshot')}
+ </span>
+ </Chip>
+ </If>
+ <Chip
+ className={actionChip({ busy: !!busy })}
+ variant="primary"
+ color="danger"
+ size="sm"
+ onClick={() => onRemove(plugin.id, plugin.name)}
+ >
+ <span className="flex items-center gap-1">
+ <If cond={busy?.id === plugin.id && busy.action === 'remove'} then={<Spinner size="sm" color="current" />} />
+ {t('plugins.uninstall')}
+ </span>
+ </Chip>
+ </If>
+ </>
+ )}
+ />
+ </Fragment>
))}
</div>
</If>
diff --git a/test/plugin-uninstall.test.ts b/test/plugin-uninstall.test.ts
index 6b6e8ba1..278c540c 100644
--- a/test/plugin-uninstall.test.ts
+++ b/test/plugin-uninstall.test.ts
@@ -37,12 +37,27 @@ describe('configPlugin preset chip', () => {
expect(source).toContain('plugins.preset')
})
+ it('renders internal plugins in a collapsed group instead of hiding them', () => {
+ const source = readFileSync(new URL('../src/ui/config/plugin.tsx', import.meta.url), 'utf8')
+ expect(source, '内置插件分组标题').toContain('plugins.builtin_title')
+ expect(source, '内置插件默认折叠').toContain('const [showInternal, toggleShowInternal] = useToggle()')
+ expect(source, '内置插件排在列表末尾').toContain('const displayPlugins = [...plugins.filter(plugin => !plugin.internal), ...internalPlugins]')
+ expect(source, '折叠时隐藏内置插件行').toContain('className={plugin.internal && !showInternal ? \'hidden\' : undefined}')
+ })
+
it('guards the chip on recommended (preset, non-internal)', () => {
const source = readFileSync(new URL('../src/ui/config/plugin.tsx', import.meta.url), 'utf8')
- // 守卫拆成两处:内置插件在列表层就被过滤掉(不再进可管理清单),
- // 预设 chip 本身只按 `recommended` 渲染。
- expect(source, '内置插件不进可管理列表').toContain('!plugin.internal')
- expect(source, '预设 chip 仅对 recommended 渲染').toContain('cond={plugin.recommended}')
+ // 预设 chip 只对「预设且非内置」渲染:内置插件即便在预设清单中也不打「预设」标。
+ expect(source, '预设 chip 仅对非内置的 recommended 渲染').toContain('cond={!plugin.internal && plugin.recommended}')
+ // 内置插件保留「内置」徽标,但与普通插件分组隔离。
+ expect(source).toContain('plugins.builtin')
+ })
+
+ it('withholds uninstall/disable/snapshot from internal plugins', () => {
+ const source = readFileSync(new URL('../src/ui/config/plugin.tsx', import.meta.url), 'utf8')
+ expect(source, '禁用入口排除内置插件').toContain('cond={!plugin.internal && !plugin.patchDisabled && !plugin.disabled}')
+ expect(source, '启用入口排除内置插件的桌面禁用态').toContain('cond={plugin.patchDisabled || (!plugin.internal && plugin.disabled)}')
+ expect(source, '快照入口由 !plugin.internal 守卫').toContain('<If cond={!plugin.internal}>')
})
})