Repository navigation
Mnemosyne v2.3.1 - Dashboard Crash Fix
Critical bug fixes for dashboard stability and terminal corruption prevention.
What's Fixed
Critical Dashboard Crash ⚠️
Fixed a critical crash in mnemosyne-dash that occurred when rendering health metrics containing NaN values, which left the terminal in a corrupted state requiring restart.
Root Cause: Sparkline widget used unsafe partial_cmp().unwrap() on floating-point values. When health metrics contained NaN values (from division by zero or invalid calculations), the comparison returned None, causing a panic. Since the terminal was in raw mode, panic messages went to the corrupted display instead of being visible.
Key Improvements
Priority 1: NaN Handling in Sparkline Widget
- Filter out non-finite values (NaN/Infinity) before min/max calculations using
is_finite()check - Gracefully render non-finite values as spaces in sparkline display
- Show placeholder when all values are non-finite
- Added 5 comprehensive tests covering NaN, infinity, and mixed scenarios
- All 11 sparkline tests passing ✅
Priority 2: SSE Bounds Checking
- Added 1MB size limit to SSE string accumulation to prevent OOM from malformed streams
- Log errors and discard events if limit exceeded
Priority 3: Safe critical_events Access
- Replaced unsafe check-then-access pattern with safe
if let Some()in system overview panel - Eliminates race condition when displaying critical events
Priority 4: Terminal Panic Handler
- Installed panic handler to restore terminal state (
disable_raw_mode(),LeaveAlternateScreen) before panic - Prevents terminal corruption on future panics
- Error messages now always visible - no more garbled terminal output
Priority 5: SSE Error Recovery
- Added explicit error handling to SSE client with logging
- Graceful reconnection on stream errors
- More resilient to parse errors
Pattern Detection & Prevention
- Found and fixed identical unsafe pattern in anaphora resolver during codebase scan
- Replaced
partial_cmp().unwrap()withunwrap_or(Ordering::Equal)for NaN-safe comparison - Added validation to
with_max_lookback()to prevent division by zero - All 8 anaphora resolution tests passing ✅
Documentation
Troubleshooting Guide (+200 lines)
- Dashboard crash diagnosis and recovery
- Terminal corruption prevention
- Connection issues troubleshooting
- Version-specific guidance (2.3.1+)
Development Best Practices
- Floating-Point Safety: Patterns for NaN handling, division by zero prevention
- Terminal/TUI Development: Panic handler setup, error visibility
- Code examples showing unsafe vs safe patterns
Testing
- ✅ 11/11 sparkline widget tests passing (including 5 new NaN/infinity tests)
- ✅ 8/8 anaphora resolver tests passing
- ✅ 735+ total tests passing (library + dashboard + new tests)
- ✅ 0 compiler warnings, 0 errors
- ✅ Dashboard starts without crashes
- ✅ Core mnemosyne functionality verified
Impact
- Dashboard now handles invalid metrics gracefully
- Terminal corruption prevented even if future panics occur
- Error messages always visible
- Similar unsafe patterns prevented throughout codebase
- Comprehensive troubleshooting guide for users
- Development best practices documented for contributors
Installation
# From source
git clone https://github.com/rand/mnemosyne.git
cd mnemosyne
git checkout v2.3.1
./scripts/build-and-install.sh
# Or use fast rebuild for development
./scripts/rebuild-and-update-install.shUpgrade Notes
If you experienced the terminal corruption crash:
- Close corrupted terminal
- Open new terminal
- Update to v2.3.1 using the commands above
- Dashboard will now handle errors gracefully
Known Issues
⚠️ PyO3 0.22.6 doesn't support Python 3.14+ (use Python 3.9-3.13)⚠️ Tier 3 LLM integration is scaffolding only (not fully functional)
Full Changelog
See CHANGELOG.md for complete details.
Commits in this release:
- 21ad82e - Fix mnemosyne-dash crash and improve stability
- 1719e3e - Simplify SSE error handling in dashboard
- c981e21 - Fix unsafe floating-point comparison in anaphora resolver
- 55a8406 - Add dashboard troubleshooting and development best practices
- d2b96cc - Release v2.3.1
- d54164f - Update documentation for v2.3.1 release
Full diff: v2.3.0...v2.3.1