From c8686ff1910bddd4f5949784ba185b598b75e128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Padez?= Date: Thu, 20 Aug 2026 04:01:00 +0000 Subject: [PATCH] channels: add useAtelierRefresh, for the atelier plugin's Generate/Gallery panels same stable-bump shape as useFilesRefresh. Generate and Gallery are independent sibling panels with no props between them (per the panel contract, components only ever receive panelId), so a finished job reaching the gallery needs a signal rather than the standalone app's onFinished callback prop. --- src/workspaces/officerdev/src/channels.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/workspaces/officerdev/src/channels.ts b/src/workspaces/officerdev/src/channels.ts index a5fab7d9..f238345c 100644 --- a/src/workspaces/officerdev/src/channels.ts +++ b/src/workspaces/officerdev/src/channels.ts @@ -97,3 +97,20 @@ export const useBackgroundJobChanged = () => { const bump = useCallback(() => setRef.current(++nonce), []); return [signal, bump] as const; }; + +/** + * "A generation finished — anyone showing the gallery should re-read." + * + * The Generate and Gallery panels are independent siblings (see `plugins/atelier/web/panels.ts`) with + * no props between them, so a finished job reaching the gallery needs a signal rather than a callback + * prop the way the standalone app's `onFinished` was. Same stable-bump shape as `useFilesRefresh`. + */ +const useAtelierRefreshChannel = defineChannel('atelier:refresh-signal', 0); + +export const useAtelierRefresh = () => { + const [signal, setSignal] = useAtelierRefreshChannel(); + const setRef = useRef(setSignal); + setRef.current = setSignal; + const bump = useCallback(() => setRef.current(++nonce), []); + return [signal, bump] as const; +};