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: build ComicScriptStage lightbox items through normalizeImage (#7347)

[._.]/ Adam Eivyf0f4af98720c
diff --git a/client/src/components/media/PinToMoodBoardMenu.jsx b/client/src/components/media/PinToMoodBoardMenu.jsx
index 717e25cad3..332119e6cf 100644
--- a/client/src/components/media/PinToMoodBoardMenu.jsx
+++ b/client/src/components/media/PinToMoodBoardMenu.jsx
@@ -18,12 +18,12 @@ import {
// `item` is the normalized MediaCard shape: `item.previewUrl` is a renderable
// thumbnail URL (or null), and `item.key` is usually a `<kind>:<ref>` media-key
// (e.g. `image:foo.png`, `video:job-123`) — but NOT always: the lightbox is
-// also used for synthetic items keyed `canon-sheet:…`, `comic-page:…`
-// that the server's media-key validator rejects. So we pin a real mediaKey only
-// when the key is a valid `image:`/`video:` media-key (for source linkage +
-// dedup), and fall back to an imageUrl-only pin otherwise — keying membership
-// on whichever identifier we sent. The button hides only when NEITHER a valid
-// media-key NOR a renderable thumbnail is available (nothing to pin).
+// also used for synthetic items keyed `canon-sheet:…` that the server's
+// media-key validator rejects. So we pin a real mediaKey only when the key is
+// a valid `image:`/`video:` media-key (for source linkage + dedup), and fall
+// back to an imageUrl-only pin otherwise — keying membership on whichever
+// identifier we sent. The button hides only when NEITHER a valid media-key
+// NOR a renderable thumbnail is available (nothing to pin).
//
// Pinning the same asset again removes it (toggle), matching the collection
// menu's behavior.
@@ -66,8 +66,8 @@ export default function PinToMoodBoardMenu({ item, size = 'sm' }) {
const [busyId, setBusyId] = useState(null);
const triggerRef = useRef(null);
- // A real media-key only when it matches the server vocabulary; synthetic keys
- // (canon-sheet:/comic-page:) fall through to an imageUrl-only pin.
+ // A real media-key only when it matches the server vocabulary; a synthetic
+ // key (canon-sheet:) falls through to an imageUrl-only pin.
const mediaKey = isValidMediaKey(item.key) ? item.key : null;
// Only http(s) / absolute app paths are valid imageUrls (mirror the board
// item schema, which rejects a protocol-relative `//host` path even though it
diff --git a/client/src/components/media/PinToMoodBoardMenu.test.jsx b/client/src/components/media/PinToMoodBoardMenu.test.jsx
index c563be02b0..fbdf7b6ad6 100644
--- a/client/src/components/media/PinToMoodBoardMenu.test.jsx
+++ b/client/src/components/media/PinToMoodBoardMenu.test.jsx
@@ -142,7 +142,7 @@ describe('PinToMoodBoardMenu', () => {
it('renders nothing when there is no valid media-key and no renderable thumbnail', () => {
const { container } = render(
- <PinToMoodBoardMenu item={{ kind: 'image', key: 'comic-page:x.png', previewUrl: 'blob:abc' }} />,
+ <PinToMoodBoardMenu item={{ kind: 'image', key: 'canon-sheet:x.png', previewUrl: 'blob:abc' }} />,
);
expect(container).toBeEmptyDOMElement();
expect(screen.queryByTitle('Pin to mood board')).toBeNull();
diff --git a/client/src/components/pipeline/stages/ComicScriptStage.jsx b/client/src/components/pipeline/stages/ComicScriptStage.jsx
index 1bf4e21ced..e30f3749d8 100644
--- a/client/src/components/pipeline/stages/ComicScriptStage.jsx
+++ b/client/src/components/pipeline/stages/ComicScriptStage.jsx
@@ -32,7 +32,8 @@ import { useConfirmDelete } from '../../../hooks/useConfirmDelete';
import useSlotInFlight from '../../../hooks/useSlotInFlight';
import MediaJobThumb from '../MediaJobThumb';
import MediaPreview from '../../media/MediaPreview';
-import usePreviewRoute from '../../../hooks/usePreviewRoute';
+import useHydratedPreviewRoute from '../../../hooks/useHydratedPreviewRoute';
+import { normalizeImage } from '../../media/normalize';
import Drawer from '../../Drawer';
import ImageGenSettingsForm from '../../imageGen/ImageGenSettingsForm';
import ExtractCanonButton from './ExtractCanonButton';
@@ -197,7 +198,7 @@ export default function ComicScriptStage({ issue, series, onStageUpdate, actions
// Shared lightbox state. PageRow reports its rendered filename up via
// `onFilenameKnown` so the parent can build a navigable items list keyed by
// page order — preview prev/next walks rendered pages in page order. URL-
- // driven via `usePreviewRoute(previewItems)` below so the modal deep-links.
+ // driven via `useHydratedPreviewRoute(previewItems)` below so the modal deep-links.
const [filenameByJobId, setFilenameByJobId] = useState({});
const onFilenameKnown = useCallback((jobId, filename) => {
if (!jobId || !filename) return;
@@ -207,12 +208,12 @@ export default function ComicScriptStage({ issue, series, onStageUpdate, actions
// root — the server stamps the prompt it sent to the image-gen backend on
// each slot as it's enqueued. Read from there so the lightbox surfaces the
// actual generation prompt (and "Refine Prompt" has something to refine).
- const buildPageItem = useCallback((pageIndex, slot, filename) => ({
- key: `comic-page:${filename}`,
- kind: 'image',
+ // Built through `normalizeImage` (canonical `image:<filename>` key) so the
+ // detail panel gets render lineage and mood-board pins dedupe against the
+ // same image pinned from Media History; `useHydratedPreviewRoute` below
+ // hydrates the rest of the lineage fields from the sidecar on open.
+ const buildPageItem = useCallback((pageIndex, slot, filename) => normalizeImage({
filename,
- previewUrl: `/data/images/${filename}`,
- downloadUrl: `/data/images/${filename}`,
prompt: slot?.prompt || `Page ${pageIndex + 1}`,
}), []);
const previewItems = useMemo(() => {
@@ -236,7 +237,7 @@ export default function ComicScriptStage({ issue, series, onStageUpdate, actions
});
return out;
}, [comicPages.pages, filenameByJobId, buildPageItem]);
- const [preview, setPreview] = usePreviewRoute(previewItems);
+ const [preview, setPreview] = useHydratedPreviewRoute(previewItems);
const openPreview = useCallback((_pageIndex, filename) => {
if (!filename) return;
const match = previewItems.find((i) => i.filename === filename);