Skip to content

perf(web-ui): blur the transcript only near the viewport in wallpaper mode - #1109

Merged
iruriQ merged 1 commit into
mainfrom
perf/wallpaper-blur-near-viewport
Nov 24, 2026
Merged

iruriQ merged 1 commit into
mainfrom
perf/wallpaper-blur-near-viewport

Conversation

@BytePioneer-AI

Copy link
Copy Markdown
Owner

Summary

  • With a wallpaper set, every message bubble carries backdrop-filter. WebKit keeps the backing stores of backdrop-filter layers that were composited during fast scrolling or streaming, so the page process's graphics memory grows with the rows scrolled past instead of with what is on screen.
  • Each conversation scrollport now shares one IntersectionObserver (rootMargin: "100% 0px"). It marks top-level transcript rows within one scrollport height of the visible area with data-chat-near-viewport. The blur rules for bubbles, expanded reasoning headers and the pinned compaction toggle drop the filter on unmarked rows, which are at least one screen away from view.
  • Rows mount marked, so a row that appears in view is blurred on its first paint, and the observer's first callback clears the mark on rows that are far away. A transcript outside a shared conversation scrollport keeps every row marked.
  • Rows inside a process group follow their group and carry no mark of their own, because the group's capped inner scroller would clip their observation. In a first version that observed every Seat, scrolling inside a group showed one frame without blur.
  • The new CSS rules are appended overrides; the original blur rules are unchanged. Pending-send echo bubbles and chat views outside the shared scrollport keep their blur.
  • docs/product/standalone-web.md describes the rule.

Measurements

Real page, on an isolated instance, with one native Codex Thread: 1650 Seats, 619 top-level rows, 86 user bubbles, about 50,000 px tall. Each reading comes from a fresh WebKit process: wallpaper on, full history loaded, then one fast pass (30 ms per screen, bottom to top to bottom), parked mid-page, 10 s settle. "Runs" counts such fresh runs. footprint figures in MB.

State Runs graphics total
History loaded, at bottom (before) 3 155–157 685–725
After fast scroll (before) 3 418–424 1013–1019
After fast scroll (this PR) 3 167 / 261 / 259 819 / 807 / 851
After fast scroll (before, with all blur removed by injected CSS) 1 255 825
  • Graphics now matches the no-blur control. The blur-caused part, about 160 MB for this Thread, is gone.
  • The remaining roughly 100 MB over the at-bottom state is also present in the no-blur control, so it is not caused by blur and this PR does not address it.
  • total is noisy: WebKit malloc briefly spikes above 1.3 GB after scrolling and falls back within 30 s, before and after. Graphics is the reliable column.
  • Scroll frame intervals are unchanged: p50 is 17 ms at a quarter screen per frame and 45–48 ms at a full screen per frame, before and after.
  • Streaming cannot be exercised on the real page without sending a message. On a synthetic page that appends an entry every 30 ms up to 1000 entries, with the product's mount-marked behavior, graphics ends at 117 MB, against 609 MB with the blur on every row.

Known limits

  • On a far jump (turn navigation, "back to bottom", a programmatic scroll position change), the target rows are unmarked on the frame where the scroll position changes and are marked on the next frame, so the target bubbles may paint one frame without blur. Continuous scrolling, including a full screen per frame, never showed an unblurred bubble in view. Removing the jump case would mean marking rows synchronously in the scroll logic, which this PR does not touch.
  • Expanded reasoning headers were checked on the real page. The compaction summary toggle was not: no Thread available had one.

Related issues

N/A

UI Demo

No visual changes: bubbles, reasoning headers and the compaction toggle in or within one screen of the viewport keep exactly the same blur, and only rows at least one screen out of view lose it.

  • The compositor output was not compared. The machine's screen was locked, window screenshots came back blank, and WKWebView's own snapshot does not render backdrop-filter; blur on and off snapshots were byte-identical.
  • Instead, computed styles of the blurred elements at four fixed positions (a mid-page bubble, a very early bubble, a code block, the last bubble) were compared before and after, and were identical.

Test plan

  • Isolated Web instance with a throwaway data directory and a minimal WKWebView shell, using the measurement method above.
  • prettier --check on the changed files and the doc: passed.
  • The Web UI build succeeded with the change, and the new rules are present in the output.
  • Not run: no Vitest configuration includes ui-chat, and the logic depends on the DOM and IntersectionObserver, so no test was added. The root tsc -b and ESLint do not cover apps/web-ui.
  • Measurements ran before this branch was rebased onto current main; the rebase was clean and nothing was re-measured.

