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.
This commit is contained in:
2026-08-20 04:01:00 +00:00
parent 5854ccd4d8
commit c8686ff191
+17
View File
@@ -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<number>('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;
};