DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
import postcss from 'postcss'
import { describe, expect, it, vi } from 'vitest'
import { cssr } from '../../../../dsh-tauri-ui/src/client/utils/cssr'
import { MOBILE_MEDIA_QUERIES } from '../../../../dsh-tauri/src/client/utils/device'
import mobileStyle from './mobile.cssr'
vi.mock('dsh-tauri/client', () => ({ MOBILE_MEDIA_QUERIES }))
vi.mock('dsh-tauri-ui/client', () => ({ cssr }))
const MOBILE_MEDIA = MOBILE_MEDIA_QUERIES.join(' and ')
describe('mobile conversation layout', () => {
const root = postcss.parse(mobileStyle.render())
it('keeps the existing mobile layout overrides scoped to narrow touch devices', () => {
const media = root.nodes.find(node => node.type === 'atrule' && node.name === 'media' && node.params === MOBILE_MEDIA)
expect(media?.type).toBe('atrule')
if (media?.type !== 'atrule')
throw new Error('Missing mobile media query')
expect(media.params).toBe(MOBILE_MEDIA)
const css = media.toString()
for (const selector of [
'[data-dsh-mobile-preferences]',
'[data-slot="conversation.composer.bar"] [class$="_dock"]',
'[class$="_composerStack"] > [data-slot="conversation.input.dock"]',
'[class$="_turnErrorCode"]',
'[data-slot="conversation.header"] [class$="_header"]',
'[data-slot="main"] header[class*="_pageHead"]',
'[data-slot="conversation.view"] [class$="_scroll"]',
'[class*="_userStack"]',
'[data-slot="main"] [data-conversation-scroll]',
]) {
expect(css).toContain(selector)
}
})
it('keeps the extension panel’s embedded official page head out of the main-slot clearance', () => {
const matches: Array<{ selector: string, paddingTop: string }> = []
root.walkRules(/header\[class\*="_pageHead"\]/, (rule) => {
let paddingTop = ''
rule.walkDecls('padding-top', (decl) => {
paddingTop = `${decl.value}${decl.important ? ' !important' : ''}`
})
matches.push({ selector: rule.selector, paddingTop })
})
expect(matches).toEqual([{
selector: '[data-slot="main"] header[class*="_pageHead"]:not([data-dsh-extension-plugins] *)',
paddingTop: '24px !important',
}])
})
it('positions the drawer without relying on the upstream collapsed marker', () => {
const css = root.toString()
for (const selector of [
'html[data-dsh-mobile-sidebar] [data-slot="root"] > [class$="_frame"]',
'html[data-dsh-mobile-sidebar] [class$="_sidebarCol"]',
'html[data-dsh-mobile-sidebar] body [data-slot="sidebar"]',
'html[data-dsh-mobile-sidebar] [class$="_centerCol"]',
'html[data-dsh-mobile-sidebar-open] [data-dsh-mobile-sidebar-shade]',
'[data-dsh-mobile-topbar]',
]) {
expect(css).toContain(selector)
}
expect(css).toContain('grid-template-columns: minmax(0, 1fr) !important')
expect(css).not.toContain('[data-sidebar-collapsed]')
})
const declarations = (selector: string): Record<string, string> => {
const values: Record<string, string> = {}
root.walkRules(selector, (rule) => {
rule.walkDecls((decl) => {
values[decl.prop] = `${decl.value}${decl.important ? ' !important' : ''}`
})
})
return values
}
it('prevents document scrolling only while the touch layout owns the mobile sidebar', () => {
const selector = 'html[data-dsh-mobile-sidebar], html[data-dsh-mobile-sidebar] body'
expect(declarations(selector)).toMatchObject({ overflow: 'hidden' })
const rules: unknown[] = []
root.walkRules(selector, (rule) => {
rules.push(rule)
expect(rule.parent?.type).toBe('atrule')
if (rule.parent?.type === 'atrule')
expect(rule.parent.params).toBe(MOBILE_MEDIA)
})
expect(rules).toHaveLength(1)
})
it('keeps the sidebar stationary behind a raised rounded main panel without a gray shade', () => {
expect(declarations('html[data-dsh-mobile-sidebar] [class$="_sidebarCol"]')).toMatchObject({
'z-index': '0',
'transform': 'none',
})
expect(declarations('html[data-dsh-mobile-sidebar] [class$="_centerCol"]')).toMatchObject({
'position': 'absolute',
'inset': '0',
'z-index': '1',
'transform': 'translate3d(0, 0, 0)',
'border-radius': '0',
'corner-shape': 'round',
'background-color': 'Canvas',
'background-image': 'linear-gradient(var(--dsw-alias-bg-base, Canvas), var(--dsw-alias-bg-base, Canvas))',
'box-shadow': 'none',
})
expect(declarations('html[data-dsh-mobile-sidebar] body [data-slot="sidebar"]')).toMatchObject({
// 终端模式外观会在折叠标记下隐藏侧栏,抽屉接管时用更高特异度还原可见性。
visibility: 'visible',
})
expect(declarations('html[data-dsh-mobile-sidebar-open] [class$="_centerCol"]')).toMatchObject({
'transform': 'translate3d(var(--dsh-mobile-sidebar-width), 0, 0)',
'border-radius': '24px 0 0 24px',
'box-shadow': 'var(--dsw-shadow-lv3)',
})
expect(declarations('[data-dsh-mobile-sidebar-shade]').background).toBe('transparent')
expect(declarations('html[data-dsh-mobile-sidebar] [data-side="sidebar"]').display).toBe('none !important')
expect(declarations('[data-dsh-mobile-topbar]')).toMatchObject({
position: 'sticky',
top: '0',
})
})
it('hides the official sidebar toggle only while the drawer owns the sidebar on touch screens', () => {
const selector = 'html[data-dsh-mobile-sidebar] [class$="_logoRow"] :is([class$="_toggle"], [class*="_toggle "])'
expect(declarations(selector)).toEqual({ display: 'none !important' })
const rules: unknown[] = []
root.walkRules(selector, (rule) => {
rules.push(rule)
expect(rule.parent?.type).toBe('atrule')
if (rule.parent?.type === 'atrule')
expect(rule.parent.params).toBe(MOBILE_MEDIA)
})
expect(rules).toHaveLength(1)
})
it('keeps the navbar controls as naked icons without button backgrounds or shadows', () => {
for (const selector of ['[data-dsh-mobile-sidebar-toggle]', '[data-dsh-mobile-new-session]']) {
expect(declarations(selector)).toMatchObject({
'padding': '0',
'border': '0',
'background': 'transparent',
'box-shadow': 'none',
})
}
})
it('removes tap focus boxes while keeping a visible keyboard focus ring', () => {
for (const selector of ['[data-dsh-mobile-sidebar-toggle]', '[data-dsh-mobile-new-session]']) {
expect(declarations(selector)).toMatchObject({
'outline': 'none',
'-webkit-tap-highlight-color': 'transparent',
})
}
expect(declarations('[data-dsh-mobile-sidebar-toggle]:focus-visible, [data-dsh-mobile-new-session]:focus-visible')).toMatchObject({
'outline': 'var(--dsw-focus-ring-width, 2px) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary))',
'outline-offset': '4px',
})
})
it('removes pointer focus boxes from mobile bottom buttons without hiding keyboard focus', () => {
expect(declarations(':is([data-dsh-mobile-preferences], [data-shell-bottom]) button')).toMatchObject({
'-webkit-tap-highlight-color': 'transparent',
})
expect(declarations(':is([data-dsh-mobile-preferences], [data-shell-bottom]) button:focus:not(:focus-visible)')).toMatchObject({
'outline': 'none',
'box-shadow': 'none',
})
expect(declarations(':is([data-dsh-mobile-preferences], [data-shell-bottom]) button:focus-visible')).toMatchObject({
'outline': 'var(--dsw-focus-ring-width, 2px) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary))',
'outline-offset': '2px',
})
})
it('limits transition suppression and offsets to active drags so clicks and releases still animate', () => {
for (const selector of ['html[data-dsh-mobile-sidebar-dragging] [class$="_centerCol"]', 'html[data-dsh-mobile-sidebar-dragging] [data-dsh-mobile-sidebar-shade]']) {
expect(declarations(selector)).toMatchObject({
transform: 'translate3d(var(--dsh-mobile-sidebar-offset), 0, 0)',
transition: 'none',
})
}
expect(declarations('html[data-dsh-mobile-sidebar] [class$="_centerCol"]').transform).toBe('translate3d(0, 0, 0)')
expect(declarations('html[data-dsh-mobile-sidebar-open] [class$="_centerCol"]').transform).toBe('translate3d(var(--dsh-mobile-sidebar-width), 0, 0)')
expect(declarations('html[data-dsh-mobile-sidebar] [class$="_centerCol"]').transition).toContain('transform 240ms cubic-bezier(.2, .8, .2, 1)')
expect(declarations('[data-dsh-mobile-sidebar-shade]').transition).toContain('transform 240ms cubic-bezier(.2, .8, .2, 1)')
const reducedMotion = root.nodes[0]
expect(reducedMotion?.type).toBe('atrule')
if (reducedMotion?.type !== 'atrule')
throw new Error('Missing mobile media query')
const rules = reducedMotion.nodes?.filter(node => node.type === 'atrule' && node.name === 'media' && node.params === '(prefers-reduced-motion: reduce)')
expect(rules).toHaveLength(1)
expect(rules?.[0]?.toString()).toContain('transition: none !important')
})
it('uses native safe-area ownership for the topbar and shade with browser inset fallbacks', () => {
expect(declarations('[data-dsh-mobile-topbar]')).toMatchObject({
height: 'calc(52px + var(--dsh-mobile-safe-area-inset-top, env(safe-area-inset-top, 0px)))',
padding: 'calc(14px + var(--dsh-mobile-safe-area-inset-top, env(safe-area-inset-top, 0px))) 16px 14px',
})
expect(declarations('[data-dsh-mobile-sidebar-shade]').inset).toBe('calc(52px + var(--dsh-mobile-safe-area-inset-top, env(safe-area-inset-top, 0px))) 0 0')
})
it('renders the mobile sidebar icon at 20px inside the touch media query', () => {
expect(declarations('[data-dsh-mobile-sidebar-toggle]')).toMatchObject({ width: '20px', height: '20px' })
const rules: unknown[] = []
root.walkRules('[data-dsh-mobile-sidebar-toggle]', (rule) => {
rules.push(rule)
expect(rule.parent?.type).toBe('atrule')
if (rule.parent?.type === 'atrule')
expect(rule.parent.params).toBe(MOBILE_MEDIA)
})
expect(rules).toHaveLength(1)
})
it('keeps the new-session icon at 24px', () => {
expect(declarations('[data-dsh-mobile-new-session]')).toMatchObject({ width: '24px', height: '24px' })
const rules: unknown[] = []
root.walkRules('[data-dsh-mobile-new-session]', (rule) => {
rules.push(rule)
expect(rule.parent?.type).toBe('atrule')
if (rule.parent?.type === 'atrule')
expect(rule.parent.params).toBe(MOBILE_MEDIA)
})
expect(rules).toHaveLength(1)
})
it('hides the foreign blank-session dock fallback that lands on the topbar toggle', () => {
expect(declarations('[data-dsh-dock-fallback]')).toMatchObject({ display: 'none !important' })
const rules: unknown[] = []
root.walkRules('[data-dsh-dock-fallback]', (rule) => {
rules.push(rule)
expect(rule.parent?.type).toBe('atrule')
if (rule.parent?.type === 'atrule')
expect(rule.parent.params).toBe(MOBILE_MEDIA)
})
expect(rules).toHaveLength(1)
})
it('hides the tool-row inspect pill whose trajectory view has no way back on phones', () => {
expect(declarations('[class$="_inspectButton"]')).toEqual({ display: 'none !important' })
const rules: unknown[] = []
root.walkRules('[class$="_inspectButton"]', (rule) => {
rules.push(rule)
expect(rule.parent?.type).toBe('atrule')
if (rule.parent?.type === 'atrule')
expect(rule.parent.params).toBe(MOBILE_MEDIA)
})
expect(rules).toHaveLength(1)
})
it('overrides conversation scroll bottom padding to zero inside the mobile media query', () => {
const declarations: unknown[] = []
root.walkRules('[data-slot="main"] [data-conversation-scroll]', (rule) => {
const parent = rule.parent
expect(parent?.type).toBe('atrule')
if (parent?.type === 'atrule')
expect(parent.params).toBe(MOBILE_MEDIA)
rule.walkDecls((decl) => {
declarations.push([decl.prop, decl.value, decl.important])
})
})
expect(declarations).toEqual([['padding-bottom', '0', true]])
})
it('pins the page to the keyboard-free height reported by the shell, outside the mobile layout', () => {
const values: unknown[] = []
root.walkRules(':root', (rule) => {
expect(rule.parent?.type).toBe('root')
rule.walkDecls((decl) => {
values.push([decl.prop, decl.value, decl.important])
})
})
expect(values).toEqual([['height', 'var(--dsh-mobile-viewport-height, 100%)', undefined]])
})
})