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.

fix: fix custom tool content is not update (#30250)

wangxiaoleibf56c2e9dbdf
diff --git a/web/app/components/tools/edit-custom-collection-modal/index.tsx b/web/app/components/tools/edit-custom-collection-modal/index.tsx
index 474c2620108..a468af7257a 100644
--- a/web/app/components/tools/edit-custom-collection-modal/index.tsx
+++ b/web/app/components/tools/edit-custom-collection-modal/index.tsx
@@ -48,6 +48,7 @@ const EditCustomCollectionModal: FC<Props> = ({
const [editFirst, setEditFirst] = useState(!isAdd)
const [paramsSchemas, setParamsSchemas] = useState<CustomParamSchema[]>(payload?.tools || [])
+ const [labels, setLabels] = useState<string[]>(payload?.labels || [])
const [customCollection, setCustomCollection, getCustomCollection] = useGetState<CustomCollectionBackend>(isAdd
? {
provider: '',
@@ -67,6 +68,15 @@ const EditCustomCollectionModal: FC<Props> = ({
const originalProvider = isEdit ? payload.provider : ''
+ // Sync customCollection state when payload changes
+ useEffect(() => {
+ if (isEdit) {
+ setCustomCollection(payload)
+ setParamsSchemas(payload.tools || [])
+ setLabels(payload.labels || [])
+ }
+ }, [isEdit, payload])
+
const [showEmojiPicker, setShowEmojiPicker] = useState(false)
const emoji = customCollection.icon
const setEmoji = (emoji: Emoji) => {
@@ -124,7 +134,6 @@ const EditCustomCollectionModal: FC<Props> = ({
const [currTool, setCurrTool] = useState<CustomParamSchema | null>(null)
const [isShowTestApi, setIsShowTestApi] = useState(false)
- const [labels, setLabels] = useState<string[]>(payload?.labels || [])
const handleLabelSelect = (value: string[]) => {
setLabels(value)
}
diff --git a/web/app/components/tools/provider/detail.tsx b/web/app/components/tools/provider/detail.tsx
index c4b65f353d0..e0a22816964 100644
--- a/web/app/components/tools/provider/detail.tsx
+++ b/web/app/components/tools/provider/detail.tsx
@@ -100,9 +100,28 @@ const ProviderDetail = ({
const [isShowEditCollectionToolModal, setIsShowEditCustomCollectionModal] = useState(false)
const [showConfirmDelete, setShowConfirmDelete] = useState(false)
const [deleteAction, setDeleteAction] = useState('')
+
+ const getCustomProvider = useCallback(async () => {
+ setIsDetailLoading(true)
+ const res = await fetchCustomCollection(collection.name)
+ if (res.credentials.auth_type === AuthType.apiKey && !res.credentials.api_key_header_prefix) {
+ if (res.credentials.api_key_value)
+ res.credentials.api_key_header_prefix = AuthHeaderPrefix.custom
+ }
+ setCustomCollection({
+ ...res,
+ labels: collection.labels,
+ provider: collection.name,
+ })
+ setIsDetailLoading(false)
+ }, [collection.labels, collection.name])
+
const doUpdateCustomToolCollection = async (data: CustomCollectionBackend) => {
await updateCustomCollection(data)
onRefreshData()
+ await getCustomProvider()
+ // Use fresh data from form submission to avoid race condition with collection.labels
+ setCustomCollection(prev => prev ? { ...prev, labels: data.labels } : null)
Toast.notify({
type: 'success',
message: t('common.api.actionSuccess'),
@@ -118,20 +137,6 @@ const ProviderDetail = ({
})
setIsShowEditCustomCollectionModal(false)
}
- const getCustomProvider = useCallback(async () => {
- setIsDetailLoading(true)
- const res = await fetchCustomCollection(collection.name)
- if (res.credentials.auth_type === AuthType.apiKey && !res.credentials.api_key_header_prefix) {
- if (res.credentials.api_key_value)
- res.credentials.api_key_header_prefix = AuthHeaderPrefix.custom
- }
- setCustomCollection({
- ...res,
- labels: collection.labels,
- provider: collection.name,
- })
- setIsDetailLoading(false)
- }, [collection.labels, collection.name])
// workflow provider
const [isShowEditWorkflowToolModal, setIsShowEditWorkflowToolModal] = useState(false)
const getWorkflowToolProvider = useCallback(async () => {
diff --git a/web/app/components/workflow/header/version-history-button.tsx b/web/app/components/workflow/header/version-history-button.tsx
index ae3bd68b48d..9ec9e6934ec 100644
--- a/web/app/components/workflow/header/version-history-button.tsx
+++ b/web/app/components/workflow/header/version-history-button.tsx
@@ -61,7 +61,7 @@ const VersionHistoryButton: FC<VersionHistoryButtonProps> = ({
>
<Button
className={cn(
- 'p-2 rounded-lg border border-transparent',
+ 'rounded-lg border border-transparent p-2',
theme === 'dark' && 'border-black/5 bg-white/10 backdrop-blur-sm',
)}
onClick={handleViewVersionHistory}