… mode

With a wallpaper set, every message bubble carries backdrop-filter. WebKit
keeps the backing stores of backdrop-filter layers that were composited during
fast scrolling or streaming, so the page's graphics memory grew with the rows
scrolled past: about 420 MB after a fast pass over a 1650-seat Thread, against
about 255 MB with the blur removed.

Each conversation scrollport now shares one IntersectionObserver
(rootMargin 100% 0px) that marks top-level rows within one scrollport height of
the visible transcript. The blur rules for bubbles, expanded reasoning headers
and the pinned compaction toggle drop the filter on unmarked rows. Rows mount
marked, so a row that appears in view is blurred on its first paint, and a
transcript outside a shared scrollport keeps every row marked.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T02:10:04.806304Z 40db7a9 PR opened
🔒 Security Review ✅ Completed 2026-11-24T02:10:24.911388Z 40db7a9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • 性能优化
    • 设置自定义背景图片时,屏幕附近的聊天内容保留背景模糊效果,远离可视区域的内容关闭模糊,滚动浏览时有助于降低图形内存占用。
  • 文档
    • 补充了聊天列表背景模糊范围、更新规则及 WebKit 图形内存行为的说明。

新增近视口观察逻辑,为会话中的顶层聊天行设置标记。壁纸模式下,非近视口行的消息气泡、压缩摘要按钮和 disclosure row 会关闭背景模糊。文档补充观察范围及 WebKit 图形内存说明。

Changes: 壁纸模式聊天模糊

Layer / File(s) Summary
近视口标记
apps/web-ui/packages/client/ui-chat/src/client/chat/near-viewport.ts, apps/web-ui/packages/client/ui-chat/src/client/chat/ChatGroupSeat.tsx, apps/web-ui/packages/client/ui-chat/src/client/chat/ChatNodeSeat.tsx
每个会话滚动容器共用 IntersectionObserver,并用 rootMargin: "100% 0px" 观察顶层聊天行。ChatGroupSeat 和 ChatNodeSeat 调用 useNearViewport;流程组成员跳过观察。
按近视口状态调整模糊
apps/web-ui/packages/client/ui-chat/src/client/chat/MessageItem.module.css, apps/web-ui/packages/client/ui-chat/src/client/chat/ReasoningRow.module.css, docs/product/standalone-web.md
壁纸模式下,非近视口聊天行的消息气泡、展开状态的压缩摘要按钮和 disclosure row 会关闭背景模糊。文档说明观察规则及 WebKit 图形内存现象。

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Sequence Diagram(s)

sequenceDiagram
  participant ChatSeat as ChatGroupSeat 或 ChatNodeSeat
  participant Hook as useNearViewport
  participant Observer as 共享 IntersectionObserver
  participant Row as 顶层聊天行
  participant Styles as 壁纸模式样式
  ChatSeat->>Hook: 提供行引用和启用状态
  Hook->>Observer: 观察会话滚动容器内的行
  Observer->>Row: 更新 data-chat-near-viewport
  Row->>Styles: 提供近视口标记状态
  Styles->>Row: 非近视口时关闭背景模糊
Loading

Possibly related PRs

  • BytePioneer-AI/codex-host#1074:该 PR 调整壁纸模式下用户消息气泡的背景模糊;本 PR 也根据近视口状态修改该类气泡的模糊效果。
Merge Risk: Minimal · up to 40db7

This change turns off wallpaper blur for transcript rows far from the viewport to reduce graphics memory. No concrete defect was found, and the effect is visual and easy to revert. Mergeability risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed 标题“perf(web-ui): blur the transcript only near the viewport in wallpaper mode”描述了本 PR 的主要变更:壁纸模式下仅对视口附近的对话行应用模糊。变更摘要中的 near-viewport.ts 新 hook、ChatNodeSeat/ChatGroupSeat 接入、CSS 规则及文档更新均与该标题一致。标题简洁,并包含…
Description check Passed 描述与变更集高度相关。描述说明了 backdrop-filter 导致 WebKit 图形内存增长的原因、共享 IntersectionObserver 的实现、data-chat-near-viewport 标记、CSS 覆盖规则、流程组成员的处理方式、文档更新以及测试与测量结果。这些内容都对应摘要中列出的文件变更。
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

