Skip to content

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

Fix FableLoom graph cards collapsing into one stacked box

Claude25089164c7e0
diff --git a/client/src/components/fableloom/LoomCanvas.jsx b/client/src/components/fableloom/LoomCanvas.jsx
index 667936a57e..7cda93f086 100644
--- a/client/src/components/fableloom/LoomCanvas.jsx
+++ b/client/src/components/fableloom/LoomCanvas.jsx
@@ -301,7 +301,7 @@ export default function LoomCanvas({
<text x={10} y={17} className="fill-port-text text-[11px] font-semibold pointer-events-none">
{truncate(node.title || 'Untitled scene', titleMax)}
</text>
- <g transform={`translate(10, ${nodeH - 16})`} className="pointer-events-none">
+ <g transform={`translate(10, ${nodeH - 13})`} className="pointer-events-none">
{isStart && (
<g>
<Play size={10} className="text-port-accent" x={0} y={-8} />
@@ -320,7 +320,7 @@ export default function LoomCanvas({
{!node.isEnding && (
<text
x={nodeW - 10}
- y={nodeH - 15}
+ y={nodeH - 12}
textAnchor="end"
className={node.playbackMode === 'cut'
? 'fill-port-accent text-[9px] font-medium pointer-events-none'
@@ -352,7 +352,7 @@ export default function LoomCanvas({
x={pos.x + 8}
y={pos.y + 24}
width={nodeW - 16}
- height={nodeH - 48}
+ height={nodeH - 52}
onPointerDown={(event) => handlePointerDown(event, node)}
onPointerMove={handlePointerMove}
onPointerUp={handlePointerUp}
diff --git a/client/src/components/fableloom/LoomSceneMedia.jsx b/client/src/components/fableloom/LoomSceneMedia.jsx
index 26eb3c0198..e3786a8324 100644
--- a/client/src/components/fableloom/LoomSceneMedia.jsx
+++ b/client/src/components/fableloom/LoomSceneMedia.jsx
@@ -88,9 +88,13 @@ export default function LoomSceneMedia({
const showStill = !showFinalVideo && !liveFrame && Boolean(node.image);
const showSpinner = !showFinalVideo && !liveFrame && !showStill && Boolean(activeJob);
+ // Scene cards are too narrow for three worded chips ("Regen…", "Gener…"),
+ // so compact actions are icon buttons; the label stays as the accessible
+ // name and the `title` tooltip explains the action.
+ const labelClass = compact ? 'sr-only' : 'truncate';
const stopNodeActivation = (event) => event.stopPropagation();
const buttonClass = compact
- ? 'inline-flex min-w-0 items-center justify-center gap-1 rounded border border-port-border bg-port-bg/80 px-1.5 py-1 text-[9px] text-port-text hover:border-port-accent hover:text-port-accent disabled:opacity-45'
+ ? 'inline-flex min-h-[26px] min-w-0 items-center justify-center rounded border border-port-border bg-port-bg/80 px-1.5 py-1 text-[9px] text-port-text hover:border-port-accent hover:text-port-accent disabled:opacity-45'
: 'inline-flex items-center justify-center gap-1.5 rounded border border-port-border px-2.5 py-1.5 text-xs text-port-text hover:border-port-accent hover:text-port-accent disabled:opacity-45';
// Compact media still lives inside an SVG foreignObject. Keep its overlapping
// preview/status layers in one grid cell: WebKit handles that more reliably
@@ -172,8 +176,8 @@ export default function LoomSceneMedia({
title={generationDisabledReason || (node.image ? 'Regenerate scene image' : 'Generate scene image')}
className={buttonClass}
>
- {imageActive ? <Loader2 size={compact ? 10 : 12} className="animate-spin" /> : <ImagePlus size={compact ? 10 : 12} />}
- <span className="truncate">{imageActive ? 'Generating image' : node.image ? 'Regenerate image' : 'Generate image'}</span>
+ {imageActive ? <Loader2 size={compact ? 13 : 12} className="animate-spin" /> : <ImagePlus size={compact ? 13 : 12} />}
+ <span className={labelClass}>{imageActive ? 'Generating image' : node.image ? 'Regenerate image' : 'Generate image'}</span>
</button>
<button
type="button"
@@ -182,8 +186,8 @@ export default function LoomSceneMedia({
title={generationDisabledReason || (node.videoHistoryId ? 'Regenerate scene video' : 'Generate scene video')}
className={buttonClass}
>
- {videoActive ? <Loader2 size={compact ? 10 : 12} className="animate-spin" /> : <Video size={compact ? 10 : 12} />}
- <span className="truncate">{videoActive ? 'Generating video' : node.videoHistoryId ? 'Regenerate video' : 'Generate video'}</span>
+ {videoActive ? <Loader2 size={compact ? 13 : 12} className="animate-spin" /> : <Video size={compact ? 13 : 12} />}
+ <span className={labelClass}>{videoActive ? 'Generating video' : node.videoHistoryId ? 'Regenerate video' : 'Generate video'}</span>
</button>
<button
type="button"
@@ -193,9 +197,9 @@ export default function LoomSceneMedia({
className={buttonClass}
>
{falActive
- ? <Loader2 size={compact ? 10 : 12} className="animate-spin" aria-hidden="true" />
- : <Sparkles size={compact ? 10 : 12} aria-hidden="true" />}
- <span className="truncate">{falActive ? 'Running fal.ai' : 'Automate fal.ai'}</span>
+ ? <Loader2 size={compact ? 13 : 12} className="animate-spin" aria-hidden="true" />
+ : <Sparkles size={compact ? 13 : 12} aria-hidden="true" />}
+ <span className={labelClass}>{falActive ? 'Running fal.ai' : 'Automate fal.ai'}</span>
</button>
{!compact && (
<button
diff --git a/client/src/hooks/useContainerWidth.js b/client/src/hooks/useContainerWidth.js
index 0bfa54f222..0c12b8e416 100644
--- a/client/src/hooks/useContainerWidth.js
+++ b/client/src/hooks/useContainerWidth.js
@@ -4,17 +4,32 @@ import { useEffect, useRef, useState } from 'react';
// — attach the ref to the element you want to measure, read width on each
// render. Width is 0 until the first observer callback fires; consumers
// should treat 0 as "not yet measured" and skip layout math.
+//
+// The element is re-checked after every render, not only on mount: a page
+// that renders a loading skeleton first attaches the ref later, and a
+// mount-only effect never observed it (FableLoom's graph then picked its
+// orientation from the wrong width).
export default function useContainerWidth() {
const ref = useRef(null);
+ const observedRef = useRef({ el: null, ro: null });
const [width, setWidth] = useState(0);
useEffect(() => {
- if (!ref.current || typeof ResizeObserver === 'undefined') return undefined;
- const ro = new ResizeObserver((entries) => {
+ const el = ref.current;
+ const observed = observedRef.current;
+ if (el === observed.el || typeof ResizeObserver === 'undefined') return;
+ observed.ro?.disconnect();
+ observed.el = el;
+ observed.ro = null;
+ if (!el) return;
+ observed.ro = new ResizeObserver((entries) => {
const w = entries[0]?.contentRect?.width;
if (w) setWidth(Math.floor(w));
});
- ro.observe(ref.current);
- return () => ro.disconnect();
+ observed.ro.observe(el);
+ });
+ useEffect(() => () => {
+ observedRef.current.ro?.disconnect();
+ observedRef.current = { el: null, ro: null };
}, []);
return [ref, width];
}
diff --git a/client/src/hooks/useContainerWidth.test.jsx b/client/src/hooks/useContainerWidth.test.jsx
new file mode 100644
index 0000000000..372447ed9e
--- /dev/null
+++ b/client/src/hooks/useContainerWidth.test.jsx
@@ -0,0 +1,35 @@
+import { describe, it, expect, vi, afterEach } from 'vitest';
+import { act, render, screen } from '@testing-library/react';
+import { useState } from 'react';
+import useContainerWidth from './useContainerWidth';
+
+let observers = [];
+class FakeResizeObserver {
+ constructor(cb) { this.cb = cb; this.el = null; this.disconnect = vi.fn(); observers.push(this); }
+ observe(el) { this.el = el; }
+ fire(width) { this.cb([{ contentRect: { width } }]); }
+}
+
+afterEach(() => { observers = []; vi.unstubAllGlobals(); });
+
+function Probe() {
+ const [ready, setReady] = useState(false);
+ const [ref, width] = useContainerWidth();
+ if (!ready) return <button type="button" onClick={() => setReady(true)}>load</button>;
+ return <div ref={ref} data-testid="measured">{width}</div>;
+}
+
+describe('useContainerWidth', () => {
+ // A loading skeleton renders before the measured element exists; a
+ // mount-only effect never observed it and width stayed 0 forever.
+ it('observes an element that attaches after the first render', () => {
+ vi.stubGlobal('ResizeObserver', FakeResizeObserver);
+ render(<Probe />);
+ expect(observers).toHaveLength(0);
+ act(() => screen.getByRole('button', { name: 'load' }).click());
+ const measured = screen.getByTestId('measured');
+ expect(observers.at(-1).el).toBe(measured);
+ act(() => observers.at(-1).fire(1234.6));
+ expect(measured.textContent).toBe('1234');
+ });
+});
diff --git a/client/src/index.css b/client/src/index.css
index e2e959e869..c7e5ef2d83 100644
--- a/client/src/index.css
+++ b/client/src/index.css
@@ -1872,8 +1872,11 @@ input[type="color"],
and GPU compositing layer up front ensures the ancestor backing store never retains
stale button pixels.
Uses :where() to keep specificity at (0,0,0) so author transform utilities
- (e.g., hover:scale-105, active:scale-95) continue to win cleanly. */
- :where(button, [role="button"]) {
+ (e.g., hover:scale-105, active:scale-95) continue to win cleanly.
+ SVG descendants are excluded: a CSS `transform` replaces an SVG element's
+ `transform` attribute, so a `<g role="button" transform="translate(…)">`
+ (FableLoom scene cards, graph nodes) collapsed onto the origin. */
+ :where(button, [role="button"]:not(svg *)) {
isolation: isolate;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
diff --git a/client/src/pages/FableLoomStory.jsx b/client/src/pages/FableLoomStory.jsx
index 076e82ffd0..8f18c76ceb 100644
--- a/client/src/pages/FableLoomStory.jsx
+++ b/client/src/pages/FableLoomStory.jsx
@@ -91,7 +91,7 @@ export default function FableLoomStory({ view = 'graph' }) {
const seriesPlanOpen = episodeId === 'plan';
const outlineOpen = view === 'outline';
// Orientation keys off the PAGE, not the canvas. The canvas is the leftover
- // after the 380px rail on `lg+`, so measuring it would stack a laptop graph
+ // after the 380–420px rail on `lg+`, so measuring it would stack a laptop graph
// while the rail is still beside it.
const [pageRef, pageWidth] = useContainerWidth();
const graphOrientation = pageWidth > 0
@@ -587,7 +587,7 @@ export default function FableLoomStory({ view = 'graph' }) {
title="Add episode"
className="flex min-h-[36px] shrink-0 items-center rounded-full border border-dashed border-port-border px-3 text-xs text-port-text-muted hover:border-port-accent hover:text-port-accent"
>
- + <span className="hidden sm:inline">Episode</span>
+ <Plus size={13} aria-hidden="true" /><span className="ml-1 hidden sm:inline">Episode</span>
</button>
{episode && (
<TabPills
@@ -689,8 +689,8 @@ export default function FableLoomStory({ view = 'graph' }) {
data-testid={node ? 'scene-details-sheet' : 'loom-validation-rail'}
aria-label={node ? `${node.title || 'Scene'} details` : 'Episode validation'}
className={node
- ? 'absolute inset-x-0 bottom-0 z-20 flex h-[calc(100%_-_0.75rem)] flex-col overflow-hidden rounded-t-2xl border border-b-0 border-port-border bg-port-card shadow-2xl motion-safe:animate-in motion-safe:slide-in-from-bottom-4 motion-safe:duration-200 lg:static lg:h-auto lg:w-[380px] lg:shrink-0 lg:rounded-none lg:border-y-0 lg:border-r-0 lg:border-l'
- : 'flex max-h-[45%] flex-col overflow-hidden border-t border-port-border lg:max-h-none lg:w-[380px] lg:shrink-0 lg:border-t-0 lg:border-l'}
+ ? 'absolute inset-x-0 bottom-0 z-20 flex h-[calc(100%_-_0.75rem)] flex-col overflow-hidden rounded-t-2xl border border-b-0 border-port-border bg-port-card shadow-2xl motion-safe:animate-in motion-safe:slide-in-from-bottom-4 motion-safe:duration-200 lg:static lg:h-auto lg:w-[380px] 2xl:w-[420px] lg:shrink-0 lg:rounded-none lg:border-y-0 lg:border-r-0 lg:border-l'
+ : 'flex max-h-[45%] flex-col overflow-hidden border-t border-port-border lg:max-h-none lg:w-[380px] 2xl:w-[420px] lg:shrink-0 lg:border-t-0 lg:border-l'}
>
{node && (
<div className="relative flex min-h-[4.5rem] shrink-0 items-center justify-center border-b border-port-border px-4 py-3 lg:hidden">
diff --git a/client/src/themes/portosThemes.test.js b/client/src/themes/portosThemes.test.js
index 45708f6ddb..66a4c2150b 100644
--- a/client/src/themes/portosThemes.test.js
+++ b/client/src/themes/portosThemes.test.js
@@ -387,9 +387,9 @@ describe('button compositor layer isolation and animation stabilization', () =>
const css = readFileSync(join(dirname(fileURLToPath(import.meta.url)), '..', 'index.css'), 'utf8');
it('isolates buttons to their own GPU compositing layer to prevent WebKit backing-sharing ghosting', () => {
- expect(css).toMatch(/:where\(button,\s*\[role="button"\]\)\s*\{[^}]*isolation:\s*isolate/);
- expect(css).toMatch(/:where\(button,\s*\[role="button"\]\)\s*\{[^}]*backface-visibility:\s*hidden/);
- expect(css).toMatch(/:where\(button,\s*\[role="button"\]\)\s*\{[^}]*transform:\s*translateZ\(0\)/);
+ expect(css).toMatch(/:where\(button,\s*\[role="button"\]:not\(svg \*\)\)\s*\{[^}]*isolation:\s*isolate/);
+ expect(css).toMatch(/:where\(button,\s*\[role="button"\]:not\(svg \*\)\)\s*\{[^}]*backface-visibility:\s*hidden/);
+ expect(css).toMatch(/:where\(button,\s*\[role="button"\]:not\(svg \*\)\)\s*\{[^}]*transform:\s*translateZ\(0\)/);
});
it('stabilizes .animate-spin on its own compositor layer with will-change and backface-visibility', () => {