DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
feat(pet): allow clearing the selected pet from settings
Lautaro Agustin Diez04ee8022d589
diff --git a/packages/dsh-tauri-pet/src/client/components/pet-settings.tsx b/packages/dsh-tauri-pet/src/client/components/pet-settings.tsxindex abee8585..1330e4e2 100644--- a/packages/dsh-tauri-pet/src/client/components/pet-settings.tsx+++ b/packages/dsh-tauri-pet/src/client/components/pet-settings.tsx@@ -175,6 +175,27 @@ export function PetSettings(props: PetSettingsProps): ReactElement {}}+ /** 取消选择:清空已选宠物;仍在启用时一并关闭桌宠(无内容可渲染,不留空窗口)。 */+ async function clearSelection(): Promise<void> {+ if (busy || active === '')+ return+ setBusy(true)+ setError(null)+ try {+ let nextStatus = await setActivePet('')+ if (nextStatus.enabled)+ nextStatus = await setPetEnabled(false)+ setPetStatus(nextStatus)+ }+ catch (clearError) {+ console.error('[dsh-tauri-pet] clear selection failed:', clearError)+ setError(text('clearFailed'))+ }+ finally {+ setBusy(false)+ }+ }+/** 启用/关闭桌宠:纯持久开关,关闭后重启不再自动拉起。 */async function toggleEnabled(): Promise<void> {if (busy)@@ -257,9 +278,9 @@ export function PetSettings(props: PetSettingsProps): ReactElement {name={item.name}desc={item.desc ?? ''}active={active === item.id}- disabled={busy || active === item.id}- actionLabel={active === item.id ? text('selected') : text('enable')}- onAction={() => { void enablePreset(item.id) }}+ disabled={busy}+ actionLabel={text(active === item.id ? 'clear' : 'enable')}+ onAction={() => { void (active === item.id ? clearSelection() : enablePreset(item.id)) }}/>))}{chatPets.map(item => (@@ -270,9 +291,9 @@ export function PetSettings(props: PetSettingsProps): ReactElement {name={item.name}desc={item.description ?? ''}active={active === item.id}- disabled={busy || active === item.id}- actionLabel={text(active === item.id ? 'selected' : 'select')}- onAction={() => { void choose(item.id) }}+ disabled={busy}+ actionLabel={text(active === item.id ? 'clear' : 'select')}+ onAction={() => { void (active === item.id ? clearSelection() : choose(item.id)) }}/>))}</div>@@ -292,9 +313,9 @@ export function PetSettings(props: PetSettingsProps): ReactElement {name={item.name}desc={item.description ?? ''}active={active === item.id}- disabled={busy || active === item.id}- actionLabel={text(active === item.id ? 'selected' : 'select')}- onAction={() => { void choose(item.id) }}+ disabled={busy}+ actionLabel={text(active === item.id ? 'clear' : 'select')}+ onAction={() => { void (active === item.id ? clearSelection() : choose(item.id)) }}/>))}</div>diff --git a/packages/dsh-tauri-pet/src/client/locales/index.ts b/packages/dsh-tauri-pet/src/client/locales/index.tsindex dbeac5dc..56d9797e 100644--- a/packages/dsh-tauri-pet/src/client/locales/index.ts+++ b/packages/dsh-tauri-pet/src/client/locales/index.ts@@ -8,6 +8,8 @@ import { PET_CLIENT_NS as NS } from '../constants'export { PET_CLIENT_NS as NS } from '../constants'const DICT_ZH: Record<LocaleKey, string> = {+ clear: '取消选择',+ clearFailed: '取消选择失败',closePet: '关闭宠物',create: '创建',createFailed: '创建宠物会话失败',@@ -20,7 +22,6 @@ const DICT_ZH: Record<LocaleKey, string> = {loading: '加载中…',name: '宠物',select: '选择',- selected: '已选',setPetFailed: '选择宠物失败',setSizeFailed: '设置宠物大小失败',sizeHint: '调整桌宠窗口的显示大小(50–200%)',@@ -31,6 +32,8 @@ const DICT_ZH: Record<LocaleKey, string> = {}const DICT_EN: Record<LocaleKey, string> = {+ clear: 'Clear selection',+ clearFailed: 'Failed to clear pet selection',closePet: 'Close pet',create: 'Create',createFailed: 'Failed to create a pet session',@@ -43,7 +46,6 @@ const DICT_EN: Record<LocaleKey, string> = {loading: 'Loading…',name: 'Pets',select: 'Choose',- selected: 'Selected',setPetFailed: 'Failed to select pet',setSizeFailed: 'Failed to set pet size',sizeHint: 'Adjust the pet window size (50–200%)',diff --git a/packages/dsh-tauri-pet/src/client/types/index.ts b/packages/dsh-tauri-pet/src/client/types/index.tsindex 3917370b..63805cec 100644--- a/packages/dsh-tauri-pet/src/client/types/index.ts+++ b/packages/dsh-tauri-pet/src/client/types/index.ts@@ -80,7 +80,9 @@ export interface ConversationInputLeftProps {}export type LocaleKey- = | 'closePet'+ = | 'clear'+ | 'clearFailed'+ | 'closePet'| 'create'| 'createFailed'| 'emptyImported'@@ -92,7 +94,6 @@ export type LocaleKey| 'loading'| 'name'| 'select'- | 'selected'| 'setPetFailed'| 'setSizeFailed'| 'sizeHint'