标题“perf(web-ui): blur the transcript only near the viewport in wallpaper mode”描述了本 PR 的主要变更:壁纸模式下仅对视口附近的对话行应用模糊。变更摘要中的 near-viewport.ts 新 hook、ChatNodeSeat/ChatGroupSeat 接入、CSS 规则及文档更新均与该标题一致。标题简洁,并包含 perf 类型前缀与范围标识。

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between ab1a0df and 40db7a9.

Files selected for processing: 6

  • apps/web-ui/packages/client/ui-chat/src/client/chat/ChatGroupSeat.tsx
  • apps/web-ui/packages/client/ui-chat/src/client/chat/ChatNodeSeat.tsx
  • apps/web-ui/packages/client/ui-chat/src/client/chat/MessageItem.module.css
  • apps/web-ui/packages/client/ui-chat/src/client/chat/ReasoningRow.module.css
  • apps/web-ui/packages/client/ui-chat/src/client/chat/near-viewport.ts
  • docs/product/standalone-web.md

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Recent review details

Context from checks skipped due to timeout: 7

  • GitHub Check: Web Host tests
  • GitHub Check: Static checks
  • GitHub Check: Check windows-latest
  • GitHub Check: Check Linux ARM64
  • GitHub Check: Check ubuntu-22.04
  • GitHub Check: Check macos-26
  • GitHub Check: Vitest
Additional context used

Code guidelines: 1

AGENTS.md — auto-discovered
Path-based instructions: 1

Source excerpt: Do not write browser, e2e, or component tests for Web pages (`apps/web-ui`); the user checks page changes directly.

CodeRabbit inference engine (AGENTS.md)

Files:

  • apps/web-ui/packages/client/ui-chat/src/client/chat/ChatGroupSeat.tsx
  • apps/web-ui/packages/client/ui-chat/src/client/chat/ChatNodeSeat.tsx
  • apps/web-ui/packages/client/ui-chat/src/client/chat/MessageItem.module.css
  • apps/web-ui/packages/client/ui-chat/src/client/chat/ReasoningRow.module.css
  • apps/web-ui/packages/client/ui-chat/src/client/chat/near-viewport.ts
LanguageTool

docs/product/standalone-web.md

[uncategorized] ~35-~35: 动词的修饰一般为‘形容词(副词)+地+动词’。您的意思是否是:远"地"行
Context: ..."),在范围内的行带 data-chat-near-viewport`,更远的行去掉模糊。WebKit 会保留快速滚动或流式输出期间合成过的模糊图层的后备存储...

(wb4)

Stylelint (17.14.0)

apps/web-ui/packages/client/ui-chat/src/client/chat/MessageItem.module.css

[error] 69-69: Unknown pseudo-class selector ":global" (selector-pseudo-class-no-unknown)

(selector-pseudo-class-no-unknown)

[error] 144-144: Unknown pseudo-class selector ":global" (selector-pseudo-class-no-unknown)

(selector-pseudo-class-no-unknown)

apps/web-ui/packages/client/ui-chat/src/client/chat/ReasoningRow.module.css

[error] 31-31: Unknown pseudo-class selector ":global" (selector-pseudo-class-no-unknown)

(selector-pseudo-class-no-unknown)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 40db7a9bc1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

{ root: scrollport, rootMargin: "100% 0px" },
);
observers.set(scrollport, observer);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Size the vertical observer margin from scrollport height

IntersectionObserver resolves percentage rootMargin values against the root's width, not the corresponding axis, so "100% 0px" is not one scrollport height. On a portrait phone, for example, rows lose their blur only one screen-width away and can enter the viewport during a fast screen-height scroll before being remarked; on a wide desktop it retains blur much farther than intended. Use a pixel margin derived from scrollport.clientHeight and refresh it when the scrollport resizes.

Useful? React with 👍 / 👎.

@iruriQ
iruriQ merged commit a02ef3b into main Nov 24, 2026
3 of 8 checks passed
@iruriQ

iruriQ commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

已在隔离 Web 环境下完成 Chrome 与 Playwright WebKit 双端 36 轮长对话壁纸模式实测:实证实测截断线精准贴合容器高度(0.99×H–1.06×H,非宽度),视口内与近区气泡/展开过程分组/吸顶思考行在滚动与瞬时远跳后均正常保持毛玻璃,远处行已降至 backdrop-filter: none,全程 0 业务报错,已合入 main。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants