Skip to content

migrate Rune module with serialization/deserialization m…#645

Draft
shororxor wants to merge 1 commit intosource-academy:masterfrom
shororxor:conductor-migration
Draft

migrate Rune module with serialization/deserialization m…#645
shororxor wants to merge 1 commit intosource-academy:masterfrom
shororxor:conductor-migration

Conversation

@shororxor
Copy link
Copy Markdown

@shororxor shororxor commented Apr 7, 2026

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:

export function getDynamicTabs(debuggerContext: DebuggerContext): SideContentTab[] {
  const moduleContexts = debuggerContext?.context?.moduleContexts;
  if (!moduleContexts) return [];

  return Object.values(moduleContexts)
    .flatMap(({ tabs }) => tabs ?? [])
    .map((rawTab: RawTab) => {
      const { default: content } = rawTab(requireProvider);
      return content;
    })
    .filter(({ toSpawn }) => !toSpawn || toSpawn(debuggerContext))
    .map(tab => {
      debuggerContext = tab.deserialize(debuggerContext);
      return tab;
    })
    .map(tab => ({
      ...tab,
      body: tab.body(debuggerContext),
      id: SideContentType.module
    }));
}

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

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.

  • Test A
  • Test B

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Comment on lines +513 to +517
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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This issue is resolved by #640 for runes

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +13 to +14
console.log("deserializedDrawnRune inside Tab Render");
console.log(deserializedDrawnRunes);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Avoid leaving debug console logs in production code.

@martin-henz martin-henz marked this pull request as draft April 8, 2026 09:12
@martin-henz martin-henz changed the title successfully migrate Rune module with serialization/deserialization m… migrate Rune module with serialization/deserialization m… Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants