fix(web): name prompt generator action (#40328)

This commit is contained in:
yyh authored and GitHub committed 2026-08-10 02:56:16 +00:00
1 parent cbd71699de
commit 83987b8eec
2 files changed
+31 -2

No files matched your search

@@ -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: () => <div role="dialog" aria-label="prompt generator" />,
}))
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(<PromptGeneratorBtn nodeId="node-1" />)
await user.click(screen.getByRole('button', { name: 'appDebug.operation.automatic' }))
expect(screen.getByRole('dialog', { name: 'prompt generator' })).toBeInTheDocument()
})
})
@@ -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<Props> = ({
editorId,
currentPrompt,
}) => {
const { t } = useTranslation()
const [showAutomatic, setShowAutomatic] = useState(false)
const handleAutomaticRes = useCallback(
(res: GenRes) => {
@@ -38,8 +40,12 @@ const PromptGeneratorBtn: FC<Props> = ({
const configsMap = useHooksStore((s) => s.configsMap)
return (
<div className={cn(className)}>
<ActionButton className="hover:bg-[#155EFF]/8" onClick={() => setShowAutomatic(true)}>
<Generator className="size-4 text-primary-600" />
<ActionButton
aria-label={t(($) => $['operation.automatic'], { ns: 'appDebug' })}
className="hover:bg-[#155EFF]/8"
onClick={() => setShowAutomatic(true)}
>
<Generator aria-hidden className="size-4 text-primary-600" />
</ActionButton>
{showAutomatic && (
<GetAutomaticResModal