fix: make deleted units count as dead#422
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the isAlive function in the UnitsTab component to return false instead of true when an entity snapshot is not found, ensuring that missing entities are not incorrectly identified as alive. I have no feedback to provide as there were no review comments to evaluate.
fank
left a comment
There was a problem hiding this comment.
The one-line fix correctly addresses the root issue. engine.computeSnapshots() only emits snapshots for entities inside [startFrame, endFrame], so a deleted unit (endFrame set at deletion) has no snapshot on later frames. The previous true default rendered deleted units as alive — the new false matches the actual semantics ("not present at this frame" → not alive).
One ask before merging: please add a regression test. ui/src/pages/recording-playback/__tests__/UnitsTab.test.tsx already exercises the alive-count path with live snapshots; extend it with a unit whose lifespan ends before currentFrame (no snapshot returned by entitySnapshots()) and assert it counts as dead and receives the unitRowDead class. Without it, this default is one careless refactor away from silently reverting.
Side note (not blocking): units that haven't spawned yet (currentFrame < startFrame) will now also render as dead. Consistent with the deleted case and fine for a roster view, but worth being aware of.
Summary
Make units that do not exist on the current frame be considered dead.
Especially useful for missions where AI units are removed after a while if no player takes control.
How to test
Check recording where units were deleted in-game.
Example of this kind of recording:
https://replays.vtg.in.ua/recording/2485/mVTG_Kontrakt_40_v01_20260502_225739
Blue side, Alpha 1-3.
The whole group was deleted at 03:00
Checklist
cd ui && npm testpasses