fix: the card keeps the position it sent, so its echo is not foreign (#397)

B3: _persistDevicePlacement sent canonicalizePosition(...) to the server
and left the raw value in _layout, then recorded the fingerprint over
that raw snapshot. Canonicalization is not identity — it snaps to the
lattice — so 39 of 115 pixel-derived coordinates differ, and the next
_reloadLayoutOnly or _adoptStructuralResponses saw its own write as a
remote edit: history cleared, _layout replaced. The old _persistLayout
wrote the canonical value back; the per-device path introduced by #74
lost that line.

M1: the smoke that was supposed to prove AC10 assigned
serverLayout = structuredClone(c._layout) right before the reload —
erasing by hand the very divergence it existed to catch, so it could not
fail. The fake WS already stores what went over the wire; the
assignment is gone and the check now reddens on the unfixed code
(verified: three checks red without the fix, including this one).

Also proven, because the fix touches their neighbourhood: the echo of a
DELETE keeps the history (the branch removes a key rather than replacing
a value), and an in-flight write still wins the merge against a server
answer holding the old position.

One existing assertion was loosened deliberately: undo now restores a
position that may differ from the raw one by the lattice snap (<1e-9 of
the plan). That is the point of the fix — local and server agree — so the
equality is stated to that precision, with the snap size pinned
separately so a real drift would still fail.

User-Visible: yes
Issue: #397
This commit is contained in:
Codex
2026-08-31 02:36:55 +03:00
parent f4fcb1fac0
commit d87cc29804
6 changed files with 138 additions and 5 deletions
+12
View File
@@ -746,6 +746,18 @@ const MUTANT_DEFINITIONS = [
replace: " this._persistDecorStyle();\n }, 0);",
}],
},
{
id: 'device-echo-keeps-local-noncanonical',
guard: 'node demo/smoke_device_position_history.mjs',
because: 'a card that keeps the raw position while sending the canonical '
+ 'one mistakes its own echo for a remote edit and wipes the undo stack '
+ '(#397 B3)',
patches: [{
file: 'src/houseplan-card.ts',
find: ' this._layout = { ...this._layout, [deviceId]: pos };',
replace: ' void pos;',
}],
},
{
id: 'camera-cancel-loses-zoom',
guard: 'node demo/smoke_smooth_zoom.mjs',