Skip to content

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

feat(preinstall): 推荐插件引导页改为 lobehub 风格卡片网格

hairyf1b9f1a94cb8e
diff --git a/src-tauri/resources/README.md b/src-tauri/resources/README.md
index b635b223..3a4c2cf1 100644
--- a/src-tauri/resources/README.md
+++ b/src-tauri/resources/README.md
@@ -74,6 +74,7 @@ that adds one entry to the JSON array:
| `repoUrl` | yes | Repository page, opened via the "open repo" button |
| `recommended` | no | Green "recommended" chip, checked by default (defaults to `false`) |
| `fix` | no | Yellow "fix" chip, checked by default — reserved for Windows minimal-mode fixes (defaults to `false`) |
+| `defaultUnchecked` | no | Listed with the "recommended" chip but **not** pre-checked in the wizard (defaults to `false`) |
| `winOnly` | no | Only listed on Windows (defaults to `false`) |
`id` must be unique across the file. The plugin itself is **not** vendored into
diff --git a/src-tauri/resources/preset-plugins.json b/src-tauri/resources/preset-plugins.json
index f4686fff..9ea7a958 100644
--- a/src-tauri/resources/preset-plugins.json
+++ b/src-tauri/resources/preset-plugins.json
@@ -30,6 +30,7 @@
"name": "DSH IM",
"description": "Connect IM channels (WeChat, Feishu, DingTalk, WeCom, QQ, Slack, Telegram, Discord, WhatsApp, iMessage and more) plus a public AI Office to a local DeepSeek Harness, with bot management in the desktop sidebar.",
"repoUrl": "https://github.com/xmanrui/dsh-im",
- "recommended": true
+ "recommended": true,
+ "defaultUnchecked": true
}
]
diff --git a/src-tauri/src/service/plugin/install/single.rs b/src-tauri/src/service/plugin/install/single.rs
index 4164f9c0..6ef38cac 100644
--- a/src-tauri/src/service/plugin/install/single.rs
+++ b/src-tauri/src/service/plugin/install/single.rs
@@ -412,6 +412,7 @@ mod tests {
recommended: false,
fix: false,
default_checked: false,
+ default_unchecked: false,
win_only: false,
internal,
}
diff --git a/src-tauri/src/service/plugin/install/spec.rs b/src-tauri/src/service/plugin/install/spec.rs
index e60b28dd..0971c0ad 100644
--- a/src-tauri/src/service/plugin/install/spec.rs
+++ b/src-tauri/src/service/plugin/install/spec.rs
@@ -158,6 +158,7 @@ mod tests {
recommended: false,
fix: false,
default_checked: false,
+ default_unchecked: false,
win_only: false,
internal,
}
diff --git a/src-tauri/src/service/plugin/installed.rs b/src-tauri/src/service/plugin/installed.rs
index 42061346..683a3f68 100644
--- a/src-tauri/src/service/plugin/installed.rs
+++ b/src-tauri/src/service/plugin/installed.rs
@@ -87,6 +87,8 @@ pub struct PreinstallPlugin {
pub fix: bool,
/// 无 chip 但默认勾选(首次引导直接勾上,不标「推荐」)
pub default_checked: bool,
+ /// 显式声明首次引导不默认勾选(仍可标「推荐」chip,但不预选)
+ pub default_unchecked: bool,
pub installed: bool,
}
@@ -124,6 +126,7 @@ pub fn list(app_handle: &AppHandle) -> Vec<PreinstallPlugin> {
recommended: p.recommended,
fix: p.fix,
default_checked: p.default_checked,
+ default_unchecked: p.default_unchecked,
installed: is_installed,
}
})
@@ -270,6 +273,7 @@ mod tests {
recommended: false,
fix: false,
default_checked: true,
+ default_unchecked: false,
win_only: false,
internal: false,
};
diff --git a/src-tauri/src/service/plugin/preset.rs b/src-tauri/src/service/plugin/preset.rs
index e86262cd..6249bde8 100644
--- a/src-tauri/src/service/plugin/preset.rs
+++ b/src-tauri/src/service/plugin/preset.rs
@@ -48,6 +48,9 @@ pub struct PreinstallPluginInfo {
/// 无 chip 但默认勾选(不标「推荐」,首次引导仍直接勾上)
#[serde(default)]
pub default_checked: bool,
+ /// 显式声明首次引导不默认勾选:仍可标「推荐」chip,但不预选(如 dsh-im)
+ #[serde(default)]
+ pub default_unchecked: bool,
/// 仅 Windows 平台列出
#[serde(default)]
pub win_only: bool,
@@ -183,6 +186,7 @@ fn discover_dev_internal_plugins_at(root: &Path) -> Vec<DevPluginCandidate> {
recommended: false,
fix: false,
default_checked: false,
+ default_unchecked: false,
win_only: false,
};
Some(DevPluginCandidate { info, directory })
@@ -1007,6 +1011,7 @@ mod tests {
recommended: false,
fix: false,
default_checked: false,
+ default_unchecked: false,
win_only: false,
},
PreinstallPluginInfo {
@@ -1020,6 +1025,7 @@ mod tests {
recommended: false,
fix: false,
default_checked: false,
+ default_unchecked: false,
win_only: false,
},
];
diff --git a/src-tauri/src/service/plugin/verify.rs b/src-tauri/src/service/plugin/verify.rs
index 757a60b9..47554006 100644
--- a/src-tauri/src/service/plugin/verify.rs
+++ b/src-tauri/src/service/plugin/verify.rs
@@ -336,6 +336,7 @@ mod tests {
recommended: false,
fix: false,
default_checked: false,
+ default_unchecked: false,
win_only: false,
internal: false,
}
diff --git a/src-tauri/src/service/plugin/watch.rs b/src-tauri/src/service/plugin/watch.rs
index 3ff7660a..b6e7225a 100644
--- a/src-tauri/src/service/plugin/watch.rs
+++ b/src-tauri/src/service/plugin/watch.rs
@@ -406,6 +406,7 @@ mod tests {
recommended: true,
fix: false,
default_checked: false,
+ default_unchecked: false,
win_only: false,
package: None,
internal: false,
@@ -490,6 +491,7 @@ mod tests {
recommended: true,
fix: false,
default_checked: false,
+ default_unchecked: false,
win_only: false,
package: None,
internal: true,
diff --git a/src/layout/components/setup-preinstall.tsx b/src/layout/components/setup-preinstall.tsx
index f7c9704b..5b8122c4 100644
--- a/src/layout/components/setup-preinstall.tsx
+++ b/src/layout/components/setup-preinstall.tsx
@@ -1,14 +1,14 @@
import type { PreinstallPlugin } from '@/store/modules/preinstall'
-import { CircleInfo, Copy, Xmark } from '@gravity-ui/icons'
-import { Button, Checkbox, Chip, Label, Spinner, Typography } from '@heroui/react'
+import { ArrowUpRightFromSquare, Copy, PlugConnection, Xmark } from '@gravity-ui/icons'
+import { Button, Card, Chip, ScrollShadow, Spinner, Switch, Typography } from '@heroui/react'
import { useMount } from '@reause/core'
import { invoke } from '@tauri-apps/api/core'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
import { Else, If, Then } from 'react-if-lite'
import { useStore } from 'valtio-define'
+import { Ellipsis } from '@/components/ellipsis'
import { Empty } from '@/components/empty'
-import { Item } from '@/components/item'
import { Logs } from '@/components/logs'
import { store } from '@/store'
import { writeClipboardText } from '@/utils/clipboard'
@@ -24,7 +24,8 @@ import { writeClipboardText } from '@/utils/clipboard'
* 用于和用户最终选择做 diff,得出 toInstall / toUninstall。
*
* 策略由 isFirstTime 决定:
- * - 首次安装引导(isFirstTime=true):已安装 + 推荐/修复/默认勾选均默认勾上
+ * - 首次安装引导(isFirstTime=true):已安装 + 推荐/修复/默认勾选均默认勾上,
+ * 但显式声明 `defaultUnchecked` 的推荐项不预选(标着「推荐」仍交由用户决定)
* - 手动打开(isFirstTime=false):只有已安装的插件才默认勾上(已卸载的推荐项不勾)
*/
function initialCheckedSet(plugins: readonly PreinstallPlugin[], isFirstTime: boolean): Set<string> {
@@ -34,15 +35,17 @@ function initialCheckedSet(plugins: readonly PreinstallPlugin[], isFirstTime: bo
// 非首次场景:不推荐未安装的插件,避免已卸载的推荐项仍默认勾着
if (!isFirstTime)
return false
+ if (p.defaultUnchecked)
+ return false
return p.recommended || p.fix || p.defaultChecked
}).map(p => p.id))
}
-/** 插件列表的一行:名称 + 推荐/已安装/待卸载标签在左,勾选框 + 仓库跳转按钮在右 */
-function PluginRow({ plugin, checked, toUninstall, disabled, onToggle, onOpenRepo }: {
+/** 插件卡片:图标 + 名称 + 状态 chip 在顶,描述居中,开关居底部右侧 */
+function PluginCard({ plugin, checked, toUninstall, disabled, onToggle, onOpenRepo }: {
plugin: PreinstallPlugin
checked: boolean
- /** 已安装但被取消勾选 → 待卸载(删除线 + 警告 chip) */
+ /** 已安装但被取消勾选 → 待卸载(警告 chip) */
toUninstall: boolean
disabled: boolean
onToggle: (id: string, checked: boolean) => void
@@ -51,62 +54,70 @@ function PluginRow({ plugin, checked, toUninstall, disabled, onToggle, onOpenRep
const { t } = useTranslation()
return (
- <Item
- left={(
- <>
- <Label className="min-w-0 truncate text-sm font-medium">
- {plugin.name}
- </Label>
- <If cond={plugin.recommended && !plugin.installed && !toUninstall}>
- <Chip size="sm" variant="soft" color="success" className="shrink-0 font-medium">
- {t('preinstall.recommend')}
- </Chip>
- </If>
- <If cond={plugin.fix && !plugin.installed && !toUninstall}>
- <Chip size="sm" variant="soft" color="warning" className="shrink-0 font-medium">
- {t('preinstall.fix')}
- </Chip>
- </If>
- <If cond={plugin.installed && !toUninstall}>
- <Chip size="sm" variant="soft" color="success" className="shrink-0 font-medium">
- {t('preinstall.installed')}
- </Chip>
- </If>
- <If cond={toUninstall}>
- <Chip size="sm" variant="soft" color="warning" className="shrink-0 font-medium">
- {t('preinstall.to_uninstall')}
- </Chip>
- </If>
- </>
- )}
- right={(
- <>
- <Checkbox
- isSelected={checked}
- isDisabled={disabled}
- onChange={isSelected => onToggle(plugin.id, isSelected)}
- className="shrink-0"
- aria-label={plugin.name}
- >
- <Checkbox.Content>
- <Checkbox.Control>
- <Checkbox.Indicator />
- </Checkbox.Control>
- </Checkbox.Content>
- </Checkbox>
- <Button
- isIconOnly
- size="sm"
- variant="ghost"
- className="size-6 shrink-0 rounded-md"
- aria-label={t('preinstall.open_repo', { name: plugin.name })}
- onPress={() => onOpenRepo(plugin.id)}
- >
- <CircleInfo className="size-4" />
- </Button>
- </>
- )}
- />
+ <Card
+ className="h-[124px] gap-1 rounded-lg border border-line bg-panel2 p-3 shadow-none transition-colors hover:border-line-strong"
+ >
+ <div className="flex min-w-0 items-center gap-1.5">
+ <span className="grid size-6 shrink-0 place-items-center rounded-md bg-accent/10 text-accent">
+ <PlugConnection className="size-3.5" />
+ </span>
+ <span className="min-w-0 flex-1 truncate text-[13px] font-medium text-ink">
+ {plugin.name}
+ </span>
+ <If cond={plugin.recommended && !plugin.installed && !toUninstall}>
+ <Chip size="sm" variant="soft" color="success" className="shrink-0 font-medium">
+ {t('preinstall.recommend')}
+ </Chip>
+ </If>
+ <If cond={plugin.fix && !plugin.installed && !toUninstall}>
+ <Chip size="sm" variant="soft" color="warning" className="shrink-0 font-medium">
+ {t('preinstall.fix')}
+ </Chip>
+ </If>
+ <If cond={plugin.installed && !toUninstall}>
+ <Chip size="sm" variant="soft" color="success" className="shrink-0 font-medium">
+ {t('preinstall.installed')}
+ </Chip>
+ </If>
+ <If cond={toUninstall}>
+ <Chip size="sm" variant="soft" color="warning" className="shrink-0 font-medium">
+ {t('preinstall.to_uninstall')}
+ </Chip>
+ </If>
+ </div>
+
+ <If cond={plugin.description !== ''}>
+ <Ellipsis lineClamp={2} className="text-[11px] leading-[17px] text-muted">
+ {plugin.description}
+ </Ellipsis>
+ </If>
+
+ <div className="mt-auto flex items-center justify-between gap-2">
+ <Button
+ isIconOnly
+ size="sm"
+ variant="ghost"
+ className="size-6 shrink-0 rounded-md text-muted"
+ aria-label={t('preinstall.open_repo', { name: plugin.name })}
+ onPress={() => onOpenRepo(plugin.id)}
+ >
+ <ArrowUpRightFromSquare className="size-3" />
+ </Button>
+ <Switch
+ size="sm"
+ isSelected={checked}
+ isDisabled={disabled}
+ onChange={isSelected => onToggle(plugin.id, isSelected)}
+ aria-label={plugin.name}
+ >
+ <Switch.Content>
+ <Switch.Control>
+ <Switch.Thumb />
+ </Switch.Control>
+ </Switch.Content>
+ </Switch>
+ </div>
+ </Card>
)
}
@@ -212,8 +223,8 @@ export function PreinstallSetup() {
return (
<div className="flex h-full w-full items-center justify-center bg-canvas">
- <div className="flex w-[min(560px,88vw)] flex-col gap-5">
- <header className="flex flex-col items-center gap-1.5 text-center">
+ <div className="flex w-[min(880px,92vw)] flex-col gap-4">
+ <header className="flex flex-col items-center gap-1 text-center">
<Typography type="h4" className="!text-ink">{t('preinstall.title')}</Typography>
<Typography color="muted" type="body-sm" className="max-w-[440px]">{t('preinstall.subtitle')}</Typography>
</header>
@@ -226,54 +237,56 @@ export function PreinstallSetup() {
cond={preinstall.error !== ''}
else={(
<>
- {/* 插件列表 */}
- <div className="space-y-3 flex-wrap gap-2">
- <If
- cond={preinstall.loadError === ''}
- else={(
- // 列表加载失败(区别于空列表):错误说明 + 重试
- <div className="flex flex-col items-center gap-2 rounded-md border border-danger/30 bg-danger/5 p-4 text-center">
- <p className="text-xs font-medium text-danger">{t('preinstall.load_failed')}</p>
- <p className="max-h-[80px] max-w-full overflow-y-auto break-all font-mono text-[11px] text-muted">
- {preinstall.loadError}
- </p>
- <Button
- className="h-8 rounded-md"
- size="sm"
- variant="primary"
- onPress={() => void store.preinstall.load()}
- isDisabled={preinstall.loading}
- >
- {t('app.retry')}
- </Button>
- </div>
- )}
- >
+ {/* 卡片网格限定高度滚动,上下溢出由 ScrollShadow 渐隐提示 */}
+ <ScrollShadow className="max-h-[min(50vh,420px)]" size={36}>
+ <div className="grid grid-cols-1 gap-2.5 pr-1 sm:grid-cols-2 lg:grid-cols-3">
<If
- cond={preinstall.plugins.length > 0}
+ cond={preinstall.loadError === ''}
else={(
- <Empty>{t('preinstall.empty')}</Empty>
+ // 列表加载失败(区别于空列表):错误说明 + 重试
+ <div className="flex flex-col items-center gap-2 rounded-lg border border-danger/30 bg-danger/5 p-4 text-center sm:col-span-2 lg:col-span-3">
+ <p className="text-xs font-medium text-danger">{t('preinstall.load_failed')}</p>
+ <p className="max-h-[80px] max-w-full overflow-y-auto break-all font-mono text-[11px] text-muted">
+ {preinstall.loadError}
+ </p>
+ <Button
+ className="h-8 rounded-md"
+ size="sm"
+ variant="primary"
+ onPress={() => void store.preinstall.load()}
+ isDisabled={preinstall.loading}
+ >
+ {t('app.retry')}
+ </Button>
+ </div>
)}
>
- {preinstall.plugins.map((plugin) => {
- const checked = effectiveSelected.has(plugin.id)
- // 已安装但用户取消勾选 → 待卸载
- const toUninstall = plugin.installed && !checked
- return (
- <PluginRow
- key={plugin.id}
- plugin={plugin}
- checked={checked}
- toUninstall={toUninstall}
- disabled={installing}
- onToggle={toggle}
- onOpenRepo={openRepo}
- />
- )
- })}
+ <If
+ cond={preinstall.plugins.length > 0}
+ else={(
+ <Empty className="sm:col-span-2 lg:col-span-3">{t('preinstall.empty')}</Empty>
+ )}
+ >
+ {preinstall.plugins.map((plugin) => {
+ const checked = effectiveSelected.has(plugin.id)
+ // 已安装但用户取消勾选 → 待卸载
+ const toUninstall = plugin.installed && !checked
+ return (
+ <PluginCard
+ key={plugin.id}
+ plugin={plugin}
+ checked={checked}
+ toUninstall={toUninstall}
+ disabled={installing}
+ onToggle={toggle}
+ onOpenRepo={openRepo}
+ />
+ )
+ })}
+ </If>
</If>
- </If>
- </div>
+ </div>
+ </ScrollShadow>
{/* 可取消勾选提示:让用户知道预设插件可减选,取消后不会安装 */}
<If cond={preinstall.plugins.length > 0 && !installing && preinstall.error === ''}>
diff --git a/src/store/modules/preinstall/types.ts b/src/store/modules/preinstall/types.ts
index 5f212e24..d9442dde 100644
--- a/src/store/modules/preinstall/types.ts
+++ b/src/store/modules/preinstall/types.ts
@@ -9,6 +9,8 @@ export interface PreinstallPlugin {
fix: boolean
/** 无 chip 但默认勾选(首次引导直接勾上,不标「推荐」) */
defaultChecked: boolean
+ /** 显式声明首次引导不默认勾选(仍可标「推荐」chip,但不预选) */
+ defaultUnchecked: boolean
installed: boolean
}
diff --git a/test/preinstall-uncheck.test.ts b/test/preinstall-uncheck.test.ts
index c7cf00a1..9133961e 100644
--- a/test/preinstall-uncheck.test.ts
+++ b/test/preinstall-uncheck.test.ts
@@ -40,6 +40,27 @@ describe('preinstallSetup primary button morph', () => {
})
})
+// ── Suite B2 — defaultUnchecked suppresses preselection (behavior) ────────────
+// 推荐项仍显示「推荐」chip,但声明 defaultUnchecked 时首次引导不预选。
+describe('defaultUnchecked suppresses first-run preselection', () => {
+ it('is honored by initialCheckedSet and keeps the recommended chip independent', () => {
+ const source = readFileSync(new URL('../src/layout/components/setup-preinstall.tsx', import.meta.url), 'utf8')
+ expect(source).toContain('p.defaultUnchecked')
+ // 预选判定必须先于 recommended,否则 defaultUnchecked 永远不会生效
+ expect(source.indexOf('p.defaultUnchecked')).toBeLessThan(source.indexOf('p.recommended || p.fix'))
+ })
+
+ it('declares defaultUnchecked for the DSH IM preset entry', () => {
+ const presets = JSON.parse(
+ readFileSync(new URL('../src-tauri/resources/preset-plugins.json', import.meta.url), 'utf8'),
+ ) as Array<{ id: string, recommended?: boolean, defaultUnchecked?: boolean }>
+ const im = presets.find(p => p.id === '@xmanrui/dsh-im')
+ expect(im).toBeDefined()
+ expect(im?.defaultUnchecked).toBe(true)
+ expect(im?.recommended).toBe(true)
+ })
+})
+
// ── Suite D — store empty-selection guard (behavior, regression lock) ────────
// vi.mock 工厂会被提升到文件顶部,必须先经 vi.hoisted 声明模块级 mock 状态,
// 否则工厂执行时引用未初始化的绑定(Vitest 4.x 语义)。