Skip to content

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

feat(plugin): add advanced options toggle for snapshot entries

hairyf6b5d2875e6fe
diff --git a/src/i18n/locales/en-US.json b/src/i18n/locales/en-US.json
index 28594a68..8d76b2f8 100644
--- a/src/i18n/locales/en-US.json
+++ b/src/i18n/locales/en-US.json
@@ -286,6 +286,7 @@
"plugins.enable_override_confirm_title": "Enable via config override",
"plugins.enable_override_confirm_desc": "{{name}} is disabled in cordis.patch.yml. Enabling will remove only that disable override (other config entries are kept) and restart the service. Continue?",
"plugins.enable_override_confirm": "Remove override & enable",
+ "plugins.advanced_options": "Advanced options",
"plugins.snapshot": "Snapshot",
"plugins.snapshot_toast": "Plugin {{name}} snapshotted",
"plugins.snapshot_failed": "Failed to snapshot {{name}}",
diff --git a/src/i18n/locales/zh-CN.json b/src/i18n/locales/zh-CN.json
index 5bfb00a2..cdfcdea1 100644
--- a/src/i18n/locales/zh-CN.json
+++ b/src/i18n/locales/zh-CN.json
@@ -286,6 +286,7 @@
"plugins.enable_override_confirm_title": "启用被配置覆盖禁用的插件",
"plugins.enable_override_confirm_desc": "插件 {{name}} 在 cordis.patch.yml 中被配置覆盖禁用。启用将仅移除该禁用覆盖(保留其它配置条目)并重启服务,确定吗?",
"plugins.enable_override_confirm": "移除覆盖并启用",
+ "plugins.advanced_options": "高级选项",
"plugins.snapshot": "快照",
"plugins.snapshot_toast": "插件 {{name}} 已创建快照",
"plugins.snapshot_failed": "创建插件 {{name}} 快照失败",
diff --git a/src/ui/config/plugin.tsx b/src/ui/config/plugin.tsx
index 08f44850..d23c8d5d 100644
--- a/src/ui/config/plugin.tsx
+++ b/src/ui/config/plugin.tsx
@@ -1,7 +1,7 @@
import type { BlockedRefusal } from '@/store/modules/preinstall'
import type { DshPlugin } from '@/types'
import { ChevronRight, CircleExclamation } from '@gravity-ui/icons'
-import { Button, Chip, Label, Spinner, Tooltip } from '@heroui/react'
+import { Button, Chip, Label, Spinner, Switch, Tooltip } from '@heroui/react'
import { useOverlay } from '@overlastic/react'
import { useMount, useToggle } from '@reause/core'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
@@ -79,6 +79,8 @@ export function ConfigPlugin() {
/** 「内置插件」分组是否展开:默认折叠,内置插件由启动自愈维护,不作为常规可管理项 */
const [showInternal, toggleShowInternal] = useToggle()
+ /** 高级选项:默认关闭,快照(创建/还原/删除)属于低频维护操作,不常驻每行 */
+ const [advanced, toggleAdvanced] = useToggle()
// 内置插件(internal)随包分发、由启动自愈安装与维护,排到列表末尾并收进默认折叠的
// 分组:与可升级/可卸载的插件并列只会让用户把它们当作普通插件。它们仍可升级
// (切换核心版本后内置包可能落后),但不提供卸载/禁用/快照入口。
@@ -614,43 +616,45 @@ export function ConfigPlugin() {
</Chip>
</If>
<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}>
+ <If cond={advanced}>
+ {/* 单插件快照:快照始终可用(已存在时覆盖确认);还原/删除快照仅在
+ 存在快照时显示。还原会停服务,还原后 toast 提示重启(issue #303) */}
<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)}
+ onClick={() => onSnapshot(plugin.id, plugin.name, plugin.hasSnapshot)}
>
<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')}
+ <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>
</If>
<Chip
className={actionChip({ busy: !!busy })}
@@ -678,20 +682,35 @@ export function ConfigPlugin() {
title={t('plugins.title')}
testId="dsh-config-panel-title"
action={(
- <Tooltip delay={0}>
- <Button
+ <div className="flex shrink-0 items-center gap-3">
+ <Switch
size="sm"
- variant="primary"
- className="rounded-md"
- onPress={store.preinstall.open}
- isDisabled={preinstall.installing}
+ isSelected={advanced}
+ onChange={() => toggleAdvanced()}
+ aria-label={t('plugins.advanced_options')}
>
- {t('preinstall.open_preset')}
- </Button>
- <Tooltip.Content>
- <p>{t('preinstall.settings_hint')}</p>
- </Tooltip.Content>
- </Tooltip>
+ <Switch.Content>
+ <Switch.Control>
+ <Switch.Thumb />
+ </Switch.Control>
+ </Switch.Content>
+ </Switch>
+ <span className="text-xs font-medium text-muted">{t('plugins.advanced_options')}</span>
+ <Tooltip delay={0}>
+ <Button
+ size="sm"
+ variant="primary"
+ className="rounded-md"
+ onPress={store.preinstall.open}
+ isDisabled={preinstall.installing}
+ >
+ {t('preinstall.open_preset')}
+ </Button>
+ <Tooltip.Content>
+ <p>{t('preinstall.settings_hint')}</p>
+ </Tooltip.Content>
+ </Tooltip>
+ </div>
)}
description={t('plugins.panel_tooltip')}
/>
diff --git a/test/plugin-uninstall.test.ts b/test/plugin-uninstall.test.ts
index a682b4d5..9f14fbf5 100644
--- a/test/plugin-uninstall.test.ts
+++ b/test/plugin-uninstall.test.ts
@@ -65,6 +65,13 @@ describe('configPlugin preset chip', () => {
expect(source, '启用入口排除内置插件的桌面禁用态').toContain('cond={plugin.patchDisabled || (!plugin.internal && plugin.disabled)}')
expect(source, '快照入口由 !plugin.internal 守卫').toContain('<If cond={!plugin.internal}>')
})
+
+ it('hides the snapshot entries behind a default-off advanced toggle', () => {
+ const source = readFileSync(new URL('../src/ui/config/plugin.tsx', import.meta.url), 'utf8')
+ expect(source, '高级选项默认关闭').toContain('const [advanced, toggleAdvanced] = useToggle()')
+ expect(source, '快照入口受高级选项控制').toContain('<If cond={advanced}>')
+ expect(source, '控件挂在「打开预设」左侧').toContain('plugins.advanced_options')
+ })
})
// ── Suite C — uninstall flow wires to remove_dsh_plugin + restart ────────────