Skip to content

bug: metric badges disappear after page reload and on IPFS-saved canvas view #225

@tnkshuuhei

Description

@tnkshuuhei

Bug

Metric badges on canvas cards disappear in the following scenarios:

  1. Page reload — after an agent generates a logic model with metrics, reloading the page causes all metric badges to vanish
  2. IPFS-saved canvas — when viewing a canvas loaded from IPFS URL, metric badges are not rendered

Root Cause

cardsToNodes() in lib/canvas/react-flow-utils.ts does not include metrics in node.data. When the canvas state is restored (from localStorage or IPFS props), nodes are created without metric data, so CardNode cannot render the badges.

// cardsToNodes() output — missing metrics
data: {
  id: card.id,
  title: card.title,
  description: card.description,
  color: card.color,
  type: card.type,
  // metrics is absent
}

Meanwhile, CardNode relies on data.metrics to render badges:

{data.metrics && data.metrics.length > 0 && (
  <div>...</div>
)}

Fix

Merge cardMetrics into node.data.metrics during both initialization and localStorage hydration in CanvasContext.tsx.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions