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(sharing): portal peer Sync/Share dropdowns so they don't render behind cards
[._.]/ Adam Eivy12a8518cb894
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex b62d35fc42..7d77500444 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -26,5 +26,6 @@- **[issue-1090] Git tab dialogs are now screen-reader friendly** — the diff and release-confirmation pop-ups announce themselves as dialogs, their close buttons are labeled, and pressing Escape (or clicking outside) dismisses them.- **[issue-1091] Cleared two dependency security advisories** — pinned patched versions of two transitive packages to resolve a pair of moderate denial-of-service advisories flagged by `npm audit`, with no breaking changes. A couple of remaining advisories stay blocked on upstream projects publishing compatible major releases.- **Tests no longer write to a developer's real Postgres (and federate fixtures to live peers).** `memoryBackend.getBackend()` selected the file backend under `NODE_ENV=test` only when Postgres was *unreachable* — so on any dev machine with a healthy local `portos` DB the suite wrote hundreds of fixture universes/series/works straight into the real database, fanned them out to live Tailscale peers via `autoSubscribeRecordToAllPeers`, and let test-cleanup tombstones delete the user's real records. Test mode now short-circuits to the file backend **before** the health probe, so a running dev DB is never touched (an explicit `MEMORY_BACKEND=postgres` still opts a suite into the PG path). Adds a regression test asserting test mode bypasses a healthy Postgres, plus a one-off recovery script (`scripts/recover-synced-test-fixtures.mjs`) that restores tombstoned-real records, purges fixtures, and prunes the peer-subscription ledger.+- **Sync/Share peer dropdowns no longer render behind the next card.** The "Subscribe to peer" (cloud) and "Share to bucket" popovers on series/universe cards were absolutely positioned inside each card, so they were painted under the following card's stacking context. Both dropdowns now portal to `document.body` with fixed positioning anchored to their trigger (re-anchored on scroll/resize), and a peer missing its name shows a sensible fallback instead of the literal "undefined".## Removeddiff --git a/client/src/components/sharing/ShareToButton.jsx b/client/src/components/sharing/ShareToButton.jsxindex 8ce882b218..07fdadfe8d 100644--- a/client/src/components/sharing/ShareToButton.jsx+++ b/client/src/components/sharing/ShareToButton.jsx@@ -22,7 +22,8 @@* compact?: boolean*/-import { useEffect, useRef, useState } from 'react';+import { useEffect, useLayoutEffect, useRef, useState } from 'react';+import { createPortal } from 'react-dom';import { Share2, Check, Circle, CheckCircle2, Loader2 } from 'lucide-react';import toast from '../ui/Toast';import {@@ -50,6 +51,20 @@ export default function ShareToButton({ kind, ids, items, label = 'Share', compaconst [loading, setLoading] = useState(false);const [busyBucketId, setBusyBucketId] = useState(null);const wrapperRef = useRef(null);+ const triggerRef = useRef(null);+ const menuRef = useRef(null);+ // Portal the dropdown to <body> so it escapes each card's stacking context+ // (an in-card `absolute z-30` popover is otherwise painted under the next+ // card). Position it `fixed`, anchored to the trigger's viewport rect.+ const MENU_WIDTH = 288; // w-72+ const [coords, setCoords] = useState(null);+ const updateCoords = () => {+ const el = triggerRef.current;+ if (!el) return;+ const r = el.getBoundingClientRect();+ const left = Math.max(8, Math.min(r.right - MENU_WIDTH, window.innerWidth - MENU_WIDTH - 8));+ setCoords({ top: r.bottom + 4, left });+ };const isSubscribable = SUBSCRIBABLE_KINDS.has(kind);const recordId = isSubscribable && Array.isArray(ids) && ids.length > 0 ? ids[0] : null;@@ -82,10 +97,24 @@ export default function ShareToButton({ kind, ids, items, label = 'Share', compa// eslint-disable-next-line react-hooks/exhaustive-deps}, [open]);+ useLayoutEffect(() => {+ if (!open) { setCoords(null); return; }+ updateCoords();+ const onMove = () => updateCoords();+ window.addEventListener('scroll', onMove, true);+ window.addEventListener('resize', onMove);+ return () => {+ window.removeEventListener('scroll', onMove, true);+ window.removeEventListener('resize', onMove);+ };+ }, [open]);+useEffect(() => {if (!open) return;const handler = (e) => {- if (wrapperRef.current && !wrapperRef.current.contains(e.target)) setOpen(false);+ const inTrigger = wrapperRef.current && wrapperRef.current.contains(e.target);+ const inMenu = menuRef.current && menuRef.current.contains(e.target);+ if (!inTrigger && !inMenu) setOpen(false);};window.addEventListener('mousedown', handler);return () => window.removeEventListener('mousedown', handler);@@ -149,6 +178,7 @@ export default function ShareToButton({ kind, ids, items, label = 'Share', compareturn (<div ref={wrapperRef} className={`relative inline-block ${className}`}><button+ ref={triggerRef}type="button"onClick={() => setOpen((v) => !v)}disabled={nothingToShare}@@ -159,8 +189,12 @@ export default function ShareToButton({ kind, ids, items, label = 'Share', compa{!compact && <span>{label}</span>}</button>- {open && (- <div className="absolute right-0 z-30 mt-1 w-72 bg-port-card border border-port-border rounded-lg shadow-lg overflow-hidden">+ {open && coords && createPortal(+ <div+ ref={menuRef}+ style={{ position: 'fixed', top: coords.top, left: coords.left, width: MENU_WIDTH }}+ className="z-50 bg-port-card border border-port-border rounded-lg shadow-lg overflow-hidden"+ ><div className="px-3 py-2 text-[10px] uppercase tracking-wider text-gray-500 border-b border-port-border">{isSubscribable ? 'Subscribe to bucket' : 'Share to bucket'}</div>@@ -206,7 +240,8 @@ export default function ShareToButton({ kind, ids, items, label = 'Share', compaSubscribed buckets receive your edits automatically as you save.</div>)}- </div>+ </div>,+ document.body,)}</div>);diff --git a/client/src/components/sharing/SyncToPeerButton.jsx b/client/src/components/sharing/SyncToPeerButton.jsxindex ab8b27eb6d..699b0bcb64 100644--- a/client/src/components/sharing/SyncToPeerButton.jsx+++ b/client/src/components/sharing/SyncToPeerButton.jsx@@ -22,7 +22,8 @@* compact?: boolean*/-import { useEffect, useRef, useState } from 'react';+import { useEffect, useLayoutEffect, useRef, useState } from 'react';+import { createPortal } from 'react-dom';import { Cloud, Circle, CheckCircle2, Loader2 } from 'lucide-react';import toast from '../ui/Toast';import {@@ -45,6 +46,22 @@ export default function SyncToPeerButton({const [loading, setLoading] = useState(false);const [busyPeerId, setBusyPeerId] = useState(null);const wrapperRef = useRef(null);+ const triggerRef = useRef(null);+ const menuRef = useRef(null);+ // The dropdown is portaled to <body> so it escapes each series/universe+ // card's stacking context (the cards have their own compositing layer, so an+ // in-card `absolute z-30` popover is painted UNDER the next card). Position+ // it `fixed`, anchored to the trigger button's viewport rect.+ const MENU_WIDTH = 288; // w-72+ const [coords, setCoords] = useState(null);+ const updateCoords = () => {+ const el = triggerRef.current;+ if (!el) return;+ const r = el.getBoundingClientRect();+ // Right-align the menu to the button, clamped to the viewport.+ const left = Math.max(8, Math.min(r.right - MENU_WIDTH, window.innerWidth - MENU_WIDTH - 8));+ setCoords({ top: r.bottom + 4, left });+ };const refresh = async () => {setLoading(true);@@ -86,10 +103,27 @@ export default function SyncToPeerButton({// eslint-disable-next-line react-hooks/exhaustive-deps}, [open]);+ // Anchor the portaled menu to the trigger while open, and keep it pinned as+ // the page scrolls/resizes (capture-phase scroll catches inner scrollers too).+ useLayoutEffect(() => {+ if (!open) { setCoords(null); return; }+ updateCoords();+ const onMove = () => updateCoords();+ window.addEventListener('scroll', onMove, true);+ window.addEventListener('resize', onMove);+ return () => {+ window.removeEventListener('scroll', onMove, true);+ window.removeEventListener('resize', onMove);+ };+ }, [open]);+useEffect(() => {if (!open) return;const handler = (e) => {- if (wrapperRef.current && !wrapperRef.current.contains(e.target)) setOpen(false);+ // The menu lives in a portal outside wrapperRef, so check both.+ const inTrigger = wrapperRef.current && wrapperRef.current.contains(e.target);+ const inMenu = menuRef.current && menuRef.current.contains(e.target);+ if (!inTrigger && !inMenu) setOpen(false);};window.addEventListener('mousedown', handler);return () => window.removeEventListener('mousedown', handler);@@ -136,6 +170,7 @@ export default function SyncToPeerButton({return (<div ref={wrapperRef} className={`relative inline-block ${className}`}><button+ ref={triggerRef}type="button"onClick={() => setOpen((v) => !v)}disabled={nothingToSync}@@ -146,8 +181,12 @@ export default function SyncToPeerButton({{!compact && <span>{label}</span>}</button>- {open && (- <div className="absolute right-0 z-30 mt-1 w-72 bg-port-card border border-port-border rounded-lg shadow-lg overflow-hidden">+ {open && coords && createPortal(+ <div+ ref={menuRef}+ style={{ position: 'fixed', top: coords.top, left: coords.left, width: MENU_WIDTH }}+ className="z-50 bg-port-card border border-port-border rounded-lg shadow-lg overflow-hidden"+ ><div className="px-3 py-2 text-[10px] uppercase tracking-wider text-gray-500 border-b border-port-border">Subscribe to peer</div>@@ -205,7 +244,7 @@ export default function SyncToPeerButton({: <Circle size={14} className="text-gray-600" />}</span><div className="flex-1 min-w-0">- <div className="text-sm text-white truncate">{p.name}</div>+ <div className="text-sm text-white truncate">{p.name || p.host || p.address || 'Unnamed peer'}</div><div className="text-[10px] text-gray-500 truncate">{p.status === 'online' ? 'online' : p.status || 'offline'}{p.host ? ` · ${p.host}` : p.address ? ` · ${p.address}` : ''}@@ -223,7 +262,8 @@ export default function SyncToPeerButton({Subscribed peers receive your edits automatically; their edits flow back if their config allows.</div>)}- </div>+ </div>,+ document.body,)}</div>);