Skip to content

refactor(window): 优化窗口置顶装配体验、交互稳定性与非Windows环境零影响 - #234

Merged
lioensky merged 1 commit into
lioensky:mainfrom
Ldl-h:feat/window-pin-governance-and-parity
Oct 6, 2026
Merged

lioensky merged 1 commit into
lioensky:mainfrom
Ldl-h:feat/window-pin-governance-and-parity

Conversation

@Ldl-h

@Ldl-h Ldl-h commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

变更说明 (Overview)

针对此前贡献的窗口置顶(Always-On-Top)与层级调度功能做进一步的体验优化与稳定性收敛:

  1. 精准限定装配边界,避免对非受管沙箱窗口(如 Loom、终端等)的不稳定注入导致点击无响应;
  2. 优化官方受管子窗口(骰子、音乐、备忘录等)的装配性能,装配完成后断开整树 DOM 监听进入深度休眠,彻底消除正文渲染时的额外开销;
  3. 对 macOS / Linux 环境做物理级零影响隔离,首帧不发 IPC、不插 DOM,保持纯净;
  4. 规范单向 IPC 广播状态同步与拖拽节流,保障主界面流式输入流畅度。

详细改动 (Details)

  1. 装配边界收敛,消除事件死锁

    • 之前尝试通过全局脚本向外部异构窗口注入置顶按钮,但在 Loom 与终端等自带独立沙箱或特定拖拽区域的窗口中容易产生点击无响应的死锁;
    • 本次明确将装配范围收敛于官方受管体系:一是由现代 VCPUI.WindowControls 原生受控,二是通过 utility.js
      精确装配超级骰子、音乐、备忘录等官方独立窗口;对于非受管沙箱窗口保持纯净,不再做外部注入。
  2. DOM 监听深度休眠 (Deep Sleep)

    • 优化了 pinButton.js 的挂载状态机:置顶按钮在标题栏装配成功后,立即断开全局 MutationObserver 监听,仅对直接容器保持极浅层监控;
    • 窗口内的正文频繁更新(如终端打印、歌词滚动、3D 骰子物理模拟)不再唤醒置顶逻辑,将后台开销降至最低。
  3. 非 Windows 平台物理级零影响

    • 在 Preload 层提供同步本地门禁 utilityAPI.canPin(),首帧在 V8 内部计算完成(win32 && !isEmbeddedSurface),无需异步 IPC 往返;
    • 控制器首帧直接确定 3 键或 4 键,消除布局跳变。macOS / Linux 系统下不生成按钮 DOM、不注册广播监听、不启动任何观察器,保证完全零开销与零影响。
  4. 单向事件流驱动与通道隔离

    • 废除原先状态变更时的 wc.executeJavaScript 字符串注入,统一改为轻量 IPC 广播(window-pinned-changed),避免争抢渲染端 V8 微任务栈;
    • 按钮点击后状态完全由主进程广播驱动,并内置 150ms 防连击锁,防止快速连击造成 IPC 拥塞。
  5. 拖拽硬件级节流与防抖排序

    • 窗口拖动过程中加入节流门禁,仅在首帧声明置顶,移动期间停止 AABB 碰撞重排计算;
    • 用户松手静止 120ms 后才对重叠的置顶窗口按面积排序(小窗口浮于上方),拖拽过程 CPU 占用大幅降低。

测试验证 (Verification)

  • tests/preload-registry.test.js PASS (100%)
  • tests/window-pin-service.test.js PASS (100%)
  • scripts/test-ui-system.mjs PASS (100%)

- [装配边界收敛] 仅面向加载 preloads/utility.js 的官方受管子窗口(超级骰子、音乐、备忘录等),废除对非受管沙箱的不稳定注入
- [深度休眠机制] 优化 utility 窗口的 MutationObserver 挂载机制,装配完成后断开整树监听,收敛为极浅层观察,正文渲染 0 消耗
- [非Win环境零影响] Preload 层暴露同步 canPin 本地门禁,macOS/Linux 首帧即保持原生 3 键布局,无 IPC 往返、无 DOM 插入、0 资源开销
- [单向广播与通道隔离] 状态由主进程 window-pinned-changed 广播统一驱动,避免 executeJavaScript 抢占 V8 微任务栈,内置 150ms 防连击锁
- [拖拽节流与防抖重排] 引入硬件级拖拽节流,移动期间仅首帧提升一次,松手 120ms 后按 AABB 碰撞面积自动重排,杜绝高频 CPU 占用
- [测试全绿] Preload 注册表契约、窗口置顶调度与 UI System 测试全部 PASS
@Ldl-h
Ldl-h force-pushed the feat/window-pin-governance-and-parity branch from 2c4fac8 to 6b8fd07 Compare October 6, 2026 17:15
@lioensky
lioensky merged commit 5886cb5 into lioensky:main Oct 6, 2026
1 check failed
RoxyAsahi pushed a commit to RoxyAsahi/VCPChat that referenced this pull request Oct 7, 2026
… literal colour

