mirror of
https://github.com/Matysh/houseplan-card
synced 2026-09-29 03:09:36 +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:
@@ -7297,6 +7297,55 @@ const MUTANT_DEFINITIONS = [
|
||||
replace: ' this._loadOk = true;',
|
||||
}],
|
||||
},
|
||||
{
|
||||
id: 'live-editor-devices-drops-align-guides',
|
||||
guard: 'node demo/smoke_align_guides.mjs',
|
||||
because: 'the device editor paints nothing else from a template, so dropping the guides '
|
||||
+ 'leaves the settled scene as their only owner — and a live gesture never reaches it: '
|
||||
+ 'the regression of #521, invisible to a smoke that fabricates the drag',
|
||||
patches: [{
|
||||
file: 'src/live-editor.ts',
|
||||
find: " return svg`<g class=\"hp-live-devices\" aria-hidden=\"true\" pointer-events=\"none\">\n"
|
||||
+ ' ${host._renderAlignGuides()}\n'
|
||||
+ ' </g>`;',
|
||||
replace: ' return nothing;',
|
||||
}],
|
||||
},
|
||||
{
|
||||
id: 'live-editor-decor-drops-align-guides',
|
||||
guard: 'node demo/smoke_align_guides.mjs',
|
||||
because: 'drawing a shape in the backdrop editor is a live gesture too: without the guides '
|
||||
+ 'in its own layer the corner snap has nothing to show (#521 AC3)',
|
||||
patches: [{
|
||||
file: 'src/live-editor.ts',
|
||||
find: ' ${host._renderDecorLayer(activeId)}\n ${host._renderAlignGuides()}',
|
||||
replace: ' ${host._renderDecorLayer(activeId)}',
|
||||
}],
|
||||
},
|
||||
{
|
||||
id: 'live-editor-plan-drops-align-guides',
|
||||
guard: 'node demo/smoke_align_guides.mjs',
|
||||
because: 'in the plan editor the guides used to reappear only on a click; without them in '
|
||||
+ 'the live layer the contour is drawn against a guide frozen at the last click (#521 AC4)',
|
||||
patches: [{
|
||||
file: 'src/live-editor.ts',
|
||||
find: ' ${host._renderAlignGuides()}\n'
|
||||
+ " ${host._tool === 'draw' ? nothing : host._renderPlanSnapOverlay()}",
|
||||
replace: " ${host._tool === 'draw' ? nothing : host._renderPlanSnapOverlay()}",
|
||||
}],
|
||||
},
|
||||
{
|
||||
id: 'align-point-reads-frozen-snapshot',
|
||||
guard: 'node demo/smoke_align_guides.mjs',
|
||||
because: 'during a live gesture `_pos` answers from the snapshot of the last settled '
|
||||
+ 'render, so the guide is measured from where the marker stood before the drag — eight '
|
||||
+ 'grid steps away on a measured run (#521 AC2)',
|
||||
patches: [{
|
||||
file: 'src/houseplan-card.ts',
|
||||
find: ' return d ? (() => { const p = this._livePos(d); return [p.x, p.y]; })() : null;',
|
||||
replace: ' return d ? (() => { const p = this._pos(d); return [p.x, p.y]; })() : null;',
|
||||
}],
|
||||
},
|
||||
{
|
||||
id: 'live-editor-view-mode-routes-live',
|
||||
guard: 'node --test test/live-editor.test.mjs',
|
||||
|
||||
Reference in New Issue
Block a user