ultisuite-client/lib/ai/use-ai-panel.ts
R3D347HR4Y 303b2b1074
Some checks are pending
E2E / Playwright e2e (push) Waiting to run
wow
2026-06-11 01:22:40 +02:00

33 lines
789 B
TypeScript

"use client"
import { create } from "zustand"
import type { AiChatContext } from "@/lib/ai/chat-context"
type AiPanelState = {
open: boolean
context: AiChatContext
openPanel: (context?: Partial<AiChatContext>) => void
closePanel: () => void
setContext: (patch: Partial<AiChatContext>) => void
}
const DEFAULT_CONTEXT: AiChatContext = {
app: "standalone",
temporary: true,
}
export const useAiPanelStore = create<AiPanelState>((set) => ({
open: false,
context: DEFAULT_CONTEXT,
openPanel: (patch) =>
set((s) => ({
open: true,
context: { ...s.context, ...patch, temporary: patch?.temporary ?? true },
})),
closePanel: () => set({ open: false }),
setContext: (patch) =>
set((s) => ({
context: { ...s.context, ...patch },
})),
}))