check:ui-system was red on the side pane branch. tool-presentation.css had
101 selectors outside .vcp-ui-scope, an !important on the reduced-motion
rule and two fixed 11px sizes; components.css (from upstream lioensky#234) fell back
to a hard-coded indigo because --vcp-ui-primary is not a token.

Every tool presentation selector now sits under .vcp-ui-scope (the chat
messages container already carries it, and the file is alone in its layer,
so the uniform specificity bump changes no cascade). The reduced-motion rule
reuses the shimmer selector instead of !important, the 11px sizes use
--vcp-ui-text-xs, and the pinned window button uses the accent token.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCGGgmHsCToooXTgSXpmq9
RoxyAsahi pushed a commit to RoxyAsahi/VCPChat that referenced this pull request Oct 7, 2026
… literal colour

check:ui-system was red on the side pane branch. tool-presentation.css had
101 selectors outside .vcp-ui-scope, an !important on the reduced-motion
rule and two fixed 11px sizes; components.css (from upstream lioensky#234) fell back
to a hard-coded indigo because --vcp-ui-primary is not a token.

Every tool presentation selector now sits under .vcp-ui-scope (the chat
messages container already carries it, and the file is alone in its layer,
so the uniform specificity bump changes no cascade). The reduced-motion rule
reuses the shimmer selector instead of !important, the 11px sizes use
--vcp-ui-text-xs, and the pinned window button uses the accent token.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCGGgmHsCToooXTgSXpmq9
RoxyAsahi pushed a commit to RoxyAsahi/VCPChat that referenced this pull request Oct 7, 2026
… literal colour

check:ui-system was red on the side pane branch. tool-presentation.css had
101 selectors outside .vcp-ui-scope, an !important on the reduced-motion
rule and two fixed 11px sizes; components.css (from upstream lioensky#234) fell back
to a hard-coded indigo because --vcp-ui-primary is not a token.

Every tool presentation selector now sits under .vcp-ui-scope (the chat
messages container already carries it, and the file is alone in its layer,
so the uniform specificity bump changes no cascade). The reduced-motion rule
reuses the shimmer selector instead of !important, the 11px sizes use
--vcp-ui-text-xs, and the pinned window button uses the accent token.
(Ported from 2200d12 on the integration PR; components.css part dropped because the pin rule it touched is not on this branch.)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SADzqzusVz3S3z7qBUSy8M
RoxyAsahi pushed a commit to RoxyAsahi/VCPChat that referenced this pull request Oct 7, 2026
Second half of 2200d12 from the integration PR: the pin rule arrived with the
upstream lioensky#234 merge, so it now applies here.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SADzqzusVz3S3z7qBUSy8M
RoxyAsahi pushed a commit to RoxyAsahi/VCPChat that referenced this pull request Oct 7, 2026
…s.css fix

The base now carries upstream lioensky#234, whose components.css falls back to a
literal colour, so check:ui-system was red again on the merge. Both files
now match 2200d12 on the integration branch (#2), which fixes that and
scopes the tool card styles, so the two branches merge without a conflict.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019DFRovoZHMzeheXKkLNWKG
RoxyAsahi pushed a commit to RoxyAsahi/VCPChat that referenced this pull request Oct 7, 2026
… literal colour

check:ui-system was red on the side pane branch. tool-presentation.css had
101 selectors outside .vcp-ui-scope, an !important on the reduced-motion
rule and two fixed 11px sizes; components.css (from upstream lioensky#234) fell back
to a hard-coded indigo because --vcp-ui-primary is not a token.

Every tool presentation selector now sits under .vcp-ui-scope (the chat
messages container already carries it, and the file is alone in its layer,
so the uniform specificity bump changes no cascade). The reduced-motion rule
reuses the shimmer selector instead of !important, the 11px sizes use
--vcp-ui-text-xs, and the pinned window button uses the accent token.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCGGgmHsCToooXTgSXpmq9
(cherry picked from commit 2200d12)
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