Skip to content

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

fix(ui): align settings content width with conversation (#1096)

Hairy2f583ee2de28
diff --git a/packages/dsh-tauri-ui/src/client/styles/index.ts b/packages/dsh-tauri-ui/src/client/styles/index.ts
index c91b5f21..2fc3ca56 100644
--- a/packages/dsh-tauri-ui/src/client/styles/index.ts
+++ b/packages/dsh-tauri-ui/src/client/styles/index.ts
@@ -510,9 +510,6 @@ const TAILWINDCSS_GENERATED = `
.w-\\[min\\(760px\\,100\\%\\)\\]\\! {
width: min(760px, 100%) !important;
}
- .w-\\[min\\(calc\\(var\\(--dsh-composer-card-max-width\\)_\\+_2_\\*_var\\(--dsh-composer-side-clearance\\)\\)\\,100\\%\\)\\] {
- width: min(calc(var(--dsh-composer-card-max-width) + 2 * var(--dsh-composer-side-clearance)), 100%);
- }
.w-\\[var\\(--dsh-settings-rail-width\\)\\] {
width: var(--dsh-settings-rail-width);
}
@@ -1566,15 +1563,6 @@ const TAILWINDCSS_GENERATED = `
.\\[--detail-gutter\\:24px\\] {
--detail-gutter: 24px;
}
- .\\[--dsh-chat-content-width\\:748px\\] {
- --dsh-chat-content-width: 748px;
- }
- .\\[--dsh-composer-card-max-width\\:calc\\(var\\(--dsh-chat-content-width\\)_\\+_32px\\)\\] {
- --dsh-composer-card-max-width: calc(var(--dsh-chat-content-width) + 32px);
- }
- .\\[--dsh-composer-side-clearance\\:16px\\] {
- --dsh-composer-side-clearance: 16px;
- }
.\\[--dsh-scrollbar-thumb-border\\:2px\\] {
--dsh-scrollbar-thumb-border: 2px;
}
diff --git a/packages/dsh-tauri-ui/src/client/ui/settings-sidebar.test.tsx b/packages/dsh-tauri-ui/src/client/ui/settings-sidebar.test.tsx
new file mode 100644
index 00000000..44799881
--- /dev/null
+++ b/packages/dsh-tauri-ui/src/client/ui/settings-sidebar.test.tsx
@@ -0,0 +1,49 @@
+// @vitest-environment jsdom
+import { cleanup, render } from '@testing-library/react'
+import { afterEach, expect, it, vi } from 'vitest'
+import { SettingsSidebar } from './settings-sidebar'
+
+const observer = vi.hoisted(() => ({ resize: () => {} }))
+vi.mock('dsh-tauri/client', () => ({
+ clamp: (value: number, min: number, max: number) => Math.min(Math.max(value, min), max),
+ cn: (...values: unknown[]) => values.filter(Boolean).join(' '),
+ isEmpty: (values: unknown[]) => values.length === 0,
+ useEventListener: () => {},
+ useStore: (value: unknown) => value,
+ useResizeObserver: (_ref: unknown, callback: () => void) => { observer.resize = callback },
+}))
+vi.mock('../locales', () => ({ locale: { text: (key: string) => key, useLocale: () => 'en' } }))
+vi.mock('../store', () => ({ store: {
+ settings: { open: true, query: '', activeId: 'general' },
+ sections: { rows: [{ id: 'general', label: 'General' }] },
+} }))
+vi.mock('../components/official', () => ({ Input: 'input' }))
+vi.mock('@deepseek-ai/dsh-client-ui-primitives', () => ({ useModalLayer: undefined }))
+vi.mock('@deepseek-ai/dsh-client-ui-renderer', () => ({ SlotOutlet: () => <section>Settings</section> }))
+
+afterEach(() => {
+ cleanup()
+ vi.restoreAllMocks()
+ document.body.replaceChildren()
+})
+
+it('uses the conversation content width on open and resize, excluding settings padding', () => {
+ const dock = document.createElement('div')
+ dock.dataset.slot = 'conversation.input.dock'
+ dock.style.setProperty('--dsh-chat-content-width', '860px')
+ document.body.append(dock)
+ const view = render(<SettingsSidebar useSessions={selector => selector({} as never)} />)
+ const content = view.container.querySelector<HTMLElement>('[data-slot="settings.content"]')!
+ observer.resize()
+ expect(content.style.getPropertyValue('--dsh-chat-content-width')).toBe('860px')
+ const column = content.firstElementChild as HTMLElement
+ expect(column.style.maxWidth).toBe('calc(var(--dsh-chat-content-width, 748px) + 72px)')
+ expect(column.classList.contains('w-full')).toBe(true)
+ expect(column.classList.contains('px-[36px]')).toBe(true)
+ dock.style.setProperty('--dsh-chat-content-width', '700px')
+ observer.resize()
+ expect(content.style.getPropertyValue('--dsh-chat-content-width')).toBe('700px')
+ dock.remove()
+ observer.resize()
+ expect(content.style.getPropertyValue('--dsh-chat-content-width')).toBe('')
+})
diff --git a/packages/dsh-tauri-ui/src/client/ui/settings-sidebar.tsx b/packages/dsh-tauri-ui/src/client/ui/settings-sidebar.tsx
index 3e6d0c4b..4bedbec4 100644
--- a/packages/dsh-tauri-ui/src/client/ui/settings-sidebar.tsx
+++ b/packages/dsh-tauri-ui/src/client/ui/settings-sidebar.tsx
@@ -4,7 +4,7 @@ import type { IconComponent } from '../components/icon'
import type { SelectorHook } from '../types/selector'
import { useModalLayer } from '@deepseek-ai/dsh-client-ui-primitives'
import { SlotOutlet } from '@deepseek-ai/dsh-client-ui-renderer'
-import { clamp, cn, isEmpty, useEventListener, useStore } from 'dsh-tauri/client'
+import { clamp, cn, isEmpty, useEventListener, useResizeObserver, useStore } from 'dsh-tauri/client'
import { useEffect, useRef, useState } from 'react'
import { Icon } from '../components/icon'
import { ArrowLeft, Cubes3Overlap, Database, Gear, Ghost, Globe, LayoutSplitSideContentRight, PersonPencil, Puzzle, Smartphone, Tray } from '../components/icons'
@@ -43,6 +43,12 @@ export function SettingsSidebar(_props: SettingsSidebarProps): ReactElement | nu
locale.useLocale()
const searchRef = useRef<HTMLInputElement>(null)
const dialogRef = useRef<HTMLDivElement>(null)
+ const contentRef = useRef<HTMLDivElement>(null)
+ useResizeObserver(contentRef, () => {
+ const conversation = document.querySelector('[data-slot="conversation.input.dock"]')
+ const width = conversation ? getComputedStyle(conversation).getPropertyValue('--dsh-chat-content-width') : ''
+ contentRef.current?.style.setProperty('--dsh-chat-content-width', width)
+ })
// 官方 `Input` 的 props 类型没声明 ref(实现里 `...rest` 会落到 <input>),官方类型补全后可直接写 ref。
const searchInputRefProps = { ref: searchRef }
const [dragging, setDragging] = useState(false)
@@ -112,7 +118,7 @@ export function SettingsSidebar(_props: SettingsSidebarProps): ReactElement | nu
<>
<div
ref={dialogRef}
- className="fixed inset-0 z-[1000] flex bg-[var(--dsw-specific-sidebar-fill)] text-primary [--dsh-chat-content-width:748px] [--dsh-composer-card-max-width:calc(var(--dsh-chat-content-width)_+_32px)] [--dsh-composer-side-clearance:16px]"
+ className="fixed inset-0 z-[1000] flex bg-[var(--dsw-specific-sidebar-fill)] text-primary"
data-slot-sidebar="dsh-tauri-ui"
data-shortcut-modal="settings"
role="dialog"
@@ -168,10 +174,11 @@ export function SettingsSidebar(_props: SettingsSidebarProps): ReactElement | nu
onPointerDown={onHandlePointerDown}
/>
<div
+ ref={contentRef}
data-slot="settings.content"
className="flex-1 min-w-0 h-full box-border overflow-y-auto flex bg-[var(--dsw-alias-bg-base)] rounded-tl-[16px] [corner-shape:round]"
>
- <div className="w-[min(calc(var(--dsh-composer-card-max-width)_+_2_*_var(--dsh-composer-side-clearance)),100%)] mx-auto box-border px-[36px] py-[28px]">
+ <div className="w-full mx-auto box-border px-[36px] py-[28px]" style={{ maxWidth: 'calc(var(--dsh-chat-content-width, 748px) + 72px)' }}>
{activeId !== undefined && (
<SlotOutlet
slotKey={SETTINGS_SECTION_SLOT}