Uh oh!
There was an error while loading. Please reload this page.
test(desktop): deselect-proof the code-scroll selection drag - #4632
Conversation
The selection-drag assertion raced selection anchoring: mousedown on a guessed container offset sometimes never formed a selection anchor (cold-start font reflow moves the glyphs), so the long drag auto-scrolled without selecting and failed with an opaque zero at the end. Anchor on the measured first line after fonts settle, prove the selection exists with a short in-viewport drag, then start the long auto-scroll drag. Generated-by: Claude Code
72d05b6 to
30f0a0aCompare
jackwener
left a comment
There was a problem hiding this comment.
Approved at exact head 30f0a0ac84b7206bc16147531172149ea89f46c5. I found no blocking or non-blocking issues.
The test now waits for font loading, anchors against the first rendered code line, and proves that an in-viewport selection exists before exercising horizontal auto-scroll. This localizes the previous opaque zero-length failure without weakening the wheel, keyboard, auto-scroll, or final-selection assertions.
I independently confirmed the prior CI failure ended with a zero-length selection, rebuilt Desktop at this head, and passed the changed Electron test 5/5. Moving the anchor into the leading edge caused the new establishment assertion to fail, confirming that it detects the intended failure mode. A synthetic merge with current main was clean, and that merge result also built and passed the changed test. The exact-head hosted test check is complete and successful.
Automated review notice: This comment was posted by an automated review agent operated by jackwener. It is not an independent human review and does not replace one.
Uh oh!
There was an error while loading. Please reload this page.
…4632) `code-scroll.spec.ts` pressed at a guessed offset inside the `code` element's box, so cold font loading could reflow the line after that measurement and leave the press off the glyphs. No selection formed, and the failure surfaced only at the final poll as `Expected: > 10 / Received: 0`. Anchor the press on the measured `[data-line]` box after `document.fonts.ready`, and assert the selection exists before the drag so a failure points at the step that actually broke. The product assertions are unchanged: the closing `scrollLeft` and selection-length expectations are the same, so a real regression in drag auto-scroll would still fail this test. Closesapache#4633 Generated-by: Claude Code Generated-by: GLM-5.3-Flash (ZCode)
Summary
The code-scroll selection-drag test raced selection anchoring: mousedown on a guessed container offset (
codeBox.x + 24) sometimes landed outside the glyphs — cold-start font loading reflows the line after the box is measured — so no selection anchor formed and the long drag auto-scrolled without selecting, failing at the end with an opaque zero. The fix makes anchoring observable instead of assumed: measure afterdocument.fonts.ready, anchor on the first[data-line], prove the selection exists with a short in-viewport drag, then start the long auto-scroll drag. A future anchoring failure now surfaces at the establishment step with a retry window.Fixes#4633
Verification
Before (unpatched, first run after a fresh
build:with-deps; same failure as CI run 33726683004):After (patched, five consecutive runs including the cold one):
Anchor-position mechanism confirmed by counter-experiment: anchoring at
x + 2(leading whitespace) fails 4/5 runs.AI use
Select exactly one:
Tool(s) and scope: Claude Code — diagnosis, patch, and this description, under the contributor's direction; the commit carries a
Generated-by: Claude Codetrailer.Checklist