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
fix: address codex review — editable dangling links + per-axis opposition dedup (#1287)
[._.]/ Adam Eivy77ba3c4d68be
diff --git a/client/src/components/universe/CharacterDetailEditor.jsx b/client/src/components/universe/CharacterDetailEditor.jsxindex 858a8aa12c..11c88fe3ef 100644--- a/client/src/components/universe/CharacterDetailEditor.jsx+++ b/client/src/components/universe/CharacterDetailEditor.jsx@@ -326,6 +326,11 @@ function RelationshipRow({ link, idx, others, onUpdate, onRemove, disabled }) {const toggleOpposition = () => onUpdate({opposition: hasOpposition ? null : { axis: 'custom', thisRole: '', targetRole: '', note: '' },});+ // A link whose target was deleted points at an id no longer in the cast. Show+ // it as an explicit "(missing)" option so the dangling state is visible and+ // the select still reflects the stored value (rather than silently snapping to+ // the first cast member) — the user can re-point it or delete the row.+ const targetMissing = !!link.targetCharacterId && !others.some((c) => c.id === link.targetCharacterId);return (<div className={`rounded border ${hasOpposition ? 'border-port-warning/40' : 'border-port-border'} bg-port-bg/40 p-2 space-y-1.5`}><div className="flex items-center gap-1.5">@@ -336,6 +341,9 @@ function RelationshipRow({ link, idx, others, onUpdate, onRemove, disabled }) {aria-label={`relationship ${idx + 1} target character`}className={REL_SELECT_CLASS}>+ {targetMissing ? (+ <option value={link.targetCharacterId}>(missing: {link.targetCharacterId})</option>+ ) : null}{others.map((c) => <option key={c.id} value={c.id}>{c.name || c.id}</option>)}</select><select@@ -413,34 +421,36 @@ function RelationshipsSection({ entry, characters, onPatch, disabled }) {: `${links.length} link${links.length === 1 ? '' : 's'}${oppositionCount ? ` · ${oppositionCount} opposing` : ''}`;return (<CollapsibleSection icon={Users} label="Relationships" summary={summary}>+ {/* Always render existing rows — even with no other cast — so a stale+ link (its target was deleted, leaving this the only character) stays+ removable/repointable instead of being stranded behind the add-cast+ prompt where the dangling-target check can flag what the UI hides. */}+ {links.length > 0 ? (+ <div className="space-y-2">+ {links.map((link, idx) => (+ <RelationshipRow+ key={link.id || `rel-${idx}`}+ link={link}+ idx={idx}+ others={others}+ onUpdate={(patch) => updateLink(idx, patch)}+ onRemove={() => removeLink(idx)}+ disabled={disabled}+ />+ ))}+ </div>+ ) : (+ <p className="text-[11px] text-gray-500 italic">No relationships yet.</p>+ )}{others.length === 0 ? (- <p className="text-[11px] text-gray-500 italic">Add another character to the cast to link relationships.</p>+ <p className="text-[11px] text-gray-500 italic">Add another character to the cast to {links.length ? 're-point these links' : 'link relationships'}.</p>) : (- <>- {links.length === 0 ? (- <p className="text-[11px] text-gray-500 italic">No relationships yet.</p>- ) : (- <div className="space-y-2">- {links.map((link, idx) => (- <RelationshipRow- key={link.id || `rel-${idx}`}- link={link}- idx={idx}- others={others}- onUpdate={(patch) => updateLink(idx, patch)}- onRemove={() => removeLink(idx)}- disabled={disabled}- />- ))}- </div>- )}- <button- type="button" onClick={addLink} disabled={disabled}- 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 disabled:opacity-40"- >- <Plus size={10} /> Add relationship- </button>- </>+ <button+ type="button" onClick={addLink} disabled={disabled}+ 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 disabled:opacity-40"+ >+ <Plus size={10} /> Add relationship+ </button>)}</CollapsibleSection>);diff --git a/client/src/components/universe/CharacterDetailEditor.test.jsx b/client/src/components/universe/CharacterDetailEditor.test.jsxindex 83eeacd398..2c5a97cc16 100644--- a/client/src/components/universe/CharacterDetailEditor.test.jsx+++ b/client/src/components/universe/CharacterDetailEditor.test.jsx@@ -81,6 +81,24 @@ describe('CharacterDetailEditor — Relationships (#1287)', () => {});});+ it('keeps an existing link removable even when there is no other cast', () => {+ // Target was deleted, leaving Aria the only character. The link must still+ // render (with a delete button) instead of being hidden behind the+ // add-more-cast prompt — otherwise the dangling-target check flags a+ // problem the UI won't let the user fix.+ const onPatch = vi.fn();+ const entry = {+ ...ARIA,+ relationshipLinks: [{ id: 'rel-1', targetCharacterId: 'chr-deleted', type: 'rival' }],+ };+ render(<CharacterDetailEditor entry={entry} characters={[ARIA]} onPatch={onPatch} />);+ openRelationships();+ // Dangling target is surfaced as a "(missing: …)" option.+ expect(screen.getByText(/missing: chr-deleted/i)).toBeInTheDocument();+ fireEvent.click(screen.getByRole('button', { name: /remove relationship 1/i }));+ expect(onPatch).toHaveBeenCalledWith({ relationshipLinks: [] });+ });+it('shows the opposition count in the collapsed summary', () => {const entry = {...ARIA,diff --git a/server/lib/editorial/checkRegistry.js b/server/lib/editorial/checkRegistry.jsindex 731d0a3ee5..c02e2baff0 100644--- a/server/lib/editorial/checkRegistry.js+++ b/server/lib/editorial/checkRegistry.js@@ -224,12 +224,14 @@ export const EDITORIAL_CHECKS = [run: (ctx) => {const { chars, nameById } = relationshipCanon(ctx);const findings = [];- // Dedupe by the unordered character pair so a reciprocally-tagged- // opposition (A→B and B→A both carry an axis) surfaces once, not twice.+ // Dedupe by the unordered character pair + axis so a reciprocally-tagged+ // opposition (A→B and B→A on the SAME axis) surfaces once — but two+ // DIFFERENT axes on the same pair (hunter/prey AND winner/loser) each+ // surface, since they're distinct payoffs the reader tracks separately.const seenPairs = new Set();for (const { c, link, targetId } of eachRelationshipLink(chars)) {if (!link.opposition?.axis || !nameById.has(targetId)) continue;- const pairKey = [c.id, targetId].sort().join('|');+ const pairKey = `${[c.id, targetId].sort().join('|')}|${link.opposition.axis}`;if (seenPairs.has(pairKey)) continue;seenPairs.add(pairKey);const aName = nameById.get(c.id);diff --git a/server/lib/editorial/checkRegistry.test.js b/server/lib/editorial/checkRegistry.test.jsindex 70c9895e9e..bd1a10c240 100644--- a/server/lib/editorial/checkRegistry.test.js+++ b/server/lib/editorial/checkRegistry.test.js@@ -291,6 +291,23 @@ describe('relationships.opposition-reversal — deterministic advisory', () => {expect(findings[0].problem).toMatch(/hunter\/prey/);});+ it('surfaces two DIFFERENT axes on the same pair separately', () => {+ const findings = run([+ {+ id: 'a',+ name: 'Aria',+ relationshipLinks: [+ { id: 'r1', targetCharacterId: 'b', opposition: { axis: 'hunter/prey' } },+ { id: 'r2', targetCharacterId: 'b', opposition: { axis: 'winner/loser' } },+ ],+ },+ { id: 'b', name: 'Bram' },+ ]);+ expect(findings).toHaveLength(2);+ expect(findings.map((f) => f.problem.match(/axis "([^"]+)"/)[1]).sort())+ .toEqual(['hunter/prey', 'winner/loser']);+ });+it('does not surface links without an opposition tag', () => {const findings = run([{ id: 'a', name: 'Aria', relationshipLinks: [{ targetCharacterId: 'b', type: 'ally' }] },