Repository navigation
fix(ui): settle drag selections after pointer release - #2575
Conversation
33394a2 to
867e19a
Compare
Astro-Han
left a comment
There was a problem hiding this comment.
Thanks for making pointer release the explicit selection boundary — the normal in-window path is clear and the small state machine is easy to follow.
[P2] One window-boundary case still looks open: a mouse drag can leave the Electron window and be released without the document receiving pointerup and without the window necessarily blurring. Because the gesture does not capture the pointer, activePointerId can then remain set; later keyboard or programmatic selection changes keep hiding the quote without scheduling settlement until another matching pointer release happens.
Could the owning turn capture the pointer and also settle or cancel on lostpointercapture? A focused real-DOM/Electron test for releasing outside the window would help cover the listener wiring—the current head only contains the pure boundary tests, since the earlier quote E2E is no longer present.
Thanks again — the original in-window timing race does look correctly addressed.
b02fc8f to
68c26e2
Compare
|
Addressed the window-boundary case: the owning turn now captures the pointer and settles on |
Astro-Han
left a comment
There was a problem hiding this comment.
Approving this revision. The original timing race is fixed at the right boundary: selectionchange remains the authority for what changed, the owning pointer release commits a drag selection, and pointer capture preserves the release path beyond the viewport. The focused Electron coverage and the full CI run are green.
I left two non-blocking P2 follow-ups around the capture lifecycle. They appear to share one underlying issue: the logical gesture identity and the DOM capture identity can currently diverge. One clean direction would be a single nullable { pointerId, owner, changed } record and a shared terminal helper with explicit commit and cancel outcomes. That is a suggestion rather than a prescribed implementation—if Chromium/Electron provides a stronger ordering guarantee here, or there is a smaller way to preserve the same invariant, please push back with that evidence.
I would keep both levels of coverage, while simplifying them around the behavior they actually prove: table-test the meaningful state transitions, retain the outside-viewport Electron pointerup path, and avoid treating the browser’s normal post-pointerup capture-loss event as coverage of the production fallback.
Review disclosure: Codex assisted with an adversarial analysis of the changed pointer state machine, browser event semantics, and tests, including an independent AI review pass. I (Astro-Han) reviewed the current head, verified the relevant event ordering and CI state, and made the approval and severity decisions.
eecd007 to
a9bbf46
Compare
Astro-Han
left a comment
There was a problem hiding this comment.
Thanks for consolidating the gesture and capture lifecycle in a9bbf46. I reviewed the final incremental commit, and it addresses both follow-ups from the previous approval.
The accepted gesture now owns one { pointerId, owner, changed } record, a second primary pointer cannot replace that owner, and the shared terminal path distinguishes commit on pointerup from cancellation on pointercancel or lostpointercapture. Removing the normal capture-loss assertion from the Electron test also keeps that test focused on the real outside-viewport release behavior.
The final head is cleanly mergeable, and all CI checks are green. I did not find any remaining reproducible P0–P3 issues. Approved and ready to merge.
AI-assisted review disclosure
Codex performed the incremental source and test inspection. I, Astro-Han, reviewed the evidence and made the final review decision.
Summary
The quote affordance currently treats 350 ms without a
selectionchangeas a settled drag. Once the pointer moves past the available text, the browser may stop changing the Selection while the button is still held, so the layer can appear before the gesture ends.This makes primary pointer release the commit boundary for drag selection. Selection changes while that pointer is held clear the old affordance but do not arm the timer; pointerup then starts the existing settle path. Keyboard and programmatic selections keep the same delay, while unchanged clicks, another pointer, pointer cancellation, and window blur cannot resurrect a dismissed quote.
Pointer tracking starts only inside a turn that can own a quote. Controls elsewhere in the scroll surface, including the quote actions, therefore cannot clear the quote they are trying to consume.
The E2E drives a deterministic pointer/selection event boundary through the real transcript DOM without driver-side timing sleeps. A deterministic UI boundary test owns the timing policy.
Fixes #2400
中文对照
引用浮层目前把“350ms 内没有
selectionchange”当成拖选已经结束。当指针越过可选文本后,浏览器可能不再改变 Selection,但鼠标仍处于按下状态,因此浮层会在手势结束前出现。本 PR 将主指针释放设为拖选的提交边界。指针按住期间的选区变化只会清除旧浮层,不会启动 timer;pointerup 后才进入原有 settle 路径。键盘和程序化选区仍保留相同延迟,同时未改变选区的点击、其他 pointer、pointercancel 与窗口失焦都不能让已关闭的引用浮层重新出现。
pointer tracking 只会从可拥有引用的 turn 内部开始,因此滚动区域中的其他控件(包括引用操作按钮本身)不会在消费引用前把它清掉。
E2E 改为在真实 transcript DOM 中确定性地驱动 pointer/selection event 边界,不再依赖 driver 侧 sleep;确定性的 UI boundary 单测负责时序规则。
Verification
npm --workspace @maka/ui test— 265 tests passednpm --workspace @maka/desktop run build:with-depsnpx biome checkon all changed source, test, and E2E filesCI=1visible-window modeChecklist
Does this PR entail a change in behavior?