Skip to content

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

feat(desktop): 宠物社区分享、帮助菜单开发者工具与预安装向导改进 (#935)

Mao Mr21a4051d0adc
diff --git a/packages/dsh-tauri-pet/src/client/components/pet-settings.test.tsx b/packages/dsh-tauri-pet/src/client/components/pet-settings.test.tsx
index c30732a8..c4e7a92a 100644
--- a/packages/dsh-tauri-pet/src/client/components/pet-settings.test.tsx
+++ b/packages/dsh-tauri-pet/src/client/components/pet-settings.test.tsx
@@ -19,6 +19,7 @@ vi.mock('dsh-tauri/client', async () => ({
vi.mock('dsh-tauri-ui/client', () => ({
ArrowRightFromSquare: () => null,
+ Globe: () => null,
Plus: () => null,
Icon: () => null,
Button: ({ variant: _variant, size: _size, icon: _icon, ...props }: ButtonHTMLAttributes<HTMLButtonElement> & { variant?: string, size?: string, icon?: ReactNode }) => <button {...props} />,
@@ -37,6 +38,7 @@ vi.mock('../service/pet', () => ({
loadForceXwayland: vi.fn(),
loadPetCatalog: vi.fn(),
loadPetOverlaySupported: vi.fn(),
+ openCommunityShare: vi.fn(),
resizePet: vi.fn(),
toggleForceXwayland: vi.fn(),
togglePet: vi.fn(),
@@ -93,7 +95,7 @@ beforeEach(() => {
overlaySupported: false,
forceXwayland: false,
})
- for (const action of [petService.loadPetCatalog, petService.choosePet, petService.clearPetSelection, petService.enablePet, petService.togglePet, petService.toggleForceXwayland, petService.resizePet, petService.importPetArchive])
+ for (const action of [petService.loadPetCatalog, petService.choosePet, petService.clearPetSelection, petService.enablePet, petService.togglePet, petService.toggleForceXwayland, petService.resizePet, petService.importPetArchive, petService.openCommunityShare])
vi.mocked(action).mockResolvedValue({ ok: true })
container = document.createElement('div')
document.body.append(container)
@@ -241,4 +243,17 @@ describe('pet settings action boundaries', () => {
expect(input.disabled).toBe(false)
expect(input.value).toBe('')
})
+
+ it('community share sits in the Codex tab, opens the site and reports its own failure', async () => {
+ vi.mocked(petService.openCommunityShare).mockResolvedValueOnce({ ok: false, error: 'no browser' })
+ await mount()
+ expect(container.textContent).not.toContain(locale.text('communityShare'))
+ await click(button('codex'))
+ await click(button(locale.text('communityShare')))
+ expect(petService.openCommunityShare).toHaveBeenCalledExactlyOnceWith()
+ expect(petService.importPetArchive).not.toHaveBeenCalled()
+ expect(container.querySelector('[role="alert"]')?.textContent).toBe(locale.text('communityShareFailed'))
+ await click(button(locale.text('communityShare')))
+ expect(container.querySelector('[role="alert"]')).toBeNull()
+ })
})
diff --git a/packages/dsh-tauri-pet/src/client/components/pet-settings.tsx b/packages/dsh-tauri-pet/src/client/components/pet-settings.tsx
index 1f9fa334..cb50096e 100644
--- a/packages/dsh-tauri-pet/src/client/components/pet-settings.tsx
+++ b/packages/dsh-tauri-pet/src/client/components/pet-settings.tsx
@@ -1,6 +1,6 @@
import type { ChangeEvent, ReactElement } from 'react'
import type { PetActionResult, PetListItem } from '../service/pet.types'
-import { ArrowRightFromSquare, Button, Icon, Plus, SegmentedControl } from 'dsh-tauri-ui/client'
+import { ArrowRightFromSquare, Button, Globe, Icon, Plus, SegmentedControl } from 'dsh-tauri-ui/client'
import { useStore, useWatchImmediate } from 'dsh-tauri/client'
import { useEffect, useId, useRef, useState } from 'react'
import { PET_DEFAULT_SIZE, PET_SIZE_MAX, PET_SIZE_MIN, PET_SIZE_STEP } from '../constants'
@@ -13,6 +13,7 @@ import {
loadForceXwayland,
loadPetCatalog,
loadPetOverlaySupported,
+ openCommunityShare,
resizePet,
toggleForceXwayland,
togglePet,
@@ -134,6 +135,11 @@ export function PetSettings(props: PetSettingsProps): ReactElement {
}, 'xwaylandFailed')
}
+ /** 社区分享:在系统浏览器中打开 Codex 宠物社区站点。 */
+ async function shareCommunity(): Promise<void> {
+ await run(openCommunityShare, 'communityShareFailed')
+ }
+
async function commitSize(value: number): Promise<void> {
setError(null)
const result = await resizePet({ size: value })
@@ -266,7 +272,7 @@ export function PetSettings(props: PetSettingsProps): ReactElement {
type="button"
variant="outline"
size="sm"
- icon={<Icon as={Plus} />}
+ icon={<Icon size={14} as={Plus} />}
disabled={busy}
onClick={() => { void createPet() }}
>
@@ -289,7 +295,7 @@ export function PetSettings(props: PetSettingsProps): ReactElement {
type="button"
variant="outline"
size="sm"
- icon={<Icon as={ArrowRightFromSquare} />}
+ icon={<Icon size={14} as={ArrowRightFromSquare} />}
disabled={busy}
onClick={() => fileRef.current?.click()}
>
@@ -303,6 +309,16 @@ export function PetSettings(props: PetSettingsProps): ReactElement {
disabled={busy}
onChange={(event) => { void onImport(event) }}
/>
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ icon={<Icon size={14} as={Globe} />}
+ disabled={busy}
+ onClick={() => { void shareCommunity() }}
+ >
+ {locale.text('communityShare')}
+ </Button>
</>
)}
</div>
diff --git a/packages/dsh-tauri-pet/src/client/constants/index.ts b/packages/dsh-tauri-pet/src/client/constants/index.ts
index 52e65a51..f0f49aff 100644
--- a/packages/dsh-tauri-pet/src/client/constants/index.ts
+++ b/packages/dsh-tauri-pet/src/client/constants/index.ts
@@ -28,6 +28,10 @@ export const CMD_SET_PET_SIZE = 'set_pet_size'
export const CMD_LIST_PETS = 'list_pets'
export const CMD_IMPORT_PET = 'import_pet'
export const CMD_LIST_PRESET_PETS = 'list_preset_pets'
+export const CMD_OPEN_EXTERNAL_URL = 'open_external_url'
+
+/** Codex 宠物社区站点(「社区分享」按钮的目标地址)。 */
+export const PET_COMMUNITY_URL = 'https://codex-pets.net/#/'
/**
* 设置菜单补丁的选择器与守卫属性。
diff --git a/packages/dsh-tauri-pet/src/client/locales/index.ts b/packages/dsh-tauri-pet/src/client/locales/index.ts
index 36cf4b65..3b1e6987 100644
--- a/packages/dsh-tauri-pet/src/client/locales/index.ts
+++ b/packages/dsh-tauri-pet/src/client/locales/index.ts
@@ -6,6 +6,8 @@ const zh = {
clear: '取消选择',
clearFailed: '取消选择失败',
closePet: '关闭宠物',
+ communityShare: '社区分享',
+ communityShareFailed: '打开社区分享页面失败',
create: '创建',
createFailed: '创建宠物会话失败',
emptyImported: '尚未导入宠物,点击右上角「导入」添加 .zip 资源包',
@@ -36,6 +38,8 @@ const en: Record<keyof typeof zh, string> = {
clear: 'Clear selection',
clearFailed: 'Failed to clear pet selection',
closePet: 'Close pet',
+ communityShare: 'Community share',
+ communityShareFailed: 'Failed to open the community share page',
create: 'Create',
createFailed: 'Failed to create a pet session',
emptyImported: 'No pets imported yet. Click “Import” to add a .zip package',
diff --git a/packages/dsh-tauri-pet/src/client/service/pet.test.ts b/packages/dsh-tauri-pet/src/client/service/pet.test.ts
index 05219dd8..7a209b51 100644
--- a/packages/dsh-tauri-pet/src/client/service/pet.test.ts
+++ b/packages/dsh-tauri-pet/src/client/service/pet.test.ts
@@ -13,6 +13,7 @@ import {
loadPetCatalog,
loadPetOverlaySupported,
loadPetStatus,
+ openCommunityShare,
resizePet,
toggleForceXwayland,
togglePet,
@@ -165,6 +166,12 @@ describe('pet service native command contracts', () => {
expect(store.pet.catalogLoaded).toBe(false)
})
+ it('community share opens the Codex pets site through the external URL command', async () => {
+ invoke.mockResolvedValue(undefined)
+ expect(await openCommunityShare()).toEqual({ ok: true })
+ expect(invoke.mock.calls).toEqual([['open_external_url', { url: 'https://codex-pets.net/#/' }]])
+ })
+
it('xWayland query and action retain native boolean results', async () => {
invoke.mockResolvedValueOnce(true).mockResolvedValueOnce(false)
expect(await loadForceXwayland()).toBe(true)
@@ -189,6 +196,7 @@ describe('pet service native command contracts', () => {
{ label: 'toggle force xwayland', action: () => toggleForceXwayland({ enabled: true }) },
{ label: 'resize pet', action: () => resizePet({ size: 140 }) },
{ label: 'import pet', action: () => importPetArchive({ name: 'bad.zip', data: 'bad' }) },
+ { label: 'open community share', action: openCommunityShare },
])('$label preserves error messages and logging labels without changing cached values', async ({ label, action }) => {
const error = new Error('native refused')
const log = vi.spyOn(console, 'error').mockImplementation(() => {})
diff --git a/packages/dsh-tauri-pet/src/client/service/pet.ts b/packages/dsh-tauri-pet/src/client/service/pet.ts
index bdb61e5e..d820b321 100644
--- a/packages/dsh-tauri-pet/src/client/service/pet.ts
+++ b/packages/dsh-tauri-pet/src/client/service/pet.ts
@@ -8,10 +8,12 @@ import {
CMD_IMPORT_PET,
CMD_LIST_PETS,
CMD_LIST_PRESET_PETS,
+ CMD_OPEN_EXTERNAL_URL,
CMD_SET_ACTIVE_PET,
CMD_SET_FORCE_XWAYLAND,
CMD_SET_PET_ENABLED,
CMD_SET_PET_SIZE,
+ PET_COMMUNITY_URL,
PET_HATCH_PROMPT,
} from '../constants'
import { store } from '../store'
@@ -177,6 +179,18 @@ export async function importPetArchive(input: { name: string, data: string }): P
})
}
+/**
+ * Action:在系统浏览器中打开 Codex 宠物社区站点。
+ *
+ * 只借桌面端既有的外链命令,不开新窗口、不改任何持久状态。
+ */
+export async function openCommunityShare(): Promise<PetActionResult> {
+ return guard('open community share', async () => {
+ await invoke(CMD_OPEN_EXTERNAL_URL, { url: PET_COMMUNITY_URL })
+ return { ok: true }
+ })
+}
+
/**
* Action:新建桌宠会话——挑工作区、建会话、装一次性草稿、打开会话并收起设置面板。
*
diff --git a/src-tauri/resources/manifest.jsonc b/src-tauri/resources/manifest.jsonc
index 8c623415..33eb4e96 100644
--- a/src-tauri/resources/manifest.jsonc
+++ b/src-tauri/resources/manifest.jsonc
@@ -155,7 +155,7 @@
"spec": "dshmarket",
"name": "DSH Market",
"repo": "https://github.com/dsh-market/dsh-market",
- "description": "Visual plugin market inside DeepSeek Harness — browse, search, and one-click install community plugins.",
+ "description": "The plugin market inside DeepSeek Harness — browse, search, one-click install · DSH 可视化插件市场",
"recommended": true,
"checked": true,
"version": "latest"
@@ -164,67 +164,103 @@
"id": "dsh-better-sidebar",
"spec": "dsh-better-sidebar",
"name": "DSH Better Sidebar",
- "description": "A VSCode-like right sidebar (explorer / editor / terminal / git / browser), isolated per conversation session. Exposes a service for other plugins to register sidebar tabs and file viewers.",
+ "description": "开放的侧边栏底座,支持三方拓展注册新侧边栏页面。内置文件渲染编辑/终端/侧边对话/Git/子代理页面 | Open sidebar foundation, supports third-party extensions to register new sidebar pages. Built-in file rendering/editing, terminal, side chat, Git, and sub-agent pages.",
"repo": "https://github.com/omdsh-dev/DSH-better-sidebar",
"recommended": true,
"checked": true,
"version": [
- { "version": "^0.19.1", "dsh": "^0.1.5-rc.1" },
- { "version": "^0.21.1", "dsh": "^0.1.7-rc.1" },
- { "version": "latest", "dsh": "^0.2.0-rc.1" }
+ {
+ "version": "^0.19.1",
+ "dsh": "^0.1.5-rc.1"
+ },
+ {
+ "version": "^0.21.1",
+ "dsh": "^0.1.7-rc.1"
+ },
+ {
+ "version": "latest",
+ "dsh": "^0.2.0-rc.1"
+ }
]
},
{
"id": "dsh-rewind-plugin",
"spec": "dsh-rewind-plugin",
"name": "DSH Rewind",
- "description": "In-window conversation rewind that never forks a new session, with a lightweight workspace backup that restores files together with the rewind.",
+ "description": "便捷无感的同窗口内对话回退,从不新建分支;自带轻量工作区备份,可一并还原文件(Claude Code /rewind 语义)。 · DSH plugin: effortless in-window conversation rewind — never forking a new session; ships a lightweight workspace backup that restores files together with the rewind (Claude Code /rewind semantics).",
"repo": "https://github.com/SiriLee/dsh-rewind",
"recommended": true,
"checked": true,
"version": [
- { "version": "^0.12.2", "dsh": "^0.1.5-rc.1" },
- { "version": "^0.14.0", "dsh": "^0.1.7-rc.1" },
- { "version": "latest", "dsh": "^0.2.0-rc.1" }
+ {
+ "version": "^0.12.2",
+ "dsh": "^0.1.5-rc.1"
+ },
+ {
+ "version": "^0.14.0",
+ "dsh": "^0.1.7-rc.1"
+ },
+ {
+ "version": "latest",
+ "dsh": "^0.2.0-rc.1"
+ }
]
},
+ {
+ "id": "billion-context",
+ "spec": "billion-context",
+ "name": "Billion Context",
+ "description": "基本稳定可用 A context-compression plugin for small context windows (a 100K context is enough), token savings (5x fewer tokens), and month-long single sessions (billions of tokens).上下文压缩插件,兼顾小窗口(100k上下文足矣)省token(省5倍token)和超长会话(数月级别几十亿token单会话)。billion-context is all you need",
+ "repo": "https://github.com/ranxianglei/billion-context",
+ "recommended": true,
+ "checked": false,
+ "version": "latest"
+ },
{
"id": "@wenbin_wb/dsh-bridge",
"spec": "@wenbin_wb/dsh-bridge",
"name": "DSH Bridge",
- "description": "Remote access and security guard for a local DeepSeek Harness: LAN QR-code connect, Cloudflare or self-hosted public tunnels, and full-lifecycle WeChat / QQ / Feishu / Telegram bot conversations, with built-in access authentication and tamper safeguards.",
+ "description": "DeepSeek Harness 多通道远程访问与安全守护插件 | 局域网扫码直连、Cloudflare / 自建公网隧道、微信 / QQ / 飞书 / Telegram 机器人全生命周期对话 | 内置全协议访问安全认证、后台防篡改与容灾保命体系",
"repo": "https://github.com/wenbin-wb/dsh-bridge",
- "recommended": true,
+ "recommended": false,
"checked": false,
"version": [
- { "version": "^2.11.0", "dsh": "^0.1.5-rc.1" },
- { "version": "^2.11.3", "dsh": "^0.1.7-rc.1" },
- { "version": "latest", "dsh": "^0.2.0-rc.1" }
+ {
+ "version": "^2.11.0",
+ "dsh": "^0.1.5-rc.1"
+ },
+ {
+ "version": "^2.11.3",
+ "dsh": "^0.1.7-rc.1"
+ },
+ {
+ "version": "latest",
+ "dsh": "^0.2.0-rc.1"
+ }
]
},
{
"id": "@xmanrui/dsh-im",
"spec": "@xmanrui/dsh-im",
"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.",
+ "description": "通过扫码或机器人凭据把IM机器人接入DeepSeek Harness(支持飞书、微信、钉钉、企业微信、QQ、Slack、Telegram、Discord和WhatsApp)。 Connect IM bots to DeepSeek Harness via QR code or credentials (9 channels).",
"repo": "https://github.com/xmanrui/dsh-im",
"recommended": true,
"checked": false,
"version": [
- { "version": "^4.25.0", "dsh": "^0.1.5-rc.1" },
- { "version": "^4.29.0", "dsh": "^0.1.7-rc.1" },
- { "version": "latest", "dsh": "^0.2.0-rc.1" }
+ {
+ "version": "^4.25.0",
+ "dsh": "^0.1.5-rc.1"
+ },
+ {
+ "version": "^4.29.0",
+ "dsh": "^0.1.7-rc.1"
+ },
+ {
+ "version": "latest",
+ "dsh": "^0.2.0-rc.1"
+ }
]
- },
- {
- "id": "billion-context",
- "spec": "billion-context",
- "name": "Billion Context",
- "description": "Context compression for DeepSeek Harness: folds conversation history as it grows so long sessions keep running within a small context window, and restores folded content on demand via decompress / search_context.",
- "repo": "https://github.com/ranxianglei/billion-context",
- "recommended": false,
- "checked": false,
- "version": "latest"
}
]
},
diff --git a/src-tauri/src/config/i18n.rs b/src-tauri/src/config/i18n.rs
index 24d0d484..bd5d1ed4 100644
--- a/src-tauri/src/config/i18n.rs
+++ b/src-tauri/src/config/i18n.rs
@@ -70,6 +70,7 @@ pub fn t(key: &str) -> String {
"menu.enter_fullscreen" => ("进入全屏幕", "Enter Full Screen"),
"menu.exit_fullscreen" => ("退出全屏幕", "Exit Full Screen"),
"menu.about" => ("关于 Desktop", "About Desktop"),
+ "menu.toggle_devtools" => ("切换开发者工具", "Toggle Developer Tools"),
"menu.task_manager" => ("任务管理器", "Task Manager"),
"menu.run_logs" => ("运行日志", "Run Logs"),
"menu.check_update" => ("检查更新", "Check for Updates"),
diff --git a/src-tauri/src/desktop/builder.rs b/src-tauri/src/desktop/builder.rs
index 042c2e2e..862dca41 100644
--- a/src-tauri/src/desktop/builder.rs
+++ b/src-tauri/src/desktop/builder.rs
@@ -423,6 +423,13 @@ pub fn install_macos_menu(app: &tauri::AppHandle<Wry>) -> tauri::Result<()> {
true,
None::<&str>,
)?;
+ let toggle_devtools = MenuItem::with_id(
+ app,
+ "desktop-toggle-devtools",
+ crate::config::i18n::t("menu.toggle_devtools"),
+ true,
+ None::<&str>,
+ )?;
let task_manager = MenuItem::with_id(
app,
"desktop-task-manager",
@@ -473,6 +480,7 @@ pub fn install_macos_menu(app: &tauri::AppHandle<Wry>) -> tauri::Result<()> {
&harness_feedback,
&feedback_separator,
&run_logs,
+ &toggle_devtools,
&task_manager,
],
)?;
@@ -1567,6 +1575,7 @@ pub fn handler() -> impl Fn(Invoke<Wry>) -> bool + Send + Sync + 'static {
crate::desktop::window::create_app_window,
crate::desktop::builder::sync_view_menu,
crate::desktop::window::quit_app,
+ crate::desktop::window::toggle_devtools,
crate::bridge::log_frontend,
crate::bridge::get_pet_status,
crate::bridge::get_pet_overlay_supported,
@@ -1699,6 +1708,7 @@ pub fn builder() -> tauri::Builder<tauri::Wry> {
| "desktop-harness"
| "desktop-about"
| "desktop-copy-run-logs"
+ | "desktop-toggle-devtools"
| "desktop-check-update"
| "desktop-restart"
| "desktop-keyboard-shortcuts"
diff --git a/src-tauri/src/desktop/window.rs b/src-tauri/src/desktop/window.rs
index 330a25f6..2577d041 100644
--- a/src-tauri/src/desktop/window.rs
+++ b/src-tauri/src/desktop/window.rs
@@ -5,11 +5,9 @@ use std::sync::Arc;
#[cfg(windows)]
use tauri::webview::{PageLoadEvent, PageLoadPayload};
-#[cfg(windows)]
-use tauri::WebviewWindow;
use tauri::{
webview::{DownloadEvent, NewWindowFeatures, NewWindowResponse},
- AppHandle, Emitter, Runtime, Url, Webview, Wry,
+ AppHandle, Emitter, Runtime, Url, Webview, WebviewWindow, Wry,
};
use tauri_plugin_opener::OpenerExt;
@@ -134,3 +132,17 @@ pub async fn create_app_window(app_handle: AppHandle<Wry>) -> Result<(), String>
pub fn quit_app(app_handle: AppHandle<Wry>) {
app_handle.exit(0);
}
+
+/// 壳层「帮助 → 切换开发者工具」:开/关调用方所在窗口的 WebView 检查器。
+///
+/// 「切换」只能做到近似:只有 macOS 的 wkwebview 如实回报检查器状态;
+/// Windows 侧(wry 0.55 + WebView2)`is_devtools_open()` 恒为 false 且
+/// `close_devtools()` 是空实现,重复调用等价于再次打开/聚焦,不会误关。
+#[tauri::command]
+pub fn toggle_devtools(window: WebviewWindow<Wry>) {
+ if window.is_devtools_open() {
+ window.close_devtools();
+ } else {
+ window.open_devtools();
+ }
+}
diff --git a/src/components/ellipsis.test.tsx b/src/components/ellipsis.test.tsx
new file mode 100644
index 00000000..2818c9b8
--- /dev/null
+++ b/src/components/ellipsis.test.tsx
@@ -0,0 +1,39 @@
+// @vitest-environment jsdom
+import { cleanup, fireEvent, render, screen } from '@testing-library/react'
+import { afterEach, describe, expect, it } from 'vitest'
+import { Ellipsis } from './ellipsis'
+
+afterEach(cleanup)
+
+function hoverTrigger(trigger: HTMLElement) {
+ fireEvent.pointerDown(trigger, { pointerType: 'mouse' })
+ fireEvent.mouseDown(trigger)
+ fireEvent.pointerEnter(trigger, { pointerType: 'mouse' })
+ fireEvent.mouseOver(trigger)
+}
+
+describe('ellipsis tooltip', () => {
+ it('溢出放行时 hover 在 500ms 延迟后打开 tooltip,并与触发器互相引用', async () => {
+ render(<Ellipsis forceTooltip>a very long truncated line</Ellipsis>)
+ const trigger = screen.getByRole('button')
+
+ hoverTrigger(trigger)
+
+ const tooltip = await screen.findByRole('tooltip', undefined, { timeout: 2000 })
+ expect(tooltip.textContent).toContain('a very long truncated line')
+ expect(trigger.getAttribute('aria-describedby')).toBe(tooltip.id)
+ })
+
+ it('未溢出时 hover 触发器不打开 tooltip', async () => {
+ render(<Ellipsis>short</Ellipsis>)
+ const trigger = screen.getByRole('button')
+
+ hoverTrigger(trigger)
+ await new Promise((resolve) => {
+ setTimeout(resolve, 1600)
+ })
+
+ expect(screen.queryByRole('tooltip')).toBeNull()
+ expect(trigger.hasAttribute('aria-describedby')).toBe(false)
+ })
+})
diff --git a/src/components/ellipsis.tsx b/src/components/ellipsis.tsx
index 3c9df653..577390c8 100644
--- a/src/components/ellipsis.tsx
+++ b/src/components/ellipsis.tsx
@@ -46,9 +46,8 @@ export function Ellipsis(props: EllipsisProps & VariantProps<typeof ellipsis>) {
}
return (
- <Tooltip isOpen={open} onOpenChange={onOpenChange}>
- <div
- ref={triggerRef}
+ <Tooltip delay={500} isOpen={open} onOpenChange={onOpenChange}>
+ <Tooltip.Trigger
className={cn(
props.lineClamp === undefined ? 'truncate' : 'line-clamp-[var(--line-clamp)] [display:-webkit-inline-box]!',
container({ className: props.className }),
@@ -58,9 +57,19 @@ export function Ellipsis(props: EllipsisProps & VariantProps<typeof ellipsis>) {
'--line-clamp': props.lineClamp,
} as React.CSSProperties
}
+ render={({ ref, ...triggerProps }) => (
+ <div
+ {...triggerProps}
+ ref={(node) => {
+ triggerRef.current = node
+ if (typeof ref === 'function')
+ ref(node)
+ }}
+ />
+ )}
>
{props.lineClamp ? props.children : <span>{props.children}</span>}
- </div>
+ </Tooltip.Trigger>
<Tooltip.Content className={cn(tooltip(), props.tooltipClassName)}>
{props.tooltip || props.children}
</Tooltip.Content>
diff --git a/src/i18n/locales/en-US.json b/src/i18n/locales/en-US.json
index a51e980c..a1ee7530 100644
--- a/src/i18n/locales/en-US.json
+++ b/src/i18n/locales/en-US.json
@@ -71,6 +71,7 @@
"menu.check_update": "Check for Updates",
"menu.new_version": "New version available",
"menu.about": "About Desktop",
+ "menu.toggle_devtools": "Toggle Developer Tools",
"menu.run_logs": "Run Logs",
"menu.file": "File",
"menu.settings": "Settings…",
diff --git a/src/i18n/locales/zh-CN.json b/src/i18n/locales/zh-CN.json
index be645189..36d77332 100644
--- a/src/i18n/locales/zh-CN.json
+++ b/src/i18n/locales/zh-CN.json
@@ -71,6 +71,7 @@
"menu.check_update": "检查更新",
"menu.new_version": "存在新版本",
"menu.about": "关于 Desktop",
+ "menu.toggle_devtools": "切换开发者工具",
"menu.run_logs": "运行日志",
"menu.file": "文件",
"menu.settings": "设置…",
diff --git a/src/layout/components/help-menu.test.tsx b/src/layout/components/help-menu.test.tsx
index 397ac031..12dd9f1d 100644
--- a/src/layout/components/help-menu.test.tsx
+++ b/src/layout/components/help-menu.test.tsx
@@ -5,13 +5,14 @@ import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-libra
import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { Navbar } from './navbar'
-const { userAgent, openUrl, writeText, toast } = vi.hoisted(() => {
+const { userAgent, openUrl, writeText, toast, toggleDevtools } = vi.hoisted(() => {
const userAgent = navigator.userAgent
Object.defineProperty(navigator, 'userAgent', { configurable: true, value: 'Windows' })
return {
userAgent,
openUrl: vi.fn<(args: { url: string }) => Promise<void>>(),
writeText: vi.fn<(args: { text: string }) => Promise<void>>(),
+ toggleDevtools: vi.fn<() => Promise<void>>(),
toast: vi.fn<(title: string, options?: {
variant?: string
description?: ReactNode
@@ -50,6 +51,7 @@ beforeEach(() => {
vi.stubGlobal('CSS', { escape: (value: string) => value.replace(/[^\w-]/g, character => `\\${character}`) })
openUrl.mockReset().mockResolvedValue(undefined)
writeText.mockReset().mockResolvedValue(undefined)
+ toggleDevtools.mockReset().mockResolvedValue(undefined)
toast.mockClear()
mockWindows('main')
mockIPC((command, args) => {
@@ -58,6 +60,8 @@ beforeEach(() => {
return openUrl(args as { url: string })
case 'write_clipboard_text':
return writeText(args as { text: string })
+ case 'toggle_devtools':
+ return toggleDevtools()
case 'plugin:event|listen':
return (args as { handler: number }).handler
case 'plugin:event|unlisten':
@@ -117,6 +121,32 @@ describe('help menu links', () => {
expect(toast.mock.calls.map(([title]) => title)).toEqual(['messages.open_link_failed', 'messages.copy_success'])
})
+ it('toggles the developer tools from the item above the task manager', async () => {
+ render(<Navbar onRemoteChange={vi.fn()} />)
+ fireEvent.click(screen.getByTestId('dsh-navbar-menu-help'))
+ const devtools = await screen.findByTestId('dsh-navbar-item-toggle-devtools')
+ const taskManager = screen.getByTestId('dsh-navbar-item-task-manager')
+ expect(devtools.compareDocumentPosition(taskManager) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy()
+
+ fireEvent.click(devtools)
+
+ await waitFor(() => expect(toggleDevtools).toHaveBeenCalledExactlyOnceWith())
+ expect(toast).not.toHaveBeenCalled()
+ })
+
+ it('reports a developer tools failure once', async () => {
+ const failure = new Error('devtools unavailable')
+ const log = vi.spyOn(console, 'error').mockImplementation(() => {})
+ toggleDevtools.mockRejectedValue(failure)
+
+ render(<Navbar onRemoteChange={vi.fn()} />)
+ fireEvent.click(screen.getByTestId('dsh-navbar-menu-help'))
+ fireEvent.click(await screen.findByTestId('dsh-navbar-item-toggle-devtools'))
+
+ await waitFor(() => expect(log).toHaveBeenCalledExactlyOnceWith('[Navbar] failed to toggle devtools:', failure))
+ expect(toast).not.toHaveBeenCalled()
+ })
+
it('reports a clipboard failure once when copying a failed feedback link', async () => {
const failure = new Error('clipboard unavailable')
const log = vi.spyOn(console, 'error').mockImplementation(() => {})
diff --git a/src/layout/components/navbar.tsx b/src/layout/components/navbar.tsx
index a291f92b..5acbe02f 100644
--- a/src/layout/components/navbar.tsx
+++ b/src/layout/components/navbar.tsx
@@ -91,7 +91,7 @@ const HELP_LINKS = {
type FileAction = 'new-window' | 'new-chat' | 'open-folder' | 'close' | 'quit'
/** 「帮助」菜单的动作 id。 */
-type HelpAction = 'task-manager' | 'keyboard-shortcuts' | 'copy-run-logs' | 'check-update' | 'about' | keyof typeof HELP_LINKS
+type HelpAction = 'toggle-devtools' | 'task-manager' | 'keyboard-shortcuts' | 'copy-run-logs' | 'check-update' | 'about' | keyof typeof HELP_LINKS
/** 「运行」菜单项:直接打开配置对话框并定位到对应面板。 */
const CONFIG_TABS = [
@@ -289,7 +289,9 @@ export function Navbar({ onRemoteChange, sidebarCollapsed = false, onToggleSideb
}
function onHelpAction(key: HelpAction) {
- if (key === 'task-manager')
+ if (key === 'toggle-devtools')
+ void toggleDevtools()
+ else if (key === 'task-manager')
void openTaskManager().catch(() => { })
else if (key === 'check-update')
void handleCheckUpdate()
@@ -344,6 +346,16 @@ export function Navbar({ onRemoteChange, sidebarCollapsed = false, onToggleSideb
}
}
+ /** 切换开发者工具:Rust 侧就近作用于调用窗口(Windows 上只能反复打开,无法关闭检查器) */
+ async function toggleDevtools() {
+ try {
+ await invoke('toggle_devtools')
+ }
+ catch (error) {
+ console.error('[Navbar] failed to toggle devtools:', error)
+ }
+ }
+
async function openHelpLink(key: keyof typeof HELP_LINKS) {
try {
await invoke('open_external_url', { url: HELP_LINKS[key] })
@@ -443,6 +455,9 @@ export function Navbar({ onRemoteChange, sidebarCollapsed = false, onToggleSideb
case 'desktop-about':
handleOpenAbout()
break
+ case 'desktop-toggle-devtools':
+ void toggleDevtools()
+ break
case 'desktop-task-manager':
onHelpAction('task-manager')
break
@@ -714,6 +729,14 @@ export function Navbar({ onRemoteChange, sidebarCollapsed = false, onToggleSideb
<Label>{t('menu.harness_feedback')}</Label>
</Dropdown.Item>
<Separator />
+ <Dropdown.Item
+ id="toggle-devtools"
+ data-testid="dsh-navbar-item-toggle-devtools"
+ textValue={t('menu.toggle_devtools')}
+ onAction={() => onHelpAction('toggle-devtools')}
+ >
+ <Label>{t('menu.toggle_devtools')}</Label>
+ </Dropdown.Item>
<Dropdown.Item
id="task-manager"
data-testid="dsh-navbar-item-task-manager"
diff --git a/src/layout/components/setup-preinstall.tsx b/src/layout/components/setup-preinstall.tsx
index 184300c6..fe2ca894 100644
--- a/src/layout/components/setup-preinstall.tsx
+++ b/src/layout/components/setup-preinstall.tsx
@@ -1,6 +1,7 @@
+import type { IconComponent } from './loadable'
import type { PluginProcess } from '@/store/modules/plugins'
import type { PreinstallPlugin } from '@/store/modules/preinstall'
-import { ArrowUpRightFromSquare, Copy, PlugConnection, Xmark } from '@gravity-ui/icons'
+import { ArrowUpRightFromSquare, ArrowUturnCcwLeft, Comments, Copy, Cubes3Overlap, Globe, LayoutSideContentLeft, PlugConnection, ShoppingCart, Xmark } from '@gravity-ui/icons'
import { Button, Card, Checkbox, Chip, ScrollShadow, Spinner, Switch, Typography } from '@heroui/react'
import { useMount } from '@reause/core'
import { invoke } from '@tauri-apps/api/core'
@@ -47,6 +48,16 @@ function initialCheckedSet(plugins: readonly PreinstallPlugin[], isFirstTime: bo
}).map(p => p.id))
}
+/** 预设插件标识 → 图标;清单新增预设时回落通用图标,不因缺映射而空白 */
+const PLUGIN_ICONS: Record<string, IconComponent | undefined> = {
+ 'dshmarket': ShoppingCart,
+ 'dsh-better-sidebar': LayoutSideContentLeft,
+ 'dsh-rewind-plugin': ArrowUturnCcwLeft,
+ 'billion-context': Cubes3Overlap,
+ '@wenbin_wb/dsh-bridge': Globe,
+ '@xmanrui/dsh-im': Comments,
+}
+
/** 插件卡片:图标 + 名称 + 状态 chip 在顶,描述居中,开关居底部右侧 */
function PluginCard({ plugin, checked, toUninstall, disabled, onToggle, onOpenRepo }: {
plugin: PreinstallPlugin
@@ -58,15 +69,14 @@ function PluginCard({ plugin, checked, toUninstall, disabled, onToggle, onOpenRe
onOpenRepo: (id: string) => void
}) {
const { t } = useTranslation()
+ const PluginIcon = PLUGIN_ICONS[plugin.id] ?? PlugConnection
return (
<Card
- className={`h-[124px] gap-1 bg-panel2 p-3 shadow-none transition-colors ${plugin.unsupported ? 'opacity-60' : 'hover:border-line-strong'}`}
+ className={`h-[120px] gap-1 bg-panel2 p-3 shadow-none transition-colors ${plugin.unsupported ? 'opacity-60' : '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-info/10 text-info">
- <PlugConnection className="size-3.5" />
- </span>
+ <PluginIcon className="size-3.5" />
<span className="min-w-0 flex-1 truncate text-[13px] font-medium text-ink">
{plugin.name}
</span>
@@ -86,7 +96,7 @@ function PluginCard({ plugin, checked, toUninstall, disabled, onToggle, onOpenRe
</Chip>
</If>
<If cond={plugin.installed && !toUninstall}>
- <Chip size="sm" variant="soft" color="success" className="shrink-0 font-medium">
+ <Chip size="sm" variant="soft" color="default" className="shrink-0 font-medium">
{t('preinstall.installed')}
</Chip>
</If>
@@ -98,12 +108,12 @@ function PluginCard({ plugin, checked, toUninstall, disabled, onToggle, onOpenRe
</div>
<If cond={plugin.description !== ''}>
- <Ellipsis lineClamp={2} className="text-[11px] leading-[17px] text-muted">
+ <Ellipsis lineClamp={2} className="text-[11px] leading-[17px] text-muted my-auto">
{plugin.description}
</Ellipsis>
</If>
- <div className="mt-auto flex items-center justify-between gap-2">
+ <div className="flex items-center justify-between gap-2">
<Button
isIconOnly
size="sm"
diff --git a/src/layout/components/view-menu.test.tsx b/src/layout/components/view-menu.test.tsx
index 831b4101..053ecb09 100644
--- a/src/layout/components/view-menu.test.tsx
+++ b/src/layout/components/view-menu.test.tsx
@@ -8,13 +8,14 @@ import { useDshShortcuts } from '@/hooks/use-dsh-shortcuts'
import { Navbar } from './navbar'
import { Webview } from './webview'
-const { store, userAgent, openOverlay, openUrl } = vi.hoisted(() => {
+const { store, userAgent, openOverlay, openUrl, toggleDevtools } = vi.hoisted(() => {
const userAgent = navigator.userAgent
Object.defineProperty(navigator, 'userAgent', { configurable: true, value: 'Macintosh' })
return {
userAgent,
openOverlay: vi.fn().mockResolvedValue(undefined),
openUrl: vi.fn<(args: { url: string }) => Promise<void>>(),
+ toggleDevtools: vi.fn<() => Promise<void>>(),
store: {
harness: { status: 'ready', serviceHealthy: true },
recovery: { recovery: { required: false } },
@@ -102,6 +103,7 @@ beforeEach(() => {
listeners.clear()
openOverlay.mockClear()
openUrl.mockReset().mockResolvedValue(undefined)
+ toggleDevtools.mockReset().mockResolvedValue(undefined)
menuEntries = []
store.harness.status = 'ready'
store.harness.serviceHealthy = true
@@ -111,6 +113,8 @@ beforeEach(() => {
switch (command) {
case 'open_external_url':
return openUrl(args as { url: string })
+ case 'toggle_devtools':
+ return toggleDevtools()
case 'plugin:event|listen': {
const listener = args as unknown as Listener
listeners.set(listener.handler, listener)
@@ -263,4 +267,13 @@ describe('native Help menu links', () => {
await waitFor(() => expect(openUrl).toHaveBeenCalledExactlyOnceWith({ url }))
})
+
+ it('toggles the shell window developer tools from the native item', async () => {
+ render(<Navbar onRemoteChange={vi.fn()} />)
+ await waitFor(() => expect([...listeners.values()].filter(listener => listener.event === 'macos-menu-action')).toHaveLength(1))
+
+ act(() => nativeEvent('macos-menu-action', 'desktop-toggle-devtools', 'main'))
+
+ await waitFor(() => expect(toggleDevtools).toHaveBeenCalledExactlyOnceWith())
+ })
})
diff --git a/src/ui/config/core.tsx b/src/ui/config/core.tsx
index 9d0bb607..231ad3e6 100644
--- a/src/ui/config/core.tsx
+++ b/src/ui/config/core.tsx
@@ -327,7 +327,6 @@ export function ConfigCore() {
<Button
size="sm"
variant="tertiary"
- className="h-7 shrink-0 text-xs"
isDisabled={busy || refreshing}
aria-label={t('core.refresh')}
onPress={onRefresh}
diff --git a/src/ui/config/debug.tsx b/src/ui/config/debug.tsx
index e74f6981..902dd9ce 100644
--- a/src/ui/config/debug.tsx
+++ b/src/ui/config/debug.tsx
@@ -255,7 +255,21 @@ export function ConfigDebug() {
return (
<div className="space-y-3">
- <Panel.Header title={t('config.application')} testId="dsh-config-panel-title" />
+ <Panel.Header
+ title={t('config.application')}
+ testId="dsh-config-panel-title"
+ action={(
+ <Button
+ size="sm"
+ variant="tertiary"
+ isDisabled={!info || copyingEnvironment}
+ onPress={() => onCopyEnvironment()}
+ >
+ <If cond={copyingEnvironment} then={<Spinner size="sm" color="current" />} else={<Copy className="size-3.5" />} />
+ {t('buttons.copy_environment')}
+ </Button>
+ )}
+ />
{coreBreakingHolder}
{coreProfileSwitchHolder}
<div className="space-y-1.5">
@@ -346,17 +360,6 @@ export function ConfigDebug() {
{info ? `${info.platform} / ${info.arch}` : '-'}
</Info>
</div>
- <div className="mt-2 flex justify-end">
- <Button
- size="sm"
- variant="secondary"
- isDisabled={!info || copyingEnvironment}
- onPress={() => onCopyEnvironment()}
- >
- <If cond={copyingEnvironment} then={<Spinner size="sm" color="current" />} else={<Copy className="size-3.5" />} />
- {t('buttons.copy_environment')}
- </Button>
- </div>
</div>
<div className="border-t border-line/30" />
<div className="space-y-1.5">
diff --git a/src/ui/config/plugin.test.tsx b/src/ui/config/plugin.test.tsx
index 11a038f8..908b5340 100644
--- a/src/ui/config/plugin.test.tsx
+++ b/src/ui/config/plugin.test.tsx
@@ -184,11 +184,12 @@ describe('built-in plugin toggles', () => {
})
describe('one-click plugin upgrade', () => {
- it('shows the bulk upgrade immediately after open preset without enabling advanced options', () => {
+ it('shows the bulk upgrade right before open preset without enabling advanced options', () => {
+ manager.installed = [plugin({ id: 'updated', internal: false, updateAvailable: true, latest: '2.0.0' })]
render(<ConfigPlugin />)
const preset = screen.getByRole('button', { name: 'preinstall.open_preset' })
const upgradeAll = screen.getByRole('button', { name: 'plugins.upgrade_all' })
- expect(preset.nextElementSibling).toBe(upgradeAll)
+ expect(upgradeAll.nextElementSibling).toBe(preset)
expect(screen.getByRole('switch', { name: 'plugins.advanced_options' }).getAttribute('aria-checked')).toBe('false')
})
@@ -196,12 +197,10 @@ describe('one-click plugin upgrade', () => {
['no plugins', []],
['only current managed plugins', [plugin({ internal: false })]],
['only built-in updates', [plugin({ updateAvailable: true, latest: '2.0.0' })]],
- ] as const)('disables bulk upgrade with %s', (_case, installed) => {
+ ] as const)('hides bulk upgrade with %s', (_case, installed) => {
manager.installed = [...installed]
render(<ConfigPlugin />)
- const upgradeAll = screen.getByRole('button', { name: 'plugins.upgrade_all' }) as HTMLButtonElement
- expect(upgradeAll.disabled).toBe(true)
- fireEvent.click(upgradeAll)
+ expect(screen.queryByRole('button', { name: 'plugins.upgrade_all' })).toBeNull()
expect(manager.upgrade).not.toHaveBeenCalled()
})
@@ -231,15 +230,13 @@ describe('one-click plugin upgrade', () => {
}))
manager.installed = [plugin({ id: 'updated', internal: false, updateAvailable: true, latest: '2.0.0' })]
render(<ConfigPlugin />)
- const upgradeAll = screen.getByRole('button', { name: 'plugins.upgrade_all' }) as HTMLButtonElement
- fireEvent.click(upgradeAll)
- expect(upgradeAll.disabled).toBe(true)
- fireEvent.click(upgradeAll)
+ fireEvent.click(screen.getByRole('button', { name: 'plugins.upgrade_all' }))
+ expect(screen.queryByRole('button', { name: 'plugins.upgrade_all' })).toBeNull()
await act(async () => fireEvent.click(screen.getByRole('button', { name: 'plugins.upgrade 2.0.0' })))
expect(manager.upgrade).toHaveBeenCalledExactlyOnceWith([{ spec: 'updated', version: '2.0.0' }])
await act(async () => settle())
- expect(upgradeAll.disabled).toBe(false)
+ expect((screen.getByRole('button', { name: 'plugins.upgrade_all' }) as HTMLButtonElement).disabled).toBe(false)
await act(async () => fireEvent.click(screen.getByRole('button', { name: 'plugins.upgrade 2.0.0' })))
expect(manager.upgrade).toHaveBeenCalledTimes(2)
expect(manager.upgrade).toHaveBeenLastCalledWith({ spec: 'updated', version: '2.0.0' })
@@ -257,7 +254,7 @@ describe('one-click plugin upgrade', () => {
manager.installed = [plugin({ id: 'queued', internal: false, updateAvailable: true })]
rerender(<ConfigPlugin />)
- expect((screen.getByRole('button', { name: 'plugins.upgrade_all' }) as HTMLButtonElement).disabled).toBe(true)
+ expect(screen.queryByRole('button', { name: 'plugins.upgrade_all' })).toBeNull()
})
it('excludes a row whose local action is still pending', async () => {
@@ -268,12 +265,9 @@ describe('one-click plugin upgrade', () => {
manager.installed = [plugin({ id: 'updated', internal: false, updateAvailable: true, latest: '2.0.0' })]
render(<ConfigPlugin />)
fireEvent.click(screen.getByRole('button', { name: 'plugins.disable' }))
- const upgradeAll = screen.getByRole('button', { name: 'plugins.upgrade_all' }) as HTMLButtonElement
- expect(upgradeAll.disabled).toBe(true)
- fireEvent.click(upgradeAll)
- expect(manager.upgrade).not.toHaveBeenCalled()
+ expect(screen.queryByRole('button', { name: 'plugins.upgrade_all' })).toBeNull()
await act(async () => settle())
- expect(upgradeAll.disabled).toBe(false)
+ expect((screen.getByRole('button', { name: 'plugins.upgrade_all' }) as HTMLButtonElement).disabled).toBe(false)
})
it('releases the bulk and row guards after a manager failure without duplicating its toast', async () => {
@@ -283,7 +277,7 @@ describe('one-click plugin upgrade', () => {
render(<ConfigPlugin />)
const upgradeAll = screen.getByRole('button', { name: 'plugins.upgrade_all' }) as HTMLButtonElement
await act(async () => fireEvent.click(upgradeAll))
- expect(upgradeAll.disabled).toBe(false)
+ expect((screen.getByRole('button', { name: 'plugins.upgrade_all' }) as HTMLButtonElement).disabled).toBe(false)
expect(mocks.toast).not.toHaveBeenCalled()
await act(async () => fireEvent.click(screen.getByRole('button', { name: 'plugins.upgrade' })))
expect(manager.upgrade.mock.calls).toEqual([[['updated']], ['updated']])
diff --git a/src/ui/config/plugin.tsx b/src/ui/config/plugin.tsx
index e4737831..633a1129 100644
--- a/src/ui/config/plugin.tsx
+++ b/src/ui/config/plugin.tsx
@@ -1,5 +1,5 @@
import type { Plugin, PluginProcess, PluginSearchProblem, PluginSearchResult } from '@/store/modules/plugins'
-import { ChevronRight, CircleExclamation, FolderOpen } from '@gravity-ui/icons'
+import { ChevronRight, CircleExclamation, FolderOpen, Rocket } from '@gravity-ui/icons'
import { Button, Chip, Description, Input, Label, Spinner, Switch, Tooltip } from '@heroui/react'
import { useOverlay } from '@overlastic/react'
import { useToggle } from '@reause/core'
@@ -661,13 +661,36 @@ export function ConfigPlugin() {
onChange={() => toggleAdvanced()}
aria-label={t('plugins.advanced_options')}
>
- <Switch.Content>
+ <Switch.Content className="gap-2">
<Switch.Control>
<Switch.Thumb />
</Switch.Control>
+ <span className="text-xs font-medium text-muted">{t('plugins.advanced_options')}</span>
</Switch.Content>
</Switch>
- <span className="text-xs font-medium text-muted">{t('plugins.advanced_options')}</span>
+ <If cond={upgradable.length}>
+ <Tooltip delay={0}>
+ <Button
+ size="sm"
+ variant="tertiary"
+ onPress={() => void onUpgradeAll()}
+ isDisabled={upgradingAll}
+ >
+
+ <If cond={upgradingAll} then={<Spinner size="sm" color="current" />} else={<Rocket className="size-3.5" />} />
+ {t('plugins.upgrade_all')}
+ </Button>
+ <Tooltip.Content>
+ <p>
+ <If
+ cond={upgradable.length > 0}
+ then={t('plugins.upgrade_all_hint', { count: upgradable.length })}
+ else={t('plugins.upgrade_all_empty')}
+ />
+ </p>
+ </Tooltip.Content>
+ </Tooltip>
+ </If>
<Tooltip delay={0}>
<Button
size="sm"
@@ -681,28 +704,7 @@ export function ConfigPlugin() {
<p>{t('preinstall.settings_hint')}</p>
</Tooltip.Content>
</Tooltip>
- <Tooltip delay={0}>
- <Button
- size="sm"
- variant="tertiary"
- onPress={() => void onUpgradeAll()}
- isDisabled={upgradingAll || upgradable.length === 0}
- >
- <span className="flex items-center gap-1">
- <If cond={upgradingAll} then={<Spinner size="sm" color="current" />} />
- {t('plugins.upgrade_all')}
- </span>
- </Button>
- <Tooltip.Content>
- <p>
- <If
- cond={upgradable.length > 0}
- then={t('plugins.upgrade_all_hint', { count: upgradable.length })}
- else={t('plugins.upgrade_all_empty')}
- />
- </p>
- </Tooltip.Content>
- </Tooltip>
+
</div>
)}
description={t('plugins.panel_tooltip')}
diff --git a/test/macos-run-menu.test.ts b/test/macos-run-menu.test.ts
index 442594a7..ca126fdc 100644
--- a/test/macos-run-menu.test.ts
+++ b/test/macos-run-menu.test.ts
@@ -98,7 +98,7 @@ describe('macOS native menu', () => {
expect(i18nSource).toContain(`"${key}" => ("${zh}", "${en}")`)
})
- it('groups feedback links before run logs and the task manager in Help', () => {
+ it('groups feedback links before run logs, developer tools and the task manager in Help', () => {
expect(submenuItems('desktop-help-menu')).toEqual([
'&documentation',
'&keyboard_shortcuts',
@@ -107,8 +107,10 @@ describe('macOS native menu', () => {
'&harness_feedback',
'&feedback_separator',
'&run_logs',
+ '&toggle_devtools',
'&task_manager',
])
+ expect(i18nSource).toContain('"menu.toggle_devtools" => ("切换开发者工具", "Toggle Developer Tools")')
expect(i18nSource).toContain('"menu.task_manager" => ("任务管理器", "Task Manager")')
})
diff --git a/test/preinstall-uncheck.test.ts b/test/preinstall-uncheck.test.ts
deleted file mode 100644
index 3d403160..00000000
--- a/test/preinstall-uncheck.test.ts
+++ /dev/null
@@ -1,114 +0,0 @@
-import type { Event } from '@tauri-apps/api/event'
-import { readFileSync } from 'node:fs'
-import { beforeEach, describe, expect, it, vi } from 'vitest'
-
-/** 资源清单是 JSONC(允许行注释):解析前先剥掉行注释。 */
-function readManifest(): { plugins: { preset: Array<{ id: string, recommended?: boolean, checked?: boolean }> } } {
- const raw = readFileSync(new URL('../src-tauri/resources/manifest.jsonc', import.meta.url), 'utf8')
- return JSON.parse(raw.replace(/^\s*\/\/.*$/gm, ''))
-}
-
-// ── Suite A — i18n keys exist (source assertion on JSON) ─────────────────────
-describe('preinstall can-uncheck hint i18n keys', () => {
- it('provides preinstall.can_uncheck_hint in en-US', () => {
- const source = readFileSync(new URL('../src/i18n/locales/en-US.json', import.meta.url), 'utf8')
- const messages = JSON.parse(source) as Record<string, string>
- expect(messages).toHaveProperty('preinstall.can_uncheck_hint')
- expect(messages['preinstall.can_uncheck_hint']).toContain('Unchecked plugins won\'t be installed')
- })
-
- it('provides preinstall.can_uncheck_hint in zh-CN', () => {
- const source = readFileSync(new URL('../src/i18n/locales/zh-CN.json', import.meta.url), 'utf8')
- const messages = JSON.parse(source) as Record<string, string>
- expect(messages).toHaveProperty('preinstall.can_uncheck_hint')
- expect(messages['preinstall.can_uncheck_hint']).toContain('取消后不会安装')
- })
-})
-
-// ── Suite B — component references the hint key (source assertion) ───────────
-describe('preinstallSetup hint text', () => {
- it('renders the can_uncheck_hint key', () => {
- const source = readFileSync(new URL('../src/layout/components/setup-preinstall.tsx', import.meta.url), 'utf8')
- expect(source).toContain('preinstall.can_uncheck_hint')
- })
-})
-
-// ── Suite C — component has dynamic button label (source assertion) ──────────
-describe('preinstallSetup primary button morph', () => {
- it('guards the label switch on hasChanges', () => {
- const source = readFileSync(new URL('../src/layout/components/setup-preinstall.tsx', import.meta.url), 'utf8')
- expect(source).toContain('hasChanges')
- })
-
- it('can render the Skip label', () => {
- const source = readFileSync(new URL('../src/layout/components/setup-preinstall.tsx', import.meta.url), 'utf8')
- expect(source).toContain('preinstall.skip')
- })
-})
-
-// ── Suite B2 — 未预选声明抑制首次预选(behavior) ──────────────────────────────
-// 推荐项仍显示「推荐」chip,但清单声明 `checked: false` 时首次引导不预选。
-describe('unchecked preset 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 DSH Bridge and DSH IM as recommended but not pre-checked', () => {
- const preset = readManifest().plugins.preset
- for (const id of ['@wenbin_wb/dsh-bridge', '@xmanrui/dsh-im']) {
- const entry = preset.find(p => p.id === id)
- expect(entry, id).toBeDefined()
- expect(entry?.recommended, id).toBe(true)
- // 资源清单是唯一真值:Rust 侧据此派生 defaultUnchecked(checked === false)
- expect(entry?.checked, id).toBe(false)
- }
- })
-})
-
-// ── Suite B3 — 非推荐预设既不标推荐也不预选(behavior) ────────────────────────
-// 缺省语义:recommended / checked 未声明即为 false,故断言按 `?? false` 取值。
-describe('non-recommended preset stays fully opt-in', () => {
- it('declares Billion Context without the recommended chip and without preselecting it', () => {
- const entry = readManifest().plugins.preset.find(p => p.id === 'billion-context')
- expect(entry).toBeDefined()
- expect(entry?.recommended ?? false).toBe(false)
- expect(entry?.checked ?? false).toBe(false)
- })
-})
-
-// ── Suite D — store empty-selection guard (behavior, regression lock) ────────
-// vi.mock 工厂会被提升到文件顶部,必须先经 vi.hoisted 声明模块级 mock 状态,
-// 否则工厂执行时引用未初始化的绑定(Vitest 4.x 语义)。
-const { eventListeners, invoke } = vi.hoisted(() => ({
- eventListeners: new Map<string, (event: Event<unknown>) => void>(),
- invoke: vi.fn(),
-}))
-
-vi.mock('@tauri-apps/api/core', () => ({ invoke }))
-vi.mock('@tauri-apps/api/event', () => ({
- listen: vi.fn(async (event: string, callback: (payload: Event<unknown>) => void) => {
- eventListeners.set(event, callback)
- return vi.fn()
- }),
-}))
-vi.mock('@/config/client', () => ({ queryClient: { invalidateQueries: vi.fn() } }))
-vi.mock('../src/store/modules/harness-updater', () => ({
- harnessUpdater: { checkForUpdate: vi.fn() },
-}))
-
-const { preinstall } = await import('../src/store/modules/preinstall')
-
-beforeEach(() => {
- eventListeners.clear()
- invoke.mockReset()
-})
-
-describe('confirmPreinstall empty-selection guard', () => {
- it('does not invoke the backend when ids is empty', async () => {
- await preinstall.confirm([])
- expect(invoke).not.toHaveBeenCalled()
- })
-})