Memory Lab's dashboard had a silent fragility problem. We built five beautiful panels—scope distribution, confidence histogram, recency heatmap, all of it—but we never answered a simple question: what happens when one of them crashes?
The answer, as it turns out, was: the entire dashboard goes blank. One panel throws an error, React's default error boundary kicks in, and suddenly you're staring at a white screen. Not great when you're trying to debug your memory system.
The Real Data Problem
We discovered this because we weren't actually rendering real data. The Memory Lab dashboard was built against hardcoded fixtures—clean, predictable test data that never had missing fields or unexpected nulls. When we finally wired it up to the actual lab database, panels started throwing errors.
The shape mismatches were small but fatal: a missing timestamp here, an unexpected data structure there. Each one was fixable in isolation, but the blast radius was unacceptable. One bad panel shouldn't take down the entire observability surface.
Enter PanelBoundary
The fix is a component-level error boundary called PanelBoundary. It wraps each dashboard panel and catches errors before they propagate up to React's root error boundary. When a panel crashes, PanelBoundary renders a friendly error message in that panel's card—and leaves the other four panels untouched.
The implementation is straightforward: React's error boundary lifecycle (componentDidCatch, getDerivedStateFromError) wrapped in a component that knows how to render an error state. The interesting part is the test coverage.
We wrote tests that intentionally throw errors inside a panel. The test verifies two things: the crashing panel shows an error message, and the sibling panels keep rendering normally. It's the kind of test that feels almost perverse to write—you're literally testing that your code fails gracefully—but it documents the exact behavior we need.
Real Data, Real Tests
With PanelBoundary in place, we could finally wire up the real lab data. Each panel now reads from the actual memory_lab_entries table instead of hardcoded fixtures. We added tests that verify the panels can handle the real data shape—including edge cases like entries with missing metadata or unexpected confidence scores.
The new tests are specific: memory-lab-real-data-shape.test.tsx exercises each panel's data transformation logic against realistic lab data. If the shape changes, the test breaks. If a panel can't handle a valid lab entry, the test catches it.
What's Next
This fix unblocks the Memory Lab dashboard for production use, but there's more to do:
- Error telemetry: Right now, panel errors are silent except for the UI fallback. We should log them to our observability pipeline so we know when panels are crashing in production.
- Retry logic: Some panel errors might be transient (network timeouts, temporary database unavailability). PanelBoundary could expose a "Retry" button that resets the error state and re-renders the panel.
- Data validation: We're handling shape mismatches reactively (catch the error, show a fallback). We could validate lab data shape proactively with a schema validation layer, failing fast with better error messages.
But for now, the dashboard is resilient enough to ship. One panel can crash without taking down the whole UI, and we're rendering real data instead of fixtures. It's the kind of unglamorous infrastructure work that makes everything else possible.