Skip to content

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

fix(desktop): 「无视风险切换」改为 warning Chip,并修更新失败时的档案回滚

hairyf1d6114643052
diff --git a/src/store/modules/harness-updater/store.ts b/src/store/modules/harness-updater/store.ts
index 2ddd278c..a2557766 100644
--- a/src/store/modules/harness-updater/store.ts
+++ b/src/store/modules/harness-updater/store.ts
@@ -34,14 +34,17 @@ export const harnessUpdater = defineStore({
/**
* 手动更新:重新下载安装新版并重启服务。
*
- * 返回是否真的切到了新版本:false 表示未发生安装(已是最新/无法校验)或安装失败——
- * 调用方据此回滚为本次更新预先切换的版本档案(旧核心不能配新档案)。
+ * 返回是否真的发生了安装(新版本已落盘):false 表示未发生安装(已是最新/无法校验)
+ * 或安装前就失败——调用方据此回滚为本次更新预先切换的版本档案(旧核心不能配新档案)。
+ * 安装已落盘但随后的启动失败仍返回 true:核心已经是新版,把档案切回旧版本只会造出
+ * 反向的不配套(新核心配旧档案),启动失败另有 `harness.fail` 的失败态呈现。
*/
async handleUpdate(): Promise<boolean> {
if (this.updating)
return false
this.updating = true
let unlistenInstall: UnlistenFn | null = null
+ let installed = false
try {
unlistenInstall = await harness.listenInstallProgress()
harness.prepareInstall(i18next.t('status.updating'))
@@ -49,6 +52,7 @@ export const harnessUpdater = defineStore({
// 限流拿不到可信摘要而保持本地安装)。此时绝不重启页面、也不丢弃
// “有新版本”提示——否则用户会看到“页面刷新了、版本却没变、提示也没了”。
const changed = await invoke<boolean>('install_dependencies')
+ installed = changed
if (!changed) {
// 回到就绪态(若当前停在安装/更新界面,则恢复到原 iframe 视图)
harness.status = 'ready'
@@ -73,7 +77,9 @@ export const harnessUpdater = defineStore({
catch (err) {
console.error('[Harness] update failed:', err)
harness.fail(String(err))
- return false
+ // 已落盘的安装不能报成「没切换」:调用方会据此把档案切回旧版本,反而造出
+ // 「新核心 + 旧档案」的不配套状态。
+ return installed
}
finally {
unlistenInstall?.()
diff --git a/src/ui/dialog/core-upgrade-profile.tsx b/src/ui/dialog/core-upgrade-profile.tsx
index 259a5d30..80284258 100644
--- a/src/ui/dialog/core-upgrade-profile.tsx
+++ b/src/ui/dialog/core-upgrade-profile.tsx
@@ -1,5 +1,6 @@
import type { PropsWithOverlays } from '@overlastic/react'
-import { AlertDialog, Button, InputGroup, Label, Link, TextField } from '@heroui/react'
+import { TriangleExclamationFill } from '@gravity-ui/icons'
+import { AlertDialog, Button, Chip, InputGroup, Label, TextField } from '@heroui/react'
import { useDisclosure } from '@overlastic/react'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
@@ -69,9 +70,10 @@ export function CoreUpgradeProfileDialog(props: CoreUpgradeProfileDialogProps) {
</TextField>
</AlertDialog.Body>
<AlertDialog.Footer className="justify-end">
- <Link className="text-warning" onPress={() => disclosure.confirm({ mode: 'ignore' })}>
+ <Chip className="rounded-md cursor-pointer" color="warning" variant="soft" onClick={() => disclosure.confirm({ mode: 'ignore' })}>
+ <TriangleExclamationFill width={12} />
{t('core.breaking_ignore')}
- </Link>
+ </Chip>
<div className="flex flex-row items-center gap-2">
<Button className="rounded-md" variant="tertiary" onPress={disclosure.cancel}>
{t('buttons.cancel')}
diff --git a/test/core-upgrade-profile.test.ts b/test/core-upgrade-profile.test.ts
index 577a159a..31c9e5c1 100644
--- a/test/core-upgrade-profile.test.ts
+++ b/test/core-upgrade-profile.test.ts
@@ -171,6 +171,15 @@ describe('更新提示入口(桌面外壳 / 调试页)走同一守卫', () =
expect(source).toMatch(/return false/)
expect(source).toMatch(/return true/)
})
+
+ it('已落盘的新版本即使随后启动失败也不报「没切换」(否则会回滚出旧档案配新核心)', () => {
+ const source = updaterSource()
+
+ // 安装结果记在 try 之外,catch 里回传它而不是一律 false
+ expect(source).toMatch(/let installed = false/)
+ expect(source).toMatch(/installed = changed/)
+ expect(source).toMatch(/catch \(err\) \{[\s\S]*?return installed/)
+ })
})
describe('警告对话框控件', () => {
@@ -188,7 +197,7 @@ describe('警告对话框控件', () => {
expect(source).not.toMatch(/<Input[\s>]/)
})
- it('「无视风险切换」用 HeroUI Link,且与取消/确认按钮同处一行的 footer', () => {
+ it('「无视风险切换」是 warning Chip,与取消/确认按钮同处一行的 footer', () => {
const source = dialogSource()
const footerStart = source.indexOf('<AlertDialog.Footer')
const footerEnd = source.indexOf('</AlertDialog.Footer>')
@@ -197,8 +206,9 @@ describe('警告对话框控件', () => {
expect(footerEnd).toBeGreaterThan(footerStart)
const footer = source.slice(footerStart, footerEnd)
- expect(source).toMatch(/import \{[^}]+Link[^}]*\} from '@heroui\/react'/)
- expect(footer).toMatch(/<Link[\s>]/)
+ expect(source).toMatch(/import \{[^}]+Chip[^}]*\} from '@heroui\/react'/)
+ expect(footer).toMatch(/<Chip[\s>]/)
+ expect(footer).toMatch(/color="warning"/)
expect(footer).toContain('core.breaking_ignore')
expect(footer).toMatch(/disclosure\.confirm\(\{ mode: 'ignore' \}\)/)
expect(footer).toContain('buttons.cancel')