From 83987b8eec5a5ed5dfe18593c97c1be0b866d4e3 Mon Sep 17 00:00:00 2001
From: yyh <92089059+lyzno1@users.noreply.github.com>
Date: Mon, 10 Aug 2026 10:56:16 +0800
Subject: [PATCH] fix(web): name prompt generator action (#40328)
---
.../__tests__/prompt-generator-btn.spec.tsx | 23 +++++++++++++++++++
.../llm/components/prompt-generator-btn.tsx | 10 ++++++--
2 files changed, 31 insertions(+), 2 deletions(-)
create mode 100644 web/app/components/workflow/nodes/llm/components/__tests__/prompt-generator-btn.spec.tsx
diff --git a/web/app/components/workflow/nodes/llm/components/__tests__/prompt-generator-btn.spec.tsx b/web/app/components/workflow/nodes/llm/components/__tests__/prompt-generator-btn.spec.tsx
new file mode 100644
index 00000000000..b91a0c1c835
--- /dev/null
+++ b/web/app/components/workflow/nodes/llm/components/__tests__/prompt-generator-btn.spec.tsx
@@ -0,0 +1,23 @@
+import { render, screen } from '@testing-library/react'
+import userEvent from '@testing-library/user-event'
+import PromptGeneratorBtn from '../prompt-generator-btn'
+
+vi.mock('@/app/components/app/configuration/config/automatic/get-automatic-res', () => ({
+ default: () =>
,
+}))
+
+vi.mock('@/app/components/workflow/hooks-store', () => ({
+ useHooksStore: (selector: (state: { configsMap: { flowId: string } }) => unknown) =>
+ selector({ configsMap: { flowId: 'flow-1' } }),
+}))
+
+describe('PromptGeneratorBtn', () => {
+ it('should open the prompt generator from the named action', async () => {
+ const user = userEvent.setup()
+ render()
+
+ await user.click(screen.getByRole('button', { name: 'appDebug.operation.automatic' }))
+
+ expect(screen.getByRole('dialog', { name: 'prompt generator' })).toBeInTheDocument()
+ })
+})
diff --git a/web/app/components/workflow/nodes/llm/components/prompt-generator-btn.tsx b/web/app/components/workflow/nodes/llm/components/prompt-generator-btn.tsx
index 4068921793e..138bbb00dc6 100644
--- a/web/app/components/workflow/nodes/llm/components/prompt-generator-btn.tsx
+++ b/web/app/components/workflow/nodes/llm/components/prompt-generator-btn.tsx
@@ -5,6 +5,7 @@ import type { GenRes } from '@/service/debug'
import { cn } from '@langgenius/dify-ui/cn'
import * as React from 'react'
import { useCallback, useState } from 'react'
+import { useTranslation } from 'react-i18next'
import GetAutomaticResModal from '@/app/components/app/configuration/config/automatic/get-automatic-res'
import { ActionButton } from '@/app/components/base/action-button'
import { Generator } from '@/app/components/base/icons/src/vender/other'
@@ -27,6 +28,7 @@ const PromptGeneratorBtn: FC = ({
editorId,
currentPrompt,
}) => {
+ const { t } = useTranslation()
const [showAutomatic, setShowAutomatic] = useState(false)
const handleAutomaticRes = useCallback(
(res: GenRes) => {
@@ -38,8 +40,12 @@ const PromptGeneratorBtn: FC = ({
const configsMap = useHooksStore((s) => s.configsMap)
return (
-
setShowAutomatic(true)}>
-
+ $['operation.automatic'], { ns: 'appDebug' })}
+ className="hover:bg-[#155EFF]/8"
+ onClick={() => setShowAutomatic(true)}
+ >
+
{showAutomatic && (