mirror of
https://github.com/langgenius/dify.git
synced 2026-07-28 07:28:34 +08:00
Co-authored-by: Jingyi-Dify <jingyi.qi@dify.ai> Co-authored-by: yyh <yuanyouhuilyz@gmail.com> Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: hjlarry <hjlarry@163.com> Co-authored-by: Bond Zhu <783504079@qq.com> Co-authored-by: Yansong Zhang <916125788@qq.com> Co-authored-by: yyh <92089059+lyzno1@users.noreply.github.com>
26 lines
867 B
TypeScript
26 lines
867 B
TypeScript
import type { AgentSoulAppFeaturesConfig } from '@dify/contracts/api/console/agent/types.gen'
|
|
import type { DraftFieldUpdate } from './utils'
|
|
import { atom, useAtomValue, useSetAtom } from 'jotai'
|
|
import { agentComposerDraftAtom } from '../store'
|
|
import { resolveDraftFieldUpdate } from './utils'
|
|
|
|
export const agentComposerAppFeaturesAtom = atom(
|
|
get => get(agentComposerDraftAtom).appFeatures,
|
|
(get, set, appFeaturesUpdate: DraftFieldUpdate<AgentSoulAppFeaturesConfig | undefined>) => {
|
|
const draft = get(agentComposerDraftAtom)
|
|
|
|
set(agentComposerDraftAtom, {
|
|
...draft,
|
|
appFeatures: resolveDraftFieldUpdate(draft.appFeatures, appFeaturesUpdate),
|
|
})
|
|
},
|
|
)
|
|
|
|
export function useAppFeatures() {
|
|
return useAtomValue(agentComposerAppFeaturesAtom)
|
|
}
|
|
|
|
export function useSetAppFeatures() {
|
|
return useSetAtom(agentComposerAppFeaturesAtom)
|
|
}
|