diff --git a/client/src/hooks/Artifacts/useArtifacts.ts b/client/src/hooks/Artifacts/useArtifacts.ts index a60df713cc..a348d0f212 100644 --- a/client/src/hooks/Artifacts/useArtifacts.ts +++ b/client/src/hooks/Artifacts/useArtifacts.ts @@ -8,7 +8,6 @@ import store from '~/store'; export default function useArtifacts() { const { isSubmitting, latestMessage, conversation } = useChatContext(); - const [isVisible, setIsVisible] = useState(false); const [activeTab, setActiveTab] = useState('preview'); const artifacts = useRecoilValue(store.artifactsState); const [currentArtifactId, setCurrentArtifactId] = useRecoilState(store.currentArtifactId); @@ -48,10 +47,6 @@ export default function useArtifacts() { prevConversationIdRef.current = conversation?.conversationId ?? null; }, [conversation, resetArtifacts, resetCurrentArtifactId]); - useEffect(() => { - setIsVisible(true); - }, []); - useEffect(() => { if (orderedArtifactIds.length > 0) { const latestArtifactId = orderedArtifactIds[orderedArtifactIds.length - 1]; @@ -110,14 +105,12 @@ export default function useArtifacts() { }; return { - isVisible, - setIsVisible, activeTab, setActiveTab, - currentArtifact, currentIndex, - cycleArtifact, isSubmitting, + cycleArtifact, + currentArtifact, orderedArtifactIds, }; } diff --git a/client/src/store/artifacts.ts b/client/src/store/artifacts.ts index 1e1bff61f2..26359a06a6 100644 --- a/client/src/store/artifacts.ts +++ b/client/src/store/artifacts.ts @@ -31,3 +31,18 @@ export const currentArtifactId = atom({ }, ] as const, }); + +export const artifactsVisible = atom({ + key: 'artifactsVisible', + default: true, + effects: [ + ({ onSet, node }) => { + onSet(async (newValue) => { + logger.log('artifacts', 'Recoil Effect: Setting artifactsVisible', { + key: node.key, + newValue, + }); + }); + }, + ] as const, +});