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(agent): preserve prompt copy confirmation (#43327)

yyhca27376211ce
diff --git a/web/features/agent-v2/agent-detail/configure/components/__tests__/agent-prompt-editor.spec.tsx b/web/features/agent-v2/agent-detail/configure/components/__tests__/agent-prompt-editor.spec.tsx
index 6d76dc64ea0..b5d1246bdd9 100644
--- a/web/features/agent-v2/agent-detail/configure/components/__tests__/agent-prompt-editor.spec.tsx
+++ b/web/features/agent-v2/agent-detail/configure/components/__tests__/agent-prompt-editor.spec.tsx
@@ -361,6 +361,30 @@ describe('AgentPromptEditor', () => {
expect(mockCopy).toHaveBeenCalledWith('Review these tenders')
})
+ it('should keep copied feedback visible after clicking the copy control', async () => {
+ const user = userEvent.setup()
+ const { useClipboard } =
+ await vi.importActual<typeof import('foxact/use-clipboard')>('foxact/use-clipboard')
+ mockUseClipboard.mockImplementation(useClipboard)
+ renderAgentPromptEditor('Review these tenders')
+ const copyButton = screen.getByRole('button', {
+ name: /agentDetail\.configure\.prompt\.copy/i,
+ })
+
+ await user.hover(copyButton)
+ expect(await screen.findByText(/agentDetail\.configure\.prompt\.copy$/)).toBeVisible()
+ await user.click(copyButton)
+
+ expect(await screen.findByText(/agentDetail\.configure\.prompt\.copied$/)).toBeVisible()
+ expect(await navigator.clipboard.readText()).toBe('Review these tenders')
+ await user.unhover(copyButton)
+ await waitFor(() => {
+ expect(
+ screen.queryByText(/agentDetail\.configure\.prompt\.copied$/),
+ ).not.toBeInTheDocument()
+ })
+ })
+
it('should let clipboard timeout restore the copied state instead of resetting on mouse leave', () => {
renderAgentPromptEditor('Review these tenders')
diff --git a/web/features/agent-v2/agent-detail/configure/components/orchestrate/prompt-editor/index.tsx b/web/features/agent-v2/agent-detail/configure/components/orchestrate/prompt-editor/index.tsx
index 5a88f45d0d1..b5f9949b57e 100644
--- a/web/features/agent-v2/agent-detail/configure/components/orchestrate/prompt-editor/index.tsx
+++ b/web/features/agent-v2/agent-detail/configure/components/orchestrate/prompt-editor/index.tsx
@@ -1095,6 +1095,7 @@ export function AgentPromptEditor() {
</div>
<Tooltip>
<TooltipTrigger
+ closeOnClick={false}
render={
<button
type="button"