DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
fix(core): 本地核心兼容性只看最低支持基线,不再复用推荐版本
hairyfaa93424f4c6f
diff --git a/src/ui/config/core.tsx b/src/ui/config/core.tsxindex 1953b258..493ca6da 100644--- a/src/ui/config/core.tsx+++ b/src/ui/config/core.tsx@@ -17,7 +17,7 @@ import { useInvalidateOnSettingUpdated } from '@/hooks/use-invalidate-on-settingimport { store } from '@/store'import { useCoreBreakingConfirm } from '@/ui/config/hooks/use-core-breaking-confirm'import { DownloadCoreDialog } from '@/ui/dialog/update-core'-import { compareVersions, isCoreBelowBaseline, isCoreUnsupported } from '@/utils/core-version'+import { compareVersions, isCoreUnsupported, MIN_SUPPORTED_CORE_VERSION } from '@/utils/core-version'import { silence } from '@/utils/silence'import { toast } from '@/utils/toast'@@ -25,7 +25,7 @@ import { toast } from '@/utils/toast'* 「核心」面板:管理 Harness 引擎来源与多版本。** - 列表来自 `get_cores` 查询(`setting_updated` 事件一并失效刷新):- * `local` = 用户通过 CLI 全局安装的本地核心(存在且不低于内置插件基线时优先使用,+ * `local` = 用户通过 CLI 全局安装的本地核心(存在且不低于最低支持基线时优先使用,* 需求 3;低于基线时后端改用预打包核心,行内标注「不兼容」并给出更新提示);* `app-<tag>` = deepseek-harness-pkg 各发布版本(GitHub releases 拉取失败时* 降级为 git tags / 磁盘扫描,仅显示已下载版本)。预览版(Pre-release label@@ -137,12 +137,12 @@ export function ConfigCore() {async function onActivate(core: HarnessCore) {if (core.active || busy || !core.present)return- // 低于内置插件基线的本地核心无法加载随包插件(issue #596):桌面端此时使用+ // 低于最低支持基线的本地核心无法加载随包插件(issue #596):桌面端此时使用// 预打包核心,激活入口改为给出可操作提示,而不是切过去再撞一次启动失败。if (isUnsupportedLocal(core)) {toast(t('core.local_unsupported_toast'), {variant: 'warning',- description: t('core.local_unsupported_hint', { version: core.recommendedVersion ?? '' }),+ description: t('core.local_unsupported_hint', { version: MIN_SUPPORTED_CORE_VERSION }),timeout: 10_000,})return@@ -371,7 +371,7 @@ export function ConfigCore() {{t('core.preview')}</Chip></If>- {/* 低于内置插件基线的本地核心:桌面端改用预打包核心,激活会被拒绝并给出更新提示 */}+ {/* 低于最低支持基线的本地核心:桌面端改用预打包核心,激活会被拒绝并给出更新提示 */}<If cond={isUnsupportedLocal(core)}><Chip size="sm" variant="soft" color="danger" className="shrink-0 font-medium">{t('core.local_unsupported')}@@ -487,11 +487,13 @@ function displayVersion(version: HarnessCore): string {}/**- * 本地核心是否低于内置插件基线(推荐核心版本)。低于基线时随包内置插件无法加载- * (见 `isCoreBelowBaseline`),桌面端自动改用预打包核心。+ * 本地核心是否低于最低支持基线。判据与「不兼容版本」分组完全一致(同一基线,+ * `isUnsupportedCore`),低于基线时随包内置插件无法加载(issue #596),桌面端自动+ * 改用预打包核心。不可与推荐核心版本(`version-recommend.json`)混用——后者只用于+ * 更新提示,高于最低支持基线,拿它当基线会把 0.1.5-rc.3 这类可用本地核心误判为不兼容。*/function isUnsupportedLocal(core: HarnessCore): boolean {- return core.source === 'local' && core.present && isCoreBelowBaseline(core.version, core.recommendedVersion)+ return core.source === 'local' && core.present && isUnsupportedCore(core)}/**diff --git a/src/utils/core-version.ts b/src/utils/core-version.tsindex ee0ba237..7fb97af5 100644--- a/src/utils/core-version.ts+++ b/src/utils/core-version.ts@@ -31,19 +31,12 @@ export function isCoreBreakingVersion(version: string): boolean {return !!version && compareVersions(version, CORE_BREAKING_BASELINE) > 0}-/**- * 核心是否低于内置插件基线(即推荐核心版本):随包内置插件按该基线编译,核心低于- * 它时 client bundle 需要的 `@deepseek-ai/*` 平台模块在运行时模块表里不存在,插件- * 必然加载失败并把应用卡在启动阶段(issue #596)。版本缺失或不可解析时返回 false- * ——漏放行只是回到修复前的行为,误拦截会把可用的本地核心判死。- */-export function isCoreBelowBaseline(version: string, baseline: string | null | undefined): boolean {- return !!version && !!baseline && compareVersions(version, baseline) < 0-}-/*** 最低支持的核心版本(与 Rust `MIN_SUPPORTED_CORE_VERSION` 对齐)。低于它的核心缺少* 内置插件依赖的平台种子词,随包插件必然加载失败并把应用卡在启动阶段(issue #596)。+ *+ * 这是兼容性的唯一基线:它低于推荐核心版本(`version-recommend.json`,仅用于更新+ * 提示),两者不可混用——拿推荐版本当基线会把 0.1.5-rc.3 这类可用核心误判为不兼容。*/export const MIN_SUPPORTED_CORE_VERSION = '0.1.5-rc.1'diff --git a/test/core-local-unsupported.test.ts b/test/core-local-unsupported.test.tsnew file mode 100644index 00000000..2202eaad--- /dev/null+++ b/test/core-local-unsupported.test.ts@@ -0,0 +1,69 @@+import { readFileSync } from 'node:fs'+import { describe, expect, it } from 'vitest'+import { compareVersions, isCoreUnsupported, MIN_SUPPORTED_CORE_VERSION } from '@/utils/core-version'++const CORE_PANEL = new URL('../src/ui/config/core.tsx', import.meta.url)+const RECOMMEND_MANIFEST = new URL('../src-tauri/resources/version-recommend.json', import.meta.url)++/** 随包推荐核心版本(前端核心面板的「更新」提示基线)。 */+function recommendedVersion(): string {+ const raw = JSON.parse(readFileSync(RECOMMEND_MANIFEST, 'utf8')) as { dsh: string }+ return raw.dsh+}++/** `isUnsupportedLocal` 的函数体源码(用于锁定它不再复用推荐版本当基线)。 */+function localPredicateSource(): string {+ const source = readFileSync(CORE_PANEL, 'utf8')+ const start = source.indexOf('function isUnsupportedLocal')+ expect(start).toBeGreaterThan(-1)+ return source.slice(start, source.indexOf('\n}', start))+}++/**+ * 兼容性只由**最低支持基线**(0.1.5-rc.1)决定,与推荐核心版本无关。+ *+ * 回归背景:本地核心的判定曾复用「推荐核心版本」(`version-recommend.json`,当前+ * 0.1.7-alpha.1)当基线,于是 0.1.5-rc.3 这类**高于最低支持基线**的本地核心被误判为+ * 「不兼容」:行内挂红标、激活被拒、提示文案还引用推荐版本号。最低支持基线独立于推荐+ * 版本(issue #596),两者不可混用。+ */+describe('local core compatibility baseline', () => {+ it('最低支持基线与推荐核心版本是两个不同的版本', () => {+ expect(MIN_SUPPORTED_CORE_VERSION).toBe('0.1.5-rc.1')+ expect(recommendedVersion()).not.toBe(MIN_SUPPORTED_CORE_VERSION)+ // 推荐版本高于最低支持基线,这正是误判的来源+ expect(compareVersions(recommendedVersion(), MIN_SUPPORTED_CORE_VERSION)).toBeGreaterThan(0)+ })++ it('高于最低支持基线但低于推荐版本的本地核心不算不兼容', () => {+ // 被误报的本地核心:0.1.5-rc.3 > 0.1.5-rc.1,但 < 推荐版本+ expect(compareVersions('0.1.5-rc.3', MIN_SUPPORTED_CORE_VERSION)).toBeGreaterThan(0)+ expect(compareVersions('0.1.5-rc.3', recommendedVersion())).toBeLessThan(0)+ expect(isCoreUnsupported('0.1.5-rc.3')).toBe(false)+ })++ it('基线本身及更高版本都算兼容,低于基线的旧版本才算不兼容', () => {+ expect(isCoreUnsupported(MIN_SUPPORTED_CORE_VERSION)).toBe(false)+ expect(isCoreUnsupported('0.1.5-rc.2')).toBe(false)+ expect(isCoreUnsupported('0.1.7-alpha.1')).toBe(false)+ expect(isCoreUnsupported('0.1.5-alpha.2')).toBe(true)+ expect(isCoreUnsupported('0.1.2-rc.1')).toBe(true)+ })+})++describe('config core panel local compatibility predicate', () => {+ it('不复用推荐核心版本当兼容性基线', () => {+ const predicate = localPredicateSource()+ expect(predicate).toContain('isUnsupportedCore(core)')+ expect(predicate).not.toContain('recommendedVersion')+ })++ it('不再引用已删除的推荐版本基线工具', () => {+ expect(readFileSync(CORE_PANEL, 'utf8')).not.toContain('isCoreBelowBaseline')+ })++ it('「不兼容」提示文案引用最低支持基线而不是推荐版本', () => {+ const source = readFileSync(CORE_PANEL, 'utf8')+ expect(source).toContain('t(\'core.local_unsupported_hint\', { version: MIN_SUPPORTED_CORE_VERSION })')+ })+})diff --git a/test/core-version.test.ts b/test/core-version.test.tsindex 26fa1c76..00399613 100644--- a/test/core-version.test.ts+++ b/test/core-version.test.ts@@ -1,41 +1,16 @@import { describe, expect, it } from 'vitest'-import { compareVersions, isCoreBelowBaseline, isCoreUnsupported, MIN_SUPPORTED_CORE_VERSION } from '@/utils/core-version'+import { isCoreUnsupported, MIN_SUPPORTED_CORE_VERSION } from '@/utils/core-version'/**- * issue #596:随包内置插件按推荐核心版本(`version-recommend.json`)编译,本地核心- * 低于该基线时 client bundle 需要的 `@deepseek-ai/*` 平台模块在运行时模块表里不存在- * (`@deepseek-ai/dsh-client-store` 首版为 dsh 0.1.2-alpha.2,0.1.5 起才成为平台种子- * 词),插件必然加载失败并把应用卡在启动阶段。+ * issue #596:随包内置插件依赖的平台种子词自 dsh 0.1.5 起才存在,核心低于最低支持+ * 基线(0.1.5-rc.1)时 `@deepseek-ai/*` 模块在运行时模块表里不存在,插件必然加载失败+ * 并把应用卡在启动阶段。** 后端据此回退预打包核心,前端核心面板据此标注「不兼容」并拒绝激活;这里锁住两侧* 共用的版本判定:低于基线为 true,等于/高于为 false,不可解析不误判。- */-describe('isCoreBelowBaseline', () => {- it('detects the issue #596 local core (0.1.0-rc.7) as below the bundled baseline', () => {- expect(isCoreBelowBaseline('0.1.0-rc.7', '0.1.5-rc.2')).toBe(true)- expect(isCoreBelowBaseline('0.1.2-rc.1', '0.1.5-rc.2')).toBe(true)- expect(isCoreBelowBaseline('0.1.5-rc.1', '0.1.5-rc.2')).toBe(true)- })-- it('accepts the baseline itself and newer cores', () => {- expect(isCoreBelowBaseline('0.1.5-rc.2', '0.1.5-rc.2')).toBe(false)- expect(isCoreBelowBaseline('0.1.5-rc.3', '0.1.5-rc.2')).toBe(false)- expect(isCoreBelowBaseline('0.1.6-alpha.2', '0.1.5-rc.2')).toBe(false)- })-- it('never blocks when a version is missing or unparsable', () => {- expect(isCoreBelowBaseline('', '0.1.5-rc.2')).toBe(false)- expect(isCoreBelowBaseline('0.1.0-rc.7', null)).toBe(false)- expect(isCoreBelowBaseline('0.1.0-rc.7', '')).toBe(false)- // compareVersions 对不可解析值返回 0 → 视为达标,避免把可用核心判死- expect(compareVersions('not-a-version', '0.1.5-rc.2')).toBe(0)- expect(isCoreBelowBaseline('not-a-version', '0.1.5-rc.2')).toBe(false)- })-})--/**- * 核心列表「不兼容版本」分组的分组判据:低于最低支持基线(0.1.5-rc.1)的旧版本默认折叠,- * 可展开显示;基线与更新版本、以及不可解析的版本都留在可用列表里。+ *+ * 兼容性只看最低支持基线,与推荐核心版本(`version-recommend.json`)无关——推荐版本+ * 高于基线、仅用于更新提示。*/describe('isCoreUnsupported', () => {it('把低于 0.1.5-rc.1 的旧版本判为不兼容', () => {