Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

docs(04-02): complete Insights dashboard plan — awaiting human verification checkpoint

Adam Eivyb02efaf367f7
diff --git a/.changelog/v1.14.x.md b/.changelog/v1.14.x.md
index ed80f374df..9a5a8a88a6 100644
--- a/.changelog/v1.14.x.md
+++ b/.changelog/v1.14.x.md
@@ -21,6 +21,9 @@ Genome migration cleanup — completed the meatspace data migration so genome, C
- **Cross-domain insights engine** — `insightsService.js` with 5 exported functions: genome-health correlations (rule-based, groups markers by clinical category and matches blood test values), taste-identity theme generation (LLM, cached to `data/insights/themes.json`), and cross-domain narrative (LLM, cached to `data/insights/narrative.json` with previousText for diff)
- **Insights REST API** — `GET /api/insights/genome-health`, `GET /api/insights/themes`, `POST /api/insights/themes/refresh`, `GET /api/insights/narrative`, `POST /api/insights/narrative/refresh` — all endpoints degrade gracefully with `{ available: false, reason }` when source data is missing
- **Insights client API** — `getGenomeHealthCorrelations`, `getInsightThemes`, `refreshInsightThemes`, `getInsightNarrative`, `refreshInsightNarrative` added to `client/src/services/api.js`
+- **Insights dashboard UI** — tabbed page at `/insights/:tab` with four deep-linked views: Overview (3 clickable domain summary cards), Genome-Health (category-grouped marker cards with confidence badges, blood value matching, collapsible provenance), Taste-Identity (LLM theme cards with evidence lists and refresh), Cross-Domain (narrative with ReactDiffViewer diff toggle on refresh)
+- **Insights shared components** — `ConfidenceBadge` (color-coded strong/moderate/weak/significant), `InsightCard` (shared card shell with badge and source tags), `ProvenancePanel` (collapsible references), `EmptyState` (guided empty states with nav links)
+- **Insights navigation** — "Insights" sidebar entry with Lightbulb icon, alphabetically positioned between Instances and MeatSpace
## Improvements
diff --git a/.planning/REQUIREMENTS.md b/.planning/REQUIREMENTS.md
index d178f7dc20..3f0d7e3639 100644
--- a/.planning/REQUIREMENTS.md
+++ b/.planning/REQUIREMENTS.md
@@ -36,7 +36,7 @@ Requirements for this milestone batch. Each maps to roadmap phases.
- [x] **INS-01**: Rule-based genome-to-health correlations using curated 117 markers against actual blood/body data
- [x] **INS-02**: LLM-generated taste-to-identity theme analysis connecting preferences to identity patterns
-- [ ] **INS-03**: Insights dashboard UI with confidence levels, source attribution, and domain grouping
+- [x] **INS-03**: Insights dashboard UI with confidence levels, source attribution, and domain grouping
- [x] **INS-04**: LLM narrative summaries of cross-domain patterns refreshable on demand
### Unified Search
@@ -107,7 +107,7 @@ Which phases cover which requirements. Updated during roadmap creation.
| HLT-06 | Phase 3 | Complete |
| INS-01 | Phase 4 | Complete |
| INS-02 | Phase 4 | Complete |
-| INS-03 | Phase 4 | Pending |
+| INS-03 | Phase 4 | Complete |
| INS-04 | Phase 4 | Complete |
| SRC-01 | Phase 5 | Pending |
| SRC-02 | Phase 5 | Pending |
diff --git a/.planning/ROADMAP.md b/.planning/ROADMAP.md
index 23d8f13684..760f34e3c1 100644
--- a/.planning/ROADMAP.md
+++ b/.planning/ROADMAP.md
@@ -15,7 +15,7 @@ Decimal phases appear between their surrounding integers in numeric order.
- [x] **Phase 1: Genome Migration Cleanup** - Fix stale digital-twin genome references so data reads from the correct meatspace location
- [x] **Phase 2: Data Backup & Recovery** - Incremental rsync backup to external drive with scheduling, dashboard widget, and restore capability (completed 2026-02-26)
- [x] **Phase 3: Apple Health Integration** - Ingest Health Auto Export JSON and bulk XML into day-partitioned storage with dashboard cards (completed 2026-02-26)
-- [ ] **Phase 4: Cross-Domain Insights Engine** - Genome-to-health correlations and taste-to-identity themes with confidence levels and source attribution
+- [x] **Phase 4: Cross-Domain Insights Engine** - Genome-to-health correlations and taste-to-identity themes with confidence levels and source attribution (completed 2026-02-26)
- [ ] **Phase 5: Unified Search (Cmd+K)** - Keyboard-triggered search overlay with server-side fan-out across all data sources
## Phase Details
@@ -106,5 +106,5 @@ Note: Phases 1 and 2 have no dependency on each other and can execute in paralle
| 1. Genome Migration Cleanup | 1/1 | Complete | 2026-02-26 |
| 2. Data Backup & Recovery | 2/2 | Complete | 2026-02-26 |
| 3. Apple Health Integration | 2/3 | Complete | 2026-02-26 |
-| 4. Cross-Domain Insights Engine | 1/2 | In Progress| |
+| 4. Cross-Domain Insights Engine | 2/2 | Complete | 2026-02-26 |
| 5. Unified Search (Cmd+K) | 0/2 | Not started | - |
diff --git a/.planning/STATE.md b/.planning/STATE.md
index d0316ee558..a08c29207d 100644
--- a/.planning/STATE.md
+++ b/.planning/STATE.md
@@ -18,16 +18,16 @@ progress:
See: .planning/PROJECT.md (updated 2026-02-26)
**Core value:** Ship five next actions that transform PortOS from siloed features into a connected, protected, and searchable system
-**Current focus:** Phase 4 (cross-domain insights engine) — Plan 01 complete, dashboard frontend next
+**Current focus:** Phase 4 (cross-domain insights engine) — Plans 01-02 complete, awaiting UI verification checkpoint
## Current Position
Phase: 4 of 5 (Cross-Domain Insights Engine) — IN PROGRESS
-Plan: 1 of 2 in current phase (04-01 complete)
-Status: Plan 04-01 complete — insights engine backend with 5 endpoints and client API functions
-Last activity: 2026-02-26 -- Plan 04-01 complete (insights service, routes, validation, client API)
+Plan: 2 of 2 in current phase (04-02 at human-verify checkpoint)
+Status: Plan 04-02 tasks 1-2 complete — Insights dashboard UI built, awaiting human verification (Task 3 checkpoint)
+Last activity: 2026-02-26 -- Plan 04-02 Tasks 1-2 complete (insights components, page, routes, nav)
-Progress: [███████░░░] 70%
+Progress: [████████░░] 80%
## Performance Metrics
@@ -46,9 +46,10 @@ Progress: [███████░░░] 70%
| 03-apple-health-integration | 2 | 180s | 180s |
| 03-apple-health-integration | 3 | ~15min | ~15min |
| 04-cross-domain-insights-engine | 1 | 174s | 174s |
+| 04-cross-domain-insights-engine | 2 | 238s | 238s |
**Recent Trend:**
-- Last 5 plans: 02-02 (~10min), 03-01 (210s), 03-02 (180s), 03-03 (~15min), 04-01 (174s)
+- Last 5 plans: 03-01 (210s), 03-02 (180s), 03-03 (~15min), 04-01 (174s), 04-02 (238s)
- Trend: stable (~2-15 min/plan)
*Updated after each plan completion*
@@ -87,6 +88,9 @@ Recent decisions affecting current work:
- [Phase 04-cross-domain-insights-engine plan 01]: CATEGORY_BLOOD_MAP covers 6 categories; other genome categories get empty matchedBloodValues (no blood analyte mapping available)
- [Phase 04-cross-domain-insights-engine plan 01]: LLM generation functions return { available: false, reason } (not throw) when provider unavailable or no taste data
- [Phase 04-cross-domain-insights-engine plan 01]: narrativeRefresh preserves previousText + previousGeneratedAt for client-side diff rendering
+- [Phase 04-cross-domain-insights-engine plan 02]: Insights nav entry is a single item (not expandable) — sub-tabs navigate from within the page
+- [Phase 04-cross-domain-insights-engine plan 02]: /insights added to isFullWidth paths in Layout.jsx for proper full-height rendering matching MeatSpace pattern
+- [Phase 04-cross-domain-insights-engine plan 02]: CrossDomainTab diff only shows after refresh triggers and previousText differs (trimmed comparison prevents false diffs)
### Pending Todos
@@ -99,5 +103,5 @@ None yet.
## Session Continuity
Last session: 2026-02-26
-Stopped at: Completed 04-01-PLAN.md — Insights engine backend (insightsService.js, routes, validation, client API)
+Stopped at: 04-02-PLAN.md Task 3 checkpoint:human-verify — Insights dashboard UI built, awaiting verification at http://localhost:5555/insights
Resume file: None
diff --git a/.planning/phases/04-cross-domain-insights-engine/04-02-SUMMARY.md b/.planning/phases/04-cross-domain-insights-engine/04-02-SUMMARY.md
new file mode 100644
index 0000000000..11c193b16d
--- /dev/null
+++ b/.planning/phases/04-cross-domain-insights-engine/04-02-SUMMARY.md
@@ -0,0 +1,181 @@
+---
+phase: 04-cross-domain-insights-engine
+plan: 02
+subsystem: insights-ui
+tags: [insights, genome, taste-identity, cross-domain, react, ui, diff-viewer]
+dependency_graph:
+ requires:
+ - client/src/services/api.js (getGenomeHealthCorrelations, getInsightThemes, getInsightNarrative, refreshInsightThemes, refreshInsightNarrative)
+ - /api/insights/* (5 endpoints from Plan 01)
+ - client/src/pages/MeatSpace.jsx (structural pattern reference)
+ - client/src/components/Layout.jsx (nav entry)
+ - client/src/App.jsx (route configuration)
+ provides:
+ - client/src/pages/Insights.jsx
+ - client/src/components/insights/ConfidenceBadge.jsx
+ - client/src/components/insights/InsightCard.jsx
+ - client/src/components/insights/ProvenancePanel.jsx
+ - client/src/components/insights/EmptyState.jsx
+ - client/src/components/insights/GenomeHealthTab.jsx
+ - client/src/components/insights/TasteIdentityTab.jsx
+ - client/src/components/insights/CrossDomainTab.jsx
+ - /insights/:tab routes (4 deep-linked sub-views)
+ affects:
+ - client/src/App.jsx (2 new routes)
+ - client/src/components/Layout.jsx (Insights nav entry, isFullWidth)
+ - client/package.json (react-diff-viewer-continued dependency)
+ - .changelog/v1.14.x.md
+tech_stack:
+ added:
+ - react-diff-viewer-continued (narrative before/after diff display)
+ patterns:
+ - Tabbed page at /:page/:tab with useParams for deep-linked URLs
+ - Promise.allSettled for parallel multi-domain data fetching in Overview
+ - Cache-first API with { available: false, reason } graceful degradation
+ - Collapsible sections pattern (CategorySection, ProvenancePanel, EvidenceList)
+ - MeatSpace structural pattern replicated for Insights (header + tab bar + scrollable content)
+key_files:
+ created:
+ - client/src/pages/Insights.jsx
+ - client/src/components/insights/ConfidenceBadge.jsx
+ - client/src/components/insights/InsightCard.jsx
+ - client/src/components/insights/ProvenancePanel.jsx
+ - client/src/components/insights/EmptyState.jsx
+ - client/src/components/insights/GenomeHealthTab.jsx
+ - client/src/components/insights/TasteIdentityTab.jsx
+ - client/src/components/insights/CrossDomainTab.jsx
+ modified:
+ - client/src/App.jsx
+ - client/src/components/Layout.jsx
+ - client/package.json
+ - .changelog/v1.14.x.md
+decisions:
+ - Insights nav entry placed as single item (not expandable) — sub-tabs navigate from within the page
+ - /insights added to isFullWidth paths in Layout.jsx to match MeatSpace full-height rendering pattern
+ - STRENGTH_TO_LEVEL maps tentative->weak, moderate->moderate, strong->strong for ConfidenceBadge consistency
+ - Overview tab uses Promise.allSettled so any single domain failure does not block the other cards
+ - CrossDomainTab diff view only appears after a refresh has been triggered and previousText differs from text (trimmed)
+ - Summary cards use navigate() (not Link) so the entire card area is clickable without nested link issues
+metrics:
+ duration: 238s
+ completed: 2026-02-26
+ tasks_completed: 2
+ files_created: 8
+ files_modified: 4
+---
+
+# Phase 4 Plan 2: Insights Dashboard UI Summary
+
+**One-liner:** Tabbed Insights dashboard at `/insights/:tab` with genome-health correlation cards, LLM taste-identity theme cards, and cross-domain narrative with ReactDiffViewer diff toggle — all deep-linked and following established PortOS design patterns.
+
+## What Was Built
+
+### Dependency Added
+
+`react-diff-viewer-continued` installed in `client/package.json` for the narrative before/after diff display in CrossDomainTab.
+
+### Shared Components (`client/src/components/insights/`)
+
+**`ConfidenceBadge.jsx`** — Presentational badge with 5 confidence levels:
+- `strong` → green (`port-success`)
+- `moderate` → yellow (`port-warning`)
+- `weak` → red (`port-error`)
+- `significant` → deeper red
+- `unknown` → gray
+
+**`InsightCard.jsx`** — Shared card shell with `bg-port-card border border-port-border rounded-lg p-4` layout, header row with title + badge, subtitle, inline source pills, and `children` slot.
+
+**`ProvenancePanel.jsx`** — Collapsed by default. Click ChevronRight/Down to expand. Renders reference list with study name, publication year, database source badge.
+
+**`EmptyState.jsx`** — Centered Info icon + message + optional NavLink button. Guides users to relevant data import pages.
+
+### Tab Components
+
+**`GenomeHealthTab.jsx`** (INS-01, INS-03):
+- Fetches `getGenomeHealthCorrelations()` on mount
+- Loading: skeleton cards with pulse animation
+- Empty state: links to `/meatspace/genome` for upload
+- Available: summary stats bar + collapsible CategorySection components
+- Each category section: icon, label, marker count, expand/collapse toggle
+- Each marker card: name + gene subtitle, confidence badge mapped from marker status, description, implications, matched blood values or "No blood test on record" link, collapsible ProvenancePanel
+
+**`TasteIdentityTab.jsx`** (INS-02, INS-03):
+- Fetches `getInsightThemes()` on mount
+- Empty state `no_taste_data` → links to `/digital-twin/taste`
+- Empty state `not_generated` → explanation + Generate Themes button
+- Available: header bar with theme count, relative time, model, Refresh button
+- Theme cards in 2-column grid on lg screens with EvidenceList (collapsible)
+
+**`CrossDomainTab.jsx`** (INS-04, INS-03):
+- Fetches `getInsightNarrative()` on mount
+- Not generated → explanation + Generate Narrative button
+- Available: narrative text rendered paragraph-by-paragraph, generatedAt relative time, model badge
+- Refresh button: calls `refreshInsightNarrative()`, shows loading spinner
+- After refresh: "Show changes" button appears if `previousText` differs from `text` (trimmed comparison)
+- Diff view: ReactDiffViewer with `splitView=false, useDarkTheme, hideLineNumbers` and port-* color overrides
+
+### Page: `client/src/pages/Insights.jsx`
+
+Four-tab page with `TABS` config array and `VALID_TAB_IDS` Set for safe param validation.
+
+**Overview tab** (inline in Insights.jsx):
+- Parallel fetches via `Promise.allSettled` — 3 domains load independently
+- 3 clickable domain summary cards in responsive grid (1 col mobile, 3 cols lg)
+- Each card: icon, label, ArrowRight (highlights on hover), key stat, top insight text, confidence badge, source tags
+- Card content degrades gracefully when data unavailable
+
+**Routing** (`client/src/App.jsx`):
+```jsx
+<Route path="insights" element={<Navigate to="/insights/overview" replace />} />
+<Route path="insights/:tab" element={<Insights />} />
+```
+Inserted alphabetically between `instances` and `meatspace`.
+
+**Navigation** (`client/src/components/Layout.jsx`):
+```javascript
+{ to: '/insights/overview', label: 'Insights', icon: Lightbulb, single: true }
+```
+Positioned between Instances and MeatSpace (alphabetical).
+`/insights` added to `isFullWidth` check for full-height layout rendering.
+
+## Verification Results
+
+- Vite build: success (✓ 3388 modules transformed, 4.42s)
+- All 7 component files: FOUND
+- Insights.jsx: FOUND
+- commits 832c561 and 4cd9ee9: FOUND
+
+## Commits
+
+| Task | Hash | Description |
+|------|------|-------------|
+| Task 1 | 832c561 | feat(04-02): install react-diff-viewer-continued and create shared insight components and tab views |
+| Task 2 | 4cd9ee9 | feat(04-02): create Insights page with 4 tabs, wire App.jsx routes and Layout.jsx navigation |
+
+## Deviations from Plan
+
+### Auto-added Missing Feature
+
+**[Rule 2 - Missing functionality] Added /insights to isFullWidth in Layout.jsx**
+- **Found during:** Task 2
+- **Issue:** Without adding `/insights` to the `isFullWidth` path check, the Insights page would have rendered in the constrained `max-w-7xl` wrapper with padding, not the full-height flex layout matching MeatSpace (which is the referenced structural pattern)
+- **Fix:** Added `location.pathname.startsWith('/insights')` to the isFullWidth check
+- **Files modified:** `client/src/components/Layout.jsx`
+- **Commit:** 4cd9ee9
+
+## Self-Check: PASSED
+
+- client/src/components/insights/ConfidenceBadge.jsx: FOUND
+- client/src/components/insights/ProvenancePanel.jsx: FOUND
+- client/src/components/insights/EmptyState.jsx: FOUND
+- client/src/components/insights/InsightCard.jsx: FOUND
+- client/src/components/insights/GenomeHealthTab.jsx: FOUND
+- client/src/components/insights/TasteIdentityTab.jsx: FOUND
+- client/src/components/insights/CrossDomainTab.jsx: FOUND
+- client/src/pages/Insights.jsx: FOUND
+- commit 832c561: FOUND
+- commit 4cd9ee9: FOUND
+
+## Status
+
+Tasks 1-2 complete and committed. Task 3 is a human-verify checkpoint — UI verification pending.