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
address review (codex): keep series cover thumbnail in sync + robustness
[._.]/ Adam Eivy01ff1e1c7753
diff --git a/client/src/components/ui/ImageThumb.jsx b/client/src/components/ui/ImageThumb.jsxindex 53063cbea2..afdbc0417a 100644--- a/client/src/components/ui/ImageThumb.jsx+++ b/client/src/components/ui/ImageThumb.jsx@@ -1,4 +1,4 @@-import { useState } from 'react';+import { useState, useEffect } from 'react';/*** List-card thumbnail with graceful fallback. Renders the image from@@ -10,6 +10,11 @@ import { useState } from 'react';*/export default function ImageThumb({ imageRef, FallbackIcon, alt = '', sizeClass = 'w-12 h-12' }) {const [broken, setBroken] = useState(false);+ // Reset the error state when the ref changes — otherwise a stale/404 ref that+ // tripped `broken` would keep the fallback icon stuck even after `imageRef`+ // updates to a valid filename (cover rendered / synced while the list stayed+ // mounted), until a remount.+ useEffect(() => { setBroken(false); }, [imageRef]);const showImage = imageRef && !broken;return (<div className={`flex-shrink-0 ${sizeClass} rounded-md overflow-hidden bg-port-bg border border-port-border flex items-center justify-center`}>diff --git a/server/scripts/backfillSeriesCoverImages.js b/server/scripts/backfillSeriesCoverImages.jsindex 1d2289a26b..26b80d0bf9 100644--- a/server/scripts/backfillSeriesCoverImages.js+++ b/server/scripts/backfillSeriesCoverImages.js@@ -65,9 +65,15 @@ export async function backfillSeriesCoverImages({ force = false } = {}) {// cover — and load every issue just ONCE, grouped by series, rather than a// per-series store scan. Drop run history (not needed to read a cover slot).const issuesBySeries = new Map();+ let issueScanFailed = false;if (series.some((s) => !pickVolumeCoverFilename(s?.seasons))) {const all = await listAllIssues({ withHistory: false }).catch((err) => {+ // A transient store/DB failure here would otherwise be treated as "no+ // issues" and the marker below would still be written, permanently+ // skipping issue-cover backfill for volume-less series. Flag it so we+ // leave the marker unwritten and retry on the next boot instead.console.error(`❌ series cover backfill: listAllIssues failed: ${err?.message || err}`);+ issueScanFailed = true;return [];});for (const issue of all) {@@ -91,6 +97,13 @@ export async function backfillSeriesCoverImages({ force = false } = {}) {});}+ // Don't mark the backfill applied if the issue scan failed — the volume-less+ // series were never actually scanned, so re-run on the next boot.+ if (issueScanFailed) {+ console.warn(`⚠️ series cover backfill: issue scan failed — leaving marker unwritten to retry next boot (scanned ${scanned} series, ${decorated} have a cover)`);+ return { skipped: false, scanned, decorated, issueScanFailed: true };+ }+await writeMarker({ version: MARKER_VERSION, appliedAt: new Date().toISOString(), scanned });console.log(`🖼️ series cover backfill: scanned ${scanned} series, ${decorated} have a cover`);return { skipped: false, scanned, decorated };diff --git a/server/scripts/backfillSeriesCoverImages.test.js b/server/scripts/backfillSeriesCoverImages.test.jsindex a52012e0d5..f82b6ca0cf 100644--- a/server/scripts/backfillSeriesCoverImages.test.js+++ b/server/scripts/backfillSeriesCoverImages.test.js@@ -87,6 +87,14 @@ describe('backfillSeriesCoverImages', () => {expect(listSeries).toHaveBeenCalled(); // force re-ran the walk});+ it('leaves the marker unwritten (retry next boot) when the issue scan fails', async () => {+ listSeries.mockResolvedValue([{ id: 'ser-1', coverImage: null, seasons: [] }]); // no volume cover → needs issue scan+ listAllIssues.mockRejectedValue(new Error('db down'));+ const res = await backfillSeriesCoverImages();+ expect(res).toMatchObject({ skipped: false, issueScanFailed: true });+ expect(existsSync(MARKER())).toBe(false); // not applied — will retry+ });+it('writes the marker even when there are no series', async () => {listSeries.mockResolvedValue([]);const res = await backfillSeriesCoverImages();diff --git a/server/services/pipeline/issues.js b/server/services/pipeline/issues.jsindex 49c4c85a30..19123e4ec8 100644--- a/server/services/pipeline/issues.js+++ b/server/services/pipeline/issues.js@@ -1178,7 +1178,17 @@ export function deleteIssue(id) {// Series export bundles every issue, so a deletion is an update on the// parent series for any active share-bucket subscription.emitRecordUpdated('series', seriesId);- return { id };+ return { id, seriesId };+ }).then(async (result) => {+ // The deleted issue may have owned the series' list thumbnail+ // (`series.coverImage`). Recompute outside the queue (it reads fresh+ // post-delete state) so the Pipeline list falls back to the next eligible+ // cover instead of pointing at a tombstone. Dynamic import dodges the+ // static cycle (seriesCoverImage → issues). Best-effort — a cosmetic+ // thumbnail must never fail the delete.+ const { refreshSeriesCoverImage } = await import('./seriesCoverImage.js');+ await refreshSeriesCoverImage(result.seriesId).catch(() => {});+ return { id: result.id };}));}diff --git a/server/services/pipeline/seasons.js b/server/services/pipeline/seasons.jsindex 3ac7e2738c..0c4d840888 100644--- a/server/services/pipeline/seasons.js+++ b/server/services/pipeline/seasons.js@@ -161,5 +161,11 @@ export async function deleteSeason(seriesId, seasonId, { reassignTo = null } = {await seriesSvc.updateSeries(seriesId, { seasons: merged });});emitRecordUpdated('series', seriesId);+ // The deleted season may have owned the series' list thumbnail (a volume+ // cover). Recompute so the Pipeline list falls back to the next eligible+ // cover (the next volume, then the earliest issue cover) instead of pointing+ // at the removed season. Dynamic import dodges the static cycle; best-effort.+ const { refreshSeriesCoverImage } = await import('./seriesCoverImage.js');+ await refreshSeriesCoverImage(seriesId).catch(() => {});return { id: seasonId, reassignedIssueCount, reassignedTo: reassignTo };}