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.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
refactor(web): read system features through suspense queries (#45657)
yyh84004c7c31b4
diff --git a/web/app/components/api-key/dataset-scope-dialog.tsx b/web/app/components/api-key/dataset-scope-dialog.tsxindex 8af6e256004..169f72a9087 100644--- a/web/app/components/api-key/dataset-scope-dialog.tsx+++ b/web/app/components/api-key/dataset-scope-dialog.tsx@@ -33,7 +33,7 @@ import {} from '@langgenius/dify-ui/dialog'import { IconButton } from '@langgenius/dify-ui/icon-button'import { Radio, RadioGroup } from '@langgenius/dify-ui/radio-group'-import { useInfiniteQuery, useSuspenseQuery } from '@tanstack/react-query'+import { useInfiniteQuery, useQuery } from '@tanstack/react-query'import { useId, useMemo, useRef, useState } from 'react'import { useTranslation } from 'react-i18next'import { consoleQuery } from '@/service/console'@@ -163,7 +163,7 @@ function DatasetScopeContent({}: Omit<DatasetScopeDialogProps, 'open' | 'finalFocus' | 'onOpenChange'>) {const { t } = useTranslation(['appApi', 'common'])const scopeId = useId()- const { data: knowledgeFsEnabled } = useSuspenseQuery(+ const { data: knowledgeFsEnabled = false } = useQuery(consoleQuery.features.get.queryOptions({select: (features) => features.enable_knowledge_fs,}),diff --git a/web/app/components/app/tracing/__tests__/panel.spec.tsx b/web/app/components/app/tracing/__tests__/panel.spec.tsxindex 317bb1c61be..a5e55919619 100644--- a/web/app/components/app/tracing/__tests__/panel.spec.tsx+++ b/web/app/components/app/tracing/__tests__/panel.spec.tsx@@ -107,6 +107,10 @@ function renderPanel({mode = 'chat',}: { readOnly?: boolean; searchParams?: string; mode?: AppMode } = {}) {const client = createTestQueryClient()+ client.setQueryData(+ consoleQuery.systemFeatures.get.queryKey(),+ createSystemFeaturesFixture({ agent_tracing_api_collection_enabled: agentTracingEnabled }),+ )const QueryWrapper = createQueryClientWrapper(client)const { wrapper: NuqsWrapper, onUrlUpdate } = createNuqsTestWrapper({searchParams,@@ -231,34 +235,13 @@ describe('Tracing overview panel', () => {await client.invalidateQueries({ queryKey: consoleQuery.systemFeatures.get.queryKey() })})- expect(requested('/system-features')).toHaveLength(2)+ expect(requested('/system-features')).toHaveLength(1)expect(screen.getByRole('switch', { name: 'app.tracing.captureAgent' })).toBeChecked()expect(screen.queryByRole('note')).not.toBeInTheDocument()expect(writes).toEqual([])expect(requested('/features')).toEqual([])})- it('does not report a disabled deployment when the initial system-features request fails', async () => {- mockServer()- const server = request.getMockImplementation()!- request.mockImplementation(async (...args) => {- if (new URL(args[2].request.url).pathname.endsWith('/system-features'))- throw await httpErrorFromResponse(- Response.json({ message: 'System features unavailable' }, { status: 500 }),- )- return server(...args)- })- renderPanel({ searchParams: 'tracing=configure', mode: 'workflow' })-- await screen.findByRole('group', { name: 'app.tracing.langfuse.title' })- expect(screen.queryByRole('note')).not.toBeInTheDocument()- expect(- screen.queryByRole('button', { name: 'app.tracing.captureTitle' }),- ).not.toBeInTheDocument()- expect(requested('/trace-capabilities')).toEqual([])- expect(requested('/features')).toEqual([])- })-it('keeps Workflow capture policy read-only without fetching provider credentials', async () => {const writes = mockServer()renderPanel({ readOnly: true, mode: 'workflow' })diff --git a/web/app/components/app/tracing/config-popup.tsx b/web/app/components/app/tracing/config-popup.tsxindex 713a7c25b09..6b10fbc331f 100644--- a/web/app/components/app/tracing/config-popup.tsx+++ b/web/app/components/app/tracing/config-popup.tsx@@ -17,7 +17,7 @@ import { Separator } from '@langgenius/dify-ui/separator'import { StatusDot } from '@langgenius/dify-ui/status-dot'import { Switch } from '@langgenius/dify-ui/switch'import { Tooltip, TooltipContent, TooltipTrigger } from '@langgenius/dify-ui/tooltip'-import { useIsMutating, useQuery } from '@tanstack/react-query'+import { useIsMutating, useSuspenseQuery } from '@tanstack/react-query'import { useId, useRef } from 'react'import { useTranslation } from 'react-i18next'import { systemFeaturesQueryOptions } from '@/features/system-features/client'@@ -72,19 +72,18 @@ export function ConfigPopup({? consoleQuery.agent.byAgentId.traceConfig.key({ type: 'mutation' }): consoleQuery.apps.byAppId.traceConfig.key({ type: 'mutation' }),}) > 0- const { data: agentTracingEnabled } = useQuery({+ const { data: agentTracingEnabled } = useSuspenseQuery({...systemFeaturesQueryOptions(),select: (features) => features.agent_tracing_api_collection_enabled,})// Deployment availability is independent of the application destination.- const agentTracingSection =- usesAgentTracePipeline(resource) && agentTracingEnabled !== undefined- ? agentTracingEnabled- ? chosenProvider- ? 'settings'- : null- : 'unavailable'- : null+ const agentTracingSection = usesAgentTracePipeline(resource)+ ? agentTracingEnabled+ ? chosenProvider+ ? 'settings'+ : null+ : 'unavailable'+ : nullconst groups = [configurableProviders.filter((provider) => !!configs[provider]),configurableProviders.filter((provider) => !configs[provider]),diff --git a/web/app/components/app/tracing/configuration.tsx b/web/app/components/app/tracing/configuration.tsxindex 46043b0e00f..ba038816fb8 100644--- a/web/app/components/app/tracing/configuration.tsx+++ b/web/app/components/app/tracing/configuration.tsx@@ -8,7 +8,14 @@ import { cn } from '@langgenius/dify-ui/cn'import { Popover, PopoverContent, PopoverTrigger } from '@langgenius/dify-ui/popover'import { Separator } from '@langgenius/dify-ui/separator'import { StatusDot } from '@langgenius/dify-ui/status-dot'-import { noop, useMutation, useQueries, useQuery, useQueryClient } from '@tanstack/react-query'+import {+ noop,+ useMutation,+ useQueries,+ useQuery,+ useQueryClient,+ useSuspenseQuery,+} from '@tanstack/react-query'import { useQueryState } from 'nuqs'import { useTranslation } from 'react-i18next'import { SkeletonRectangle } from '@/app/components/base/skeleton'@@ -89,7 +96,7 @@ export function TracingConfiguration({ resource, readOnly }: TracingConfiguratioproviders.find((provider) => provider === tracingStatus?.tracing_provider) ?? nullconst queryClient = useQueryClient()// The popup's selected provider card shows these; start the request once the user aims at the trigger.- const { data: agentTracingEnabled } = useQuery({+ const { data: agentTracingEnabled } = useSuspenseQuery({...systemFeaturesQueryOptions(),select: (features) => features.agent_tracing_api_collection_enabled,})diff --git a/web/app/components/app/tracing/inherited-tracing-summary.tsx b/web/app/components/app/tracing/inherited-tracing-summary.tsxindex 18e676e7460..a09d09fd5c6 100644--- a/web/app/components/app/tracing/inherited-tracing-summary.tsx+++ b/web/app/components/app/tracing/inherited-tracing-summary.tsx@@ -3,7 +3,7 @@ import { Button, buttonVariants } from '@langgenius/dify-ui/button'import { cn } from '@langgenius/dify-ui/cn'import { Infotip, InfotipContent, InfotipTrigger } from '@langgenius/dify-ui/infotip'import { StatusDot } from '@langgenius/dify-ui/status-dot'-import { useQuery } from '@tanstack/react-query'+import { useQuery, useSuspenseQuery } from '@tanstack/react-query'import { useAtomValue } from 'jotai'import { useId } from 'react'import { useTranslation } from 'react-i18next'@@ -55,7 +55,7 @@ export function InheritedTracingSummary({const policy = statusQuery.dataconst provider = hasProviderForm(policy?.tracing_provider) ? policy.tracing_provider : nullconst enabled = !!policy?.enabled && !!provider- const { data: agentTracingEnabled } = useQuery({+ const { data: agentTracingEnabled } = useSuspenseQuery({...systemFeaturesQueryOptions(),select: (features) => features.agent_tracing_api_collection_enabled,})@@ -97,7 +97,7 @@ export function InheritedTracingSummary({<InfotipContent className="max-w-72"><p>{t(($) => $['tracing.inherited.description'], { ns: 'app' })}</p>{/* The capture policy has no effect where Agent tracing is unavailable. */}- {enabled && agentTracingEnabled !== false && (+ {enabled && agentTracingEnabled && (<dl className="mt-2 space-y-0.5"><div className="flex justify-between gap-3"><dt>{t(($) => $['tracing.captureContent'], { ns: 'app' })}</dt>@@ -153,7 +153,7 @@ export function InheritedTracingSummary({</span>)}</div>- {agentTracingEnabled === false ? (+ {!agentTracingEnabled ? (<p className="flex gap-1 system-xs-regular text-text-warning"><span aria-hidden className="mt-px i-ri-error-warning-line size-3.5 shrink-0" />{t(($) => $['tracing.agentTracingUnavailable'], { ns: 'app' })}diff --git a/web/app/components/app/tracing/provider-panel.tsx b/web/app/components/app/tracing/provider-panel.tsxindex 36da6e29348..a5fc58526ba 100644--- a/web/app/components/app/tracing/provider-panel.tsx+++ b/web/app/components/app/tracing/provider-panel.tsx@@ -6,7 +6,7 @@ import { Button, buttonVariants } from '@langgenius/dify-ui/button'import { cn } from '@langgenius/dify-ui/cn'import { DialogTrigger } from '@langgenius/dify-ui/dialog'import { RadioItem } from '@langgenius/dify-ui/radio-group'-import { useQuery } from '@tanstack/react-query'+import { useSuspenseQuery } from '@tanstack/react-query'import { useTranslation } from 'react-i18next'import { systemFeaturesQueryOptions } from '@/features/system-features/client'import { ProviderCapabilities } from './provider-capabilities'@@ -40,7 +40,7 @@ export function ProviderPanel({configError,}: ProviderPanelProps) {const { t } = useTranslation(['app', 'common'])- const { data: agentTracingEnabled } = useQuery({+ const { data: agentTracingEnabled } = useSuspenseQuery({...systemFeaturesQueryOptions(),select: (features) => features.agent_tracing_api_collection_enabled,})diff --git a/web/app/components/apps/app-list-catalog.tsx b/web/app/components/apps/app-list-catalog.tsxindex 34b2db7cd90..402f70eb3ad 100644--- a/web/app/components/apps/app-list-catalog.tsx+++ b/web/app/components/apps/app-list-catalog.tsx@@ -15,7 +15,13 @@ import {} from '@langgenius/dify-ui/alert-dialog'import { Button } from '@langgenius/dify-ui/button'import { cn } from '@langgenius/dify-ui/cn'-import { keepPreviousData, useInfiniteQuery, useMutation, useQuery } from '@tanstack/react-query'+import {+ keepPreviousData,+ useInfiniteQuery,+ useMutation,+ useQuery,+ useSuspenseQuery,+} from '@tanstack/react-query'import { useCallback, useMemo, useState } from 'react'import { useTranslation } from 'react-i18next'import { DeleteAppForm } from '@/app/components/app/delete-app-form'@@ -372,8 +378,7 @@ export function AppListCatalog(props: AppListCatalogProps) {onTryLearnDify,scrollViewportRef,} = props- const systemFeaturesQuery = useQuery(systemFeaturesQueryOptions())- const systemFeatures = systemFeaturesQuery.data+ const { data: systemFeatures } = useSuspenseQuery(systemFeaturesQueryOptions())const { data: isCollaborationEnabled = false } = useQuery(consoleQuery.features.get.queryOptions({retry: false,@@ -407,14 +412,9 @@ export function AppListCatalog(props: AppListCatalogProps) {}),)- if (systemFeatures === undefined && systemFeaturesQuery.error) throw systemFeaturesQuery.errorif (appList.data === undefined && appList.error) throw appList.error- if (- systemFeatures === undefined ||- appList.data === undefined ||- (starredAppList.data === undefined && !starredAppList.error)- )+ if (appList.data === undefined || (starredAppList.data === undefined && !starredAppList.error))return <CatalogSkeleton />return (diff --git a/web/app/components/rag-pipeline/hooks/use-available-nodes-meta-data.ts b/web/app/components/rag-pipeline/hooks/use-available-nodes-meta-data.tsindex b95652a2efa..3a734874b1b 100644--- a/web/app/components/rag-pipeline/hooks/use-available-nodes-meta-data.ts+++ b/web/app/components/rag-pipeline/hooks/use-available-nodes-meta-data.ts@@ -1,5 +1,5 @@import type { AvailableNodesMetaData } from '@/app/components/workflow/hooks-store/store'-import { useSuspenseQuery } from '@tanstack/react-query'+import { useQuery } from '@tanstack/react-query'import { useMemo } from 'react'import { useTranslation } from 'react-i18next'import { WORKFLOW_COMMON_NODES } from '@/app/components/workflow/constants/node'@@ -16,7 +16,7 @@ export const useAvailableNodesMetaData = () => {const { t } = useTranslation(['workflow'])const docLink = useDocLink()const agentV2Enabled = isAgentV2Enabled()- const { data: knowledgeFsEnabled } = useSuspenseQuery(+ const { data: knowledgeFsEnabled = false } = useQuery(consoleQuery.features.get.queryOptions({select: (features) => features.enable_knowledge_fs,}),diff --git a/web/app/components/workflow/node-catalog.ts b/web/app/components/workflow/node-catalog.tsindex b1d488a6fa7..d29f60fee6a 100644--- a/web/app/components/workflow/node-catalog.ts+++ b/web/app/components/workflow/node-catalog.ts@@ -1,6 +1,6 @@import type { AvailableNodesMetaData } from '@/app/components/workflow/hooks-store/store'import type { DocPathWithoutLang } from '@/types/doc-paths'-import { useSuspenseQuery } from '@tanstack/react-query'+import { useQuery } from '@tanstack/react-query'import { useAtomValue } from 'jotai'import { useMemo } from 'react'import { useTranslation } from 'react-i18next'@@ -39,7 +39,7 @@ export const useWorkflowNodeCatalog = () => {// Chatflow (advanced-chat) keeps Agent v2 hidden by default; opt in via// NEXT_PUBLIC_ENABLE_AGENT_V2_IN_CHATFLOW. Pure workflows are unaffected.const shouldUseAgentV2 = agentV2Enabled && (!isChatflow || isAgentV2InChatflowEnabled())- const { data: knowledgeFsEnabled } = useSuspenseQuery(+ const { data: knowledgeFsEnabled = false } = useQuery(consoleQuery.features.get.queryOptions({select: (features) => features.enable_knowledge_fs,}),diff --git a/web/app/components/workflow/nodes/agent-v2/components/agent-orchestrate-panel-content.tsx b/web/app/components/workflow/nodes/agent-v2/components/agent-orchestrate-panel-content.tsxindex ad4b849fd8c..639b347e24b 100644--- a/web/app/components/workflow/nodes/agent-v2/components/agent-orchestrate-panel-content.tsx+++ b/web/app/components/workflow/nodes/agent-v2/components/agent-orchestrate-panel-content.tsx@@ -13,7 +13,13 @@ import type { EditorResource } from '@/app/components/workflow/editor-resource/rimport type { AgentPreviewChatController } from '@/features/agent-v2/agent-detail/configure/components/preview/chat-conversation'import { IconButton } from '@langgenius/dify-ui/icon-button'import { Menu, MenuContent, MenuItem, MenuTrigger } from '@langgenius/dify-ui/menu'-import { skipToken, useMutation, useQuery, useQueryClient } from '@tanstack/react-query'+import {+ skipToken,+ useMutation,+ useQuery,+ useQueryClient,+ useSuspenseQuery,+} from '@tanstack/react-query'import { useAtom, useAtomValue, useStore as useJotaiStore, useSetAtom } from 'jotai'import { ScopeProvider } from 'jotai-scope'import { useCallback, useRef, useState } from 'react'@@ -274,7 +280,7 @@ function WorkflowInlineAgentConfigureWorkspaceContent({const queryClient = useQueryClient()const jotaiStore = useJotaiStore()const setBuildDraftSoulSourceOverride = buildDraft.setSoulSourceOverride- const { data: systemFeatures } = useQuery(systemFeaturesQueryOptions())+ const { data: systemFeatures } = useSuspenseQuery(systemFeaturesQueryOptions())const composerState = inlineComposerStateconst [clearPreviewChat, setClearPreviewChat] = useState(false)const [completedBuildConversationId, setCompletedBuildConversationId] = useState<string | null>(@@ -284,7 +290,7 @@ function WorkflowInlineAgentConfigureWorkspaceContent({const appId = resource?.kind === 'app' ? resource.appId : undefinedconst conversationIds = useAtomValue(agentConfigureConversationIdsAtom)const [rightPanelMode, setRightPanelMode] = useAtom(agentConfigureRightPanelModeAtom)- const previewEnabled = systemFeatures?.deployment_edition !== 'COMMUNITY'+ const previewEnabled = systemFeatures.deployment_edition !== 'COMMUNITY'const [showWorkingDirectory, setShowWorkingDirectory] = useState(false)const resetConversation = useSetAtom(resetAgentConfigureConversationAtom)