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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
feat([issue-715]): provenance chips on Insights theme cards
[._.]/ Adam Eivy258e7e4dafbf
diff --git a/client/src/components/insights/InsightCard.jsx b/client/src/components/insights/InsightCard.jsxindex eca7ca0d45..2ea69dcd21 100644--- a/client/src/components/insights/InsightCard.jsx+++ b/client/src/components/insights/InsightCard.jsx@@ -1,4 +1,18 @@-export default function InsightCard({ title, subtitle, badge, children, sources, className = '' }) {+import ProvenanceChip from '../ui/ProvenanceChip';++// Generic card for an AI-generated or rule-derived insight. The header carries an+// optional confidence `badge` (how strong) and an optional `provenance` chip (how+// it was derived + what would change it) — the two answer different questions, so+// a card can show both. `provenance` is the shared source-chip affordance from the+// health views, surfaced here so every insight surface can declare "why am I seeing+// this?" without re-implementing the popover.+//+// provenance: { level, label?, explainer?, whatWouldChange? }+//+// `level` is a provenance taxonomy id (data-backed | inferred | experimental |+// speculative); `explainer` / `whatWouldChange` override the per-level defaults for+// surface-specific copy (e.g. taste themes vs. health markers).+export default function InsightCard({ title, subtitle, badge, provenance, children, sources, className = '' }) {return (<div className={`bg-port-card border border-port-border rounded-lg p-4 ${className}`}><div className="flex items-start justify-between gap-2 mb-1">@@ -8,7 +22,19 @@ export default function InsightCard({ title, subtitle, badge, children, sources,<p className="text-xs text-gray-500 mt-0.5">{subtitle}</p>)}</div>- {badge && <div className="shrink-0">{badge}</div>}+ {(badge || provenance) && (+ <div className="shrink-0 flex items-center gap-1.5">+ {provenance && (+ <ProvenanceChip+ level={provenance.level}+ label={provenance.label}+ explainer={provenance.explainer}+ whatWouldChange={provenance.whatWouldChange}+ />+ )}+ {badge}+ </div>+ )}</div>{sources && sources.length > 0 && (diff --git a/client/src/components/insights/InsightCard.test.jsx b/client/src/components/insights/InsightCard.test.jsxnew file mode 100644index 0000000000..5812ea7bcc--- /dev/null+++ b/client/src/components/insights/InsightCard.test.jsx@@ -0,0 +1,54 @@+import { describe, it, expect } from 'vitest';+import { render, screen, fireEvent } from '@testing-library/react';++import InsightCard from './InsightCard';++describe('InsightCard', () => {+ it('renders the title and children', () => {+ render(+ <InsightCard title="A theme">+ <p>narrative body</p>+ </InsightCard>,+ );+ expect(screen.getByRole('heading', { name: 'A theme' })).toBeTruthy();+ expect(screen.getByText('narrative body')).toBeTruthy();+ });++ it('renders no provenance chip when provenance is absent', () => {+ render(<InsightCard title="No prov" badge={<span>Strong</span>} />);+ expect(screen.queryByRole('button', { name: /tap for how this is derived/i })).toBeNull();+ });++ it('renders a provenance chip from the provenance prop and reveals override copy on click', () => {+ render(+ <InsightCard+ title="Inferred theme"+ provenance={{+ level: 'inferred',+ explainer: 'Modeled from your taste profile.',+ whatWouldChange: 'Answer more of the profile.',+ }}+ />,+ );+ const chip = screen.getByRole('button', { name: /inferred/i });+ expect(chip).toBeTruthy();+ expect(screen.queryByText('What would change this?')).toBeNull();++ fireEvent.click(chip);++ expect(screen.getByText('Modeled from your taste profile.')).toBeTruthy();+ expect(screen.getByText('Answer more of the profile.')).toBeTruthy();+ });++ it('renders both the provenance chip and the confidence badge together', () => {+ render(+ <InsightCard+ title="Both axes"+ provenance={{ level: 'inferred' }}+ badge={<span>Strong pattern</span>}+ />,+ );+ expect(screen.getByRole('button', { name: /inferred/i })).toBeTruthy();+ expect(screen.getByText('Strong pattern')).toBeTruthy();+ });+});diff --git a/client/src/components/insights/TasteIdentityTab.jsx b/client/src/components/insights/TasteIdentityTab.jsxindex f6a4694101..d9d814c37b 100644--- a/client/src/components/insights/TasteIdentityTab.jsx+++ b/client/src/components/insights/TasteIdentityTab.jsx@@ -13,6 +13,17 @@ const STRENGTH_TO_LEVEL = {tentative: 'weak'};+// Themes are modeled by the LLM from the taste profile — never something the user+// stated outright — so every card declares an `inferred` provenance. Confidence+// (strong/moderate/tentative) is a separate axis carried by ConfidenceBadge.+const THEME_PROVENANCE = {+ level: 'inferred',+ explainer:+ 'Surfaced by AI from your completed taste profile — a cross-domain pattern it inferred across your aesthetics, media, food, and values, not something you stated directly.',+ whatWouldChange:+ 'Answering more of your taste profile, or regenerating themes, refines or replaces this pattern.',+};+function EvidenceList({ evidence }) {const [expanded, setExpanded] = useState(false);if (!evidence || evidence.length === 0) return null;@@ -48,6 +59,7 @@ function ThemeCard({ theme }) {return (<InsightCardtitle={theme.title}+ provenance={THEME_PROVENANCE}badge={<ConfidenceBadgelevel={level}