mirror of
https://github.com/Matysh/houseplan-card
synced 2026-10-04 21:58:56 +00:00
fix: alignment guides follow the live gesture again (#521)
#451 moved every editor gesture onto the live painter, and the guides stayed behind in the settled scene. While a gesture runs, the settled scene is not re-rendered at all, so the guides did not follow the marker in the device editor, the shape in the backdrop editor, or the cursor while a contour is drawn in the plan editor. Measured with real pointer events on the demo stand against `origin/dev`, after waiting for the editor chrome to settle: three gestures, each exactly on another object's axis, 0 settled render cycles, `.alignline` 0 and no `.alignguides` group in all three. The report called it two breaks. It is one — the layer — plus one thing that would have broken the repair: `_alignPoint` read `_pos`, which during a live gesture answers from the snapshot of the last settled render. Over one drag: live 254.17 → 220.83 while `_pos` stayed at 254.17, eight grid steps behind, so a restored layer would have drawn the guide at the marker's old place. The live template now paints the guides in all three modes (the device editor had no template at all — `paintDevice` only moves the marker element), and `_alignPoint` takes the live position. The settled copy of `.hp-editor-only-layer` is made transparent for the duration of any editor gesture, not only in plan mode: two guides, one of them stale, is what the user would otherwise see when an unrelated settled render lands mid-gesture. `_renderAlignGuides` on the card becomes soft — a gesture that starts while the editor runtime is still loading must cost nothing, and an exception inside a `requestAnimationFrame` paint would take the whole gesture with it. The witness is rewritten around the defect that hid this for two stable releases: the old smoke assigned `_deviceDrag`/`_decorDraft` wholesale, and an assignment with `oldValue == null` does not route to the live path — it verified a state a real gesture never reaches. Every scenario now drives real `PointerEvent`s, waits for silence first (the `_hdrH` settling window right after entering a mode hands out settled frames that make even the broken code draw a guide), and asserts zero settled cycles during the movements plus exactly one `.alignguides` group. #400's exclusion is checked without touching the drag state: the dragged marker must simply be absent from the candidates. On `origin/dev` the smoke fails on nine of its facts; a witness that stays green before the fix was the actual bug here. Mutants: `live-editor-devices-drops-align-guides`, `live-editor-decor-drops-align-guides`, `live-editor-plan-drops-align-guides`, `align-point-reads-frozen-snapshot` — one per AC, all guarded by the smoke. `test/smoke-harness-contract.test.mjs` pins that the smoke cannot go back to fabricating gesture state. Issue: #521 User-Visible: yes
This commit is contained in:
@@ -122,3 +122,28 @@ test('#423 каждый page-benchmark обязан иметь вердикт и
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// #521. Свидетель направляющих выравнивания был зелёным на сломанном коде,
|
||||
// потому что фабриковал состояние жеста: `c._deviceDrag = {…, moved: true}` и
|
||||
// `c._decorDraft = {…}` присваивались целиком. Присвоение с `oldValue == null`
|
||||
// живой путь не включает, поэтому проверялась осевая отрисовка — то есть путь,
|
||||
// которого при настоящем жесте не бывает. Проверка статическая и узкая: она
|
||||
// стоит на одном файле и на двух именах, зато закрывает ровно тот способ
|
||||
// обмануть её, который однажды уже сработал.
|
||||
test('свидетель направляющих ведёт жест, а не подставляет его состояние (#521)', () => {
|
||||
const source = read('smoke_align_guides.mjs');
|
||||
for (const state of ['_deviceDrag', '_decorDraft']) {
|
||||
assert.doesNotMatch(source, new RegExp(`\\b${state}\\s*=[^=]`),
|
||||
`smoke_align_guides.mjs: ${state} присваивается напрямую — жест обязан`
|
||||
+ ' создавать его сам, иначе смок снова проверит осевой путь (#521)');
|
||||
}
|
||||
assert.match(source, /dispatchEvent\(pe\('pointerdown'/,
|
||||
'жест начинается настоящим pointerdown по элементу');
|
||||
assert.match(source, /dispatchEvent\(pe\('pointermove'/,
|
||||
'жест продолжается настоящими pointermove');
|
||||
// Тишина перед жестом и нулевой счёт осевых кадров — часть свидетеля, а не
|
||||
// украшение: без них сломанный код зеленеет на кадрах оседания `_hdrH`.
|
||||
assert.match(source, /const quiet = async \(\) =>/);
|
||||
assert.match(source, /ZeroSettledRenders/);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user