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): remove success toasts for results visible in place (#43801)
yyhce23dbcfac3d
diff --git a/.agents/skills/frontend-code-review/references/data-query-contracts.md b/.agents/skills/frontend-code-review/references/data-query-contracts.mdindex 1dc9edc3e0b..686431c38df 100644--- a/.agents/skills/frontend-code-review/references/data-query-contracts.md+++ b/.agents/skills/frontend-code-review/references/data-query-contracts.md@@ -10,6 +10,7 @@ Review explicit team conventions as contracts, including direct generated option- Distinguish a pass-through wrapper from a feature hook with actual orchestration. Check whether an independent execution condition or Promise composition justifies the documented query/mutation exception.- Trace generated input and output types through their boundaries. Identify the exact DTO mirror, field widening, placeholder input, or lost intentional empty value when reporting a violation.- Check whether a local mutation callback owns feature feedback or replaces shared invalidation, retry, or cache defaults. Match optimistic changes to the current list/detail owner.+- Check whether a new or changed toast reports something the user cannot already see. Flag a success toast for a result visible in place, a second error toast for a failure another layer already reports, and validation reported through a toast.## Imperative Access And SSRdiff --git a/.agents/skills/how-to-write-component/references/data.md b/.agents/skills/how-to-write-component/references/data.mdindex 009f14c5c52..bff14eca6ce 100644--- a/.agents/skills/how-to-write-component/references/data.md+++ b/.agents/skills/how-to-write-component/references/data.md@@ -29,6 +29,7 @@ Read this document when a component consumes generated contracts, nullable API v- Use generated `mutationOptions()` directly for owner-local mutations.- Do not introduce deprecated `useInvalid` or `useReset` APIs.- Put shared invalidation, retries, and cache behavior in `createTanstackQueryUtils(...experimental_defaults...)`. In oRPC v1, caller options override defaults, including callbacks. Local callbacks may own toast, close, and navigation effects but must preserve shared cache behavior.+- A mutation callback is not a reason to show a toast. Show one only for a result the user cannot see where they acted; a control that displays its new value, or a dialog that closes onto the updated list, is already the feedback. Do not report a failure that another layer already reports.- Prefer `mutate(...)`. Use `mutateAsync(...)` only when Promise composition is required, and catch awaited failures.- Preserve intentional empty values and current list/detail ownership when updating data. Do not add optimistic updates without a verified owner contract.diff --git a/web/AGENTS.md b/web/AGENTS.mdindex bc4e8987aaa..253708d233d 100644--- a/web/AGENTS.md+++ b/web/AGENTS.md@@ -9,6 +9,7 @@Web owns application-specific requirements and consumes shared architecture guidance from skills and primitive contracts from Dify UI. Link to those owners instead of redefining their rules here.- For truncated text disclosure and native `title` decisions, follow [Truncated Text Disclosure].+- Before adding or keeping a toast, follow [Toasts]. A toast is only for a result the user cannot see where they acted.- When adding or changing page layouts, navigation, or landmark elements, follow [Page landmarks] and inspect the composed page, including parent layouts.- User-facing strings must use `web/i18n/locales/en-US/` keys. When adding or renaming a key, update every supported locale with the correct localized value.- For new backend calls and migrated surfaces, use generated `consoleQuery` / `consoleClient` APIs from `@/service/console`. Do not add handwritten REST helpers or DTO mirrors, mock-backed app state, or direct edits to generated contracts.@@ -40,5 +41,6 @@ This block is written and re-added by `next dev` — verify at `node_modules/nex[Input Group contract]: ../packages/dify-ui/src/input-group/README.md[Keyboard commands]: docs/hotkeys.md[Page landmarks]: docs/landmarks.md+[Toasts]: docs/toasts.md[Truncated Text Disclosure]: docs/truncated-text-disclosure.md[form contract]: ../packages/dify-ui/docs/forms.mddiff --git a/web/app/components/app/annotation/__tests__/index.spec.tsx b/web/app/components/app/annotation/__tests__/index.spec.tsxindex 008887038f6..286dc435a11 100644--- a/web/app/components/app/annotation/__tests__/index.spec.tsx+++ b/web/app/components/app/annotation/__tests__/index.spec.tsx@@ -393,12 +393,7 @@ describe('Annotation', () => {AnnotationEnableStatus.disable,'job-1',)- expect(mockNotify).toHaveBeenCalledWith(- expect.objectContaining({- message: 'common.api.actionSuccess',- type: 'success',- }),- )+ expect(screen.getByRole('switch')).toHaveAttribute('aria-checked', 'false')})})diff --git a/web/app/components/app/annotation/index.tsx b/web/app/components/app/annotation/index.tsxindex 0638495abe0..f09485d32e0 100644--- a/web/app/components/app/annotation/index.tsx+++ b/web/app/components/app/annotation/index.tsx@@ -215,7 +215,6 @@ const Annotation: FC<Props> = (props) => {)await ensureJobCompleted(jobId, AnnotationEnableStatus.disable)await fetchAnnotationConfig()- toast.success(t(($) => $['api.actionSuccess'], { ns: 'common' }))}}}></Switch>diff --git a/web/app/components/app/log/list.tsx b/web/app/components/app/log/list.tsxindex 7cc8b07c7b1..6265ceced0d 100644--- a/web/app/components/app/log/list.tsx+++ b/web/app/components/app/log/list.tsx@@ -642,7 +642,6 @@ const CompletionConversationDetailComp: FC<ConversationDetailProps> = ({body: { message_id: mid, rating, content: content ?? undefined },})conversationDetailMutate()- toast.success(t(($) => $['actionMsg.modifiedSuccessfully'], { ns: 'common' }))}const handleAnnotation = async (mid: string, value: string): Promise<boolean> => {@@ -696,7 +695,6 @@ const ChatConversationDetailComp: FC<ConversationDetailProps> = ({url: `/apps/${appDetail.id}/feedbacks`,body: { message_id: mid, rating, content: content ?? undefined },})- toast.success(t(($) => $['actionMsg.modifiedSuccessfully'], { ns: 'common' }))}const handleAnnotation = async (mid: string, value: string): Promise<boolean> => {diff --git a/web/app/components/app/text-generate/saved-items/__tests__/index.spec.tsx b/web/app/components/app/text-generate/saved-items/__tests__/index.spec.tsxindex 93863263268..43e0348a695 100644--- a/web/app/components/app/text-generate/saved-items/__tests__/index.spec.tsx+++ b/web/app/components/app/text-generate/saved-items/__tests__/index.spec.tsx@@ -1,22 +1,22 @@import type { ISavedItemsProps } from '../index'import { fireEvent, render, screen } from '@testing-library/react'-import copy from 'copy-to-clipboard'import * as React from 'react'import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'-import { toast } from '@/app/notifications'import SavedItems from '../index'-vi.mock('copy-to-clipboard', () => ({- default: vi.fn(),+const mockCopy = vi.fn()++vi.mock('foxact/use-clipboard', () => ({+ useClipboard: () => ({+ copy: mockCopy,+ copied: false,+ }),}))vi.mock('@/next/navigation', () => ({useParams: () => ({}),usePathname: () => '/',}))-const mockCopy = vi.mocked(copy)-const toastSuccessSpy = vi.spyOn(toast, 'success').mockReturnValue('toast-success')-const baseProps: ISavedItemsProps = {list: [{ id: '1', answer: 'hello world' }],isShowTextToSpeech: true,@@ -27,7 +27,6 @@ const baseProps: ISavedItemsProps = {describe('SavedItems', () => {beforeEach(() => {vi.clearAllMocks()- toastSuccessSpy.mockClear()})it('renders saved answers with metadata and controls', () => {@@ -41,7 +40,7 @@ describe('SavedItems', () => {expect(screen.getByRole('button', { name: 'common.operation.delete' })).toBeInTheDocument()})- it('copies content and notifies, and triggers remove callback', () => {+ it('copies content and triggers remove callback', () => {const handleRemove = vi.fn()render(<SavedItems {...baseProps} onRemove={handleRemove} />)@@ -50,7 +49,6 @@ describe('SavedItems', () => {fireEvent.click(copyButton)expect(mockCopy).toHaveBeenCalledWith('hello world')- expect(toastSuccessSpy).toHaveBeenCalledWith('common.actionMsg.copySuccessfully')fireEvent.click(deleteButton)expect(handleRemove).toHaveBeenCalledWith('1')diff --git a/web/app/components/app/text-generate/saved-items/index.tsx b/web/app/components/app/text-generate/saved-items/index.tsxindex 2d93968d4df..76fd00eb85c 100644--- a/web/app/components/app/text-generate/saved-items/index.tsx+++ b/web/app/components/app/text-generate/saved-items/index.tsx@@ -3,13 +3,12 @@ import type { FC } from 'react'import type { SavedMessage } from '@/models/debug'import { cn } from '@langgenius/dify-ui/cn'import { IconButton } from '@langgenius/dify-ui/icon-button'-import { RiClipboardLine, RiDeleteBinLine } from '@remixicon/react'-import copy from 'copy-to-clipboard'+import { RiDeleteBinLine } from '@remixicon/react'import * as React from 'react'import { useTranslation } from 'react-i18next'+import { CopyFeedback } from '@/app/components/base/copy-feedback'import { Markdown } from '@/app/components/base/markdown'import NewAudioButton from '@/app/components/base/new-audio-button'-import { toast } from '@/app/notifications'import NoData from './no-data'export type ISavedItemsProps = {@@ -48,15 +47,7 @@ const SavedItems: FC<ISavedItemsProps> = ({<div className="absolute right-2 bottom-1"><div className="ml-1 flex items-center gap-0.5 rounded-[10px] border-[0.5px] border-components-actionbar-border bg-components-actionbar-bg p-0.5 shadow-md backdrop-blur-xs">{isShowTextToSpeech && <NewAudioButton value={answer} />}- <IconButton- aria-label={t(($) => $['operation.copy'], { ns: 'common' })}- onClick={() => {- copy(answer)- toast.success(t(($) => $['actionMsg.copySuccessfully'], { ns: 'common' }))- }}- >- <RiClipboardLine aria-hidden="true" className="size-4" />- </IconButton>+ <CopyFeedback content={answer} /><IconButtonaria-label={t(($) => $['operation.delete'], { ns: 'common' })}onClick={() => {diff --git a/web/app/components/base/chat/chat-with-history/hooks.tsx b/web/app/components/base/chat/chat-with-history/hooks.tsxindex 881bb1b965f..2e6fbd7dfe8 100644--- a/web/app/components/base/chat/chat-with-history/hooks.tsx+++ b/web/app/components/base/chat/chat-with-history/hooks.tsx@@ -594,9 +594,8 @@ export const useChatWithHistory = (installedAppInfo?: InstalledAppResponse) => {appSourceType,appId,)- toast.success(t(($) => $['api.success'], { ns: 'common' }))},- [appSourceType, appId, t],+ [appSourceType, appId],)return {isInstalledApp,diff --git a/web/app/components/base/chat/chat/__tests__/question.spec.tsx b/web/app/components/base/chat/chat/__tests__/question.spec.tsxindex fd511a1b7f5..497f5bd1ed5 100644--- a/web/app/components/base/chat/chat/__tests__/question.spec.tsx+++ b/web/app/components/base/chat/chat/__tests__/question.spec.tsx@@ -3,9 +3,7 @@ import type { ChatConfig, ChatItem, OnRegenerate } from '../../types'import type { FileEntity } from '@/app/components/base/file-uploader/types'import { act, fireEvent, render, screen, waitFor } from '@testing-library/react'import userEvent from '@testing-library/user-event'-import copy from 'copy-to-clipboard'import * as React from 'react'-import { toast } from '@/app/notifications'import { createTheme } from '../../embedded-chatbot/theme/theme'import { ChatContextProvider } from '../context-provider'import Question from '../question'@@ -52,7 +50,14 @@ vi.mock('../content-switch', () => ({)},}))-vi.mock('copy-to-clipboard', () => ({ default: vi.fn() }))+const mockCopy = vi.fn()++vi.mock('foxact/use-clipboard', () => ({+ useClipboard: () => ({+ copy: mockCopy,+ copied: false,+ }),+}))vi.mock('@/app/components/base/markdown', () => ({Markdown: ({ content }: { content: string }) => <div className="markdown-body">{content}</div>,}))@@ -188,19 +193,15 @@ describe('Question component', () => {expect(disconnectMock).toHaveBeenCalled()})- it('should call copy-to-clipboard and show a toast when copy action is clicked', async () => {+ it('should copy the question content when copy action is clicked', async () => {const user = userEvent.setup()- const toastSpy = vi.spyOn(toast, 'success').mockReturnValue('toast-success')renderWithProvider(makeItem())const copyBtn = screen.getByRole('button', { name: 'common.operation.copy' })await user.click(copyBtn)- await waitFor(() => {- expect(copy).toHaveBeenCalledWith('This is the question content')- expect(toastSpy).toHaveBeenCalled()- })+ expect(mockCopy).toHaveBeenCalledWith('This is the question content')})it('should not show edit action when enableEdit is false', () => {diff --git a/web/app/components/base/chat/chat/answer/__tests__/operation.spec.tsx b/web/app/components/base/chat/chat/answer/__tests__/operation.spec.tsxindex 786775c1b72..0cca369f854 100644--- a/web/app/components/base/chat/chat/answer/__tests__/operation.spec.tsx+++ b/web/app/components/base/chat/chat/answer/__tests__/operation.spec.tsx@@ -2,7 +2,6 @@ import type { ChatConfig, ChatItem } from '../../../types'import type { ChatContextValue } from '../../context'import { act, render, screen, waitFor } from '@testing-library/react'import userEvent from '@testing-library/user-event'-import copy from 'copy-to-clipboard'import { ChatContextProvider } from '../../context-provider'import Operation from '../operation'@@ -14,7 +13,14 @@ const { mockSetShowAnnotationFullModal, mockT, mockAddAnnotation } = vi.hoisted(}})-vi.mock('copy-to-clipboard', () => ({ default: vi.fn() }))+const mockCopy = vi.fn()++vi.mock('foxact/use-clipboard', () => ({+ useClipboard: () => ({+ copy: mockCopy,+ copied: false,+ }),+}))vi.mock('@/app/notifications', () => ({toast: { success: vi.fn() },@@ -432,7 +438,7 @@ describe('Operation', () => {const user = userEvent.setup()renderOperation()await user.click(screen.getByRole('button', { name: 'operation.copy' }))- expect(copy).toHaveBeenCalledWith('Hello world')+ expect(mockCopy).toHaveBeenCalledWith('Hello world')})it('should copy the visible answer instead of agent thought summaries', async () => {@@ -465,7 +471,7 @@ describe('Operation', () => {}renderOperation({ ...baseProps, item })await user.click(screen.getByRole('button', { name: 'operation.copy' }))- expect(copy).toHaveBeenCalledWith('Final answer')+ expect(mockCopy).toHaveBeenCalledWith('Final answer')})it('should copy public response parts after an interrupted response', async () => {@@ -473,7 +479,7 @@ describe('Operation', () => {const item = createInterruptedItem(['First public update', 'Second public update'])renderOperation({ ...baseProps, item })await user.click(screen.getByRole('button', { name: 'operation.copy' }))- expect(copy).toHaveBeenCalledWith('First public update\n\nSecond public update')+ expect(mockCopy).toHaveBeenCalledWith('First public update\n\nSecond public update')})it('should copy public thought answers for legacy messages without content', async () => {@@ -497,7 +503,7 @@ describe('Operation', () => {}renderOperation({ ...baseProps, item })await user.click(screen.getByRole('button', { name: 'operation.copy' }))- expect(copy).toHaveBeenCalledWith('Public legacy answer')+ expect(mockCopy).toHaveBeenCalledWith('Public legacy answer')})})@@ -1212,7 +1218,7 @@ describe('Operation', () => {const item: ChatItem = { ...baseItem, agent_thoughts: [] }renderOperation({ ...baseProps, item })await user.click(screen.getByRole('button', { name: 'operation.copy' }))- expect(copy).toHaveBeenCalledWith('Hello world')+ expect(mockCopy).toHaveBeenCalledWith('Hello world')})it('should hide cached annotation edit controls when chat is readonly', () => {diff --git a/web/app/components/base/chat/chat/answer/operation.tsx b/web/app/components/base/chat/chat/answer/operation.tsxindex e6cbbaaca0d..a7dbdec3947 100644--- a/web/app/components/base/chat/chat/answer/operation.tsx+++ b/web/app/components/base/chat/chat/answer/operation.tsx@@ -15,14 +15,13 @@ import { IconButton } from '@langgenius/dify-ui/icon-button'import { Textarea } from '@langgenius/dify-ui/textarea'import { Toggle } from '@langgenius/dify-ui/toggle'import { Tooltip, TooltipContent, TooltipTrigger } from '@langgenius/dify-ui/tooltip'-import copy from 'copy-to-clipboard'import { memo, useId, useMemo, useRef, useState } from 'react'import { useTranslation } from 'react-i18next'import EditReplyModal from '@/app/components/app/annotation/edit-annotation-modal'import Log from '@/app/components/base/chat/chat/log'+import { CopyFeedback } from '@/app/components/base/copy-feedback'import AnnotationCtrlButton from '@/app/components/base/features/new-feature-panel/annotation-reply/annotation-ctrl-button'import NewAudioButton from '@/app/components/base/new-audio-button'-import { toast } from '@/app/notifications'import { useChatContext } from '../context'type OperationProps = {@@ -210,7 +209,6 @@ function Operation({t(($) => $['table.header.adminRate'], { ns: 'appLog' }) || 'Admin feedback'const likeLabel = t(($) => $['detail.operation.like'], { ns: 'appLog' }) || 'Like'const dislikeLabel = t(($) => $['detail.operation.dislike'], { ns: 'appLog' }) || 'Dislike'- const copyLabel = t(($) => $['operation.copy'], { ns: 'common' }) || 'Copy'const regenerateLabel = t(($) => $['operation.regenerate'], { ns: 'common' }) || 'Regenerate'const buildFeedbackTooltip = (@@ -495,15 +493,7 @@ function Operation({<NewAudioButton id={id} value={content} voice={config?.text_to_speech?.voice} />)}{hasPublicContent && !humanInputFormDataList?.length && (- <IconButton- aria-label={copyLabel}- onClick={() => {- copy(content)- toast.success(t(($) => $['actionMsg.copySuccessfully'], { ns: 'common' }))- }}- >- <span aria-hidden="true" className="i-ri-clipboard-line size-4" />- </IconButton>+ <CopyFeedback content={content} />)}{(!noChatInput || showRegenerate) && (<IconButton aria-label={regenerateLabel} onClick={() => onRegenerate?.(item)}>diff --git a/web/app/components/base/chat/chat/question.tsx b/web/app/components/base/chat/chat/question.tsxindex c14b77c3ef7..97023e9b812 100644--- a/web/app/components/base/chat/chat/question.tsx+++ b/web/app/components/base/chat/chat/question.tsx@@ -4,13 +4,12 @@ import type { ChatItem } from '../types'import { Button } from '@langgenius/dify-ui/button'import { cn } from '@langgenius/dify-ui/cn'import { IconButton } from '@langgenius/dify-ui/icon-button'-import copy from 'copy-to-clipboard'import { memo, useCallback, useEffect, useRef, useState } from 'react'import { useTranslation } from 'react-i18next'import Textarea from 'react-textarea-autosize'+import { CopyFeedback } from '@/app/components/base/copy-feedback'import { FileList } from '@/app/components/base/file-uploader'import { Markdown } from '@/app/components/base/markdown'-import { toast } from '@/app/notifications'import { CssTransform } from '../embedded-chatbot/theme/utils'import ContentSwitch from './content-switch'import { useChatContext } from './context'@@ -37,7 +36,6 @@ const Question: FC<QuestionProps> = ({const { content, message_files } = itemconst { onRegenerate } = useChatContext()- const copyLabel = t(($) => $['operation.copy'], { ns: 'common' })const editLabel = t(($) => $['operation.edit'], { ns: 'common' })const [isEditing, setIsEditing] = useState(false)@@ -157,15 +155,7 @@ const Question: FC<QuestionProps> = ({className="absolute hidden gap-0.5 rounded-[10px] border-[0.5px] border-components-actionbar-border bg-components-actionbar-bg p-0.5 shadow-md backdrop-blur-xs group-hover:flex"style={{ right: contentWidth + 8 }}>- <IconButton- aria-label={copyLabel}- onClick={() => {- copy(content)- toast.success(t(($) => $['actionMsg.copySuccessfully'], { ns: 'common' }))- }}- >- <div className="i-ri-clipboard-line size-4" aria-hidden="true" />- </IconButton>+ <CopyFeedback content={content} />{enableEdit && (<IconButton aria-label={editLabel} onClick={handleEdit}><div className="i-ri-edit-line size-4" aria-hidden="true" />diff --git a/web/app/components/base/chat/embedded-chatbot/hooks.tsx b/web/app/components/base/chat/embedded-chatbot/hooks.tsxindex a075dfee300..16714b5840b 100644--- a/web/app/components/base/chat/embedded-chatbot/hooks.tsx+++ b/web/app/components/base/chat/embedded-chatbot/hooks.tsx@@ -427,9 +427,8 @@ export const useEmbeddedChatbot = (appSourceType: AppSourceType, tryAppId?: striappSourceType,appId,)- toast.success(t(($) => $['api.success'], { ns: 'common' }))},- [appSourceType, appId, t],+ [appSourceType, appId],)return {appSourceType,diff --git a/web/app/components/datasets/documents/components/operations.tsx b/web/app/components/datasets/documents/components/operations.tsxindex 95548d26121..6d6e4025b51 100644--- a/web/app/components/datasets/documents/components/operations.tsx+++ b/web/app/components/datasets/documents/components/operations.tsx@@ -184,7 +184,9 @@ const Operations = ({opApi({ datasetId, documentId: id }) as Promise<CommonResponse>,)if (!e) {- toast.success(t(($) => $['actionMsg.modifiedSuccessfully'], { ns: 'common' }))+ // The switch already shows the result of enable and disable.+ if (operationName !== 'enable' && operationName !== 'disable')+ toast.success(t(($) => $['actionMsg.modifiedSuccessfully'], { ns: 'common' }))// If it is a delete operation, need to update the selectedIds stateif (selectedIds && onSelectedIdChange && operationName === DocumentActionType.delete)onSelectedIdChange(selectedIds.filter((selectedId) => selectedId !== id))diff --git a/web/app/components/datasets/documents/detail/completed/hooks/__tests__/use-segment-list-data.spec.ts b/web/app/components/datasets/documents/detail/completed/hooks/__tests__/use-segment-list-data.spec.tsindex bee656a85bb..54689dd3786 100644--- a/web/app/components/datasets/documents/detail/completed/hooks/__tests__/use-segment-list-data.spec.ts+++ b/web/app/components/datasets/documents/detail/completed/hooks/__tests__/use-segment-list-data.spec.ts@@ -440,10 +440,7 @@ describe('useSegmentListData', () => {})expect(mockEnableSegment).toHaveBeenCalled()- expect(mockNotify).toHaveBeenCalledWith({- type: 'success',- message: 'common.actionMsg.modifiedSuccessfully',- })+ expect(mockNotify).not.toHaveBeenCalled()})it('should call disableSegment when enable is false', async () => {@@ -490,6 +487,10 @@ describe('useSegmentListData', () => {expect.objectContaining({ segmentIds: ['seg-1', 'seg-2'] }),expect.any(Object),)+ expect(mockNotify).toHaveBeenCalledWith({+ type: 'success',+ message: 'common.actionMsg.modifiedSuccessfully',+ })})it('should notify error on failure', async () => {diff --git a/web/app/components/datasets/documents/detail/completed/hooks/use-segment-list-data.ts b/web/app/components/datasets/documents/detail/completed/hooks/use-segment-list-data.tsindex 5005018c1ba..e702db61890 100644--- a/web/app/components/datasets/documents/detail/completed/hooks/use-segment-list-data.ts+++ b/web/app/components/datasets/documents/detail/completed/hooks/use-segment-list-data.ts@@ -207,7 +207,9 @@ export const useSegmentListData = ({ datasetId, documentId, segmentIds: targetIds },{onSuccess: () => {- toast.success(t(($) => $['actionMsg.modifiedSuccessfully'], { ns: 'common' }))+ // A single segment is toggled from its switch, which already shows the result.+ if (!segId)+ toast.success(t(($) => $['actionMsg.modifiedSuccessfully'], { ns: 'common' }))updateSegmentsInCache(targetIds, (seg) => ({ ...seg, enabled: enable }))refreshChunkListWithStatusChanged()},diff --git a/web/app/components/datasets/documents/status-item/__tests__/index.spec.tsx b/web/app/components/datasets/documents/status-item/__tests__/index.spec.tsxindex 7181879688a..6dd7d1fafd1 100644--- a/web/app/components/datasets/documents/status-item/__tests__/index.spec.tsx+++ b/web/app/components/datasets/documents/status-item/__tests__/index.spec.tsx@@ -335,38 +335,6 @@ describe('StatusItem', () => {vi.useRealTimers()})- it('should show success notification after successful operation', async () => {- vi.useFakeTimers()- render(- <StatusItem- status="available"- scene="detail"- detail={{- enabled: false,- archived: false,- id: 'doc-1',- }}- datasetId="dataset-1"- canEdit- onUpdate={mockOnUpdate}- />,- )- const switchElement = document.querySelector('[role="switch"]')- await act(async () => {- fireEvent.click(switchElement!)- })- await act(async () => {- vi.advanceTimersByTime(600)- // Flush promises- await Promise.resolve()- })- expect(toastMocks.record).toHaveBeenCalledWith({- type: 'success',- message: 'common.actionMsg.modifiedSuccessfully',- })- vi.useRealTimers()- })-it('should call onUpdate after successful operation', async () => {vi.useFakeTimers()render(diff --git a/web/app/components/datasets/documents/status-item/index.tsx b/web/app/components/datasets/documents/status-item/index.tsxindex 758f34a0dca..fcd1755d864 100644--- a/web/app/components/datasets/documents/status-item/index.tsx+++ b/web/app/components/datasets/documents/status-item/index.tsx@@ -80,7 +80,6 @@ const StatusItem = ({opApi({ datasetId, documentId: id }) as Promise<CommonResponse>,)if (!e) {- toast.success(t(($) => $['actionMsg.modifiedSuccessfully'], { ns: 'common' }))onUpdate?.(operationName)} else {toast.error(t(($) => $['actionMsg.modifiedUnsuccessfully'], { ns: 'common' }))diff --git a/web/app/components/datasets/metadata/hooks/use-edit-dataset-metadata.ts b/web/app/components/datasets/metadata/hooks/use-edit-dataset-metadata.tsindex 15454e3bafd..333127acb50 100644--- a/web/app/components/datasets/metadata/hooks/use-edit-dataset-metadata.ts+++ b/web/app/components/datasets/metadata/hooks/use-edit-dataset-metadata.ts@@ -2,7 +2,6 @@ import type { BuiltInMetadataItem, MetadataItemWithValueLength } from '../types'import type { DataSet } from '@/models/datasets'import { useBoolean } from 'ahooks'import { useCallback, useEffect, useState } from 'react'-import { useTranslation } from 'react-i18next'import { toast } from '@/app/notifications'import {useBuiltInMetaDataFields,@@ -24,7 +23,6 @@ const useEditDatasetMetadata = ({dataset?: DataSetonUpdateDocList: () => void}) => {- const { t } = useTranslation(['common'])const [isShowEditModal, { setTrue: showEditModal, setFalse: hideEditModal }] = useBoolean(false)useEffect(() => {const isShowManageMetadata = localStorage.getItem(isShowManageMetadataLocalStorageKey)@@ -87,7 +85,6 @@ const useEditDatasetMetadata = ({setBuiltInEnabled: async (enable: boolean) => {await toggleBuiltInStatus(enable)setBuiltInEnabled(enable)- toast.success(t(($) => $['actionMsg.modifiedSuccessfully'], { ns: 'common' }))},}}diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/__tests__/credential-panel.spec.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/__tests__/credential-panel.spec.tsxindex 2173af2455d..8421b457094 100644--- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/__tests__/credential-panel.spec.tsx+++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/__tests__/credential-panel.spec.tsx@@ -373,7 +373,7 @@ describe('CredentialPanel', () => {})})- it('should show success toast and refresh data after successful mutation', async () => {+ it('should refresh data after successful mutation', async () => {renderWithQueryClient(createProvider())await act(async () => {@@ -381,7 +381,6 @@ describe('CredentialPanel', () => {})await waitFor(() => {- expect(mockToastNotify).toHaveBeenCalledWith(expect.objectContaining({ type: 'success' }))expect(mockUpdateModelProviders).toHaveBeenCalled()expect(mockUpdateModelList).toHaveBeenCalledWith('llm')})diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/__tests__/use-change-provider-priority.spec.ts b/web/app/components/header/account-setting/model-provider-page/provider-added-card/__tests__/use-change-provider-priority.spec.tsindex 1d86dc9807a..97d91b43bec 100644--- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/__tests__/use-change-provider-priority.spec.ts+++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/__tests__/use-change-provider-priority.spec.ts@@ -144,10 +144,6 @@ describe('useChangeProviderPriority', () => {expect(mockUpdateModelList).toHaveBeenCalledTimes(2)expect(mockUpdateModelList).toHaveBeenNthCalledWith(1, ModelTypeEnum.textGeneration)expect(mockUpdateModelList).toHaveBeenNthCalledWith(2, ModelTypeEnum.textEmbedding)- expect(mockNotify).toHaveBeenCalledWith({- type: 'success',- message: 'common.actionMsg.modifiedSuccessfully',- })expect(result.current.isChangingPriority).toBe(false)})diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-auth-dropdown/__tests__/use-activate-credential.spec.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-auth-dropdown/__tests__/use-activate-credential.spec.tsxindex c8acafef9cf..045e54c04b7 100644--- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-auth-dropdown/__tests__/use-activate-credential.spec.tsx+++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-auth-dropdown/__tests__/use-activate-credential.spec.tsx@@ -42,13 +42,11 @@ const createCredential = (overrides: Partial<Credential> = {}): Credential =>}) as Credentialdescribe('useActivateCredential', () => {- const toastSuccessSpy = vi.spyOn(toast, 'success').mockReturnValue('toast-success')const toastErrorSpy = vi.spyOn(toast, 'error').mockReturnValue('toast-error')beforeEach(() => {vi.clearAllMocks()mockIsPending = false- toastSuccessSpy.mockClear()toastErrorSpy.mockClear()})@@ -100,7 +98,6 @@ describe('useActivateCredential', () => {callbacks.onSuccess()})- expect(toastSuccessSpy).toHaveBeenCalledWith('common.api.actionSuccess')expect(mockUpdateModelProviders).toHaveBeenCalledTimes(1)expect(mockUpdateModelList).toHaveBeenNthCalledWith(1, 'llm')expect(mockUpdateModelList).toHaveBeenNthCalledWith(2, 'text-embedding')diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-auth-dropdown/use-activate-credential.ts b/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-auth-dropdown/use-activate-credential.tsindex 00295f60878..3c01efea48d 100644--- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-auth-dropdown/use-activate-credential.ts+++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/model-auth-dropdown/use-activate-credential.ts@@ -28,7 +28,6 @@ export function useActivateCredential(provider: ModelProvider) {{ credential_id: credential.credential_id },{onSuccess: () => {- toast.success(t(($) => $['api.actionSuccess'], { ns: 'common' }))updateModelProviders()supportedModelTypesRef.current.forEach((type) => updateModelList(type))},diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/use-change-provider-priority.ts b/web/app/components/header/account-setting/model-provider-page/provider-added-card/use-change-provider-priority.tsindex 82e26054074..8095836ac05 100644--- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/use-change-provider-priority.ts+++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/use-change-provider-priority.ts@@ -27,7 +27,6 @@ export function useChangeProviderPriority(consoleQuery.workspaces.current.modelProviders.byProvider.preferredProviderType.post.mutationOptions({onSuccess: () => {- toast.success(t(($) => $['actionMsg.modifiedSuccessfully'], { ns: 'common' }))queryClient.invalidateQueries({queryKey: modelProviderModelListQueryKey,exact: true,diff --git a/web/app/components/header/account-setting/preference-page/__tests__/index.spec.tsx b/web/app/components/header/account-setting/preference-page/__tests__/index.spec.tsxindex a1e0af6e721..b7f5a88e5fb 100644--- a/web/app/components/header/account-setting/preference-page/__tests__/index.spec.tsx+++ b/web/app/components/header/account-setting/preference-page/__tests__/index.spec.tsx@@ -140,7 +140,7 @@ describe('PreferencePage - Rendering', () => {// Interactionsdescribe('PreferencePage - Interactions', () => {- it('should show success toast when language updates', async () => {+ it('should save the selected language', async () => {const chinese = getLanguageOption('zh-Hans')mockUserProfile = createUserProfile({ interface_language: 'en-US' })@@ -148,7 +148,6 @@ describe('PreferencePage - Interactions', () => {await selectOption('common.language.displayLanguage', chinese.name)- expect(await screen.findByText('common.actionMsg.modifiedSuccessfully')).toBeInTheDocument()await waitFor(() => {expect(mockRequest).toHaveBeenCalled()})@@ -169,14 +168,13 @@ describe('PreferencePage - Interactions', () => {expect(await screen.findByText('Update failed')).toBeInTheDocument()})- it('should show success toast when timezone updates', async () => {+ it('should save the selected timezone', async () => {const midwayTimezone = getTimezoneOption('Pacific/Midway')renderPage()await selectOption('common.language.timezone', midwayTimezone.name)- expect(await screen.findByText('common.actionMsg.modifiedSuccessfully')).toBeInTheDocument()await waitFor(() => {expect(mockRequest).toHaveBeenCalled()})diff --git a/web/app/components/header/account-setting/preference-page/index.tsx b/web/app/components/header/account-setting/preference-page/index.tsxindex 97ee54379bd..2e2a91505cc 100644--- a/web/app/components/header/account-setting/preference-page/index.tsx+++ b/web/app/components/header/account-setting/preference-page/index.tsx@@ -73,7 +73,6 @@ export default function PreferencePage() {setEditing(true)try {await updateProfile.mutateAsync({ body: { interface_language: item.value } })- toast.success(t(($) => $['actionMsg.modifiedSuccessfully'], { ns: 'common' }))setLocaleOnClient(item.value.toString() as Locale, false)router.refresh()} catch (e) {@@ -86,7 +85,6 @@ export default function PreferencePage() {setEditing(true)try {await updateProfile.mutateAsync({ body: { timezone: item.value } })- toast.success(t(($) => $['actionMsg.modifiedSuccessfully'], { ns: 'common' }))} catch (e) {toast.error((e as Error).message)} finally {diff --git a/web/docs/toasts.md b/web/docs/toasts.mdnew file mode 100644index 00000000000..883ee92c58a--- /dev/null+++ b/web/docs/toasts.md@@ -0,0 +1,36 @@+# Toasts++A toast reports a result the user cannot see where they acted. It is the last choice for feedback, not the default completion signal of a mutation.++## Choose the Feedback Owner++Before adding a toast, check in order:++1. If the result is already visible where the user acted, add nothing.+1. If the feedback can live at the trigger, such as a button state, an inline message, or a field error, put it there.+1. Otherwise a toast is appropriate.++## Success++Do not show a success toast when:++- A switch, select, segmented control, checkbox, toggle, or rating control shows the new value itself. After a failed request the control must show the server value again.+- A button copies content. Show the copied state on the button. For an icon button use [CopyFeedback], which changes the icon, the tooltip, and the accessible name.+- A dialog submits and closes, and the created, changed, or removed item is visible on the surface behind it.++A success toast is appropriate when the result is not on screen: a background job started, an import, export, or download finished, or the action left the page that showed its subject, such as deleting an item from its detail page. The message must name what happened. Do not use generic messages such as “Action succeeded” or “Modified successfully”.++## Errors++- When a request fails and the server returns an error message, the request layer shows that message unless the request is `silent`; see `afterResponseErrorCode` in [request layer]. Do not add a second toast for the same failure in `catch` or `onError`.+- To present a request error differently, make the request `silent` (`{ context: { silent: true } }` for generated clients) and show the error inline. A `silent` request with no other error presentation fails without any feedback.+- Failures that never reach the request layer, such as a rejected clipboard write or a client-side exception, still need their own feedback.+- Client-side validation belongs at the field through the [form contract], never in a toast.++## Existing Code++Many existing calls predate these rules and are migrated in batches: success toasts after a dialog closes, error toasts that duplicate the request layer, and validation toasts. Do not copy them into new code, and do not remove an error toast without confirming the request layer covers that failure.++[CopyFeedback]: ../app/components/base/copy-feedback/index.tsx+[form contract]: ../../packages/dify-ui/docs/forms.md+[request layer]: ../service/fetch.tsdiff --git a/web/features/agent-v2/agent-detail/logs/__tests__/log-detail-panel.spec.tsx b/web/features/agent-v2/agent-detail/logs/__tests__/log-detail-panel.spec.tsxindex 8d996902036..1669f1720e0 100644--- a/web/features/agent-v2/agent-detail/logs/__tests__/log-detail-panel.spec.tsx+++ b/web/features/agent-v2/agent-detail/logs/__tests__/log-detail-panel.spec.tsx@@ -198,7 +198,6 @@ describe('AgentLogDetailPanel', () => {})expect(invalidateQueries).toHaveBeenCalledWith({ queryKey: ['agent-logs'] })expect(invalidateQueries).toHaveBeenCalledWith({ queryKey: ['agent-log-messages'] })- expect(mocks.toastSuccess).toHaveBeenCalled()})it('reports operator feedback failures without refreshing log queries', async () => {diff --git a/web/features/agent-v2/agent-detail/logs/components/log-detail-panel.tsx b/web/features/agent-v2/agent-detail/logs/components/log-detail-panel.tsxindex 5ae705d87ba..aa2b506d713 100644--- a/web/features/agent-v2/agent-detail/logs/components/log-detail-panel.tsx+++ b/web/features/agent-v2/agent-detail/logs/components/log-detail-panel.tsx@@ -80,7 +80,6 @@ export function AgentLogDetailPanel({queryKey: consoleQuery.agent.byAgentId.logs.byConversationId.messages.get.key(),}),])- toast.success(t(($) => $['actionMsg.modifiedSuccessfully'], { ns: 'common' }))} catch (error) {toast.error(t(($) => $['actionMsg.modifiedUnsuccessfully'], { ns: 'common' }))throw error