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.

refactor(web): separate AppIcon display from picker triggers (#43041)

yyha4a18e065276
diff --git a/web/app/components/app/configuration/tools/external-data-tool-modal.tsx b/web/app/components/app/configuration/tools/external-data-tool-modal.tsx
index be5238000c9..73c792e14e1 100644
--- a/web/app/components/app/configuration/tools/external-data-tool-modal.tsx
+++ b/web/app/components/app/configuration/tools/external-data-tool-modal.tsx
@@ -41,7 +41,7 @@ const ExternalDataToolModal: FC<ExternalDataToolModalProps> = ({
onSave,
onValidateBeforeSave,
}) => {
- const { t } = useTranslation(['appDebug', 'common'])
+ const { t } = useTranslation(['appDebug', 'common', 'app'])
const docLink = useDocLink()
const locale = useLocale()
const [localeData, setLocaleData] = useState(data.type ? data : { ...data, type: 'api' })
@@ -156,15 +156,20 @@ const ExternalDataToolModal: FC<ExternalDataToolModalProps> = ({
t(($) => $['feature.tools.modal.name.placeholder'], { ns: 'appDebug' }) || ''
}
/>
- <AppIcon
- size="large"
- onClick={() => {
- setShowEmojiPicker(true)
- }}
- className="h-9! w-9! cursor-pointer rounded-lg border-[0.5px] border-components-panel-border"
- icon={localeData.icon}
- background={localeData.icon_background}
- />
+ <button
+ type="button"
+ aria-label={t(($) => $['iconPicker.title'], { ns: 'app' })}
+ className="shrink-0 cursor-pointer rounded-lg focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden"
+ onClick={() => setShowEmojiPicker(true)}
+ >
+ <AppIcon
+ decorative
+ size="large"
+ className="h-9! w-9! rounded-lg border-[0.5px] border-components-panel-border"
+ icon={localeData.icon}
+ background={localeData.icon_background}
+ />
+ </button>
</div>
</div>
<div className="py-2">
diff --git a/web/app/components/app/create-app-modal/__tests__/index.spec.tsx b/web/app/components/app/create-app-modal/__tests__/index.spec.tsx
index 7cf63ad1d0f..fe8ba1f4cb8 100644
--- a/web/app/components/app/create-app-modal/__tests__/index.spec.tsx
+++ b/web/app/components/app/create-app-modal/__tests__/index.spec.tsx
@@ -76,13 +76,6 @@ vi.mock('@/app/notifications', () => ({
vi.mock('@/app/components/billing/apps-full-in-dialog', () => ({
default: () => <div>apps-full</div>,
}))
-vi.mock('@/app/components/base/app-icon', () => ({
- default: ({ onClick }: { onClick: () => void }) => (
- <button type="button" onClick={onClick}>
- open-icon-picker
- </button>
- ),
-}))
vi.mock('@/utils/app-redirection', () => ({
getRedirection: vi.fn(),
}))
@@ -257,7 +250,7 @@ describe('CreateAppModal', () => {
fireEvent.click(screen.getByText('app.newApp.forBeginners'))
fireEvent.click(screen.getByText('app.types.chatbot'))
- fireEvent.click(screen.getByText('open-icon-picker'))
+ fireEvent.click(screen.getByRole('button', { name: 'app.iconPicker.title' }))
await waitFor(() => {
expect(screen.getByPlaceholderText('app.iconPicker.search')).toBeInTheDocument()
})
@@ -306,7 +299,7 @@ describe('CreateAppModal', () => {
renderModal()
- fireEvent.click(screen.getByText('open-icon-picker'))
+ fireEvent.click(screen.getByRole('button', { name: 'app.iconPicker.title' }))
await waitFor(() => {
expect(screen.getByPlaceholderText('app.iconPicker.search')).toBeInTheDocument()
})
diff --git a/web/app/components/app/create-app-modal/index.tsx b/web/app/components/app/create-app-modal/index.tsx
index 9df0a884635..dbfa05c8fc4 100644
--- a/web/app/components/app/create-app-modal/index.tsx
+++ b/web/app/components/app/create-app-modal/index.tsx
@@ -324,17 +324,22 @@ function CreateApp({ onClose, onCreateFromTemplate, defaultAppMode }: CreateAppP
placeholder={t(($) => $['newApp.appNamePlaceholder'], { ns: 'app' }) || ''}
/>
</div>
- <AppIcon
- iconType={appIcon.type}
- icon={appIcon.type === 'emoji' ? appIcon.icon : appIcon.fileId}
- background={appIcon.type === 'emoji' ? appIcon.background : undefined}
- imageUrl={appIcon.type === 'image' ? appIcon.url : undefined}
- size="xxl"
- className="cursor-pointer rounded-2xl"
- onClick={() => {
- setShowIconPicker(true)
- }}
- />
+ <button
+ type="button"
+ aria-label={t(($) => $['iconPicker.title'], { ns: 'app' })}
+ className="shrink-0 cursor-pointer rounded-2xl focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden"
+ onClick={() => setShowIconPicker(true)}
+ >
+ <AppIcon
+ decorative
+ iconType={appIcon.type}
+ icon={appIcon.type === 'emoji' ? appIcon.icon : appIcon.fileId}
+ background={appIcon.type === 'emoji' ? appIcon.background : undefined}
+ imageUrl={appIcon.type === 'image' ? appIcon.url : undefined}
+ size="xxl"
+ className="rounded-2xl"
+ />
+ </button>
<IconPickerDialog
open={showIconPicker}
defaultValue={appIcon}
diff --git a/web/app/components/app/overview/settings/index.tsx b/web/app/components/app/overview/settings/index.tsx
index 37fc01f41ab..5ff8a7e7e4d 100644
--- a/web/app/components/app/overview/settings/index.tsx
+++ b/web/app/components/app/overview/settings/index.tsx
@@ -440,35 +440,39 @@ const SettingsModal: FC<ISettingsModalProps> = ({
placeholder={t(($) => $.appNamePlaceholder, { ns: 'app' }) || ''}
/>
</Field>
- <AppIcon
- size="xxl"
- onClick={() => {
- setShowIconPicker(true)
- }}
- className="mt-2 cursor-pointer"
- iconType={
- appIcon
- ? appIcon.type === 'link'
- ? 'image'
- : appIcon.type
- : appInfo.site.icon_type
- }
- icon={
- appIcon
- ? appIcon.type === 'image'
- ? appIcon.fileId
- : appIcon.icon
- : (appInfo.site.icon ?? undefined)
- }
- background={
- appIcon?.type === 'emoji'
- ? appIcon.background
- : appInfo.site.icon_background
- }
- imageUrl={
- appIcon && appIcon.type !== 'emoji' ? appIcon.url : appInfo.site.icon_url
- }
- />
+ <button
+ type="button"
+ aria-label={t(($) => $['iconPicker.title'], { ns: 'app' })}
+ className="mt-2 shrink-0 cursor-pointer rounded-2xl focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden"
+ onClick={() => setShowIconPicker(true)}
+ >
+ <AppIcon
+ decorative
+ size="xxl"
+ iconType={
+ appIcon
+ ? appIcon.type === 'link'
+ ? 'image'
+ : appIcon.type
+ : appInfo.site.icon_type
+ }
+ icon={
+ appIcon
+ ? appIcon.type === 'image'
+ ? appIcon.fileId
+ : appIcon.icon
+ : (appInfo.site.icon ?? undefined)
+ }
+ background={
+ appIcon?.type === 'emoji'
+ ? appIcon.background
+ : appInfo.site.icon_background
+ }
+ imageUrl={
+ appIcon && appIcon.type !== 'emoji' ? appIcon.url : appInfo.site.icon_url
+ }
+ />
+ </button>
</div>
{/* description */}
<Field name="description">
diff --git a/web/app/components/app/switch-app-modal/index.tsx b/web/app/components/app/switch-app-modal/index.tsx
index d776d5186fd..c3c43174e3a 100644
--- a/web/app/components/app/switch-app-modal/index.tsx
+++ b/web/app/components/app/switch-app-modal/index.tsx
@@ -169,17 +169,21 @@ const SwitchAppModal = ({ show, appDetail, inAppDetail = false, onClose }: Switc
{t(($) => $.switchLabel, { ns: 'app' })}
</label>
<div className="flex items-center justify-between space-x-2">
- <AppIcon
- size="large"
- onClick={() => {
- setShowIconPicker(true)
- }}
- className="cursor-pointer"
- iconType={appIcon.type}
- icon={appIcon.type === 'image' ? appIcon.fileId : appIcon.icon}
- background={appIcon.type === 'image' ? undefined : appIcon.background}
- imageUrl={appIcon.type === 'image' ? appIcon.url : undefined}
- />
+ <button
+ type="button"
+ aria-label={t(($) => $['iconPicker.title'], { ns: 'app' })}
+ className="shrink-0 cursor-pointer rounded-[10px] focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden"
+ onClick={() => setShowIconPicker(true)}
+ >
+ <AppIcon
+ decorative
+ size="large"
+ iconType={appIcon.type}
+ icon={appIcon.type === 'image' ? appIcon.fileId : appIcon.icon}
+ background={appIcon.type === 'image' ? undefined : appIcon.background}
+ imageUrl={appIcon.type === 'image' ? appIcon.url : undefined}
+ />
+ </button>
<Input
id={nameInputId}
value={name}
diff --git a/web/app/components/base/app-icon/index.stories.tsx b/web/app/components/base/app-icon/index.stories.tsx
index f4b16e9ad76..2638626b5a6 100644
--- a/web/app/components/base/app-icon/index.stories.tsx
+++ b/web/app/components/base/app-icon/index.stories.tsx
@@ -1,7 +1,10 @@
import type { Meta, StoryObj } from '@storybook/nextjs-vite'
import type { ComponentProps } from 'react'
+import { fn } from 'storybook/test'
import AppIcon from '.'
+const onChooseIcon = fn()
+
const meta = {
title: 'Base/General/AppIcon',
component: AppIcon,
@@ -84,14 +87,29 @@ export const Sizes: Story = {
export const WithEditOverlay: Story = {
render: (args) => (
<div className="flex items-center gap-4">
- <AppIcon {...args} icon="🛠️" background="#E7F5FF" showEditIcon />
- <AppIcon
- {...args}
- iconType="image"
- background={undefined}
- imageUrl="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='80' height='80'><rect width='80' height='80' rx='16' fill='%23CBD5F5'/><text x='50%' y='54%' dominant-baseline='middle' text-anchor='middle' font-size='30' font-family='Arial' fill='%231f2937'>AI</text></svg>"
- showEditIcon
- />
+ <button
+ type="button"
+ aria-label="Choose emoji icon"
+ className="group/edit-icon rounded-lg focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden"
+ onClick={onChooseIcon}
+ >
+ <AppIcon {...args} decorative icon="🛠️" background="#E7F5FF" showEditIcon />
+ </button>
+ <button
+ type="button"
+ aria-label="Choose image icon"
+ className="group/edit-icon rounded-lg focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden"
+ onClick={onChooseIcon}
+ >
+ <AppIcon
+ {...args}
+ decorative
+ iconType="image"
+ background={undefined}
+ imageUrl="data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='80' height='80' rx='16' fill='%23CBD5F5'/><text x='50%' y='54%' dominant-baseline='middle' text-anchor='middle' font-size='30' font-family='Arial' fill='%231f2937'>AI</text></svg>"
+ showEditIcon
+ />
+ </button>
</div>
),
parameters: {
@@ -99,12 +117,9 @@ export const WithEditOverlay: Story = {
source: {
language: 'tsx',
code: `
-<AppIcon icon="🛠️" background="#E7F5FF" showEditIcon />
-<AppIcon
- iconType="image"
- imageUrl="data:image/svg+xml;utf8,&lt;svg ...&gt;"
- showEditIcon
-/>
+<button type="button" aria-label="Choose icon">
+ <AppIcon decorative icon="🛠️" background="#E7F5FF" showEditIcon />
+</button>
`.trim(),
},
},
diff --git a/web/app/components/base/app-icon/index.tsx b/web/app/components/base/app-icon/index.tsx
index c8c889982ca..84b9fd8e06b 100644
--- a/web/app/components/base/app-icon/index.tsx
+++ b/web/app/components/base/app-icon/index.tsx
@@ -2,11 +2,8 @@
import type { FC } from 'react'
import type { AppIconType } from '@/types/app'
import { cn } from '@langgenius/dify-ui/cn'
-import { RiEditLine } from '@remixicon/react'
-import { useHover } from 'ahooks'
import { cva } from 'class-variance-authority'
import * as React from 'react'
-import { useRef } from 'react'
import { resolveEmoji } from '@/utils/emoji'
type AppIconProps = {
@@ -19,9 +16,7 @@ type AppIconProps = {
decorative?: boolean
className?: string
innerIcon?: React.ReactNode
- coverElement?: React.ReactNode
showEditIcon?: boolean
- onClick?: () => void
}
const appIconVariants = cva(
'relative flex shrink-0 grow-0 items-center justify-center overflow-hidden border-[0.5px] border-divider-regular leading-none',
@@ -46,30 +41,7 @@ const appIconVariants = cva(
},
},
)
-const EditIconWrapperVariants = cva(
- 'absolute top-0 left-0 z-10 flex items-center justify-center bg-background-overlay-alt',
- {
- variants: {
- size: {
- xs: 'size-4 rounded-sm',
- tiny: 'size-6 rounded-md',
- small: 'size-8 rounded-lg',
- medium: 'h-9 w-9 rounded-[10px]',
- large: 'h-10 w-10 rounded-[10px]',
- xl: 'size-12 rounded-xl',
- xxl: 'size-14 rounded-2xl',
- },
- rounded: {
- true: 'rounded-full',
- },
- },
- defaultVariants: {
- size: 'medium',
- rounded: false,
- },
- },
-)
-const EditIconVariants = cva('text-text-primary-on-surface', {
+const EditIconVariants = cva('i-ri-edit-line text-text-primary-on-surface', {
variants: {
size: {
xs: 'size-3',
@@ -95,46 +67,30 @@ const AppIcon: FC<AppIconProps> = ({
decorative = false,
className,
innerIcon,
- coverElement,
- onClick,
showEditIcon = false,
}) => {
const isValidImageIcon = iconType === 'image' && imageUrl
- const isDecorative = decorative && !onClick
const Icon = resolveEmoji(icon)
- const wrapperRef = useRef<HTMLSpanElement>(null)
- const isHovering = useHover(wrapperRef)
- const handleKeyDown = (event: React.KeyboardEvent<HTMLSpanElement>) => {
- if (!onClick) return
-
- if (event.key !== 'Enter' && event.key !== ' ') return
-
- event.preventDefault()
- onClick()
- }
return (
<span
- ref={wrapperRef}
- className={cn(appIconVariants({ size, rounded }), className)}
+ className={cn('group/app-icon', appIconVariants({ size, rounded }), className)}
style={{ background: isValidImageIcon ? undefined : background || '#FFEAD5' }}
- onClick={onClick}
- onKeyDown={onClick ? handleKeyDown : undefined}
- role={onClick ? 'button' : undefined}
- tabIndex={onClick ? 0 : undefined}
- aria-hidden={isDecorative || undefined}
+ aria-hidden={decorative || undefined}
>
{isValidImageIcon ? (
- <img src={imageUrl} className="size-full" alt={isDecorative ? '' : 'app icon'} />
+ <img src={imageUrl} className="size-full" alt={decorative ? '' : 'app icon'} />
) : (
innerIcon || Icon
)}
- {showEditIcon && isHovering && (
- <div className={EditIconWrapperVariants({ size, rounded })}>
- <RiEditLine className={EditIconVariants({ size })} />
- </div>
+ {showEditIcon && (
+ <span
+ aria-hidden="true"
+ className="pointer-events-none absolute inset-0 z-10 hidden items-center justify-center bg-background-overlay-alt group-hover/app-icon:flex group-focus-visible/edit-icon:flex"
+ >
+ <span className={EditIconVariants({ size })} />
+ </span>
)}
- {coverElement}
</span>
)
}
diff --git a/web/app/components/datasets/create-from-pipeline/list/template-card/details/index.tsx b/web/app/components/datasets/create-from-pipeline/list/template-card/details/index.tsx
index 9e4e10cc7ad..ceed68023a9 100644
--- a/web/app/components/datasets/create-from-pipeline/list/template-card/details/index.tsx
+++ b/web/app/components/datasets/create-from-pipeline/list/template-card/details/index.tsx
@@ -65,7 +65,6 @@ const Details = ({ id, type, onApplyTemplate, onClose }: DetailsProps) => {
icon={appIcon.type === 'image' ? appIcon.fileId : appIcon.icon}
background={appIcon.type === 'image' ? undefined : appIcon.background}
imageUrl={appIcon.type === 'image' ? appIcon.url : undefined}
- showEditIcon
/>
<div className="flex grow flex-col gap-y-1 overflow-hidden py-px">
<div
diff --git a/web/app/components/datasets/create-from-pipeline/list/template-card/edit-pipeline-info.tsx b/web/app/components/datasets/create-from-pipeline/list/template-card/edit-pipeline-info.tsx
index 533a581782c..48f431133a4 100644
--- a/web/app/components/datasets/create-from-pipeline/list/template-card/edit-pipeline-info.tsx
+++ b/web/app/components/datasets/create-from-pipeline/list/template-card/edit-pipeline-info.tsx
@@ -126,9 +126,10 @@ const EditPipelineInfo = ({ onClose, pipeline }: EditPipelineInfoProps) => {
type="button"
aria-label={`${t(($) => $['operation.edit'], { ns: 'common' })} ${t(($) => $.pipelineNameAndIcon, { ns: 'datasetPipeline' })}`}
onClick={handleOpenAppIconPicker}
- className="shrink-0 cursor-pointer rounded-2xl focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden"
+ className="group/edit-icon shrink-0 cursor-pointer rounded-2xl focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden"
>
<AppIcon
+ decorative
size="xxl"
iconType={appIcon.type}
icon={appIcon.type === 'image' ? appIcon.fileId : appIcon.icon}
diff --git a/web/app/components/datasets/rename-modal/index.tsx b/web/app/components/datasets/rename-modal/index.tsx
index be6c9a6b6b4..c4867b8e7f2 100644
--- a/web/app/components/datasets/rename-modal/index.tsx
+++ b/web/app/components/datasets/rename-modal/index.tsx
@@ -128,10 +128,11 @@ const RenameDatasetModal = ({ show, dataset, onSuccess, onClose }: RenameDataset
<button
type="button"
aria-label={`${t(($) => $['operation.edit'], { ns: 'common' })} ${t(($) => $['form.nameAndIcon'], { ns: 'datasetSettings' })}`}
- className="shrink-0 cursor-pointer rounded-[10px] border-0 bg-transparent p-0 focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden"
+ className="group/edit-icon shrink-0 cursor-pointer rounded-[10px] border-0 bg-transparent p-0 focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden"
onClick={handleOpenAppIconPicker}
>
<AppIcon
+ decorative
size="medium"
iconType={appIcon.type}
icon={appIcon.type === 'image' ? appIcon.fileId : appIcon.icon}
diff --git a/web/app/components/explore/create-app-modal/__tests__/index.spec.tsx b/web/app/components/explore/create-app-modal/__tests__/index.spec.tsx
index 74d88c1b10a..3194a8129fb 100644
--- a/web/app/components/explore/create-app-modal/__tests__/index.spec.tsx
+++ b/web/app/components/explore/create-app-modal/__tests__/index.spec.tsx
@@ -44,13 +44,7 @@ const setup = async (overrides: Partial<CreateAppModalProps> = {}) => {
return { onConfirm, onHide }
}
-const getAppIconTrigger = (): HTMLElement => {
- const nameInput = screen.getByPlaceholderText('app.newApp.appNamePlaceholder')
- const iconRow = nameInput.parentElement
- const iconTrigger = iconRow?.firstElementChild
- if (!(iconTrigger instanceof HTMLElement)) throw new Error('Failed to locate app icon trigger')
- return iconTrigger
-}
+const getAppIconTrigger = () => screen.getByRole('button', { name: 'app.iconPicker.title' })
const openAppIconPicker = () => {
fireEvent.click(getAppIconTrigger())
@@ -252,6 +246,21 @@ describe('CreateAppModal', () => {
expect(onHide).toHaveBeenCalledTimes(1)
})
+ it('submits instead of opening the icon picker when Mod+Enter starts on its trigger', async () => {
+ const { onConfirm } = await setup()
+ const iconTrigger = getAppIconTrigger()
+ iconTrigger.focus()
+
+ fireEvent.keyDown(iconTrigger, { key: 'Enter', ctrlKey: true })
+ fireEvent.keyUp(iconTrigger, { key: 'Enter', ctrlKey: true })
+ await act(async () => {
+ vi.advanceTimersByTime(300)
+ })
+
+ expect(onConfirm).toHaveBeenCalledTimes(1)
+ expect(screen.queryByRole('dialog', { name: 'app.iconPicker.title' })).not.toBeInTheDocument()
+ })
+
it('does not submit while the visible confirmation action is disabled', async () => {
const { onConfirm, onHide } = await setup({ confirmDisabled: true })
expect(screen.getByRole('button', { name: /common\.operation\.create/ })).toBeDisabled()
diff --git a/web/app/components/explore/create-app-modal/index.tsx b/web/app/components/explore/create-app-modal/index.tsx
index ccec8745235..67f867bc3ea 100644
--- a/web/app/components/explore/create-app-modal/index.tsx
+++ b/web/app/components/explore/create-app-modal/index.tsx
@@ -220,19 +220,23 @@ const CreateAppModal = ({
{t(($) => $['newApp.captionName'], { ns: 'app' })}
</label>
<div className="flex items-center justify-between space-x-2">
- <AppIcon
- size="large"
- onClick={() => {
- setShowIconPicker(true)
- }}
- className="cursor-pointer"
- iconType={currentIcon.icon_type === 'link' ? 'image' : currentIcon.icon_type}
- icon={currentIcon.icon ?? undefined}
- background={currentIcon.icon_background}
- imageUrl={
- currentIcon.icon_type === 'link' ? currentIcon.icon : currentIcon.icon_url
- }
- />
+ <button
+ type="button"
+ aria-label={t(($) => $['iconPicker.title'], { ns: 'app' })}
+ className="shrink-0 cursor-pointer rounded-[10px] focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden"
+ onClick={() => setShowIconPicker(true)}
+ >
+ <AppIcon
+ decorative
+ size="large"
+ iconType={currentIcon.icon_type === 'link' ? 'image' : currentIcon.icon_type}
+ icon={currentIcon.icon ?? undefined}
+ background={currentIcon.icon_background}
+ imageUrl={
+ currentIcon.icon_type === 'link' ? currentIcon.icon : currentIcon.icon_url
+ }
+ />
+ </button>
<Input
id={nameInputId}
value={name}
diff --git a/web/app/components/tools/mcp/hooks/use-mcp-modal-form.ts b/web/app/components/tools/mcp/hooks/use-mcp-modal-form.ts
index 68afc0597dd..5dadb013cdd 100644
--- a/web/app/components/tools/mcp/hooks/use-mcp-modal-form.ts
+++ b/web/app/components/tools/mcp/hooks/use-mcp-modal-form.ts
@@ -101,7 +101,6 @@ export const useMCPModalForm = (data?: ToolWithProvider) => {
)
const [headers, setHeaders] = useState<HeaderItem[]>(() => getInitialHeaders(data))
const [isFetchingIcon, setIsFetchingIcon] = useState(false)
- const appIconRef = useRef<HTMLDivElement>(null)
const urlBlurGenerationRef = useRef(0)
// Auth state
const [authMethod, setAuthMethod] = useState<MCPAuthMethod>(MCPAuthMethod.authentication)
@@ -171,7 +170,6 @@ export const useMCPModalForm = (data?: ToolWithProvider) => {
isCreate,
originalServerUrl,
originalServerID,
- appIconRef,
// State
state: {
url,
diff --git a/web/app/components/tools/mcp/modal.tsx b/web/app/components/tools/mcp/modal.tsx
index 4e27b128f6b..8764aa92d79 100644
--- a/web/app/components/tools/mcp/modal.tsx
+++ b/web/app/components/tools/mcp/modal.tsx
@@ -11,7 +11,6 @@ import { Input } from '@langgenius/dify-ui/input'
import { SegmentedControl, SegmentedControlItem } from '@langgenius/dify-ui/segmented-control'
import { Switch } from '@langgenius/dify-ui/switch'
import { useSuspenseQuery } from '@tanstack/react-query'
-import { useHover } from 'ahooks'
import { useId } from 'react'
import { useTranslation } from 'react-i18next'
import AppIcon from '@/app/components/base/app-icon'
@@ -70,8 +69,7 @@ const MCPModalContent: FC<MCPModalContentProps> = ({ data, onConfirm, onHide })
const serverIdentifierInputId = useId()
const serverIdentifierDescriptionId = useId()
- const { isCreate, originalServerUrl, originalServerID, appIconRef, state, actions } =
- useMCPModalForm(data)
+ const { isCreate, originalServerUrl, originalServerID, state, actions } = useMCPModalForm(data)
const { data: systemFeatures } = useSuspenseQuery(systemFeaturesQueryOptions())
// SAML has no refresh_token model, so the enterprise side can't mint
@@ -82,8 +80,6 @@ const MCPModalContent: FC<MCPModalContentProps> = ({ data, onConfirm, onHide })
systemFeatures.sso_enforced_for_signin &&
(ssoProtocol === zSsoProtocol.enum.oidc || ssoProtocol === zSsoProtocol.enum.oauth2)
- const isHovering = useHover(appIconRef)
-
const authMethods = [
{
text: t(($) => $['mcp.modal.authentication'], { ns: 'tools' }),
@@ -199,10 +195,10 @@ const MCPModalContent: FC<MCPModalContentProps> = ({ data, onConfirm, onHide })
placeholder={t(($) => $['mcp.modal.namePlaceholder'], { ns: 'tools' })}
/>
</div>
- <div className="pt-2" ref={appIconRef}>
+ <div className="pt-2">
<IconButton
aria-label={t(($) => $['mcp.modal.changeIcon'], { ns: 'tools' })}
- className="size-14 rounded-2xl p-0"
+ className="group/edit-icon size-14 rounded-2xl p-0"
onClick={() => actions.setShowIconPicker(true)}
>
<AppIcon
@@ -224,16 +220,7 @@ const MCPModalContent: FC<MCPModalContentProps> = ({ data, onConfirm, onHide })
}
size="xxl"
className="relative rounded-2xl"
- coverElement={
- isHovering ? (
- <div className="absolute inset-0 flex items-center justify-center overflow-hidden rounded-2xl bg-background-overlay-alt">
- <span
- aria-hidden
- className="i-ri-edit-line size-6 text-text-primary-on-surface"
- />
- </div>
- ) : null
- }
+ showEditIcon
/>
</IconButton>
</div>
diff --git a/web/app/components/tools/workflow-tool/index.tsx b/web/app/components/tools/workflow-tool/index.tsx
index 0434ecc892f..ca856a549c8 100644
--- a/web/app/components/tools/workflow-tool/index.tsx
+++ b/web/app/components/tools/workflow-tool/index.tsx
@@ -340,16 +340,20 @@ export function WorkflowToolDrawer({
</span>
</FieldLabel>
<div className="flex items-center justify-between gap-3">
- <AppIcon
- size="large"
- onClick={() => {
- setShowEmojiPicker(true)
- }}
- className="cursor-pointer"
- iconType="emoji"
- icon={emoji.content}
- background={emoji.background}
- />
+ <button
+ type="button"
+ aria-label={t(($) => $['createTool.changeIcon'], { ns: 'tools' })}
+ className="shrink-0 cursor-pointer rounded-[10px] focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden"
+ onClick={() => setShowEmojiPicker(true)}
+ >
+ <AppIcon
+ decorative
+ size="large"
+ iconType="emoji"
+ icon={emoji.content}
+ background={emoji.background}
+ />
+ </button>
<Input
className="h-10 min-w-0 flex-1"
placeholder={t(($) => $['createTool.toolNamePlaceHolder'], { ns: 'tools' })!}
diff --git a/web/features/agent-v2/agent-detail/access/components/__tests__/access-surface-cards.spec.tsx b/web/features/agent-v2/agent-detail/access/components/__tests__/access-surface-cards.spec.tsx
index 1bb893babe0..1e08deacc77 100644
--- a/web/features/agent-v2/agent-detail/access/components/__tests__/access-surface-cards.spec.tsx
+++ b/web/features/agent-v2/agent-detail/access/components/__tests__/access-surface-cards.spec.tsx
@@ -849,7 +849,8 @@ describe('Agent access surface cards', () => {
const dialog = await screen.findByRole('dialog', {
name: 'appOverview.overview.appInfo.settings.title',
})
- expect(within(dialog).getByAltText('app icon')).toHaveAttribute(
+ const iconTrigger = within(dialog).getByRole('button', { name: 'app.iconPicker.title' })
+ expect(iconTrigger.querySelector('img')).toHaveAttribute(
'src',
'https://files.example.test/agent-icon.png',
)