refactor(ui): use asEntityId helper at piece-id boundaries

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
Joey Yakimowich-Payne 2026-04-19 13:53:45 -06:00
commit 9960ea96cf
No known key found for this signature in database
6 changed files with 79 additions and 7 deletions

View file

@ -1,6 +1,6 @@
import { MODIFIER_REGISTRY } from '../modifiers/registry';
import type { ChessEngine } from '../engine';
import type { EntityId } from '@paratype/rete';
import { asEntityId } from '@paratype/rete';
interface Props {
pieceId: number;
@ -8,8 +8,9 @@ interface Props {
}
export function ModifiedPieceIndicator({ pieceId, engine }: Props) {
const id = asEntityId(pieceId);
const isModified = MODIFIER_REGISTRY.list().some((descriptor) => {
return engine.session.get(pieceId as unknown as EntityId, descriptor.attrName) !== undefined;
return engine.session.get(id, descriptor.attrName) !== undefined;
});
if (!isModified) {

View file

@ -11,7 +11,7 @@
* state on each render so it stays reactive to fact changes (moves, rule
* changes, etc.) without any additional subscription setup.
*/
import type { EntityId } from '@paratype/rete';
import { asEntityId } from '@paratype/rete';
import { MODIFIER_REGISTRY } from '../modifiers/index.js';
import { getModifierSource } from "../modifiers/source.js";
import type { ChessEngine } from '../engine.js';
@ -26,7 +26,7 @@ export function ModifierPinnedPanel({ pieceId, engine, onClose }: Props) {
if (pieceId === null || engine === null) return null;
const { session } = engine;
const id = pieceId as unknown as EntityId;
const id = asEntityId(pieceId);
// Basic piece facts — bail if the entity doesn't exist in session.
const pieceType = session.get(id, 'PieceType') as string | undefined;

View file

@ -9,7 +9,7 @@
* MODIFIER_REGISTRY attribute is shown without distinguishing per-type /
* per-instance / preset origin (T26 can refine this).
*/
import type { EntityId } from '@paratype/rete';
import { asEntityId } from '@paratype/rete';
import { MODIFIER_REGISTRY } from '../modifiers/index.js';
import type { ChessEngine } from '../engine.js';
@ -20,7 +20,7 @@ interface Props {
export function ModifierTooltip({ pieceId, engine }: Props) {
const { session } = engine;
const id = pieceId as unknown as EntityId;
const id = asEntityId(pieceId);
// Basic piece facts
const pieceType = session.get(id, 'PieceType') as string | undefined;