fix(ui-e2e): tighten Phase 29 effect tracking + radio wiring
Tests · UI / test (push) Failing after 7m19s

Run #217 surfaced three independent bugs that survived the first
fixup pass:

1. `visibleHighBitCount` masked the id with `(prim.id >>> 0) & 0xf…`,
   but JS bitwise AND always returns a signed int32 — the mask had
   to be re-converted with `>>> 0` AFTER the AND, not before. Result
   was always 0 on the previous run, masking the next two bugs by
   making the persistence test's high-bit-count assertions a
   tautology.
2. `applyVisibilityState` was wrapped in `untrack`, so the
   `toggles.X` reads inside `computeHiddenIds` / `computeFogCircles`
   never landed in the effect's dependency set — toggling fog or any
   marker / group / kind flag did not re-run the effect, so the
   renderer never received the new hide / fog input. Explicit
   `void toggles.X` reads now live at the top of the effect so every
   key is tracked synchronously.
3. The wrap-mode radios fired on `onchange`, which Svelte 5
   suppresses on a re-activation of an already-checked input — the
   Playwright `.click()` flake on the second wrap test reflected the
   missed event. Switched to `onclick` and short-circuited when the
   target mode is already active.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilia Denisov
2026-05-19 22:23:15 +02:00
parent 2528d63b51
commit 7c46aa4bec
3 changed files with 35 additions and 6 deletions
+7 -4
View File
@@ -238,14 +238,17 @@ async function visibleHighBitCount(
page: Page,
prefix: number,
): Promise<number> {
// Convert ids to uint32 before masking so the comparison works
// for ids stored as signed-negative numbers (JS bitwise ops force
// ToInt32). `prefix >>> 0` keeps the literal in uint32 space too.
// JS bitwise `&` always returns a signed int32. Convert both
// sides to uint32 via `>>> 0` AFTER the mask so the comparison
// is well-defined for high-bit-prefix ids that arrive as
// negative Numbers (cargo route 0x80…, battle 0xa0…, bombing
// 0xc0…) as well as for the positive `prefix` literal passed in.
return await page.evaluate((p: number) => {
const prims = window.__galaxyDebug!.getMapPrimitives!() as readonly PrimitiveLite[];
const expected = p >>> 0;
return prims.filter(
(prim) =>
prim.visible && ((prim.id >>> 0) & 0xf0000000) === (p >>> 0),
prim.visible && ((prim.id & 0xf0000000) >>> 0) === expected,
).length;
}, prefix);
}