Skip to content

Portfolio Charts & Proactive Notifications#26

Merged
soomtochukwu merged 3 commits intoDXmakers:mainfrom
memplethee-lab:feat/UIBuild
Mar 30, 2026
Merged

Portfolio Charts & Proactive Notifications#26
soomtochukwu merged 3 commits intoDXmakers:mainfrom
memplethee-lab:feat/UIBuild

Conversation

@memplethee-lab
Copy link
Copy Markdown
Contributor

Overview

Implements actionable portfolio visualization and AI-driven proactive nudging to keep users on track with their savings goals.

Issues Addressed

1. Dynamic Portfolio Charts

  • Chart Component: Custom SVG pie/donut chart with zero external dependencies
  • Data Binding: Allocations dynamically bind to OpenClaw agent strategy output
  • Interactive: Hover tooltips show asset name and percentage
  • Legend: Color-coded legend matches Vanilla CSS theme (Purple/Cyan/Amber)
  • Live Updates: Chart automatically rerenders when strategy changes

Files:

  • frontend/src/app/PortfolioChart.tsx - SVG chart component
  • frontend/src/utils/chartUtils.ts - Pie slice calculations & path generation
  • frontend/src/utils/allocationParser.ts - Extracts allocations from agent messages
  • frontend/src/app/globals.css - Chart styling

2. Proactive Notification Triggers

  • Backend Detection: Monitors goals; triggers when "Falling Behind" detected
  • AI-Powered Messages: Claude generates contextual, empathetic proactive nudges
  • Real-Time Push: WebSocket broadcasts suggestions to active frontend sessions
  • Concrete Suggestions: Proposes exact contribution increases (e.g., "$50 increase")
  • Resilient: Auto-reconnect, graceful error handling, monitoring only when active

Files:

  • agent/notification-service.ts - Goal monitoring & message generation
  • agent/websocket-server.ts - Real-time client management
  • agent/agent-service.ts - Claude API integration
  • agent/notification-monitor.ts - Service runner
  • frontend/src/hooks/useNotifications.ts - WebSocket connection hook
  • frontend/src/utils/suggestionHandler.ts - Suggestion parsing utilities
  • frontend/src/app/page.tsx - Notification integration
  • .env.example - Configuration template

Acceptance Criteria ✅

  • Allocation chart replaces static UI bars; updates dynamically
  • Chart renders cleanly without bundle bloat
  • Legend clearly corresponds to chart colors
  • Backend initiates contact without user prompt when "Falling Behind"
  • Frontend displays incoming agent messages dynamically
  • OpenClaw's suggested rebalancing matches internal calculations

Testing

Run integration test:

cd agent
npm run test

Or test notifications specifically:

npm run notifications

Environment Setup

Copy .env.example to .env and set:

  • ANTHROPIC_API_KEY - Claude API key for message generation
  • NOTIFICATION_PORT - WebSocket server port (default: 3001)
  • NEXT_PUBLIC_WS_URL - Frontend WebSocket URL (default: ws://localhost:3001)

Notes

  • Charts use pure SVG (no Recharts, Plotly, etc.) → minimal bundle size

  • Notification monitoring runs every 5 minutes only while clients connected

  • WebSocket includes exponential backoff reconnection

  • Proactive messages display with "Proactive Nudge" badge for clarity

  • Closes Issue 5.3: Proactive Notification Triggers #16

- Create custom SVG-based pie/donut chart component (zero external dependencies)
- Add chartUtils for pie slice calculations and SVG path generation
- Implement allocationParser to extract allocations from agent messages
- Add hover tooltips showing asset name and percentage
- Integrate color-coded legend matching theme colors
- Update dashboard to display dynamic portfolio allocations
- Add comprehensive CSS styling for chart, legend, and interactions
- Chart automatically updates when strategy changes
Backend Components:
- Create notification-service.ts: Monitors user goals and flags 'Falling Behind' status
- Create websocket-server.ts: Real-time WebSocket server for pushing notifications to clients
- Create agent-service.ts: Claude-powered message generation for proactive nudges
- Create notification-monitor.ts: Service runner with goal monitoring every 5 minutes
- Add test-notifications.ts: Integration test demonstrating the notification flow
- Update package.json: Add 'ws' dependency and 'notifications' script

Frontend Components:
- Create useNotifications.ts: React hook for WebSocket connection management
- Create suggestionHandler.ts: Utilities for parsing and applying proactive suggestions
- Update page.tsx: Integrate notification hook, handle incoming agent messages
- Display 'Proactive Nudge' indicator on agent-initiated messages
- Add CSS styling for proactive notifications and status indicators

Features:
✅ Backend detects 'Falling Behind' status and initiates proactive messages
✅ WebSocket broadcasts AI-generated suggestions to active frontend sessions
✅ Frontend receives notifications and displays as incoming agent messages
✅ OpenClaw proposes exact rebalancing with concrete contribution increases
✅ System includes automatic reconnection with exponential backoff
✅ Monitoring runs every 5 minutes only while clients are connected

Environment:
- Add .env.example with required variables (ANTHROPIC_API_KEY, NOTIFICATION_PORT, etc.)
- Configure NEXT_PUBLIC_WS_URL for frontend WebSocket connection
@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 28, 2026

@memplethee-lab 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

@soomtochukwu
Copy link
Copy Markdown
Contributor

@memplethee-lab, could you look into this?

@soomtochukwu
Copy link
Copy Markdown
Contributor

@memplethee-lab

Try one more time, copy the errors and feed it to your AI

It's crucial that the CI/CD workflow passes/works

Thanks

@memplethee-lab
Copy link
Copy Markdown
Contributor Author

@memplethee-lab

Try one more time, copy the errors and feed it to your AI

It's crucial that the CI/CD workflow passes/works

Thanks

Oh i dont even notice i will fix this

@memplethee-lab
Copy link
Copy Markdown
Contributor Author

@soomtochukwu Approve workflow

@soomtochukwu soomtochukwu merged commit 38d5949 into DXmakers:main Mar 30, 2026
3 checks passed
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.

Issue 5.3: Proactive Notification Triggers Issue 4.2: Build Dynamic Portfolio Charts

2 participants