An AI-powered search engine with a generative UI
TypeScript generative-aigenerative-uinextjsollamareactsearxngshadcn-uitailwindcsstavilytypescriptupstashvercel-ai-sdk
feat: close sidebar when opening artifact
Yoshiki Miuraa58343932a0d
diff --git a/components/artifact/artifact-context.tsx b/components/artifact/artifact-context.tsxindex 49aa2525..7ab0917d 100644--- a/components/artifact/artifact-context.tsx+++ b/components/artifact/artifact-context.tsx@@ -2,6 +2,7 @@import type { ToolInvocation } from 'ai'import { createContext, ReactNode, useContext, useReducer } from 'react'+import { useSidebar } from '../ui/sidebar'// Part types as seen in render-message.tsxexport type TextPart = {@@ -59,9 +60,10 @@ const ArtifactContext = createContext<ArtifactContextValue | undefined>(export function ArtifactProvider({ children }: { children: ReactNode }) {const [state, dispatch] = useReducer(artifactReducer, initialState)-+ const { setOpen } = useSidebar()const open = (part: Part) => {dispatch({ type: 'OPEN', payload: part })+ setOpen(false)}const close = () => {