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
extract a shared CollapsibleSection primitive so disclosure headers report aria-expanded (#3853)
[._.]/ Adam Eivy6c5a9ebdfef4
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex d785cd78e1..0f19a98bc5 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -30,3 +30,4 @@- The Code Review Defaults panel now names every CLI reviewer in its help text, generated from the reviewer roster itself — the sentence used to spell them out by hand and fell behind twice as new reviewers shipped, telling users their CLI reviewers ran a different way than they do.- The remaining trigger-anchored dropdowns — "Run on App" on a scheduled task, and the Share and Sync buttons on series and universe cards — now use the same shared popover-positioning hook as the notification panel. "Run on App" opened a panel pinned to its button's left edge that merely got narrower on a phone rather than moving, so it ran off the right edge; the Share and Sync menus always opened downward even with no room below. All three now clamp into the viewport, flip when there is no room, and stay attached to their button as the page scrolls.- The theme switcher, the media collection picker, and the Shell photo composer now dismiss through the shared click-outside hook instead of three private copies of the same two-ref check, so the rule that a portaled panel counts as "inside" its own trigger lives in one place. Escape still closes each of them.+- Collapsible section headers in the canon cards, the character detail editor, and the digital-twin interview analysis card now announce their open/closed state to a screen reader. They were five separate hand-rolled copies of the same header, none of which reported that state, and all five now share one primitive so a layout fix lands in one place instead of three.diff --git a/client/src/components/digital-twin/InterviewAnalysisCard.jsx b/client/src/components/digital-twin/InterviewAnalysisCard.jsxindex 2a48776ca7..7fabf012b6 100644--- a/client/src/components/digital-twin/InterviewAnalysisCard.jsx+++ b/client/src/components/digital-twin/InterviewAnalysisCard.jsx@@ -1,20 +1,22 @@-import { useState } from 'react';-import { ChevronDown, ChevronRight, FileText, TrendingUp, Layers, BarChart3 } from 'lucide-react';+import { FileText, TrendingUp, Layers, BarChart3 } from 'lucide-react';+import CollapsibleSection from '../ui/CollapsibleSection';-function CollapsibleSection({ title, icon: Icon, children, defaultOpen = false }) {- const [open, setOpen] = useState(defaultOpen);+// Local wrapper so the four call sites below keep the card's rounded-border+// chrome and `title`-named prop while the toggle behaviour (and aria-expanded)+// comes from the shared primitive.+function AnalysisSection({ title, icon, children, defaultOpen = false }) {return (- <div className="border border-port-border rounded-lg overflow-hidden">- <button- onClick={() => setOpen(!open)}- className="w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-300 hover:bg-port-bg transition-colors"- >- {open ? <ChevronDown size={14} /> : <ChevronRight size={14} />}- <Icon size={14} />- <span>{title}</span>- </button>- {open && <div className="px-3 pb-3 text-sm">{children}</div>}- </div>+ <CollapsibleSection+ size="lg"+ icon={icon}+ label={title}+ defaultOpen={defaultOpen}+ className="border border-port-border rounded-lg overflow-hidden"+ buttonClassName="px-3 py-2"+ bodyClassName="px-3 pb-3 text-sm"+ >+ {children}+ </CollapsibleSection>);}@@ -62,7 +64,7 @@ export default function InterviewAnalysisCard({ analysisResult }) {{/* Collapsible sections */}<div className="space-y-1">{traitCount > 0 && (- <CollapsibleSection title="Trait Updates" icon={BarChart3}>+ <AnalysisSection title="Trait Updates" icon={BarChart3}><div className="space-y-2">{traitsUpdated.bigFive && (<div>@@ -106,11 +108,11 @@ export default function InterviewAnalysisCard({ analysisResult }) {</div>)}</div>- </CollapsibleSection>+ </AnalysisSection>)}{dimensionCount > 0 && (- <CollapsibleSection title="New Dimensions" icon={Layers}>+ <AnalysisSection title="New Dimensions" icon={Layers}><div className="space-y-2">{newDimensions.map((dim, i) => (<div key={i} className="bg-port-bg rounded p-2">@@ -125,11 +127,11 @@ export default function InterviewAnalysisCard({ analysisResult }) {</div>))}</div>- </CollapsibleSection>+ </AnalysisSection>)}{(docsCreatedCount > 0 || docsUpdatedCount > 0) && (- <CollapsibleSection title="Document Changes" icon={FileText}>+ <AnalysisSection title="Document Changes" icon={FileText}><div className="space-y-1">{(documentsCreated || []).map((f, i) => (<div key={`c-${i}`} className="text-xs text-port-success">+ {f}</div>@@ -138,13 +140,13 @@ export default function InterviewAnalysisCard({ analysisResult }) {<div key={`u-${i}`} className="text-xs text-port-warning">~ {f}</div>))}</div>- </CollapsibleSection>+ </AnalysisSection>)}{rawAnalysis && (- <CollapsibleSection title="Analysis Summary" icon={TrendingUp} defaultOpen>+ <AnalysisSection title="Analysis Summary" icon={TrendingUp} defaultOpen><p className="text-xs text-gray-300 whitespace-pre-wrap">{rawAnalysis}</p>- </CollapsibleSection>+ </AnalysisSection>)}</div></div>diff --git a/client/src/components/pipeline/CanonCard.jsx b/client/src/components/pipeline/CanonCard.jsxindex 6bf0184506..389e96118c 100644--- a/client/src/components/pipeline/CanonCard.jsx+++ b/client/src/components/pipeline/CanonCard.jsx@@ -11,7 +11,7 @@*/import { useEffect, useRef, useState } from 'react';-import { Loader2, ImagePlus, ImageUp, WandSparkles, Lock, Unlock, Shirt, Plus, Trash2, X, ChevronDown, ChevronRight, Star, Square, BookOpen, ScanText } from 'lucide-react';+import { Loader2, ImagePlus, ImageUp, WandSparkles, Lock, Unlock, Shirt, Plus, Trash2, X, Star, Square, BookOpen, ScanText } from 'lucide-react';import useMediaJobProgress from '../../hooks/useMediaJobProgress';import useRowDraft from '../../hooks/useRowDraft';import useFieldDraft from '../../hooks/useFieldDraft';@@ -24,6 +24,7 @@ import ObjectAttachmentsEditor from '../universe/ObjectAttachmentsEditor';import CharacterReferenceSheetPanel from '../universe/CharacterReferenceSheetPanel';import CharacterLoraChip from '../loraTraining/CharacterLoraChip';import Pill from '../ui/Pill';+import CollapsibleSection from '../ui/CollapsibleSection';import { BIBLE_LIMITS } from '../../lib/bibleLimits';// Place metadata enums — kept in lock-step with `PLACE_INT_EXT` and@@ -147,62 +148,63 @@ function RevealTimingField({ entry, editable, onPatch }) {);}return (- <details className="mt-2 group">- <summary className="cursor-pointer list-none flex items-center gap-1 text-[10px] uppercase tracking-wider text-gray-500 hover:text-gray-300">- <ChevronRight size={11} className="shrink-0 group-open:hidden" />- <ChevronDown size={11} className="hidden shrink-0 group-open:inline" />- Reveal timing (spoiler scoping)- {gated ? <span className="ml-1 text-port-warning normal-case tracking-normal">· gated</span> : null}- </summary>- <div className="mt-1.5 space-y-2 pl-3 border-l border-port-border">- <div className="flex flex-wrap items-center gap-3">- <div className="flex flex-col gap-0.5">- <label htmlFor={`${idBase}-issue`} className="text-[10px] uppercase tracking-wider text-gray-500">- Reveal in issue #- </label>- <input- id={`${idBase}-issue`}- type="number"- min={1}- max={BIBLE_LIMITS.REVEAL_ISSUE_MAX}- value={Number.isInteger(entry.revealIssue) ? entry.revealIssue : ''}- onChange={(e) => {- const v = e.target.value.trim();- const n = v === '' ? null : Math.trunc(Number(v));- onPatch({ revealIssue: Number.isInteger(n) && n >= 1 ? n : null });- }}- placeholder="—"- className="w-20 px-2 py-1 text-xs bg-port-bg border border-port-border rounded text-gray-200"- />- </div>- <label htmlFor={`${idBase}-spoiler`} className="flex items-center gap-1.5 text-[11px] text-gray-400 mt-3">- <input- id={`${idBase}-spoiler`}- type="checkbox"- checked={entry.spoiler === true}- onChange={(e) => onPatch({ spoiler: e.target.checked })}- className="accent-port-warning"- />- Hard spoiler (never in drafting)- </label>- </div>+ <CollapsibleSection+ className="mt-2"+ label={+ <>+ Reveal timing (spoiler scoping)+ {gated ? <span className="ml-1 text-port-warning normal-case tracking-normal">· gated</span> : null}+ </>+ }+ bodyClassName="mt-1.5 space-y-2 pl-3 border-l border-port-border"+ >+ <div className="flex flex-wrap items-center gap-3"><div className="flex flex-col gap-0.5">- <label htmlFor={`${idBase}-surface`} className="text-[10px] uppercase tracking-wider text-gray-500">- Surface descriptor (pre-reveal stand-in)+ <label htmlFor={`${idBase}-issue`} className="text-[10px] uppercase tracking-wider text-gray-500">+ Reveal in issue #</label>- <textarea- id={`${idBase}-surface`}- value={surfaceDraft.value}- onChange={surfaceDraft.onChange}- onBlur={surfaceDraft.onBlur}- rows={2}- maxLength={BIBLE_LIMITS.SURFACE_DESCRIPTOR_MAX}- placeholder="What the world looks like BEFORE the reveal (e.g. "the locked east wing"). Substituted into drafting context until the reveal issue."- className="w-full px-2 py-1 text-xs bg-port-bg border border-port-border rounded text-gray-200 whitespace-pre-wrap"+ <input+ id={`${idBase}-issue`}+ type="number"+ min={1}+ max={BIBLE_LIMITS.REVEAL_ISSUE_MAX}+ value={Number.isInteger(entry.revealIssue) ? entry.revealIssue : ''}+ onChange={(e) => {+ const v = e.target.value.trim();+ const n = v === '' ? null : Math.trunc(Number(v));+ onPatch({ revealIssue: Number.isInteger(n) && n >= 1 ? n : null });+ }}+ placeholder="—"+ className="w-20 px-2 py-1 text-xs bg-port-bg border border-port-border rounded text-gray-200"/></div>+ <label htmlFor={`${idBase}-spoiler`} className="flex items-center gap-1.5 text-[11px] text-gray-400 mt-3">+ <input+ id={`${idBase}-spoiler`}+ type="checkbox"+ checked={entry.spoiler === true}+ onChange={(e) => onPatch({ spoiler: e.target.checked })}+ className="accent-port-warning"+ />+ Hard spoiler (never in drafting)+ </label>+ </div>+ <div className="flex flex-col gap-0.5">+ <label htmlFor={`${idBase}-surface`} className="text-[10px] uppercase tracking-wider text-gray-500">+ Surface descriptor (pre-reveal stand-in)+ </label>+ <textarea+ id={`${idBase}-surface`}+ value={surfaceDraft.value}+ onChange={surfaceDraft.onChange}+ onBlur={surfaceDraft.onBlur}+ rows={2}+ maxLength={BIBLE_LIMITS.SURFACE_DESCRIPTOR_MAX}+ placeholder="What the world looks like BEFORE the reveal (e.g. "the locked east wing"). Substituted into drafting context until the reveal issue."+ className="w-full px-2 py-1 text-xs bg-port-bg border border-port-border rounded text-gray-200 whitespace-pre-wrap"+ /></div>- </details>+ </CollapsibleSection>);}@@ -211,21 +213,15 @@ function RevealTimingField({ entry, editable, onPatch }) {// card stays terse by default — the user opens it only when filling in// novelist / graphic-novelist fields or generating a reference sheet.function CharacterDetailsToggle({ children }) {- const [open, setOpen] = useState(false);- const Chevron = open ? ChevronDown : ChevronRight;return (- <div className="mt-2">- <button- type="button"- onClick={() => setOpen((v) => !v)}- className="flex w-full items-center gap-1 text-[10px] uppercase tracking-wider text-gray-500 hover:text-white"- >- <Chevron size={10} className="shrink-0" />- <BookOpen size={10} className="shrink-0" />- Character details {open ? '' : '+ reference sheet'}- </button>- {open ? <div>{children}</div> : null}- </div>+ <CollapsibleSection+ className="mt-2"+ icon={BookOpen}+ label="Character details"+ summary="+ reference sheet"+ >+ {children}+ </CollapsibleSection>);}@@ -301,6 +297,8 @@ function WardrobeRow({ wardrobe, editable, onCommit, onRemove }) {// `stripIdOnPromote` stays false to keep WardrobeRow mounted across the// swap and preserve sibling draft buffers.function WardrobeSection({ wardrobes, editable, onChange }) {+ // Kept local (rather than folded into CollapsibleSection's internal state)+ // because "Add outfit" has to force the section open from outside the header.const [open, setOpen] = useState(false);const { merged, addRow, updateRow, removeRow } = usePendingListRows({persisted: wardrobes,@@ -312,8 +310,7 @@ function WardrobeSection({ wardrobes, editable, onChange }) {if (!editable && merged.length === 0) return null;- const Chevron = open ? ChevronDown : ChevronRight;- const summary = merged.map((w) => w.name).filter(Boolean).join(', ');+ const names = merged.map((w) => w.name).filter(Boolean).join(', ');const addOne = () => {setOpen(true);@@ -321,42 +318,34 @@ function WardrobeSection({ wardrobes, editable, onChange }) {};return (- <div className="mt-2">- <button- type="button"- onClick={() => setOpen((v) => !v)}- className="flex w-full items-center gap-1 text-[10px] uppercase tracking-wider text-gray-500 hover:text-white"- >- <Chevron size={10} className="shrink-0" />- <Shirt size={10} className="shrink-0" />- <span className="shrink-0">Outfits ({merged.length})</span>- {/* One clipped line — the joined outfit names are long enough to wrap- into a paragraph-tall collapsed header on a phone. */}- {summary && !open ? <span className="min-w-0 truncate">: {summary}</span> : null}- </button>- {open ? (- <div className="mt-1.5 pl-3 border-l border-port-border space-y-1.5">- {merged.map((w, i) => (- <WardrobeRow- key={w.id || i}- wardrobe={w}- editable={editable}- onCommit={(nextRow) => updateRow(i, nextRow)}- onRemove={() => removeRow(i)}- />- ))}- {editable ? (- <button- type="button"- onClick={addOne}- className="inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded border border-port-border text-gray-400 hover:text-white hover:border-gray-500"- >- <Plus size={10} /> Add outfit- </button>- ) : null}- </div>+ <CollapsibleSection+ className="mt-2"+ icon={Shirt}+ label={`Outfits (${merged.length})`}+ summary={names ? `: ${names}` : ''}+ open={open}+ onOpenChange={setOpen}+ bodyClassName="mt-1.5 pl-3 border-l border-port-border space-y-1.5"+ >+ {merged.map((w, i) => (+ <WardrobeRow+ key={w.id || i}+ wardrobe={w}+ editable={editable}+ onCommit={(nextRow) => updateRow(i, nextRow)}+ onRemove={() => removeRow(i)}+ />+ ))}+ {editable ? (+ <button+ type="button"+ onClick={addOne}+ className="inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded border border-port-border text-gray-400 hover:text-white hover:border-gray-500"+ >+ <Plus size={10} /> Add outfit+ </button>) : null}- </div>+ </CollapsibleSection>);}diff --git a/client/src/components/ui/CollapsibleSection.jsx b/client/src/components/ui/CollapsibleSection.jsxnew file mode 100644index 0000000000..d7604a2a43--- /dev/null+++ b/client/src/components/ui/CollapsibleSection.jsx@@ -0,0 +1,94 @@+import { useState } from 'react';+import { ChevronDown, ChevronRight } from 'lucide-react';++// Shared disclosure/section-header primitive (#3853). Replaces the hand-rolled+// `useState(open)` + chevron + leading icon + collapsed-summary headers that had+// drifted across the client — none of which carried `aria-expanded`.+//+// The layout contract lives here so the mobile fix only has to exist once:+// `flex w-full items-center`, `shrink-0` on the chevron/icon/label, and+// `min-w-0 truncate` on the trailing summary so a long collapsed summary clips+// to one line instead of wrapping into a paragraph-tall header on a phone.+//+// Deliberately NOT here: a per-site `text-left` (the base-layer rule in+// index.css already left-aligns wrapped flex-button labels), animation,+// nesting support, or a controlled `open`/`onOpenChange` pair — every current+// call site owns its open state internally.+//+// `size` picks between the tones that already exist in the app rather than+// unifying them; pick the one that matches the call site's neighbours.+const SIZES = {+ // Terse inline header (canon cards): size-10 icons, gap-1, gray-500.+ sm: {+ iconSize: 10,+ button: 'gap-1 text-[10px] uppercase tracking-wider text-gray-500 hover:text-white',+ label: '',+ summary: '',+ },+ // Boxed section header (character detail editor): size-11 icons, gap-1.5, gray-400.+ md: {+ iconSize: 11,+ button: 'gap-1.5 text-[10px] uppercase tracking-wider text-gray-400 hover:text-white',+ label: 'text-gray-300',+ summary: 'text-gray-500 normal-case',+ },+ // Card row (digital-twin analysis card): size-14 icons, gap-2, sentence-case text-sm.+ lg: {+ iconSize: 14,+ button: 'gap-2 text-sm text-gray-300 hover:bg-port-bg transition-colors',+ label: '',+ summary: 'text-gray-500',+ },+};++export default function CollapsibleSection({+ icon: Icon = null,+ label,+ summary = '',+ defaultOpen = false,+ size = 'sm',+ // Chrome that varies per call site (wrapper margin/border, header padding,+ // body padding). Kept separate from `size` so a caller never has to fight a+ // preset for the same Tailwind property.+ className = '',+ buttonClassName = '',+ bodyClassName = '',+ // Optional controlled pair, for the one caller that has to open the section+ // from outside the header (CanonCard's "Add outfit"). Omit both and the+ // section owns its own state, which is what every other call site wants.+ open: controlledOpen,+ onOpenChange,+ children,+}) {+ const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);+ const isControlled = typeof controlledOpen === 'boolean';+ const open = isControlled ? controlledOpen : uncontrolledOpen;+ const toggle = () => {+ const next = !open;+ if (!isControlled) setUncontrolledOpen(next);+ if (onOpenChange) onOpenChange(next);+ };+ const tone = SIZES[size] || SIZES.sm;+ const Chevron = open ? ChevronDown : ChevronRight;+ return (+ <div className={className}>+ <button+ type="button"+ aria-expanded={open}+ onClick={toggle}+ className={`flex w-full items-center ${tone.button} ${buttonClassName}`.trim()}+ >+ <Chevron size={tone.iconSize} className="shrink-0" />+ {Icon ? <Icon size={tone.iconSize} className="shrink-0" /> : null}+ {/* The label only refuses to shrink when there's a summary competing+ for the same line — otherwise a long standalone label would+ overflow the header instead of wrapping. */}+ <span className={`${summary ? 'shrink-0' : 'min-w-0'} ${tone.label}`.trim()}>{label}</span>+ {summary && !open+ ? <span className={`min-w-0 truncate ${tone.summary}`.trim()}>{summary}</span>+ : null}+ </button>+ {open ? <div className={bodyClassName}>{children}</div> : null}+ </div>+ );+}diff --git a/client/src/components/ui/CollapsibleSection.test.jsx b/client/src/components/ui/CollapsibleSection.test.jsxnew file mode 100644index 0000000000..24593a9e15--- /dev/null+++ b/client/src/components/ui/CollapsibleSection.test.jsx@@ -0,0 +1,77 @@+import { describe, it, expect } from 'vitest';+import { fireEvent, render, screen } from '@testing-library/react';+import { Shirt } from 'lucide-react';+import CollapsibleSection from './CollapsibleSection';++describe('CollapsibleSection', () => {+ it('starts collapsed and toggles its children on click', () => {+ render(+ <CollapsibleSection label="Outfits">+ <p>body content</p>+ </CollapsibleSection>,+ );+ expect(screen.queryByText('body content')).not.toBeInTheDocument();++ fireEvent.click(screen.getByRole('button', { name: /Outfits/ }));+ expect(screen.getByText('body content')).toBeInTheDocument();++ fireEvent.click(screen.getByRole('button', { name: /Outfits/ }));+ expect(screen.queryByText('body content')).not.toBeInTheDocument();+ });++ it('tracks open state in aria-expanded', () => {+ render(<CollapsibleSection label="Relationships">body</CollapsibleSection>);+ const button = screen.getByRole('button', { name: /Relationships/ });+ expect(button).toHaveAttribute('aria-expanded', 'false');++ fireEvent.click(button);+ expect(button).toHaveAttribute('aria-expanded', 'true');++ fireEvent.click(button);+ expect(button).toHaveAttribute('aria-expanded', 'false');+ });++ it('renders the summary only while collapsed, clipped to one line', () => {+ render(+ <CollapsibleSection label="Outfits" summary=": Wedding, Rainy day">+ body+ </CollapsibleSection>,+ );+ const summary = screen.getByText(': Wedding, Rainy day');+ expect(summary).toHaveClass('min-w-0');+ expect(summary).toHaveClass('truncate');++ fireEvent.click(screen.getByRole('button', { name: /Outfits/ }));+ expect(screen.queryByText(': Wedding, Rainy day')).not.toBeInTheDocument();+ });++ it('honors defaultOpen', () => {+ render(+ <CollapsibleSection label="Analysis Summary" defaultOpen>+ <p>body content</p>+ </CollapsibleSection>,+ );+ expect(screen.getByText('body content')).toBeInTheDocument();+ expect(screen.getByRole('button', { name: /Analysis Summary/ }))+ .toHaveAttribute('aria-expanded', 'true');+ });++ it('keeps the chevron and leading icon from shrinking', () => {+ const { container } = render(+ <CollapsibleSection icon={Shirt} label="Outfits">body</CollapsibleSection>,+ );+ const svgs = container.querySelectorAll('button svg');+ expect(svgs).toHaveLength(2);+ svgs.forEach((svg) => expect(svg).toHaveClass('shrink-0'));+ });++ it('applies the size tone to the header', () => {+ const { container, rerender } = render(+ <CollapsibleSection label="Outfits" size="sm">body</CollapsibleSection>,+ );+ expect(container.querySelector('button')).toHaveClass('text-gray-500');++ rerender(<CollapsibleSection label="Outfits" size="md">body</CollapsibleSection>);+ expect(container.querySelector('button')).toHaveClass('text-gray-400');+ });+});diff --git a/client/src/components/universe/CharacterDetailEditor.jsx b/client/src/components/universe/CharacterDetailEditor.jsxindex d1a7fd03fb..d1e9ec7e12 100644--- a/client/src/components/universe/CharacterDetailEditor.jsx+++ b/client/src/components/universe/CharacterDetailEditor.jsx@@ -10,9 +10,8 @@* only knows the field shape.*/-import { useState } from 'react';import {- ChevronDown, ChevronRight, Plus, Trash2, WandSparkles, Loader2,+ Plus, Trash2, WandSparkles, Loader2,Palette, Hand, Smile, Package, BookOpen, Eye, Activity, Users, Swords,Drama, KeyRound,} from 'lucide-react';@@ -21,6 +20,7 @@ import useFieldDraft from '../../hooks/useFieldDraft';import useRowDraft from '../../hooks/useRowDraft';import usePendingListRows from '../../hooks/usePendingListRows';import VoicePicker from '../voice/VoicePicker';+import CollapsibleSection from '../ui/CollapsibleSection';const SECTIONS = Object.freeze([{@@ -219,23 +219,22 @@ function ListRow({ row, idx, columns, swatchHex, onChange, onDelete, disabled }));}-function CollapsibleSection({ icon: Icon, label, summary, defaultOpen = false, children }) {- const [open, setOpen] = useState(defaultOpen);- const Chevron = open ? ChevronDown : ChevronRight;+// Local wrapper over the shared primitive so the three call sites below keep+// their boxed chrome (bordered card, header/body padding) in one place.+function BoxedSection({ icon, label, summary, defaultOpen = false, children }) {return (- <div className="rounded border border-port-border bg-port-bg/50">- <button- type="button"- onClick={() => setOpen((v) => !v)}- className="w-full flex items-center gap-1.5 px-2 py-1.5 text-[10px] uppercase tracking-wider text-gray-400 hover:text-white"- >- <Chevron size={11} className="shrink-0" />- <Icon size={11} className="shrink-0" />- <span className="shrink-0 text-gray-300">{label}</span>- {summary && !open ? <span className="min-w-0 text-gray-500 normal-case truncate">— {summary}</span> : null}- </button>- {open ? <div className="px-2.5 pb-2.5 pt-1 space-y-2">{children}</div> : null}- </div>+ <CollapsibleSection+ size="md"+ icon={icon}+ label={label}+ summary={summary ? `— ${summary}` : ''}+ defaultOpen={defaultOpen}+ className="rounded border border-port-border bg-port-bg/50"+ buttonClassName="px-2 py-1.5"+ bodyClassName="px-2.5 pb-2.5 pt-1 space-y-2"+ >+ {children}+ </CollapsibleSection>);}@@ -285,7 +284,7 @@ function ListSectionEditor({ section, entry, onPatchList, disabled }) {? 'empty': `${merged.length} ${merged.length === 1 ? section.singular : section.singular + 's'}`;return (- <CollapsibleSection+ <BoxedSectionicon={section.icon}label={section.label}summary={summary}@@ -322,7 +321,7 @@ function ListSectionEditor({ section, entry, onPatchList, disabled }) {><Plus size={10} /> {section.addLabel}</button>- </CollapsibleSection>+ </BoxedSection>);}@@ -480,7 +479,7 @@ function RelationshipsSection({ entry, characters, onPatch, disabled }) {? 'empty': `${links.length} link${links.length === 1 ? '' : 's'}${oppositionCount ? ` · ${oppositionCount} opposing` : ''}`;return (- <CollapsibleSection icon={Users} label="Relationships" summary={summary}>+ <BoxedSection icon={Users} label="Relationships" summary={summary}>{/* Always render existing rows — even with no other cast — so a stalelink (its target was deleted, leaving this the only character) staysremovable/repointable instead of being stranded behind the add-cast@@ -512,7 +511,7 @@ function RelationshipsSection({ entry, characters, onPatch, disabled }) {<Plus size={10} /> Add relationship</button>)}- </CollapsibleSection>+ </BoxedSection>);}@@ -529,7 +528,7 @@ function ArcFrameworkControls({ entry, onPatch, disabled, idPrefix }) {const setCount = SLIDER_AXES.reduce((n, a) => n + (typeof entry[a] === 'string' ? 0 : (sliders[a] != null ? 1 : 0)), 0);const summary = `${entry.arcType || 'no arc'}${setCount ? ` · ${setCount}/3 sliders` : ''}`;return (- <CollapsibleSection icon={Drama} label="Arc type & sliders" summary={summary}>+ <BoxedSection icon={Drama} label="Arc type & sliders" summary={summary}><div className="space-y-0.5"><label htmlFor={arcId} className="block text-[10px] uppercase tracking-wider text-gray-500">Arc type@@ -588,7 +587,7 @@ function ArcFrameworkControls({ entry, onPatch, disabled, idPrefix }) {</div>);})}- </CollapsibleSection>+ </BoxedSection>);}@@ -619,7 +618,7 @@ export default function CharacterDetailEditor({ entry, onPatch, onExpand, expand) : null}{SECTIONS.map((section) => (- <CollapsibleSection+ <BoxedSectionkey={section.key}icon={section.icon}label={section.label}@@ -645,7 +644,7 @@ export default function CharacterDetailEditor({ entry, onPatch, onExpand, expandpreviewText={entry.name ? `Hi, I'm ${entry.name}. This is how I sound.` : undefined}/>) : null}- </CollapsibleSection>+ </BoxedSection>))}<ArcFrameworkControls