migrate Rune module with serialization/deserialization m…#645
migrate Rune module with serialization/deserialization m…#645shororxor wants to merge 1 commit intosource-academy:masterfrom
Conversation
| export function deserializeDrawnRune(serialized: SerializedDrawnRune): DrawnRune | AnimatedRune { | ||
| if (serialized.kind === 'normal') { | ||
| const rune = deserializeRune(serialized.rune); | ||
|
|
||
| // Create a small subclass instance to preserve isHollusion flag and draw behaviour |
There was a problem hiding this comment.
Bug: The deserializeDrawnRune function rehydrates HollusionRune objects as a generic class, causing the instanceof HollusionRune check to fail and breaking the animated hollusion effect.
Severity: HIGH
Suggested Fix
Modify deserializeDrawnRune to correctly reconstruct HollusionRune instances. When serialized.isHollusion is true, the function should return a new HollusionRune object instead of a RehydratedNormalRune. This will ensure the instanceof HollusionRune check passes, allowing the correct animated rendering component to be used.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: src/bundles/rune/src/rune.ts#L513-L517
Potential issue: The `deserializeDrawnRune` function incorrectly reconstructs
`HollusionRune` instances as a generic `RehydratedNormalRune` class. This causes the
type check `rune instanceof HollusionRune` to fail in the rendering component. As a
result, the special animated rendering for hollusion runes is skipped, and they are
displayed as static images instead. This functional regression breaks the hollusion
animation feature after a serialization and deserialization cycle, such as when
restoring a tab's state.
Did we get this right? 👍 / 👎 to inform future reviews.
There was a problem hiding this comment.
Code Review
This pull request introduces serialization and deserialization capabilities for Runes by adding serialize and deserialize methods to the ModuleSideContent interface and implementing the corresponding logic in the Rune bundle and tab. This allows Rune states to be converted to plain data structures and rehydrated. A review comment suggests removing debug console logs that were left in the RuneTab component.
| console.log("deserializedDrawnRune inside Tab Render"); | ||
| console.log(deserializedDrawnRunes); |
Description
Because DrawnRunes cannot be transferred between the Runner and the Host—since function objects are not serializable (see Transferable Objects), we need to determine the minimal set of data required from the Host to correctly render the UI.
Once the necessary data buffer is identified, we should implement a serialization mechanism that extracts only transferable data while excluding functions. Correspondingly, a deserialization process should be provided to reconstruct (or “rehydrate”) the full DrawnRunes object.
Additionally, the tab return type should expose two functions, serialize and deserialize, so that the Host can invoke them when needed. With these changes, the getDynamicTabs function on the frontend can be updated as follows:
Fixes # (issue)
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.
Checklist: