Skip to content

Commit f8f09bd

Browse files
committed
chore: 🦋 add changeset
1 parent c0a2da5 commit f8f09bd

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

.changeset/tasty-mangos-sneeze.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
'gungi.js': patch
3+
---
4+
5+
🔧 prevent duplicate piece IDs in state transitions
6+
7+
Addresses race conditions in rapid `load()` calls where same piece
8+
type/color could receive identical IDs, breaking game state integrity.
9+
10+
- `applyCanonicalToMissingIds` used flawed conflict detection
11+
- Arata moves assigned same ID to both board and hand pieces
12+
- Race conditions during rapid state transitions
13+
14+
Fixed core ID assignment logic with `Set`-based conflict tracking
15+
rather than real-time array scanning. Balanced two requirements:
16+
17+
**Stability**: Preserve IDs across close FEN states (critical for UX)
18+
**Uniqueness**: Ensure no duplicate IDs ever persist in system
19+
20+
- `ensureUniqueIdsLenient()`: Minimal fixes, preserves stability
21+
- `ensureUniqueIds()`: Complete reassignment for canonical states
22+
- `checkForDuplicateIds()`: Detection without modification
23+
24+
Arata moves now maintain hand piece ID stability while giving
25+
board pieces new IDs, eliminating the duplicate scenario without
26+
breaking expected behavior.

0 commit comments

Comments
 (0)