Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

chore: add selector for use app store (#3746)

KVOJJJin0715db768195
diff --git a/web/app/components/app/chat/log/index.tsx b/web/app/components/app/chat/log/index.tsx
index d4c1cff2b28..c4111eb2e10 100644
--- a/web/app/components/app/chat/log/index.tsx
+++ b/web/app/components/app/chat/log/index.tsx
@@ -11,7 +11,10 @@ const Log: FC<LogProps> = ({
logItem,
}) => {
const { t } = useTranslation()
- const { setCurrentLogItem, setShowPromptLogModal, setShowAgentLogModal, setShowMessageLogModal } = useAppStore()
+ const setCurrentLogItem = useAppStore(s => s.setCurrentLogItem)
+ const setShowPromptLogModal = useAppStore(s => s.setShowPromptLogModal)
+ const setShowAgentLogModal = useAppStore(s => s.setShowAgentLogModal)
+ const setShowMessageLogModal = useAppStore(s => s.setShowMessageLogModal)
const { workflow_run_id: runID, agent_thoughts } = logItem
const isAgent = agent_thoughts && agent_thoughts.length > 0
diff --git a/web/app/components/app/log/list.tsx b/web/app/components/app/log/list.tsx
index 35bf7e7b607..776daf3f72f 100644
--- a/web/app/components/app/log/list.tsx
+++ b/web/app/components/app/log/list.tsx
@@ -12,6 +12,7 @@ import { get } from 'lodash-es'
import InfiniteScroll from 'react-infinite-scroll-component'
import dayjs from 'dayjs'
import { createContext, useContext } from 'use-context-selector'
+import { useShallow } from 'zustand/react/shallow'
import { useTranslation } from 'react-i18next'
import cn from 'classnames'
import s from './style.module.css'
@@ -154,7 +155,16 @@ type IDetailPanel<T> = {
function DetailPanel<T extends ChatConversationFullDetailResponse | CompletionConversationFullDetailResponse>({ detail, onFeedback }: IDetailPanel<T>) {
const { onClose, appDetail } = useContext(DrawerContext)
- const { currentLogItem, setCurrentLogItem, showPromptLogModal, setShowPromptLogModal, showAgentLogModal, setShowAgentLogModal, showMessageLogModal, setShowMessageLogModal } = useAppStore()
+ const { currentLogItem, setCurrentLogItem, showPromptLogModal, setShowPromptLogModal, showAgentLogModal, setShowAgentLogModal, showMessageLogModal, setShowMessageLogModal } = useAppStore(useShallow(state => ({
+ currentLogItem: state.currentLogItem,
+ setCurrentLogItem: state.setCurrentLogItem,
+ showPromptLogModal: state.showPromptLogModal,
+ setShowPromptLogModal: state.setShowPromptLogModal,
+ showAgentLogModal: state.showAgentLogModal,
+ setShowAgentLogModal: state.setShowAgentLogModal,
+ showMessageLogModal: state.showMessageLogModal,
+ setShowMessageLogModal: state.setShowMessageLogModal,
+ })))
const { t } = useTranslation()
const [items, setItems] = React.useState<IChatItem[]>([])
const [hasMore, setHasMore] = useState(true)
diff --git a/web/app/components/app/switch-app-modal/index.tsx b/web/app/components/app/switch-app-modal/index.tsx
index c0b744da31e..3644d3d4e83 100644
--- a/web/app/components/app/switch-app-modal/index.tsx
+++ b/web/app/components/app/switch-app-modal/index.tsx
@@ -35,7 +35,7 @@ const SwitchAppModal = ({ show, appDetail, inAppDetail = false, onSuccess, onClo
const { push, replace } = useRouter()
const { t } = useTranslation()
const { notify } = useContext(ToastContext)
- const { setAppDetail } = useAppStore()
+ const setAppDetail = useAppStore(s => s.setAppDetail)
const { isCurrentWorkspaceManager } = useAppContext()
const { plan, enableBilling } = useProviderContext()
diff --git a/web/app/components/app/text-generate/item/index.tsx b/web/app/components/app/text-generate/item/index.tsx
index 0db3c301c75..6c0b5da6592 100644
--- a/web/app/components/app/text-generate/item/index.tsx
+++ b/web/app/components/app/text-generate/item/index.tsx
@@ -121,7 +121,8 @@ const GenerationItem: FC<IGenerationItemProps> = ({
const [childFeedback, setChildFeedback] = useState<Feedbacktype>({
rating: null,
})
- const { setCurrentLogItem, setShowPromptLogModal } = useAppStore()
+ const setCurrentLogItem = useAppStore(s => s.setCurrentLogItem)
+ const setShowPromptLogModal = useAppStore(s => s.setShowPromptLogModal)
const handleFeedback = async (childFeedback: Feedbacktype) => {
await updateFeedback({ url: `/messages/${childMessageId}/feedbacks`, body: { rating: childFeedback.rating } }, isInstalledApp, installedAppId)
diff --git a/web/app/components/base/agent-log-modal/detail.tsx b/web/app/components/base/agent-log-modal/detail.tsx
index d83901d0a2a..b9258a4092f 100644
--- a/web/app/components/base/agent-log-modal/detail.tsx
+++ b/web/app/components/base/agent-log-modal/detail.tsx
@@ -30,7 +30,7 @@ const AgentLogDetail: FC<AgentLogDetailProps> = ({
const { t } = useTranslation()
const { notify } = useContext(ToastContext)
const [currentTab, setCurrentTab] = useState<string>(activeTab)
- const { appDetail } = useAppStore()
+ const appDetail = useAppStore(s => s.appDetail)
const [loading, setLoading] = useState<boolean>(true)
const [runDetail, setRunDetail] = useState<AgentLogDetailResponse>()
const [list, setList] = useState<AgentIteration[]>([])