DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
fix(dsh-tauri-ui): 修正 logoRow 居中与品牌隐藏,并修复未分组「+」无响应
hairyffa2e9c57d422
diff --git a/packages/dsh-tauri-ui/src/client/constants/index.ts b/packages/dsh-tauri-ui/src/client/constants/index.tsindex 68548d05..a542d8dd 100644--- a/packages/dsh-tauri-ui/src/client/constants/index.ts+++ b/packages/dsh-tauri-ui/src/client/constants/index.ts@@ -20,6 +20,10 @@ export const MENU_SELECT_STYLE_ID = 'dsh-tauri-ui-menu-select-styles'export const HERO_WORKSPACE_STYLE_ID = 'dsh-tauri-ui-hero-workspace-styles'export const TURN_NAVIGATION_STYLE_ID = 'dsh-tauri-ui-turn-navigation-styles'export const GLOBAL_STYLE_ID = 'dsh-tauri-ui-global-styles'+export const SEGMENTED_CONTROL_STYLE_ID = 'dsh-tauri-ui-segmented-control-styles'+export const CHECKBOX_STYLE_ID = 'dsh-tauri-ui-checkbox-styles'+export const MODEL_EXTRAS_STYLE_ID = 'dsh-tauri-ui-model-extras-styles'+export const MODEL_CONFIG_TOOLBAR_STYLE_ID = 'dsh-tauri-ui-model-config-toolbar-styles'/** 接管后的英雄区工作区选择控件(官方 chip 由样式隐藏,见 `components/hero-workspace.cssr.ts`)。 */export const HERO_WORKSPACE_CHIP_CLASS = 'dshp-hero-workspace'@@ -38,6 +42,17 @@ export const HERO_WORKSPACE_PRIORITY = -1*/export const NEW_SESSION_LABELS = ['新建会话', 'New session'] as const+/**+ * 官方「未分组」分组行「+」的 aria-label(中英双语,逐字取自官方 ui-workspace 词典的+ * `actions.newSession.aria` 与 `group.ungrouped` 组合)。+ *+ * 0.1.7 起分组行带 `data-row-key`,优先按行键判定;此文案只作为 ≤0.1.6 的退化判据。+ */+export const UNGROUPED_NEW_SESSION_LABELS = ['在“未分组”中新建会话', 'New session in Ungrouped'] as const++/** 官方未分组分组行的行键:`workspace:` + 官方 `UNGROUPED_KEY`(后者为空串)。 */+export const UNGROUPED_ROW_KEY = 'workspace:'+/** dsh-im 客户端插件经 `ctx.provide` 发布的反射服务名(4.22.0 起)。 */export const DSH_IM_CLIENT_SERVICE = 'dshImClient'@@ -50,6 +65,7 @@ export const OBSTRUCTIONS_EFFECT = `${PLUGIN_ID}: settings obstructions`export const IM_PANEL_EFFECT = `${PLUGIN_ID}: im panel`export const HERO_WORKSPACE_EFFECT = `${PLUGIN_ID}: hero workspace picker`export const NEW_SESSION_EFFECT = `${PLUGIN_ID}: sidebar new session`+export const UNGROUPED_NEW_SESSION_EFFECT = `${PLUGIN_ID}: sidebar ungrouped new session`export const TURN_NAVIGATION_LABEL_ZH = '轮次导航'export const TURN_NAVIGATION_LABEL_EN = 'Turn navigation'diff --git a/packages/dsh-tauri-ui/src/client/index.ts b/packages/dsh-tauri-ui/src/client/index.tsindex 7ac5a5fd..27b59240 100644--- a/packages/dsh-tauri-ui/src/client/index.ts+++ b/packages/dsh-tauri-ui/src/client/index.ts@@ -1,12 +1,12 @@import type {} from '@deepseek-ai/dsh-client-ui-layout/client'import type { ClientContext } from 'dsh-tauri/client'import { PLUGIN_ID } from '../shared/constants'-import { HERO_WORKSPACE_EFFECT, IM_PANEL_EFFECT, LOCALE_EFFECT, NEW_SESSION_EFFECT, OBSTRUCTIONS_EFFECT, SEAT_EFFECT, SECTIONS_EFFECT, SETTINGS_EFFECT, STYLES_EFFECT } from './constants'+import { HERO_WORKSPACE_EFFECT, IM_PANEL_EFFECT, LOCALE_EFFECT, NEW_SESSION_EFFECT, OBSTRUCTIONS_EFFECT, SEAT_EFFECT, SECTIONS_EFFECT, SETTINGS_EFFECT, STYLES_EFFECT, UNGROUPED_NEW_SESSION_EFFECT } from './constants'import { locale } from './locales'import { composerResumeFeature } from './register/composer-resume'import { heroWorkspaceFeature } from './register/hero-workspace'import { registerImPanel } from './register/im-panel'-import { sidebarNewSessionFeature } from './register/new-session'+import { sidebarNewSessionFeature, ungroupedNewSessionFeature } from './register/new-session'import { registerSettingsObstructions } from './register/obstructions'import { registerShellSeat } from './register/seat'import { registerSettingsSections } from './register/sections'@@ -40,6 +40,7 @@ export function apply(ctx: ClientContext): void {ctx.effect(registerSettingsObstructions, OBSTRUCTIONS_EFFECT)ctx.effect(heroWorkspaceFeature, HERO_WORKSPACE_EFFECT)ctx.effect(sidebarNewSessionFeature, NEW_SESSION_EFFECT)+ ctx.effect(ungroupedNewSessionFeature, UNGROUPED_NEW_SESSION_EFFECT)ctx.effect(composerResumeFeature, COMPOSER_RESUME_EFFECT)ctx.effect(registerImPanel, IM_PANEL_EFFECT)}diff --git a/packages/dsh-tauri-ui/src/client/register/new-session.test.ts b/packages/dsh-tauri-ui/src/client/register/new-session.test.tsindex b39742ef..6fb6d577 100644--- a/packages/dsh-tauri-ui/src/client/register/new-session.test.ts+++ b/packages/dsh-tauri-ui/src/client/register/new-session.test.ts@@ -7,7 +7,7 @@*/import type { ClientContext } from 'dsh-tauri/client'import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'-import { sidebarNewSessionFeature } from './new-session'+import { sidebarNewSessionFeature, ungroupedNewSessionFeature } from './new-session'const mocks = vi.hoisted(() => ({startUngroupedSession: vi.fn(),@@ -64,7 +64,11 @@ interface ControllerStub {}class FakeElement {- closest: (selector: string) => FakeButton | null = () => null+ closest: (selector: string) => FakeElement | null = () => null++ getAttribute(_name: string): string | null {+ return null+ }}class FakeButton extends FakeElement {@@ -199,3 +203,104 @@ describe('sidebarNewSessionFeature', () => {dispose()})})++/**+ * 官方「未分组」分组行的「+」在未分组桶里是空实现(`group.workspaceId === undefined`),+ * 点击没有任何效果;这里锁住「与侧边栏『新建会话』一致」的接管行为与两代判据。+ */+describe('ungroupedNewSessionFeature', () => {+ /** 官方分组行:0.1.7 起带 `data-row-key`(未分组桶为 `workspace:`)。 */+ function rowWith(rowKey: string | null): FakeElement {+ const row = new FakeElement()+ row.getAttribute = name => (name === 'data-row-key' ? rowKey : null)+ return row+ }++ /** 分组行的「+」:最近的 `button[aria-label]` 是自己,最近的 `[data-row-key]` 是分组行。 */+ function plusIn(row: FakeElement | null, label: string | null): FakeButton {+ const button = new FakeButton(label)+ button.closest = (selector) => {+ if (selector === 'button[aria-label]')+ return button+ if (selector === '[data-row-key]')+ return row+ return null+ }+ return button+ }++ it('0.1.7:未分组分组行的「+」按行键命中并改走未分组新建', () => {+ const dispose = ungroupedNewSessionFeature.call(ctx)+ const controller = mocks.controller as ControllerStub++ const event = clickEvent(plusIn(rowWith('workspace:'), '在“未分组”中新建会话'))+ controller.click(event)++ expect(event.preventDefault, '官方空实现必须被拦下').toHaveBeenCalledTimes(1)+ expect(event.stopImmediatePropagation, '官方 onClick 挂在 React 根容器上,必须阻断传播').toHaveBeenCalledTimes(1)+ expect(mocks.startUngroupedSession).toHaveBeenCalledTimes(1)+ dispose()+ })++ it('0.1.7:真实工作区分组行的「+」不命中', () => {+ const dispose = ungroupedNewSessionFeature.call(ctx)+ const controller = mocks.controller as ControllerStub++ const event = clickEvent(plusIn(rowWith('workspace:ws-1'), '在“dsh-tauri-desktop”中新建会话'))+ controller.click(event)++ expect(event.preventDefault, '真实工作区的分组行行为必须保持不变').not.toHaveBeenCalled()+ expect(mocks.startUngroupedSession).not.toHaveBeenCalled()+ dispose()+ })++ it('≤0.1.6:没有 data-row-key 时退化按「未分组」文案命中', () => {+ const dispose = ungroupedNewSessionFeature.call(ctx)+ const controller = mocks.controller as ControllerStub++ controller.click(clickEvent(plusIn(null, '在“未分组”中新建会话')))+ expect(mocks.startUngroupedSession).toHaveBeenCalledTimes(1)++ controller.click(clickEvent(plusIn(null, 'New session in Ungrouped')))+ expect(mocks.startUngroupedSession).toHaveBeenCalledTimes(2)+ dispose()+ })++ it('≤0.1.6:真实工作区的「+」与侧边栏「新建会话」都不命中', () => {+ const dispose = ungroupedNewSessionFeature.call(ctx)+ const controller = mocks.controller as ControllerStub++ controller.click(clickEvent(plusIn(null, '在“dsh-tauri-desktop”中新建会话')))+ controller.click(clickEvent(plusIn(null, '新建会话')))++ expect(mocks.startUngroupedSession).not.toHaveBeenCalled()+ dispose()+ })++ it('缺 composer 补丁时放行官方分支,只告警一次', () => {+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})+ mocks.composerWorkspaceLess = false+ const dispose = ungroupedNewSessionFeature.call(ctx)+ const controller = mocks.controller as ControllerStub++ const first = clickEvent(plusIn(rowWith('workspace:'), '在“未分组”中新建会话'))+ controller.click(first)+ controller.click(clickEvent(plusIn(rowWith('workspace:'), '在“未分组”中新建会话')))++ expect(first.preventDefault, '能力缺席时不得拦官方点击').not.toHaveBeenCalled()+ expect(mocks.startUngroupedSession).not.toHaveBeenCalled()+ expect(warn, '告警只打一次,不刷屏').toHaveBeenCalledTimes(1)+ expect(warn).toHaveBeenCalledWith(expect.stringContaining('composer.workspace-less'))+ dispose()+ })++ it('dispose 后不再响应点击', () => {+ const dispose = ungroupedNewSessionFeature.call(ctx)+ const controller = mocks.controller as ControllerStub+ dispose()++ controller.click(clickEvent(plusIn(rowWith('workspace:'), '在“未分组”中新建会话')))++ expect(mocks.startUngroupedSession).not.toHaveBeenCalled()+ })+})diff --git a/packages/dsh-tauri-ui/src/client/register/new-session.ts b/packages/dsh-tauri-ui/src/client/register/new-session.tsindex 14d90fc4..295bac52 100644--- a/packages/dsh-tauri-ui/src/client/register/new-session.ts+++ b/packages/dsh-tauri-ui/src/client/register/new-session.ts@@ -2,7 +2,7 @@ import type { ClientContext } from 'dsh-tauri/client'import { defineRegister } from 'dsh-tauri/client'import { PLUGIN_ID } from '../../shared/constants'import { startUngroupedSession } from '../service/ungrouped-session'-import { newSessionButtonFrom } from './new-session.utils'+import { newSessionButtonFrom, ungroupedCreateButtonFrom } from './new-session.utils'/*** 官方侧边栏「新建会话」默认落到未分组:官方 onClick 挂在 React 根容器上,document 捕获阶段的@@ -34,3 +34,33 @@ export const sidebarNewSessionFeature = defineRegister<ClientContext>((controllestartUngroupedSession(ctx, adapter)}, { capture: true })})++/**+ * 官方「未分组」分组行的「+」在未分组桶里是空实现(`group.workspaceId === undefined`),+ * 点击没有任何效果。这里按与侧边栏「新建会话」完全相同的路径接管:切到会话并选中「未分组」。+ *+ * 能力探测同样在**点击时**做,缺补丁时放行官方分支(即空实现),只告警一次。+ */+export const ungroupedNewSessionFeature = defineRegister<ClientContext>((controller, ctx, adapter) => {+ if (typeof document === 'undefined')+ return++ let warned = false++ controller.listen('click', (event) => {+ if (ungroupedCreateButtonFrom(event.target) === null)+ return+ if (!adapter.has('composer.workspace-less')) {+ if (!warned) {+ warned = true+ console.warn(+ `[${PLUGIN_ID}] 「未分组」分组行新建会话不可用:缺少桌面壳 composer 补丁(composer.workspace-less),沿用官方行为。`,+ )+ }+ return+ }+ event.preventDefault()+ event.stopImmediatePropagation()+ startUngroupedSession(ctx, adapter)+ }, { capture: true })+})diff --git a/packages/dsh-tauri-ui/src/client/register/new-session.utils.test.ts b/packages/dsh-tauri-ui/src/client/register/new-session.utils.test.tsindex d2290185..e7825eea 100644--- a/packages/dsh-tauri-ui/src/client/register/new-session.utils.test.ts+++ b/packages/dsh-tauri-ui/src/client/register/new-session.utils.test.ts@@ -6,7 +6,7 @@* 文案逐字取自官方词典:sidebar `session.new.label`、workspace `actions.newSession.aria`。*/import { describe, expect, it } from 'vitest'-import { isNewSessionLabel } from './new-session.utils'+import { isNewSessionLabel, isUngroupedNewSessionLabel } from './new-session.utils'describe('isNewSessionLabel', () => {it('认官方侧边栏「新建会话」按钮的中英两条 aria-label', () => {@@ -30,3 +30,26 @@ describe('isNewSessionLabel', () => {expect(isNewSessionLabel('')).toBe(false)})})++/**+ * ≤0.1.6 的退化判据:那两代分组行没有 `data-row-key`,只能靠官方词典里的+ * 「未分组」新建会话文案识别(0.1.7 起按行键判定,见 `new-session.test.ts`)。+ */+describe('isUngroupedNewSessionLabel', () => {+ it('认官方「未分组」分组行「+」的中英两条 aria-label', () => {+ expect(isUngroupedNewSessionLabel('在“未分组”中新建会话'), '官方中文文案').toBe(true)+ expect(isUngroupedNewSessionLabel('New session in Ungrouped'), '官方英文文案').toBe(true)+ })++ it('不认真实工作区的带名字文案与侧边栏「新建会话」', () => {+ expect(isUngroupedNewSessionLabel('在“dsh-tauri-desktop”中新建会话')).toBe(false)+ expect(isUngroupedNewSessionLabel('New session in dsh-tauri-desktop')).toBe(false)+ expect(isUngroupedNewSessionLabel('新建会话')).toBe(false)+ expect(isUngroupedNewSessionLabel('New session')).toBe(false)+ })++ it('缺 aria-label 时不命中', () => {+ expect(isUngroupedNewSessionLabel(null)).toBe(false)+ expect(isUngroupedNewSessionLabel('')).toBe(false)+ })+})diff --git a/packages/dsh-tauri-ui/src/client/register/new-session.utils.ts b/packages/dsh-tauri-ui/src/client/register/new-session.utils.tsindex 6184b207..4d65c6e7 100644--- a/packages/dsh-tauri-ui/src/client/register/new-session.utils.ts+++ b/packages/dsh-tauri-ui/src/client/register/new-session.utils.ts@@ -1,4 +1,4 @@-import { NEW_SESSION_LABELS } from '../constants'+import { NEW_SESSION_LABELS, UNGROUPED_NEW_SESSION_LABELS, UNGROUPED_ROW_KEY } from '../constants'/** 官方侧边栏「新建会话」按钮的 aria-label 判据(品牌按钮与工具栏按钮共用同一条文案)。 */export function isNewSessionLabel(label: string | null): boolean {@@ -12,3 +12,29 @@ export function newSessionButtonFrom(target: unknown): Element | null {const button = target.closest('button[aria-label]')return button !== null && isNewSessionLabel(button.getAttribute('aria-label')) ? button : null}++/** 官方「未分组」分组行「+」的 aria-label 判据(仅 ≤0.1.6 需要,见 `ungroupedCreateButtonFrom`)。 */+export function isUngroupedNewSessionLabel(label: string | null): boolean {+ return label !== null && (UNGROUPED_NEW_SESSION_LABELS as readonly string[]).includes(label)+}++/**+ * 官方「未分组」分组行的「+」按钮。+ *+ * 官方 `onCreate` 在未分组桶(`group.workspaceId === undefined`)里是空实现,点击没有任何+ * 效果;这里把该按钮识别出来,交给与侧边栏「新建会话」相同的未分组开会话路径。+ *+ * 0.1.7 起分组行带 `data-row-key`(未分组桶的行键为 `workspace:`),按行键判定最稳且与语言+ * 无关;≤0.1.6 没有该属性,退化为官方词典里的「未分组」新建会话文案。+ */+export function ungroupedCreateButtonFrom(target: unknown): Element | null {+ if (!(target instanceof Element))+ return null+ const button = target.closest('button[aria-label]')+ if (button === null)+ return null+ const row = button.closest('[data-row-key]')+ if (row !== null)+ return row.getAttribute('data-row-key') === UNGROUPED_ROW_KEY ? button : null+ return isUngroupedNewSessionLabel(button.getAttribute('aria-label')) ? button : null+}diff --git a/packages/dsh-tauri-ui/src/client/styles/global.cssr.ts b/packages/dsh-tauri-ui/src/client/styles/global.cssr.tsindex fba229c7..df260730 100644--- a/packages/dsh-tauri-ui/src/client/styles/global.cssr.ts+++ b/packages/dsh-tauri-ui/src/client/styles/global.cssr.ts@@ -52,12 +52,19 @@ export default c([}),c('[class$="logoRow"]', {color: 'var(--dsw-alias-label-primary) !important',+ justifyContent: 'center !important',}, [- c('[class$="toggle"]', {+ c('[class$="toggle"], [class*="toggle "]', {justifyContent: 'center !important',}),- c('[class$="brand"]', {+ // 官方品牌按钮的类名是 `clsx(brand, wide)`,类属性以 `_wide` 结尾,+ // 仅靠 `[class$="brand"]` 匹配不到;两种形态都列上才能各代都隐藏。+ c('[class$="brand"], [class*="brand "]', {display: 'none !important',}),]),+ // 折叠轨道回到官方左对齐:上一条 `!important` 会盖掉官方 `.collapsed .logoRow`。+ c('[class*="collapsed"] [class$="logoRow"]', {+ justifyContent: 'flex-start !important',+ }),])