DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
fix(appearance): scope boot transparency and restore composer backing (#959)
SkanderBot08e30b5c3f5c
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex e18dd044..7738a348 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -143,12 +143,12 @@ jobs:- name: Install current dsh CLI (isolated)run: npm install --prefix "$RUNNER_TEMP/dsh-cli-current" --no-audit --no-fund @deepseek-ai/[email protected]- - name: Official plugins and mobile settings composition (current core)+ - name: Official plugins, appearance and mobile settings (current core)env:DSH_E2E_DSH_BIN: ${{ runner.temp }}/dsh-cli-current/node_modules/@deepseek-ai/dsh/lib/bin.jsrun: |for seed in 101 102 103 104 105; do- node node_modules/vitest/vitest.mjs run --project plugin --sequence.shuffle --sequence.seed="$seed" test/e2e/plugins/dsh-tauri-extension-panel.e2e.ts test/e2e/plugins/dsh-tauri-mobile-settings.e2e.ts || exit $?+ node node_modules/vitest/vitest.mjs run --project plugin --sequence.shuffle --sequence.seed="$seed" test/e2e/plugins/dsh-tauri-extension-panel.e2e.ts test/e2e/plugins/dsh-tauri-mobile-settings.e2e.ts test/e2e/plugins/dsh-tauri-appearance.e2e.ts test/e2e/plugins/dsh-tauri-appearance-boot.e2e.ts || exit $?done# 桌面端 L3 E2E(vitest + WebdriverIO):diff --git a/packages/dsh-tauri/src/client/register/appearance.test.ts b/packages/dsh-tauri/src/client/register/appearance.test.tsindex 902cf6e6..1a1e8273 100644--- a/packages/dsh-tauri/src/client/register/appearance.test.ts+++ b/packages/dsh-tauri/src/client/register/appearance.test.ts@@ -130,6 +130,16 @@ describe('desktop appearance bridge', () => {expect(theme.overrideTokens).not.toHaveBeenCalled()})+ it('keeps the pinned composer backing opaque in full-window transparency', () => {+ const { send, setScheme } = setup()+ send({ palette: 'nord', transparency: true, opacity: 70, sidebarOnly: false })+ expect(document.querySelector('style')!.textContent).toContain('body [data-composer-seat]{--dsw-alias-bg-base:#2e3440}')+ setScheme('light')+ expect(document.querySelector('style')!.textContent).toContain('body [data-composer-seat]{--dsw-alias-bg-base:#eceff4}')+ send({})+ expect(document.querySelector('style')!.textContent).toBe('')+ })+it('hides the collapsed sidebar while retaining the live right-panel width and restores layout on reset', async () => {const { send, frame, ctx } = setup()send({ terminal: true })diff --git a/packages/dsh-tauri/src/client/register/appearance.ts b/packages/dsh-tauri/src/client/register/appearance.tsindex f44c0f2c..0b16b4f9 100644--- a/packages/dsh-tauri/src/client/register/appearance.ts+++ b/packages/dsh-tauri/src/client/register/appearance.ts@@ -36,8 +36,9 @@ export const registerAppearance = defineRegister<ClientContext>((controller, ctx? `body :has(>[data-slot="main"]),body [data-rightbar-col]{--dsw-alias-bg-base:${canvas};background:${canvas}!important} `+ `[data-slot="settings.content"]{--dsw-alias-bg-base:${canvas};background:${canvas}!important}`: '',+ translucent ? `body [data-composer-seat]{--dsw-alias-bg-base:${canvas}}` : '',current.terminal ? 'body [data-sidebar-collapsed]:has(>[data-shell-overlay]){grid-template-columns:var(--dsh-appearance-columns)!important}body [data-sidebar-collapsed] [data-slot="sidebar"]{visibility:hidden}' : '',- appearanceBootCss(current, true),+ appearanceBootCss(current),].filter(Boolean).join('\n')}diff --git a/packages/dsh-tauri/src/shared/appearance.test.ts b/packages/dsh-tauri/src/shared/appearance.test.tsindex 91b82b40..23356559 100644--- a/packages/dsh-tauri/src/shared/appearance.test.ts+++ b/packages/dsh-tauri/src/shared/appearance.test.ts@@ -39,7 +39,7 @@ describe('appearance preferences', () => {it('projects the boot page onto the window behind it without doubling the alpha', () => {const css = appearanceBootCss(normalizeAppearance({ palette: 'nord', transparency: true, opacity: 70 }))- expect(css).toContain('html,body,#root{background:transparent!important}')+ expect(css).toContain('html:has(>body>#root>[data-dsh-boot]),body:has(>#root>[data-dsh-boot]),#root:has(>[data-dsh-boot]){background:transparent!important}')expect(css).toContain('body[data-ds-dark-theme] > #root > [data-dsh-boot]{background:color-mix(in srgb,#2e3440 70%,transparent)!important}')expect(css).toContain('body:not([data-ds-dark-theme]) > #root > [data-dsh-boot]{background:color-mix(in srgb,#eceff4 70%,transparent)!important}')expect(css).not.toContain('data-dsh-boot]{background:#2e3440')diff --git a/packages/dsh-tauri/src/shared/appearance.ts b/packages/dsh-tauri/src/shared/appearance.tsindex edb96b9d..43b0f239 100644--- a/packages/dsh-tauri/src/shared/appearance.ts+++ b/packages/dsh-tauri/src/shared/appearance.ts@@ -39,33 +39,16 @@ export function appearanceStartupFill(appearance: Appearance, canvas: string): sreturn appearanceSidebarFill(canvas, canvas, appearanceTranslucent(appearance), appearance.opacity)}-/**- * 官方 web shell boot 页(`[data-dsh-boot]`)的透明投影。- *- * 该页由内核在**插件加载之前**绘出,此刻外观插件还没激活,所以只能用与宿主同源的- * CSS 表达:`html`/`body`/`#root` 全透明,由 boot 节点自身承载与 navbar 一致的 alpha。- * 只绘制一层 alpha——boot 节点铺底后 `body` 再叠加会得到 0.7×0.7≈0.91 的错误浓度。- *- * 背景必须落在与 boot 页同优先级的规则上:官方 `.boot` 的背景表达式是- * `var(--dsw-alias-bg-base, var(--dsh-boot-bg, Canvas))`,只要 theme 的- * `--dsw-alias-bg-base` 存在,仅设 `--dsh-boot-bg` 就会被它压掉。选择器保持结构性- * 且 boot-only,boot 一被 React 交接替换,整套规则自动失效(不污染正常页面,也不需要- * 给 `[data-dsh-boot]` 注入 inline style,避免 BootHandoff hydration 额外属性告警)。- *- * `bodyOnly` 供「自己已经画了 body alpha」的调用方(外观插件)使用:此时只取 boot- * 节点本体的填充规则,避免与它后写的 `body{background:…}` 争同一层 alpha。- */-export function appearanceBootCss(appearance: Appearance, bodyOnly = false): string {+export function appearanceBootCss(appearance: Appearance): string {if (!appearanceTranslucent(appearance))return ''const blocks = (['dark', 'light'] as const).map((scheme) => {const { canvas } = appearanceColors(appearance, scheme)const selector = scheme === 'dark' ? 'body[data-ds-dark-theme]' : 'body:not([data-ds-dark-theme])'- const fill = appearanceStartupFill(appearance, canvas)- return `html:has(${selector} > #root > [data-dsh-boot]),${selector} > #root > [data-dsh-boot]{background:${fill}!important}`+ return `${selector} > #root > [data-dsh-boot]{background:${appearanceStartupFill(appearance, canvas)}!important}`})return [- ...bodyOnly ? [] : ['html,body,#root{background:transparent!important}'],+ 'html:has(>body>#root>[data-dsh-boot]),body:has(>#root>[data-dsh-boot]),#root:has(>[data-dsh-boot]){background:transparent!important}',...blocks,].join('\n')}diff --git a/test/e2e/plugins/dsh-tauri-appearance-boot.e2e.ts b/test/e2e/plugins/dsh-tauri-appearance-boot.e2e.tsnew file mode 100644index 00000000..adf1ef18--- /dev/null+++ b/test/e2e/plugins/dsh-tauri-appearance-boot.e2e.ts@@ -0,0 +1,47 @@+import type { Browser } from 'playwright'+import { afterAll, beforeAll, describe, expect, it } from 'vitest'+import { appearanceBootCss, normalizeAppearance } from '../../../packages/dsh-tauri/src/shared/appearance'+import { launchDshBrowser } from '../support/browser'++let browser: Browser+beforeAll(async () => {+ browser = await launchDshBrowser()+})+afterAll(async () => {+ await browser?.close()+})++describe('appearance boot stylesheet handoff', () => {+ it.each(['dark', 'light'] as const)('paints one translucent layer during %s boot and releases the running page', async (scheme) => {+ const page = await browser.newPage()+ try {+ await page.setContent(`<html><body ${scheme === 'dark' ? 'data-ds-dark-theme' : ''}><div id="root"><div data-dsh-boot>Loading</div></div></body></html>`)+ await page.addStyleTag({ content: 'body{background:rgb(20,30,40)!important}#root{background:rgb(40,50,60)}' })+ await page.addStyleTag({ content: appearanceBootCss(normalizeAppearance({ palette: 'nord', transparency: true, opacity: 70 })) })+ const layers = await page.locator('html,body,#root,[data-dsh-boot]').evaluateAll(elements => elements.map(el => getComputedStyle(el).backgroundColor))+ expect(layers.slice(0, 3), '启动背景不能叠加多层透明色').toEqual(['rgba(0, 0, 0, 0)', 'rgba(0, 0, 0, 0)', 'rgba(0, 0, 0, 0)'])+ expect(layers[3], '启动节点保留设置的透明度').toMatch(/(?:0\.7\)|\/ 0\.7\))/)+ await page.locator('#root').evaluate(el => el.replaceChildren(document.createElement('main')))+ expect(await page.locator('body').evaluate(el => getComputedStyle(el).backgroundColor), '启动样式不能覆盖运行页背景').toBe('rgb(20, 30, 40)')+ expect(await page.locator('#root').evaluate(el => getComputedStyle(el).backgroundColor), '启动样式不能覆盖运行页根节点').toBe('rgb(40, 50, 60)')+ }+ finally {+ await page.close()+ }+ })++ it('keeps one boot fill when the appearance plugin also paints the body', async () => {+ const page = await browser.newPage()+ try {+ await page.setContent('<body><div id="root"><div data-dsh-boot>Loading</div></div></body>')+ const appearance = normalizeAppearance({ palette: 'nord', transparency: true, opacity: 70 })+ await page.addStyleTag({ content: appearanceBootCss(appearance) })+ await page.addStyleTag({ content: `html{background:transparent!important}body{background:rgba(46,52,64,.7)!important}${appearanceBootCss(appearance)}` })+ expect(await page.locator('[data-dsh-boot]').evaluate(el => getComputedStyle(el).backgroundColor), '插件接管后启动节点仍只绘制一层透明色').toMatch(/(?:0\.7\)|\/ 0\.7\))/)+ expect(await page.locator('body').evaluate(el => getComputedStyle(el).backgroundColor)).toBe('rgba(0, 0, 0, 0)')+ }+ finally {+ await page.close()+ }+ })+})diff --git a/test/e2e/plugins/dsh-tauri-appearance.e2e.ts b/test/e2e/plugins/dsh-tauri-appearance.e2e.tsindex a6136105..58737460 100644--- a/test/e2e/plugins/dsh-tauri-appearance.e2e.ts+++ b/test/e2e/plugins/dsh-tauri-appearance.e2e.ts@@ -89,4 +89,18 @@ describe('built-in desktop appearance', () => {await app.close()}})++ it('keeps the composer backing opaque when the conversation canvas is translucent', async () => {+ const app = await newDshPage(browser, { ready: 'style[id="dsh-tauri:appearance"]' })+ try {+ await app.page.evaluate(() => document.querySelector('iframe')!.contentWindow!.postMessage({ type: 'dsh://appearance', appearance: { palette: 'nord', transparency: true, opacity: 70, sidebarOnly: false } }, location.origin))+ const composer = app.frame.locator('[data-composer-seat]').first()+ await expect.poll(() => composer.evaluate(el => getComputedStyle(el).getPropertyValue('--dsw-alias-bg-base')), { message: '固定输入区的渐变底色不能透出后方滚动的文字' }).toMatch(/^#(?:2e3440|eceff4)$/)+ expect(await app.frame.locator('body').evaluate(el => getComputedStyle(el).getPropertyValue('--dsw-alias-bg-base')), '会话画布仍保持透明').toBe('transparent')+ expect(app.errors).toEqual([])+ }+ finally {+ await app.close()+ }+ })})