Skip to content

fix: render unknown event types with a fallback - #883

Open
cartel9072-design wants to merge 1 commit into
Core-Foundry:mainfrom
cartel9072-design:fix/unknown-event-type-fallback-612
Open

cartel9072-design wants to merge 1 commit into
Core-Foundry:mainfrom
cartel9072-design:fix/unknown-event-type-fallback-612

Conversation

@cartel9072-design

Copy link
Copy Markdown

Overview

Makes the dashboard event feed tolerate event types it has never seen. When the listener forwards a type / eventName that has no presentation mapping, the feed now renders a neutral fallback badge instead of relying on unmapped lookups, and the raw payload is rendered through a crash-proof, inspectable representation, so an unrecognised event can never throw during render.

Related Issue

Closes #612

Changes

Unknown event type fallback

  • [MODIFY] dashboard/src/utils/eventTypeMapping.ts

    • Adds isKnownEventType() and extracts findKnownPresentation() so callers can tell a catalogued type apart from the fallback without duplicating the lookup.
    • getEventTypePresentation() keeps returning the neutral UNKNOWN_EVENT_TYPE_PRESENTATION for unmapped types and preserves the raw type as the label, so an unrecognised event stays identifiable.
  • [MODIFY] dashboard/src/utils/payloadViewer.ts

    • Makes sanitizePayload() circular-reference safe (path-scoped WeakSet), so arbitrary/unknown payloads stay stringifiable instead of overflowing the stack.
    • Hardens formatRawPayload() so non-serialisable values (circular references, BigInt) are caught and still produce inspectable output.
    • Adds formatPayloadPreview(), which always returns a single-line string for inline rendering — preventing "Objects are not valid as a React child" for unknown payload shapes.
  • [MODIFY] dashboard/src/components/EventCard.tsx

    • Repairs the duplicated CompactCard header left on main by the presentation-mapping merge (the file did not parse).
    • Renders unknown events with the fallback badge plus an accessible title, marks the card with data-event-type-known="false", and shows an "Unrecognized event type" note in the expanded card.
    • Value preview and expanded value go through formatPayloadPreview(), and topic is guarded.
  • [MODIFY] dashboard/src/components/EventExplorerCard.tsx

    • Repairs the merge damage (duplicate import/prop, undefined shortenAddress/copy-handler references, a duplicated <time> opening tag that broke parsing).
    • Keeps the existing getEventKind* fallback path and marks unknown kinds with the fallback badge and data-event-type-known.
  • [MODIFY] dashboard/src/components/NotificationDetailsDrawer.tsx

    • Unknown event types default to the raw JSON payload view and show an "Unrecognized event type" notice, so the payload is immediately inspectable.
    • Defensive guards for a missing ledger, eventId or sender address so a partial unknown payload cannot throw during render.
  • [ADD] dashboard/src/utils/eventTypeMapping.test.ts

    • Regression tests for unknown-type resolution, case-insensitive matching, and the fallback shape.
  • [ADD] dashboard/src/utils/payloadViewer.test.ts

    • Regression tests that unknown/arbitrary payloads stay stringifiable and inspectable (objects, invalid JSON, circular references, BigInt, null/undefined).
  • [ADD] dashboard/src/components/EventCard.unknown.test.tsx

    • Rendering regression test: an unknown event type renders the fallback badge without throwing and keeps its payload inspectable.

Verification Results

Dashboard dependencies are not installed in this workspace, so its jest/RTL suite could not be run here.
The pure fallback logic was extracted and executed directly instead:

$ node_modules/.bin/tsx scratch/tmp-145/harness.ts
ok 1 - isKnownEventType is false for an unrecognised type
...
ok 18 - arbitrary values always produce a non-empty string preview
18 checks passed

$ vitest run -c vitest.config.ts        # copies of the two new util test files
Test Files  2 passed (2)
Tests       20 passed (20)

$ node_modules/.bin/esbuild <each changed file> --outfile=/dev/null
PASS (8/8 changed files parse)
Acceptance Criteria Status
Unknown events are rendered using a fallback representation ✅ isKnownEventType + UNKNOWN_EVENT_TYPE_PRESENTATION wired into EventCard, EventExplorerCard, NotificationDetailsDrawer
The application does not throw a rendering exception ✅ fallback paths, guarded ledger/eventId/address, and a formatPayloadPreview that never throws
Unknown payload data remains inspectable ✅ unknown types default to the raw JSON view; payload formatting is circular-safe and pretty-printed
A regression test is added ✅ eventTypeMapping.test.ts, payloadViewer.test.ts, EventCard.unknown.test.tsx

Closes #612

Adds isKnownEventType + circular-safe payload formatting and wires the
fallback presentation into the event feed components.

Closes Core-Foundry#612
@drips-wave

drips-wave Bot commented Sep 28, 2026

Copy link
Copy Markdown

@cartel9072-design Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Handle Unknown Event Types Gracefully

1 participant