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(web): save the shown timezone on new schedule trigger nodes (#43532)

Juhyuk choi2849e52b882b
diff --git a/web/app/components/workflow/nodes/trigger-schedule/__tests__/use-config.spec.ts b/web/app/components/workflow/nodes/trigger-schedule/__tests__/use-config.spec.ts
index 04f224d400c..4c5a4020017 100644
--- a/web/app/components/workflow/nodes/trigger-schedule/__tests__/use-config.spec.ts
+++ b/web/app/components/workflow/nodes/trigger-schedule/__tests__/use-config.spec.ts
@@ -1,5 +1,5 @@
import type { ScheduleTriggerNodeType } from '../types'
-import { act } from '@testing-library/react'
+import { act, waitFor } from '@testing-library/react'
import { seedAccountProfileQuery } from '@/test/console/account-profile'
import { createConsoleQueryWrapper } from '@/test/console/query-data'
import { BlockEnum } from '../../../types'
@@ -77,3 +77,40 @@ it('persists raw cron mode without visual schedule fields', () => {
}),
)
})
+
+it('saves the profile timezone when the node has none, so the backend does not fall back to UTC', async () => {
+ const { queryClient } = createConsoleQueryWrapper()
+ seedAccountProfileQuery(queryClient, { timezone: 'Asia/Shanghai' })
+ const { result } = renderNodeConfig(useConfig, createData({ timezone: undefined }), {
+ queryClient,
+ })
+ await waitFor(() => {
+ expect(result.current.flow.getNode('node')?.data).toEqual(
+ expect.objectContaining({ timezone: 'Asia/Shanghai' }),
+ )
+ })
+})
+
+it('does not overwrite a timezone that is already saved', async () => {
+ const { queryClient } = createConsoleQueryWrapper()
+ seedAccountProfileQuery(queryClient, { timezone: 'Asia/Shanghai' })
+ const { result } = renderNodeConfig(useConfig, createData({ timezone: 'Europe/Berlin' }), {
+ queryClient,
+ })
+ await new Promise((resolve) => setTimeout(resolve, 0))
+ expect(result.current.flow.getNode('node')?.data).toEqual(
+ expect.objectContaining({ timezone: 'Europe/Berlin' }),
+ )
+})
+
+it('does not save the timezone in read-only mode', async () => {
+ const { queryClient } = createConsoleQueryWrapper()
+ seedAccountProfileQuery(queryClient, { timezone: 'Asia/Shanghai' })
+ const { result } = renderNodeConfig(useConfig, createData({ timezone: undefined }), {
+ queryClient,
+ initialStoreState: { isRestoring: true },
+ })
+ await new Promise((resolve) => setTimeout(resolve, 0))
+ expect(result.current.config.readOnly).toBe(true)
+ expect(result.current.flow.getNode('node')?.data.timezone).toBeUndefined()
+})
diff --git a/web/app/components/workflow/nodes/trigger-schedule/use-config.ts b/web/app/components/workflow/nodes/trigger-schedule/use-config.ts
index accfa526a11..c1c72254c7c 100644
--- a/web/app/components/workflow/nodes/trigger-schedule/use-config.ts
+++ b/web/app/components/workflow/nodes/trigger-schedule/use-config.ts
@@ -1,6 +1,6 @@
import type { ScheduleFrequency, ScheduleMode, ScheduleTriggerNodeType } from './types'
import { useQuery } from '@tanstack/react-query'
-import { useCallback, useMemo } from 'react'
+import { useCallback, useEffect, useMemo } from 'react'
import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud'
import { userProfileQueryOptions } from '@/features/account-profile/client'
import { useNodesReadOnly } from '../../hooks/use-workflow'
@@ -29,6 +29,13 @@ const useConfig = (id: string, payload: ScheduleTriggerNodeType) => {
const { inputs, setInputs } = useNodeCrud<ScheduleTriggerNodeType>(id, frontendPayload)
+ // The panel shows the profile timezone, but the backend falls back to UTC when the node has none.
+ // Save the shown timezone so the schedule runs at the time the user sees.
+ useEffect(() => {
+ if (readOnly || payload.timezone || !timezone) return
+ setInputs({ ...inputs, timezone })
+ }, [readOnly, payload.timezone, timezone, inputs, setInputs])
+
const handleModeChange = useCallback(
(mode: ScheduleMode) => {
const newInputs = {