Skip to content

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

perf(ui): 聊天流节点启用原生屏外跳过渲染,长会话不再全量布局 (#952)

Mao Mr6f2301fc0120
diff --git a/packages/dsh-tauri-ui/THIRD_PARTY_NOTICES.md b/packages/dsh-tauri-ui/THIRD_PARTY_NOTICES.md
index 6708dcc1..bf81bd27 100644
--- a/packages/dsh-tauri-ui/THIRD_PARTY_NOTICES.md
+++ b/packages/dsh-tauri-ui/THIRD_PARTY_NOTICES.md
@@ -21,6 +21,13 @@ Derived (upstream → this package):
- Official settings launcher seat (`ui-settings-general` `SettingsRoot` rendering the account menu) → `src/client/constants/index.ts` (`SETTINGS_TRIGGER_PRIORITY`), `src/client/ui/settings-trigger.tsx`: seat takeover keeping a host for the official account UI, plus the official dictionary strings for the sidebar "new session" button and the ungrouped workspace-group `+` (`new-session.utils.ts`, official `UNGROUPED_KEY`).
- Official primitives variants `PermissionRow.selector`, `PermissionSelect`, `AgentPresetSeat` → `src/client/components/chip.tsx`: per-variant wrapping and the official `@container` query that `css-render` can only emit as a top-level raw rule.
+## hongweifei/dsh-chat-content-visibility-auto
+
+- Repository: <https://github.com/hongweifei/dsh-chat-content-visibility-auto>
+- Version: `1.0.0`
+- License: MIT — Copyright (c) 2026 dsh-chat-content-visibility-auto contributors
+- Not vendored, not installed: the external client plugin stays out of this repo's manifests. Its converged windowing rule — `content-visibility: auto` + `contain-intrinsic-size: auto 320px` on `[data-chat-flow] > [data-chat-anchor-key]` — is reimplemented on this repo's own `css-render` stack in `src/client/styles/global.cssr.ts`, keyed off the official chat DOM contract (`ChatView` column `[data-chat-flow]` → node rows `[data-chat-anchor-key]`).
+
## License
```text
diff --git a/packages/dsh-tauri-ui/src/client/styles/global.cssr.test.ts b/packages/dsh-tauri-ui/src/client/styles/global.cssr.test.ts
index 2f0bd627..516db6a3 100644
--- a/packages/dsh-tauri-ui/src/client/styles/global.cssr.test.ts
+++ b/packages/dsh-tauri-ui/src/client/styles/global.cssr.test.ts
@@ -92,3 +92,37 @@ describe('center column surface', () => {
expect(css).not.toContain('data-dsh-center-col')
})
})
+
+/**
+ * 聊天流屏外渲染契约。
+ *
+ * 官方 `ChatView` 把整条会话的节点全量挂在 `[data-chat-flow]` 列里,没有滚动虚拟化:
+ * 每个节点是列的直接子元素 `[data-chat-anchor-key]`(`flowItem`)。长会话因此把上千棵
+ * markdown 与工具卡片子树留在文档里,布局与绘制开销随会话长度线性增长。本仓不动 DOM
+ * 与产品逻辑,把浏览器原生的 `content-visibility: auto` 交给这些节点:屏外节点跳过
+ * 布局与绘制,滚回来仍按真实尺寸渲染;`contain-intrinsic-size` 的 `auto` 关键字让浏览器
+ * 记住上次渲染尺寸,只有首次滚过用估算值,避免把滚动位置顶偏。这里按生成 CSS 断言规则
+ * 只做「跳过渲染」,不得用 `hidden`(那会让屏外内容在浏览器查找与无障碍树里消失)。
+ */
+describe('chat flow off-screen rendering', () => {
+ const rules: Record<string, Record<string, string>> = {}
+ postcss.parse(globalStyle.render()).walkRules((rule) => {
+ if (rule.selector.includes('data-chat-flow')) {
+ rules[rule.selector] = {}
+ rule.walkDecls((decl) => {
+ rules[rule.selector][decl.prop] = decl.value
+ })
+ }
+ })
+
+ it('对聊天流锚点启用原生屏外跳过渲染并保留尺寸记忆', () => {
+ expect(rules['[data-chat-flow] > [data-chat-anchor-key]']).toEqual({
+ 'content-visibility': 'auto',
+ 'contain-intrinsic-size': 'auto 320px',
+ })
+ })
+
+ it('不把内容整块藏起来(保浏览器查找与无障碍树)', () => {
+ expect(globalStyle.render()).not.toMatch(/content-visibility:\s*hidden/)
+ })
+})
diff --git a/packages/dsh-tauri-ui/src/client/styles/global.cssr.ts b/packages/dsh-tauri-ui/src/client/styles/global.cssr.ts
index 7f81cc84..f9d2419b 100644
--- a/packages/dsh-tauri-ui/src/client/styles/global.cssr.ts
+++ b/packages/dsh-tauri-ui/src/client/styles/global.cssr.ts
@@ -151,6 +151,14 @@ export default c([
background: 'var(--dsw-alias-label-primary)',
}),
]),
+ // 官方 `ChatView` 把整条会话的节点全量挂进 `[data-chat-flow]` 列(无虚拟滚动),长会话的
+ // 布局与绘制开销随节点数线性增长。节点本身是列的直接子元素 `[data-chat-anchor-key]`,这里
+ // 交给浏览器原生的 `content-visibility: auto` 跳过屏外节点的布局与绘制;`contain-intrinsic-size`
+ // 的 `auto` 关键字让它记住上次渲染尺寸,避免估算值把滚动位置顶偏。
+ c('[data-chat-flow] > [data-chat-anchor-key]', {
+ contentVisibility: 'auto',
+ containIntrinsicSize: 'auto 320px',
+ }),
c('[class$="sidebarCol"]', {
borderRight: 'none !important',