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
honor the sidecar refresh key as a full re-read
[._.]/ Adam Eivy016770d1ef36
diff --git a/client/src/hooks/useGallerySidecars.js b/client/src/hooks/useGallerySidecars.jsindex ed9b9ae0d4..6b83900f33 100644--- a/client/src/hooks/useGallerySidecars.js+++ b/client/src/hooks/useGallerySidecars.js@@ -13,13 +13,17 @@ import { getGalleryImages } from '../services/apiImageVideo';* with the wrong prompt.** `filenames` may be a fresh array each render — the lookup is keyed on the- * sorted, de-duplicated contents, not on array identity. Only filenames not- * already held are requested, and results merge into the map rather than- * replacing it: a render completing appends ONE filename to its record, and- * re-fetching the whole set each time turned rendering a 78-card deck into 78- * lookups carrying 3,081 filenames between them. A filename that comes back- * empty stays unresolved, so `refreshKey` (bumped once a render has landed)- * retries just that one.+ * sorted, de-duplicated contents, not on array identity. A changed list fetches+ * only what is not already held and merges it in: a render completing appends+ * ONE filename to its record, and re-fetching the whole set each time turned+ * rendering a 78-card deck into 78 lookups carrying 3,081 filenames between+ * them. A filename that comes back empty stays unresolved and is retried by the+ * next lookup.+ *+ * A changed `refreshKey` means the sidecars themselves may have changed on+ * disk, which a list comparison cannot see — so it re-reads every filename,+ * including ones already held. Pass one only when that can happen; a caller+ * whose renders always arrive under new filenames (a deck) needs none.** Returns `{ byFilename, setSidecar }`; `setSidecar(record)` splices one* freshly written record in (e.g. after a clean) without a refetch.@@ -33,7 +37,12 @@ export default function useGallerySidecars(filenames, refreshKey = 0) {// What the map already holds, readable from the effect without making the// map its own dependency (which would re-run the effect on its own result).const loadedRef = useRef(new Set());+ const refreshedAtRef = useRef(refreshKey);useEffect(() => {+ if (refreshedAtRef.current !== refreshKey) {+ refreshedAtRef.current = refreshKey;+ loadedRef.current = new Set();+ }const missing = wanted.filter((f) => !loadedRef.current.has(f));if (!missing.length) return undefined;let cancelled = false;diff --git a/client/src/hooks/useGallerySidecars.test.jsx b/client/src/hooks/useGallerySidecars.test.jsxindex ee89ba4594..f691a58019 100644--- a/client/src/hooks/useGallerySidecars.test.jsx+++ b/client/src/hooks/useGallerySidecars.test.jsx@@ -34,6 +34,16 @@ describe('useGallerySidecars', () => {expect(getGalleryImages).toHaveBeenLastCalledWith(['b.png'], { silent: true });});+ it('re-reads everything when the refresh key moves, since a sidecar can change in place', async () => {+ const { rerender } = renderHook(({ key }) => useGallerySidecars(['a.png'], key), {+ initialProps: { key: 0 },+ });+ await waitFor(() => expect(getGalleryImages).toHaveBeenCalledTimes(1));+ rerender({ key: 1 });+ await waitFor(() => expect(getGalleryImages).toHaveBeenCalledTimes(2));+ expect(getGalleryImages).toHaveBeenLastCalledWith(['a.png'], { silent: true });+ });+it('splices one freshly written record in without a refetch', async () => {const { result } = renderHook(() => useGallerySidecars(['a.png']));await waitFor(() => expect(result.current.byFilename.size).toBe(1));diff --git a/client/src/pages/DeckDetail.jsx b/client/src/pages/DeckDetail.jsxindex ddf2bebcce..bf10242d31 100644--- a/client/src/pages/DeckDetail.jsx+++ b/client/src/pages/DeckDetail.jsx@@ -125,7 +125,8 @@ function DeckEditor({ id }) {const { byFilename: sidecars } = useGallerySidecars(cardImageRefs);const previewItems = useMemo(() => (deck? deck.cards.flatMap((c) => {- const composed = c.imageRefs.length ? composeCardRenderPrompt(deck, c) : null;+ if (!c.imageRefs.length) return [];+ const composed = composeCardRenderPrompt(deck, c);return c.imageRefs.map((filename) => {const meta = sidecars.get(filename);return normalizeImage({