Skip to content

fix: stabilize pane resize host ownership and divider dragging - #96

Merged
chenbstack merged 2 commits into
chenbstack:mainfrom
defia:fix/pane-resize-host-claim
Jul 30, 2026
Merged

fix: stabilize pane resize host ownership and divider dragging#96
chenbstack merged 2 commits into
chenbstack:mainfrom
defia:fix/pane-resize-host-claim

Conversation

@defia

@defia defia commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

问题

  • 三栏布局中拖动左/中分割线时,SwiftUI divider 偶尔已经移动,但中栏 Ghostty surface 仍留在旧 host,形成一条空白带;切换 workspace 后恢复。
  • 分割线正中心 1px 偶尔会把鼠标事件漏给 borderless window,结果变成拖动整个窗口。

根因与复现边界

  • 原始 UI 问题没有通过黑盒压力测试自然复现:真实 左|(中|右) tree、Claude Code、极限拖拽、workspace 切换,以及反复 close/split 右栏均保持同步。
  • 代码级竞态可以确定性重现:split tree 重塑时,旧 host A、新 host B 会短暂共存;B claim stable surface 后,A 的延迟 reassert 仍能通过现有的 attached / expected surface / pane visible 检查,把 surface 抢回旧 host。
  • 新增 A → B → A 的实际 NSView 重挂载 harness,覆盖这个机制级失败顺序。

修复

  • 给 pane host 增加创建代数;仍附着的新 host 确定性优先,旧 tree 的延迟 update/reassert 不能再抢回 surface。
  • 延迟 reassert 同时校验 surface-side host claim。
  • split 两侧都使用显式尺寸,并明确扣除 1pt divider,避免第二分支依赖陈旧的隐式布局提案。
  • 用原生 AppKit drag handle 替代透明 SwiftUI 手势层;handle 明确 mouseDownCanMoveWindow = false,并自行转发水平/垂直拖拽。

验证

  • PerformanceRegressionTests: 24/24 通过。
  • 完整 GlintTests: 257/257 通过。
  • 真实 UI 从 divider 正中心像素拖动 200pt:
    • window frame 保持 {0, 39, 1800, 1051}
    • split ratio 从 0.5194958870 变为 0.3909611826
    • 即 resize pane,不再移动窗口。

@chenbstack
chenbstack merged commit 611cc56 into chenbstack:main Jul 30, 2026
1 check passed
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