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-2677]): reframe Character page around the human, demote D&D mechanics
[._.]/ Adam Eivy6dc012eeac26
diff --git a/client/src/pages/CharacterSheet.framing.test.jsx b/client/src/pages/CharacterSheet.framing.test.jsxnew file mode 100644index 0000000000..c741a3acf7--- /dev/null+++ b/client/src/pages/CharacterSheet.framing.test.jsx@@ -0,0 +1,119 @@+import { describe, it, expect, vi, beforeEach } from 'vitest';+import { render, screen, waitFor, fireEvent } from '@testing-library/react';+import { MemoryRouter } from 'react-router-dom';++// Coverage for the human-centered Character reframe (#2677): the page centers the human+// (name/avatar/age-level, with skills/goals/metrics as primary content), prompts for a birth+// date when the age-level is unknown, and demotes the D&D damage/rest/dice/XP mechanics into a+// collapsed "legacy" section that is closed by default. The RPG endpoints/events[] are kept+// for back-compat — this suite only asserts the framing, not their removal.++const get = vi.fn();++vi.mock('../services/api', () => ({+ default: { get: (...a) => get(...a), post: vi.fn(), put: vi.fn() },+ generateAvatar: vi.fn(() => Promise.resolve({})),+}));++// GoalsCard (#2675) owns its own mount-effect fetch — stub it so this suite stays scoped to+// the framing and settles synchronously (a live child trips the act(...) guard).+vi.mock('../components/character/GoalsCard', () => ({ default: () => null }));++vi.mock('../services/socket', () => ({+ default: { on: vi.fn(), off: vi.fn(), emit: vi.fn() },+}));++vi.mock('../components/ui/Toast', () => ({+ default: { error: vi.fn(), success: vi.fn(), info: vi.fn() },+}));++// Spy on navigation so the birth-date prompt's deep link is assertable.+const navigate = vi.fn();+vi.mock('react-router-dom', async (importOriginal) => {+ const actual = await importOriginal();+ return { ...actual, useNavigate: () => navigate };+});++import CharacterSheet from './CharacterSheet';++const BASE_CHAR = {+ name: 'Ada Lovelace',+ class: 'Analyst',+ level: 42,+ hp: 15,+ maxHp: 15,+ xp: 1200,+ ageYears: 42.5,+ avatarPath: null,+ events: [],+ metrics: [],+ skills: [],+};++const renderChar = async (overrides = {}) => {+ get.mockResolvedValue({ ...BASE_CHAR, ...overrides });+ render(+ <MemoryRouter>+ <CharacterSheet />+ </MemoryRouter>,+ );+ // Wait for load to resolve; the header is always present once loaded.+ await waitFor(() => expect(screen.getByRole('heading', { name: 'Character' })).toBeInTheDocument());+};++beforeEach(() => {+ vi.clearAllMocks();+});++describe('human-centered framing', () => {+ it('renders a human "Character" header, not "Character Sheet"', async () => {+ await renderChar();+ expect(screen.getByRole('heading', { name: 'Character' })).toBeInTheDocument();+ expect(screen.queryByText('Character Sheet')).not.toBeInTheDocument();+ });++ it('shows the age-level badge when a level is derived', async () => {+ await renderChar({ level: 42 });+ expect(screen.getByText('42')).toBeInTheDocument();+ expect(screen.getByText('Level')).toBeInTheDocument();+ expect(screen.queryByText('Set your birth date')).not.toBeInTheDocument();+ });++ it('falls back to human-centered placeholders for an unnamed person', async () => {+ await renderChar({ name: '', class: '' });+ expect(screen.getByText('Your name')).toBeInTheDocument();+ expect(screen.getByText('Add a title')).toBeInTheDocument();+ });+});++describe('birth-date prompt', () => {+ it('prompts to set a birth date when the level is null, deep-linking to the age editor', async () => {+ await renderChar({ level: null, ageYears: null });+ const prompt = screen.getByText('Set your birth date');+ expect(prompt).toBeInTheDocument();+ // The badge number is gone — no NaN / "—" level shown as a value.+ expect(screen.queryByText('Level')).not.toBeInTheDocument();++ fireEvent.click(prompt);+ expect(navigate).toHaveBeenCalledWith('/meatspace/age');+ });+});++describe('demoted D&D mechanics', () => {+ it('hides the RPG damage/rest/xp actions behind a collapsed legacy section by default', async () => {+ await renderChar();+ // Collapsed by default → the RPG actions are not in the DOM.+ expect(screen.queryByText('Take Damage')).not.toBeInTheDocument();+ expect(screen.queryByText('Event Log')).not.toBeInTheDocument();+ // But the section toggle is present.+ expect(screen.getByRole('button', { name: /RPG mechanics/i })).toBeInTheDocument();+ });++ it('reveals the legacy mechanics when the section is expanded', async () => {+ await renderChar();+ fireEvent.click(screen.getByRole('button', { name: /RPG mechanics/i }));+ expect(screen.getByText('Take Damage')).toBeInTheDocument();+ expect(screen.getByText('Event Log')).toBeInTheDocument();+ expect(screen.getByText('Sync JIRA')).toBeInTheDocument();+ });+});diff --git a/client/src/pages/CharacterSheet.jsx b/client/src/pages/CharacterSheet.jsxindex 16f7499741..2662168252 100644--- a/client/src/pages/CharacterSheet.jsx+++ b/client/src/pages/CharacterSheet.jsx@@ -1,6 +1,7 @@import { useState, useEffect, useCallback, useRef } from 'react';+import { useNavigate } from 'react-router-dom';import {- Sword, Star, Moon, ScrollText, Shield, Heart,+ Sword, Star, Moon, ScrollText, Heart, UserRound, Cake,Sparkles, RefreshCw, Dices, X, ChevronDown, Zap, Image, Activity} from 'lucide-react';import BrailleSpinner from '../components/BrailleSpinner';@@ -147,10 +148,15 @@ function MetricsCard({ metrics }) {}export default function CharacterSheet() {+ const navigate = useNavigate();const [char, setChar] = useState(null);const [loading, setLoading] = useState(true);const [loadError, setLoadError] = useState(null);const [activeAction, setActiveAction] = useState(null);+ // The D&D damage/rest/dice/XP mechanics are legacy relative to the human-centered sheet+ // (#2677) — kept for back-compat with existing character.json + the RPG endpoints, but+ // collapsed out of the primary view so age-level / skills / goals / metrics lead. Opt-in.+ const [showLegacy, setShowLegacy] = useState(false);const [editingName, setEditingName] = useState(false);const [editingClass, setEditingClass] = useState(false);const [nameVal, setNameVal] = useState('');@@ -400,8 +406,8 @@ export default function CharacterSheet() {{/* Header */}<div className="flex items-center justify-between px-6 py-4 border-b border-port-border bg-port-card"><div className="flex items-center gap-3">- <Shield className="w-6 h-6 text-port-accent" />- <h1 className="text-xl font-semibold text-white">Character Sheet</h1>+ <UserRound className="w-6 h-6 text-port-accent" />+ <h1 className="text-xl font-semibold text-white">Character</h1></div><buttononClick={() => { setLoading(true); load(); }}@@ -429,7 +435,7 @@ export default function CharacterSheet() {<img src={char.avatarPath} alt={char.name} className="w-full h-full object-cover" />) : (<div className="w-full h-full flex items-center justify-center text-gray-600">- <Shield className="w-8 h-8" />+ <UserRound className="w-8 h-8" /></div>)}{/* Progress bar overlay */}@@ -481,10 +487,10 @@ export default function CharacterSheet() {type="button"onClick={startNameEdit}disabled={nameSaving}- aria-label={`Edit character name (currently ${char.name || 'Unnamed Hero'})`}+ aria-label={`Edit your name (currently ${char.name || 'Your name'})`}className="text-2xl font-bold text-white cursor-pointer hover:text-port-accent transition-colors truncate text-left bg-transparent border-0 p-0 disabled:opacity-60 disabled:cursor-wait">- {char.name || 'Unnamed Hero'}+ {char.name || 'Your name'}</button>)}</div>@@ -503,52 +509,58 @@ export default function CharacterSheet() {onClick={() => setEditingClass(true)}{...clickableProps(() => setEditingClass(true))}className="text-sm text-gray-400 cursor-pointer hover:text-port-accent transition-colors"- title="Click to edit class"+ title="Click to edit your title">- {char.class || 'Adventurer'}+ {char.class || 'Add a title'}</span>)}</div></div>- {/* Level Badge */}+ {/* Level Badge — life experience = age (#2673). When no birthDate is set the level+ is null, so instead of a "—" badge we prompt the user to set their birth date,+ deep-linking to the age editor where the field actually lives. */}<div className="flex-shrink-0 flex items-center gap-3">- <div className="relative w-20 h-20 flex items-center justify-center rounded-full border-2 border-port-accent bg-port-bg">- <div className="text-center">- <div className="text-2xl font-bold text-port-accent">{char.level ?? '—'}</div>- <div className="text-[10px] uppercase tracking-wider text-gray-500">Level</div>+ {char.level != null ? (+ <div className="relative w-20 h-20 flex items-center justify-center rounded-full border-2 border-port-accent bg-port-bg">+ <div className="text-center">+ <div className="text-2xl font-bold text-port-accent">{char.level}</div>+ <div className="text-[10px] uppercase tracking-wider text-gray-500">Level</div>+ </div></div>- </div>+ ) : (+ <button+ type="button"+ onClick={() => navigate('/meatspace/age')}+ aria-label="Set your birth date to show your level"+ title="Set your birth date"+ className="w-20 h-20 flex flex-col items-center justify-center gap-1 rounded-full border-2 border-dashed border-port-accent/60 bg-port-bg text-port-accent hover:bg-port-accent/10 transition-colors px-1 text-center"+ >+ <Cake className="w-5 h-5" />+ <span className="text-[10px] leading-tight">Set birth date</span>+ </button>+ )}</div></div>- {/* HP Bar */}- <div className="mt-4">- <div className="flex items-center justify-between mb-1">- <div className="flex items-center gap-1.5 text-sm font-medium text-gray-300">- <Heart className="w-4 h-4 text-port-error" />- HP+ {/* Birth-date prompt — the human-centered level is age (#2673). Until a birth date+ is on record there is no level to show, so surface a clear call to set it,+ deep-linking to the age editor where the field lives. */}+ {char.level == null && (+ <button+ type="button"+ onClick={() => navigate('/meatspace/age')}+ className="mt-4 w-full flex items-center gap-3 px-4 py-3 rounded-lg border border-dashed border-port-accent/50 bg-port-accent/5 hover:bg-port-accent/10 text-left transition-colors"+ >+ <Cake className="w-5 h-5 text-port-accent flex-shrink-0" />+ <div className="min-w-0">+ <div className="text-sm font-medium text-white">Set your birth date</div>+ <div className="text-xs text-gray-400">+ Your level is your life experience — each year lived is a level. Add your birth date to see it.+ </div></div>- <span className="text-sm text-gray-400">- {char.hp} / {char.maxHp}- </span>- </div>- <div className="h-5 bg-port-bg rounded-full overflow-hidden border border-port-border">- <div- className={`h-full rounded-full transition-all duration-500 ease-out ${hpColor(hpPct)}`}- style={{ width: `${hpPct}%` }}- />- </div>- </div>-- {/* XP — a cumulative stat now (no longer a level-progress bar; level is age-based) */}- <div className="mt-3 flex items-center justify-between">- <div className="flex items-center gap-1.5 text-sm font-medium text-gray-300">- <Sparkles className="w-4 h-4 text-port-warning" />- XP- </div>- <span className="text-sm text-gray-400">{char.xp}</span>- </div>+ </button>+ )}{/* Progress toward the next birthday (fractional part of the current year of life) */}{char.level != null && (@@ -580,8 +592,51 @@ export default function CharacterSheet() {{/* Skills — derived per-domain from real PortOS usage (#2674) */}<SkillsCard skills={char.skills} />- {/* Quick Actions */}- <div className="bg-port-card border border-port-border rounded-xl p-4">+ {/* Legacy RPG mechanics — demoted out of the primary view (#2677). Kept for+ back-compat with existing character.json and the damage/rest/dice/XP + JIRA/task+ sync endpoints (they still work); just collapsed by default so the human-centered+ content leads. */}+ <div className="bg-port-card border border-port-border rounded-xl">+ <button+ type="button"+ onClick={() => setShowLegacy(v => !v)}+ aria-expanded={showLegacy}+ className="w-full flex items-center gap-2 px-4 py-3 text-left text-gray-300 hover:text-white transition-colors"+ >+ <Dices className="w-4 h-4 text-gray-400" />+ <span className="text-sm font-medium">RPG mechanics</span>+ <span className="text-xs text-gray-500 hidden sm:inline">— legacy HP, XP, dice & sync</span>+ <ChevronDown className={`w-4 h-4 text-gray-500 ml-auto transition-transform ${showLegacy ? 'rotate-180' : ''}`} />+ </button>++ {showLegacy && (+ <div className="px-4 pb-4 pt-2 border-t border-port-border space-y-4">+ {/* HP + XP — flat, backward-compatible mechanics (no longer scaled off level) */}+ <div className="grid grid-cols-1 sm:grid-cols-2 gap-4">+ <div>+ <div className="flex items-center justify-between mb-1">+ <div className="flex items-center gap-1.5 text-sm font-medium text-gray-300">+ <Heart className="w-4 h-4 text-port-error" />+ HP+ </div>+ <span className="text-sm text-gray-400">{char.hp} / {char.maxHp}</span>+ </div>+ <div className="h-5 bg-port-bg rounded-full overflow-hidden border border-port-border">+ <div+ className={`h-full rounded-full transition-all duration-500 ease-out ${hpColor(hpPct)}`}+ style={{ width: `${hpPct}%` }}+ />+ </div>+ </div>+ <div className="flex items-center justify-between sm:justify-start sm:gap-2 self-end pb-1">+ <div className="flex items-center gap-1.5 text-sm font-medium text-gray-300">+ <Sparkles className="w-4 h-4 text-port-warning" />+ XP+ </div>+ <span className="text-sm text-gray-400">{char.xp}</span>+ </div>+ </div>+<div className="flex flex-wrap gap-2"><buttononClick={() => toggleAction('damage')}@@ -759,15 +814,15 @@ export default function CharacterSheet() {</div></div>)}- </div>- {/* Event Log */}- <div className="bg-port-card border border-port-border rounded-xl flex flex-col min-h-0">- <div className="flex items-center gap-2 px-4 py-3 border-b border-port-border">- <ScrollText className="w-4 h-4 text-gray-400" />- <h3 className="text-sm font-medium text-gray-300">Event Log</h3>- <span className="text-xs text-gray-500">({char.events?.length || 0} entries)</span>- </div>+ {/* Event Log — the legacy events[] feed (damage/rest/xp/sync). Kept for+ back-compat; lives inside the collapsed legacy section. */}+ <div className="bg-port-bg border border-port-border rounded-xl flex flex-col min-h-0">+ <div className="flex items-center gap-2 px-4 py-3 border-b border-port-border">+ <ScrollText className="w-4 h-4 text-gray-400" />+ <h3 className="text-sm font-medium text-gray-300">Event Log</h3>+ <span className="text-xs text-gray-500">({char.events?.length || 0} entries)</span>+ </div><div className="overflow-y-auto max-h-[400px] divide-y divide-port-border/50">{(!char.events || char.events.length === 0) ? (<div className="px-4 py-8 text-center text-gray-500 text-sm">@@ -820,7 +875,10 @@ export default function CharacterSheet() {);}))}- </div>+ </div>+ </div>+ </div>+ )}</div></div></div>