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
refactor([issue-2953]): address /simplify review
[._.]/ Adam Eivy7a20c83568de
diff --git a/client/src/components/media/GlbViewer.jsx b/client/src/components/media/GlbViewer.jsxindex 4f9562d4a0..a280ea150e 100644--- a/client/src/components/media/GlbViewer.jsx+++ b/client/src/components/media/GlbViewer.jsx@@ -1,4 +1,4 @@-import { Suspense, useEffect } from 'react';+import { Suspense } from 'react';import { Canvas } from '@react-three/fiber';import { Bounds, OrbitControls, useGLTF } from '@react-three/drei';import { Download, Rotate3d } from 'lucide-react';@@ -18,10 +18,11 @@ function filenameFromSrc(src) {}function GlbModel({ src }) {+ // `useGLTF` keys drei's global cache on the URL, so a new generation (a new+ // `src`) parses fresh while revisiting the same mesh reuses the cache — no+ // manual cache-clear needed (clearing on unmount would force a full multi-MB+ // re-fetch every time the viewer remounts for the same URL).const { scene } = useGLTF(src);- // drei caches loaded GLTFs globally; clear this entry on unmount/src-change so a- // re-render after a new generation doesn't show the stale cached mesh.- useEffect(() => () => useGLTF.clear(src), [src]);return <primitive object={scene} />;}diff --git a/client/src/components/media/MediaCard.jsx b/client/src/components/media/MediaCard.jsxindex 6026696a3b..1238f5b130 100644--- a/client/src/components/media/MediaCard.jsx+++ b/client/src/components/media/MediaCard.jsx@@ -18,7 +18,7 @@ export default function MediaCard({onRemix,onSendToImage,onSendToVideo,- onSendToThreejs,+ onSendTo3d,onContinue,onUpscale,onDelete,@@ -169,10 +169,10 @@ export default function MediaCard({<Film className="w-3 h-3" /></button>)}- {!isVideo && onSendToThreejs && (+ {!isVideo && onSendTo3d && (<buttontype="button"- onClick={() => onSendToThreejs(item)}+ onClick={() => onSendTo3d(item)}className="shrink-0 px-1.5 py-1 bg-purple-600/20 hover:bg-purple-600/40 text-purple-300 text-[10px] rounded flex items-center justify-center"title="Build a procedural Three.js model"aria-label="Send to Three.js Models"diff --git a/client/src/components/media/MediaCard.test.jsx b/client/src/components/media/MediaCard.test.jsxindex 39e1d5b66c..79e4045e32 100644--- a/client/src/components/media/MediaCard.test.jsx+++ b/client/src/components/media/MediaCard.test.jsx@@ -77,23 +77,23 @@ describe('MediaCard', () => {});it('offers the image-to-Three.js handoff only when its handler is provided', () => {- const onSendToThreejs = vi.fn();+ const onSendTo3d = vi.fn();const { rerender } = render(<MediaCarditem={imageItem}- onSendToThreejs={onSendToThreejs}+ onSendTo3d={onSendTo3d}showCollectionMenu={false}showMoodBoardMenu={false}/>);fireEvent.click(screen.getByRole('button', { name: 'Send to Three.js Models' }));- expect(onSendToThreejs).toHaveBeenCalledWith(imageItem);+ expect(onSendTo3d).toHaveBeenCalledWith(imageItem);rerender(<MediaCarditem={{ ...imageItem, kind: 'video' }}- onSendToThreejs={onSendToThreejs}+ onSendTo3d={onSendTo3d}showCollectionMenu={false}showMoodBoardMenu={false}/>diff --git a/client/src/components/media/MediaLightbox.jsx b/client/src/components/media/MediaLightbox.jsxindex 164e5d209c..c28addbf66 100644--- a/client/src/components/media/MediaLightbox.jsx+++ b/client/src/components/media/MediaLightbox.jsx@@ -90,7 +90,7 @@ export default function MediaLightbox({onRemix,onSendToImage,onSendToVideo,- onSendToThreejs,+ onSendTo3d,onContinue,onClean,onRegenerate,@@ -347,7 +347,7 @@ export default function MediaLightbox({onRemix={onRemix}onSendToImage={onSendToImage}onSendToVideo={onSendToVideo}- onSendToThreejs={onSendToThreejs}+ onSendTo3d={onSendTo3d}onContinue={onContinue}onClean={onClean}onRegenerate={onRegenerate}@@ -395,7 +395,7 @@ function PeerNotes({ others }) {function SettingsPane({item, meta, isVideo,- onClose, onRemix, onSendToImage, onSendToVideo, onSendToThreejs, onContinue, onClean, onRegenerate, onRemoveWatermark, regenAvailable, regenBounds,+ onClose, onRemix, onSendToImage, onSendToVideo, onSendTo3d, onContinue, onClean, onRegenerate, onRemoveWatermark, regenAvailable, regenBounds,copy, onRefine,annotation, onAnnotationChange,variantGroup, onSelectVariant,@@ -670,10 +670,10 @@ function SettingsPane({<Film className="w-3.5 h-3.5" /> Send to Video</button>)}- {!isVideo && onSendToThreejs && (+ {!isVideo && onSendTo3d && (<buttontype="button"- onClick={() => closeThenRun(onSendToThreejs)}+ onClick={() => closeThenRun(onSendTo3d)}className="flex-1 flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs bg-purple-600/80 text-white hover:opacity-90 rounded"><Box className="w-3.5 h-3.5" /> Send to 3Ddiff --git a/client/src/hooks/useMediaPreviewActions.js b/client/src/hooks/useMediaPreviewActions.jsindex 3f1f625782..eeeac11870 100644--- a/client/src/hooks/useMediaPreviewActions.js+++ b/client/src/hooks/useMediaPreviewActions.js@@ -127,6 +127,14 @@ export default function useMediaPreviewActions({ onCleanComplete = null } = {})navigate(`/media/video?${params}`);}, [navigate]);+ // Send to 3D: open the image-to-3D workspace (/media/3d) with this image as the+ // source. Images only — the 3D page resolves `?image=<filename>` against the+ // gallery (URL is the source of truth for the staged source image).+ const handleSendTo3d = useCallback((item) => {+ if (!item?.filename || item.kind === 'video') return;+ navigate(`/media/3d?image=${encodeURIComponent(item.filename)}`);+ }, [navigate]);+// Continue: extract the LAST frame of a video clip and seed Video Gen// with it as the i2v source — the canonical "extend this take" path.// `item.id` is the video job id; extractLastFrame returns the new image@@ -182,5 +190,5 @@ export default function useMediaPreviewActions({ onCleanComplete = null } = {})return variant;}, [onCleanComplete]);- return { handleRemix, handleSendToImage, handleSendToVideo, handleContinue, handleClean, handleRemoveWatermark };+ return { handleRemix, handleSendToImage, handleSendToVideo, handleSendTo3d, handleContinue, handleClean, handleRemoveWatermark };}diff --git a/client/src/pages/ImageGen.jsx b/client/src/pages/ImageGen.jsxindex a491f9f322..9e31925299 100644--- a/client/src/pages/ImageGen.jsx+++ b/client/src/pages/ImageGen.jsx@@ -1051,7 +1051,7 @@ export default function ImageGen() {// "Send to 3D" opens the image-to-3D workspace (/media/3d) with this render as// the source image — deep-linked via ?image= (URL is the source of truth).- const handleSendToThreejs = (img) => {+ const handleSendTo3d = (img) => {if (!img?.filename) return;navigate(`/media/3d?image=${encodeURIComponent(img.filename)}`);};@@ -1443,7 +1443,7 @@ export default function ImageGen() {onRemix={() => handleRemix(img)}onSendToImage={() => handleSendToImage(img)}onSendToVideo={() => sendToVideo(img)}- onSendToThreejs={() => handleSendToThreejs(img)}+ onSendTo3d={() => handleSendTo3d(img)}onDelete={() => handleDelete(img.filename)}onToggleHidden={() => handleToggleHidden(item)}{...getCardProps(item.key)}@@ -1477,7 +1477,7 @@ export default function ImageGen() {onRemix={() => handleRemix(img)}onSendToImage={() => handleSendToImage(img)}onSendToVideo={() => sendToVideo(img)}- onSendToThreejs={() => handleSendToThreejs(img)}+ onSendTo3d={() => handleSendTo3d(img)}onDelete={() => handleDelete(img.filename)}onToggleHidden={() => handleToggleHidden(item)}{...getCardProps(item.key)}@@ -1498,7 +1498,7 @@ export default function ImageGen() {onRemix={(item) => item?.raw && handleRemix(item.raw)}onSendToImage={(item) => item?.raw?.filename && handleSendToImage(item.raw)}onSendToVideo={(item) => item?.raw?.filename && sendToVideo(item.raw)}- onSendToThreejs={(item) => item?.raw?.filename && handleSendToThreejs(item.raw)}+ onSendTo3d={(item) => item?.raw?.filename && handleSendTo3d(item.raw)}onClean={(item) => handleClean(item?.raw)}onRegenerate={(item, opts) => handleRegenerate(item?.raw, opts)}onRemoveWatermark={(item) => handleRemoveWatermark(item?.raw)}diff --git a/client/src/pages/Media3D.jsx b/client/src/pages/Media3D.jsxindex eceb8b4707..3c1bba87d2 100644--- a/client/src/pages/Media3D.jsx+++ b/client/src/pages/Media3D.jsx@@ -141,35 +141,40 @@ export default function Media3D() {}, [targets, targetFromRoute]);// Keep the URL honest: if a bare `/media/3d` resolved a default target, reflect- // it so the selection is shareable/reload-safe (URL as source of truth).+ // it so the selection is shareable/reload-safe (URL as source of truth). The+ // functional updater reads the freshest params, so this effect depends only on+ // the resolved target — not on every unrelated `?image=`/`?glb=` change.useEffect(() => {if (!selectedTarget || targetFromRoute === selectedTarget.id) return;- const next = new URLSearchParams(searchParams);- next.set('target', selectedTarget.id);- setSearchParams(next, { replace: true });- }, [selectedTarget, targetFromRoute, searchParams, setSearchParams]);+ setSearchParams((prev) => {+ const next = new URLSearchParams(prev);+ next.set('target', selectedTarget.id);+ return next;+ }, { replace: true });+ }, [selectedTarget, targetFromRoute, setSearchParams]);const setParam = useCallback((key, value) => {- const next = new URLSearchParams(searchParams);- if (value) next.set(key, value); else next.delete(key);- setSearchParams(next);- }, [searchParams, setSearchParams]);+ setSearchParams((prev) => {+ const next = new URLSearchParams(prev);+ if (value) next.set(key, value); else next.delete(key);+ return next;+ });+ }, [setSearchParams]);const handlePick = (item) => { setParam('image', item.filename); setPickerOpen(false); };- const ready = isTargetReady(selectedTarget);- // The image→mesh runner (POST generate + landed .glb) lands with #2952; until- // then the workspace lets the user stage the source image + target and preview- // any produced mesh, but the Generate action stays gated rather than pretending.- const generateGatedReason = !selectedImage- ? 'Pick a source image to continue.'- : !selectedTarget- ? 'No image-to-3D model is registered.'- : !selectedTarget.available- ? (REASON_LABEL[selectedTarget.unavailableReason] || 'This model can’t run on this host.')- : selectedTarget.installed === false- ? `Install ${selectedTarget.label} below before generating.`- : 'Generation lands with the on-device runner — coming next.';+ // The image→mesh runner (POST generate + landed .glb) lands with #2952. Until a+ // producer exists the workspace only *stages* the source image + target, so the+ // Generate action is always gated — this returns the reason it's blocked, and the+ // button stays disabled whenever a reason is present (which, today, is always,+ // via the terminal "coming next" branch — so no inert-but-enabled button leaks).+ const generateGatedReason = (() => {+ if (!selectedImage) return 'Pick a source image to continue.';+ if (!selectedTarget) return 'No image-to-3D model is registered.';+ if (!selectedTarget.available) return REASON_LABEL[selectedTarget.unavailableReason] || 'This model can’t run on this host.';+ if (selectedTarget.installed === false) return `Install ${selectedTarget.label} below before generating.`;+ return 'Generation lands with the on-device runner — coming next.';+ })();return (<div className="mx-auto max-w-4xl">@@ -242,7 +247,7 @@ export default function Media3D() {<div className="mt-auto flex flex-col items-start gap-2"><buttontype="button"- disabled={!ready || !selectedImage}+ disabled={!!generateGatedReason}title={generateGatedReason}className="inline-flex items-center gap-2 rounded-lg bg-port-accent px-4 py-2 text-sm text-white hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-40">diff --git a/client/src/pages/Media3D.test.jsx b/client/src/pages/Media3D.test.jsxindex 43b640180f..93d40dc799 100644--- a/client/src/pages/Media3D.test.jsx+++ b/client/src/pages/Media3D.test.jsx@@ -108,9 +108,13 @@ describe('Media3D — generation workspace', () => {expect(screen.queryByText(/Pick a source image to continue/i)).not.toBeInTheDocument();});- it('enables Generate when an image is chosen and the target is ready', async () => {+ it('keeps Generate disabled with a "coming next" reason once an image + ready target are staged', async () => {+ // Generation is deferred to the runner (#2952); even a fully-staged workspace+ // must not present a live-but-inert button.renderAt('/media/3d?image=example-robot.png');- expect(await screen.findByRole('button', { name: /Generate 3D/i })).toBeEnabled();+ const btn = await screen.findByRole('button', { name: /Generate 3D/i });+ expect(btn).toBeDisabled();+ expect(screen.getByText(/Generation lands with the on-device runner/i)).toBeInTheDocument();});it('keeps Generate disabled and explains why when no image is picked', async () => {diff --git a/client/src/pages/MediaHistory.jsx b/client/src/pages/MediaHistory.jsxindex d4ef35d232..638b828b22 100644--- a/client/src/pages/MediaHistory.jsx+++ b/client/src/pages/MediaHistory.jsx@@ -132,7 +132,7 @@ export default function MediaHistory() {// the cleaned image to the top of the local list) is page-specific —// wired through `onCleanComplete` so the cleaned record lands in `items`// without a full gallery refetch.- const { handleRemix, handleSendToImage, handleSendToVideo, handleContinue, handleClean, handleRemoveWatermark } = useMediaPreviewActions({+ const { handleRemix, handleSendToImage, handleSendToVideo, handleSendTo3d, handleContinue, handleClean, handleRemoveWatermark } = useMediaPreviewActions({onCleanComplete: (cleaned) => {const normalized = normalizeImage(cleaned);setItems((prev) => [normalized, ...prev.filter((x) => x.key !== normalized.key)]);@@ -155,12 +155,6 @@ export default function MediaHistory() {}};- // "Send to 3D" opens the image-to-3D workspace (/media/3d) with this render as- // the source image — deep-linked via ?image= (URL is the source of truth).- const handleSendToThreejs = (item) => {- if (item?.kind !== 'image' || !item.filename) return;- navigate(`/media/3d?image=${encodeURIComponent(item.filename)}`);- };return (<div className="space-y-4">@@ -262,7 +256,7 @@ export default function MediaHistory() {onRemix={!stitchMode ? handleRemix : undefined}onSendToImage={!stitchMode ? handleSendToImage : undefined}onSendToVideo={!stitchMode ? handleSendToVideo : undefined}- onSendToThreejs={!stitchMode ? handleSendToThreejs : undefined}+ onSendTo3d={!stitchMode ? handleSendTo3d : undefined}onContinue={!stitchMode ? handleContinue : undefined}onUpscale={!stitchMode && it.kind === 'video' ? handleUpscale : undefined}onDelete={!stitchMode ? handleDelete : undefined}@@ -288,7 +282,7 @@ export default function MediaHistory() {onRemix={handleRemix}onSendToImage={handleSendToImage}onSendToVideo={handleSendToVideo}- onSendToThreejs={handleSendToThreejs}+ onSendTo3d={handleSendTo3d}onContinue={handleContinue}onClean={(item) => handleClean(item?.raw)}onRemoveWatermark={(item) => handleRemoveWatermark(item?.raw)}