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
fix(web): migrate legacy plain tabs to Dify UI (#42620)
yyhefd1fb09671f
diff --git a/web/app/components/app/annotation/view-annotation-modal/__tests__/index.spec.tsx b/web/app/components/app/annotation/view-annotation-modal/__tests__/index.spec.tsxindex 9b496487ffe..7c1cbb63f1b 100644--- a/web/app/components/app/annotation/view-annotation-modal/__tests__/index.spec.tsx+++ b/web/app/components/app/annotation/view-annotation-modal/__tests__/index.spec.tsx@@ -1,6 +1,7 @@import type { Mock } from 'vite-plus/test'import type { AnnotationItem, HitHistoryItem } from '../../type'import { fireEvent, render, screen, waitFor } from '@testing-library/react'+import userEvent from '@testing-library/user-event'import * as React from 'react'import { fetchHitHistoryList } from '@/service/annotation'import ViewAnnotationModal from '../index'@@ -121,7 +122,8 @@ describe('ViewAnnotationModal', () => {})})- it('should switch to hit history tab and show no data message', async () => {+ it('switches named panels with the keyboard while preserving the drawer name', async () => {+ const user = userEvent.setup()// Arrangeconst { props } = renderComponent()@@ -130,7 +132,19 @@ describe('ViewAnnotationModal', () => {})// Act- fireEvent.click(screen.getByText('appAnnotation.viewModal.hitHistory'))+ expect(+ screen.getByRole('dialog', { name: 'appAnnotation.viewModal.annotatedResponse' }),+ ).toBeInTheDocument()+ await user.click(screen.getByRole('tab', { name: 'appAnnotation.viewModal.annotatedResponse' }))+ await user.keyboard('{ArrowRight}{Enter}')+ expect(screen.getByRole('tab', { name: 'appAnnotation.viewModal.hitHistory' })).toHaveFocus()+ expect(+ screen.getByRole('tabpanel', { name: 'appAnnotation.viewModal.hitHistory' }),+ ).toBeInTheDocument()+ expect(screen.queryByTestId('edit-query')).not.toBeInTheDocument()+ expect(+ screen.getByRole('dialog', { name: 'appAnnotation.viewModal.annotatedResponse' }),+ ).toBeInTheDocument()// Assert// Assert@@ -138,7 +152,7 @@ describe('ViewAnnotationModal', () => {expect(mockFormatTime).toHaveBeenCalledWith(props.item.created_at, 'appLog.dateTimeFormat')})- it('should render hit history entries with pagination badge when data exists', async () => {+ it('should render hit history entries with their hit count when data exists', async () => {const hits = [createHitHistoryItem({ question: 'user input' }),createHitHistoryItem({ id: 'hit-2', question: 'second' }),diff --git a/web/app/components/app/annotation/view-annotation-modal/index.tsx b/web/app/components/app/annotation/view-annotation-modal/index.tsxindex 6611c2858b1..314fbf31420 100644--- a/web/app/components/app/annotation/view-annotation-modal/index.tsx+++ b/web/app/components/app/annotation/view-annotation-modal/index.tsx@@ -21,12 +21,11 @@ import {DrawerViewport,} from '@langgenius/dify-ui/drawer'import { Pagination } from '@langgenius/dify-ui/pagination'+import { Tabs, TabsList, TabsPanel, TabsTab } from '@langgenius/dify-ui/tabs'import * as React from 'react'import { useEffect, useState } from 'react'import { useTranslation } from 'react-i18next'-import Badge from '@/app/components/base/badge'import { MessageCheckRemove } from '@/app/components/base/icons/src/vender/line/communication'-import TabSlider from '@/app/components/base/tab-slider-plain'import { APP_PAGE_LIMIT } from '@/config'import useTimestamp from '@/hooks/use-timestamp'import { fetchHitHistoryList } from '@/service/annotation'@@ -87,26 +86,6 @@ const ViewAnnotationModal: FC<Props> = ({ appId, isShow, onHide, item, onSave, oif (isShow && id) fetchHitHistory(1)}, [id, isShow])- const tabs = [- {- value: TabType.annotation,- text: t(($) => $['viewModal.annotatedResponse'], { ns: 'appAnnotation' }),- },- {- value: TabType.hitHistory,- text:- hitHistoryList.length > 0 ? (- <div className="flex items-center space-x-1">- <div>{t(($) => $['viewModal.hitHistory'], { ns: 'appAnnotation' })}</div>- <Badge- text={`${total} ${t(($) => $[`viewModal.hit${hitHistoryList.length > 1 ? 's' : ''}`], { ns: 'appAnnotation' })}`}- />- </div>- ) : (- t(($) => $['viewModal.hitHistory'], { ns: 'appAnnotation' })- ),- },- ]const [activeTab, setActiveTab] = useState(TabType.annotation)const handleSave = async (type: EditItemType, editedContent: string) => {try {@@ -237,61 +216,74 @@ const ViewAnnotationModal: FC<Props> = ({ appId, isShow, onHide, item, onSave, o<DrawerViewport><DrawerPopup className="data-[swipe-direction=right]:top-16 data-[swipe-direction=right]:right-2 data-[swipe-direction=right]:bottom-3 data-[swipe-direction=right]:h-auto data-[swipe-direction=right]:w-200 data-[swipe-direction=right]:max-w-[calc(100vw-1rem)] data-[swipe-direction=right]:rounded-xl data-[swipe-direction=right]:border-r-[0.5px] data-[swipe-direction=right]:border-divider-subtle"><DrawerContent className="flex min-h-0 flex-1 flex-col p-0 pb-0">- <div className="shrink-0 border-b border-divider-subtle py-4">- <div className="flex h-6 items-center justify-between pr-5 pl-6">- <DrawerTitle render={<div />} className="min-w-0">- <TabSlider- className="relative top-2.25 shrink-0"- value={activeTab}- onChange={(v) => setActiveTab(v as TabType)}- options={tabs}- noBorderBottom- itemClassName="pb-3.5!"- />- </DrawerTitle>+ <DrawerTitle className="sr-only">+ {t(($) => $['viewModal.annotatedResponse'], { ns: 'appAnnotation' })}+ </DrawerTitle>+ <Tabs+ value={activeTab}+ onValueChange={setActiveTab}+ className="flex min-h-0 flex-1 flex-col"+ >+ <div className="flex shrink-0 items-center justify-between gap-4 border-b border-divider-subtle pr-5 pl-6">+ <TabsList>+ <TabsTab value={TabType.annotation}>+ {t(($) => $['viewModal.annotatedResponse'], { ns: 'appAnnotation' })}+ </TabsTab>+ <TabsTab value={TabType.hitHistory}>+ {t(($) => $['viewModal.hitHistory'], { ns: 'appAnnotation' })}+ {hitHistoryList.length > 0 && (+ <span className="ml-1 system-xs-medium text-text-tertiary">+ {`${total} ${t(($) => $[`viewModal.hit${hitHistoryList.length > 1 ? 's' : ''}`], { ns: 'appAnnotation' })}`}+ </span>+ )}+ </TabsTab>+ </TabsList><DrawerCloseButtonaria-label={t(($) => $['operation.close'], { ns: 'common' })}className="size-6 rounded-md"/></div>- </div>- <div className="min-h-0 flex-1 overflow-y-auto">- <div className="space-y-6 p-6 pb-4">- {activeTab === TabType.annotation ? annotationTab : hitHistoryTab}+ <div className="min-h-0 flex-1 overflow-y-auto">+ <TabsPanel value={TabType.annotation} className="space-y-6 p-6 pb-4">+ {annotationTab}+ </TabsPanel>+ <TabsPanel value={TabType.hitHistory} className="p-6 pb-4">+ {hitHistoryTab}+ </TabsPanel>+ <AlertDialog+ open={showModal}+ onOpenChange={(open) => !open && setShowModal(false)}+ >+ <AlertDialogContent>+ <div className="flex flex-col gap-2 px-6 pt-6 pb-4">+ <AlertDialogTitle+ title={t(($) => $['feature.annotation.removeConfirm'], {+ ns: 'appDebug',+ })}+ className="w-full truncate title-2xl-semi-bold text-text-primary"+ >+ {t(($) => $['feature.annotation.removeConfirm'], { ns: 'appDebug' })}+ </AlertDialogTitle>+ </div>+ <AlertDialogActions>+ <AlertDialogCancelButton>+ {t(($) => $['operation.cancel'], { ns: 'common' })}+ </AlertDialogCancelButton>+ <AlertDialogConfirmButton+ tone="destructive"+ onClick={async () => {+ await onRemove()+ setShowModal(false)+ onHide()+ }}+ >+ {t(($) => $['operation.confirm'], { ns: 'common' })}+ </AlertDialogConfirmButton>+ </AlertDialogActions>+ </AlertDialogContent>+ </AlertDialog></div>- <AlertDialog- open={showModal}- onOpenChange={(open) => !open && setShowModal(false)}- >- <AlertDialogContent>- <div className="flex flex-col gap-2 px-6 pt-6 pb-4">- <AlertDialogTitle- title={t(($) => $['feature.annotation.removeConfirm'], {- ns: 'appDebug',- })}- className="w-full truncate title-2xl-semi-bold text-text-primary"- >- {t(($) => $['feature.annotation.removeConfirm'], { ns: 'appDebug' })}- </AlertDialogTitle>- </div>- <AlertDialogActions>- <AlertDialogCancelButton>- {t(($) => $['operation.cancel'], { ns: 'common' })}- </AlertDialogCancelButton>- <AlertDialogConfirmButton- tone="destructive"- onClick={async () => {- await onRemove()- setShowModal(false)- onHide()- }}- >- {t(($) => $['operation.confirm'], { ns: 'common' })}- </AlertDialogConfirmButton>- </AlertDialogActions>- </AlertDialogContent>- </AlertDialog>- </div>+ </Tabs>{id && (<div className="flex h-16 shrink-0 items-center justify-between rounded-b-xl border-t border-divider-subtle bg-background-section-burn px-4 system-sm-medium text-text-tertiary"><buttondiff --git a/web/app/components/app/configuration/config/agent/agent-tools/__tests__/setting-built-in-tool.spec.tsx b/web/app/components/app/configuration/config/agent/agent-tools/__tests__/setting-built-in-tool.spec.tsxindex a4270cc7f0a..86b86cfb398 100644--- a/web/app/components/app/configuration/config/agent/agent-tools/__tests__/setting-built-in-tool.spec.tsx+++ b/web/app/components/app/configuration/config/agent/agent-tools/__tests__/setting-built-in-tool.spec.tsx@@ -172,16 +172,25 @@ describe('SettingBuiltInTool', () => {expect(await screen.findByText('Search Tool')).toBeInTheDocument()})- it('should switch between info and setting tabs', async () => {+ it('preserves the settings draft when switching named tab panels', async () => {+ const user = userEvent.setup()renderComponent()await waitFor(() => {expect(screen.getByTestId('mock-form')).toBeInTheDocument()})- await userEvent.click(screen.getByText('tools.setBuiltInTools.parameters'))- expect(screen.getByText('Info Param')).toBeInTheDocument()- await userEvent.click(screen.getByText('tools.setBuiltInTools.setting'))- expect(screen.getByTestId('mock-form')).toBeInTheDocument()+ nextFormValue = { settingParam: 'unsaved draft' }+ await user.click(screen.getByRole('button', { name: 'update-form' }))+ await user.click(screen.getByRole('tab', { name: 'tools.setBuiltInTools.parameters' }))+ expect(+ screen.getByRole('tabpanel', { name: 'tools.setBuiltInTools.parameters' }),+ ).toHaveTextContent('Info Param')+ expect(screen.queryByTestId('mock-form')).not.toBeInTheDocument()+ await user.click(screen.getByRole('tab', { name: 'tools.setBuiltInTools.setting' }))+ expect(+ screen.getByRole('tabpanel', { name: 'tools.setBuiltInTools.setting' }),+ ).toHaveTextContent('unsaved draft')+ expect(screen.getByRole('dialog', { name: 'Search Tool' })).toBeInTheDocument()})it('should keep the setting tab hidden when readonly by default', async () => {@@ -189,6 +198,8 @@ describe('SettingBuiltInTool', () => {expect(await screen.findByText('Info Param')).toBeInTheDocument()expect(screen.queryByText('tools.setBuiltInTools.setting')).not.toBeInTheDocument()+ expect(screen.queryByRole('tablist')).not.toBeInTheDocument()+ expect(screen.queryByRole('tabpanel')).not.toBeInTheDocument()})it('should expose readonly setting details when explicitly enabled', async () => {diff --git a/web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.tsx b/web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.tsxindex 7538e1b68a6..cd4546c8cbd 100644--- a/web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.tsx+++ b/web/app/components/app/configuration/config/agent/agent-tools/setting-built-in-tool.tsx@@ -10,16 +10,17 @@ import {DrawerContent,DrawerPopup,DrawerPortal,+ DrawerTitle,DrawerViewport,} from '@langgenius/dify-ui/drawer'import { IconButton } from '@langgenius/dify-ui/icon-button'+import { Tabs, TabsList, TabsPanel, TabsTab } from '@langgenius/dify-ui/tabs'import { RiArrowLeftLine, RiCloseLine } from '@remixicon/react'import * as React from 'react'import { useEffect, useState } from 'react'import { useTranslation } from 'react-i18next'import { useLocale } from '#i18n'import { LoadingPlaceholder } from '@/app/components/base/loading-placeholder'-import TabSlider from '@/app/components/base/tab-slider-plain'import Form from '@/app/components/header/account-setting/model-provider-page/model-modal/Form'import Icon from '@/app/components/plugins/card/base/card-icon'import Description from '@/app/components/plugins/card/base/description'@@ -81,7 +82,6 @@ const SettingBuiltInTool: FC<Props> = ({const showSettingAsDetails = readonly && showReadOnlySettingDetailsconst [tempSetting, setTempSetting] = useState(setting)const [currType, setCurrType] = useState('info')- const isInfoActive = currType === 'info'useEffect(() => {if (!collection || hasPassedTools) return@@ -214,9 +214,9 @@ const SettingBuiltInTool: FC<Props> = ({packageName={collection.name.split('/').pop() || ''}/></div>- <div className="mt-1 system-md-semibold text-text-primary">+ <DrawerTitle className="mt-1 system-md-semibold text-text-primary">{currTool?.label[language]}- </div>+ </DrawerTitle>{!!currTool?.description[language] && (<DescriptionclassName="mt-3 mb-2 h-auto"@@ -237,60 +237,53 @@ const SettingBuiltInTool: FC<Props> = ({/>)}</div>- {/* form */}- <div className="h-full">- <div className="flex h-full flex-col">+ <Tabs+ value={currType}+ onValueChange={setCurrType}+ className="flex min-h-0 flex-1 flex-col"+ >+ {showSettingTab ? (+ <TabsList className="mt-1 shrink-0 px-4">+ <TabsTab value="info">+ {t(($) => $['setBuiltInTools.parameters'], { ns: 'tools' })}+ </TabsTab>+ <TabsTab value="setting">+ {t(($) => $['setBuiltInTools.setting'], { ns: 'tools' })}+ </TabsTab>+ </TabsList>+ ) : (+ <div className="p-4 pb-1 system-sm-semibold-uppercase text-text-primary">+ {t(($) => $['setBuiltInTools.parameters'], { ns: 'tools' })}+ </div>+ )}+ <div className="min-h-0 flex-1 overflow-y-auto px-4">{showSettingTab ? (- <TabSlider- className="mt-1 shrink-0 px-4"- itemClassName="py-3"- noBorderBottom- value={currType}- onChange={(value) => {- setCurrType(value)- }}- options={[- {- value: 'info',- text: t(($) => $['setBuiltInTools.parameters'], { ns: 'tools' })!,- },- {- value: 'setting',- text: t(($) => $['setBuiltInTools.setting'], { ns: 'tools' })!,- },- ]}- />+ <>+ <TabsPanel value="info">{infoUI}</TabsPanel>+ <TabsPanel value="setting">+ {showSettingAsDetails ? settingDetailsUI : settingUI}+ {!readonly && (+ <div className="flex justify-end gap-2 py-2">+ <Button onClick={onHide}>+ {t(($) => $['operation.cancel'], { ns: 'common' })}+ </Button>+ <Button+ variant="primary"+ disabled={!isValid}+ onClick={() => onSave?.(tempSetting)}+ >+ {t(($) => $['operation.save'], { ns: 'common' })}+ </Button>+ </div>+ )}+ </TabsPanel>+ </>) : (- <div className="p-4 pb-1 system-sm-semibold-uppercase text-text-primary">- {t(($) => $['setBuiltInTools.parameters'], { ns: 'tools' })}- </div>+ infoUI)}- <div className="h-0 grow overflow-y-auto px-4">- {isInfoActive && infoUI}- {!isInfoActive && showSettingAsDetails && settingDetailsUI}- {!isInfoActive && !showSettingAsDetails && settingUI}- {!readonly && !isInfoActive && (- <div className="flex shrink-0 justify-end space-x-2 rounded-b-[10px] bg-components-panel-bg py-2">- <Button- className="flex h-8 items-center px-3! text-[13px]! font-medium"- onClick={onHide}- >- {t(($) => $['operation.cancel'], { ns: 'common' })}- </Button>- <Button- className="flex h-8 items-center px-3! text-[13px]! font-medium"- variant="primary"- disabled={!isValid}- onClick={() => onSave?.(tempSetting)}- >- {t(($) => $['operation.save'], { ns: 'common' })}- </Button>- </div>- )}- </div>- <ReadmeEntrance pluginDetail={collection as any} className="mt-auto" /></div>- </div>+ <ReadmeEntrance pluginDetail={collection as any} className="mt-auto" />+ </Tabs></>)}</DrawerContent>diff --git a/web/app/components/base/tab-slider-plain/__tests__/index.spec.tsx b/web/app/components/base/tab-slider-plain/__tests__/index.spec.tsxdeleted file mode 100644index 3e64c81dafd..00000000000--- a/web/app/components/base/tab-slider-plain/__tests__/index.spec.tsx+++ /dev/null@@ -1,22 +0,0 @@-import { render, screen } from '@testing-library/react'-import userEvent from '@testing-library/user-event'-import TabSlider from '../index'--const options = [- { value: 'overview', text: 'Overview' },- { value: 'settings', text: 'Settings' },-]--describe('TabSlider', () => {- it('changes only when users select an inactive tab', async () => {- const user = userEvent.setup()- const onChange = vi.fn()- render(<TabSlider value="overview" options={options} onChange={onChange} />)-- await user.click(screen.getByText('Overview'))- expect(onChange).not.toHaveBeenCalled()-- await user.click(screen.getByText('Settings'))- expect(onChange).toHaveBeenCalledWith('settings')- })-})diff --git a/web/app/components/base/tab-slider-plain/index.stories.tsx b/web/app/components/base/tab-slider-plain/index.stories.tsxdeleted file mode 100644index f87cfe67e6b..00000000000--- a/web/app/components/base/tab-slider-plain/index.stories.tsx+++ /dev/null@@ -1,49 +0,0 @@-import type { Meta, StoryObj } from '@storybook/nextjs-vite'-import { useState } from 'react'-import TabSliderPlain from '.'--const OPTIONS = [- { value: 'analytics', text: 'Analytics' },- { value: 'activity', text: 'Recent activity' },- { value: 'alerts', text: 'Alerts' },-]--const TabSliderPlainDemo = ({ initialValue = 'analytics' }: { initialValue?: string }) => {- const [value, setValue] = useState(initialValue)-- return (- <div className="flex w-full max-w-2xl flex-col gap-4 rounded-2xl border border-divider-subtle bg-components-panel-bg p-6">- <div className="text-xs tracking-[0.18em] text-text-tertiary uppercase">Underline tabs</div>- <TabSliderPlain value={value} onChange={setValue} options={OPTIONS} />- </div>- )-}--const meta = {- title: 'Base/Navigation/TabSliderPlain',- component: TabSliderPlainDemo,- parameters: {- layout: 'centered',- docs: {- description: {- component:- 'Underline-style navigation commonly used in dashboards. Toggle between three sections.',- },- },- },- argTypes: {- initialValue: {- control: 'radio',- options: OPTIONS.map((option) => option.value),- },- },- args: {- initialValue: 'analytics',- },- tags: ['autodocs'],-} satisfies Meta<typeof TabSliderPlainDemo>--export default meta-type Story = StoryObj<typeof meta>--export const Playground: Story = {}diff --git a/web/app/components/base/tab-slider-plain/index.tsx b/web/app/components/base/tab-slider-plain/index.tsxdeleted file mode 100644index 5ac8027fbb4..00000000000--- a/web/app/components/base/tab-slider-plain/index.tsx+++ /dev/null@@ -1,89 +0,0 @@-'use client'-import type { FC } from 'react'-import { cn } from '@langgenius/dify-ui/cn'-import * as React from 'react'--type Option = {- value: string- text: string | React.JSX.Element-}--type ItemProps = Readonly<{- className?: string- isActive: boolean- onClick: (v: string) => void- option: Option- smallItem?: boolean-}>-const Item: FC<ItemProps> = ({ className, isActive, onClick, option, smallItem }) => {- return (- <button- type="button"- key={option.value}- data-testid={`tab-slider-item-${option.value}`}- className={cn(- 'relative appearance-none border-0 bg-transparent px-0 pt-0 pb-2.5 text-left',- !isActive && 'cursor-pointer',- smallItem ? 'system-sm-semibold-uppercase' : 'system-xl-semibold',- className,- )}- onClick={() => !isActive && onClick(option.value)}- >- <span- data-testid="tab-slider-item-text"- className={cn('block', isActive ? 'text-text-primary' : 'text-text-tertiary')}- >- {option.text}- </span>- {isActive && (- <span- data-testid="tab-active-indicator"- className="absolute inset-x-0 bottom-0 h-0.5 bg-util-colors-blue-brand-blue-brand-600"- ></span>- )}- </button>- )-}--type Props = Readonly<{- className?: string- value: string- onChange: (v: string) => void- options: Option[]- noBorderBottom?: boolean- smallItem?: boolean- itemClassName?: string-}>--const TabSlider: FC<Props> = ({- className,- value,- onChange,- options,- noBorderBottom,- itemClassName,- smallItem,-}) => {- return (- <div- data-testid="tab-slider"- className={cn(- className,- !noBorderBottom && 'border-b border-divider-subtle',- 'flex space-x-6',- )}- >- {options.map((option) => (- <Item- isActive={option.value === value}- option={option}- onClick={onChange}- key={option.value}- className={itemClassName}- smallItem={smallItem}- />- ))}- </div>- )-}-export default React.memo(TabSlider)diff --git a/web/app/components/plugins/plugin-detail-panel/tool-selector/components/__tests__/tool-settings-panel.spec.tsx b/web/app/components/plugins/plugin-detail-panel/tool-selector/components/__tests__/tool-settings-panel.spec.tsxindex cfee2b95b8f..3cc8e339108 100644--- a/web/app/components/plugins/plugin-detail-panel/tool-selector/components/__tests__/tool-settings-panel.spec.tsx+++ b/web/app/components/plugins/plugin-detail-panel/tool-selector/components/__tests__/tool-settings-panel.spec.tsx@@ -1,26 +1,10 @@import type { ToolWithProvider } from '@/app/components/workflow/types'-import { fireEvent, render, screen } from '@testing-library/react'+import { render, screen } from '@testing-library/react'+import userEvent from '@testing-library/user-event'+import { useState } from 'react'import { describe, expect, it, vi } from 'vite-plus/test'import { ToolSettingsPanel } from '../tool-settings-panel'-vi.mock('@/app/components/base/tab-slider-plain', () => ({- default: ({- options,- onChange,- }: {- options: Array<{ value: string; text: string }>- onChange: (value: string) => void- }) => (- <div data-testid="tab-slider">- {options.map((option) => (- <button key={option.value} onClick={() => onChange(option.value)}>- {option.text}- </button>- ))}- </div>- ),-}))-vi.mock('@/app/components/workflow/nodes/tool/components/tool-form', () => ({default: ({ schema }: { schema: Array<{ name: string }> }) => (<div data-testid="tool-form">{schema.map((item) => item.name).join(',')}</div>@@ -68,14 +52,44 @@ describe('ToolSettingsPanel', () => {expect(container).toBeEmptyDOMElement()})- it('renders the settings form and lets the tab slider switch to params', () => {- const onCurrTypeChange = vi.fn()- render(<ToolSettingsPanel {...baseProps} onCurrTypeChange={onCurrTypeChange} />)+ it('switches the controlled settings and params panels with the keyboard', async () => {+ const user = userEvent.setup()+ function ControlledPanel() {+ const [currType, setCurrType] = useState<'settings' | 'params'>('settings')+ return <ToolSettingsPanel {...baseProps} currType={currType} onCurrTypeChange={setCurrType} />+ }+ render(<ControlledPanel />)- expect(screen.getByTestId('tool-form')).toHaveTextContent('api_key')- fireEvent.click(screen.getByText('plugin.detailPanel.toolSelector.params'))+ expect(+ screen.getByRole('tabpanel', { name: 'plugin.detailPanel.toolSelector.settings' }),+ ).toHaveTextContent('api_key')+ await user.click(screen.getByRole('tab', { name: 'plugin.detailPanel.toolSelector.settings' }))+ await user.keyboard('{ArrowRight}{Enter}')+ expect(+ screen.getByRole('tab', { name: 'plugin.detailPanel.toolSelector.params' }),+ ).toHaveFocus()+ expect(+ screen.getByRole('tabpanel', { name: 'plugin.detailPanel.toolSelector.params' }),+ ).toHaveTextContent('temperature')+ expect(screen.queryByTestId('tool-form')).not.toBeInTheDocument()+ await user.keyboard('{ArrowLeft}{Enter}')+ expect(+ screen.getByRole('tabpanel', { name: 'plugin.detailPanel.toolSelector.settings' }),+ ).toHaveTextContent('api_key')+ })- expect(onCurrTypeChange).toHaveBeenCalledWith('params')+ it('renders a settings-only form without an orphaned tab panel', () => {+ render(+ <ToolSettingsPanel+ {...baseProps}+ paramsFormSchemas={[]}+ showTabSlider={false}+ userSettingsOnly+ />,+ )+ expect(screen.getByTestId('tool-form')).toHaveTextContent('api_key')+ expect(screen.queryByRole('tablist')).not.toBeInTheDocument()+ expect(screen.queryByRole('tabpanel')).not.toBeInTheDocument()})it('renders params tips and the reasoning config form for params-only views', () => {@@ -86,10 +100,13 @@ describe('ToolSettingsPanel', () => {settingsFormSchemas={[]}userSettingsOnly={false}reasoningConfigOnly+ showTabSlider={false}/>,)- expect(screen.getAllByText('plugin.detailPanel.toolSelector.paramsTip1')).toHaveLength(2)+ expect(screen.getByText('plugin.detailPanel.toolSelector.paramsTip1')).toBeInTheDocument()+ expect(screen.queryByRole('tablist')).not.toBeInTheDocument()+ expect(screen.queryByRole('tabpanel')).not.toBeInTheDocument()expect(screen.getByTestId('reasoning-config-form')).toHaveTextContent('temperature')})})diff --git a/web/app/components/plugins/plugin-detail-panel/tool-selector/components/tool-settings-panel.tsx b/web/app/components/plugins/plugin-detail-panel/tool-selector/components/tool-settings-panel.tsxindex 10088fda041..de4a1b1876f 100644--- a/web/app/components/plugins/plugin-detail-panel/tool-selector/components/tool-settings-panel.tsx+++ b/web/app/components/plugins/plugin-detail-panel/tool-selector/components/tool-settings-panel.tsx@@ -7,9 +7,9 @@ import type { ToolFormSchema } from '@/app/components/tools/utils/to-form-schemaimport type { ToolValue } from '@/app/components/workflow/block-selector/types'import type { ToolVarInputs } from '@/app/components/workflow/nodes/tool/types'import type { NodeOutPutVar, ToolWithProvider } from '@/app/components/workflow/types'+import { Tabs, TabsList, TabsPanel, TabsTab } from '@langgenius/dify-ui/tabs'import { useTranslation } from 'react-i18next'import Divider from '@/app/components/base/divider'-import TabSlider from '@/app/components/base/tab-slider-plain'import ToolForm from '@/app/components/workflow/nodes/tool/components/tool-form'import ReasoningConfigForm from './reasoning-config-form'@@ -74,84 +74,73 @@ export function ToolSettingsPanel({if ((!hasSettings && !hasParams) || !isTeamAuthorized) return null+ const settingsForm = (+ <div className="px-4 py-2">+ <ToolForm+ inPanel+ readOnly={false}+ nodeId={nodeId}+ schema={settingsFormSchemas as CredentialFormSchema[]}+ value={settingsValue}+ onChange={onSettingsFormChange}+ />+ </div>+ )+ const paramsForm = (+ <ReasoningConfigForm+ value={(value?.parameters || {}) as ReasoningConfigValue}+ onChange={onParamsFormChange}+ schemas={paramsFormSchemas}+ nodeOutputVars={nodeOutputVars}+ availableNodes={availableNodes}+ nodeId={nodeId}+ />+ )+return (<><Divider className="my-1 w-full" />-- {/* Tab slider - shown only when both settings and params exist */}- {nodeId && showTabSlider && (- <TabSlider- className="mt-1 shrink-0 px-4"- itemClassName="py-3"- noBorderBottom- smallItem+ {nodeId && showTabSlider ? (+ <Tabsvalue={currType}- onChange={(v) => {- if (v === 'settings' || v === 'params') onCurrTypeChange(v)+ onValueChange={(value) => {+ if (value === 'settings' || value === 'params') onCurrTypeChange(value)}}- options={[- {- value: 'settings',- text: t(($) => $['detailPanel.toolSelector.settings'], { ns: 'plugin' })!,- },- {- value: 'params',- text: t(($) => $['detailPanel.toolSelector.params'], { ns: 'plugin' })!,- },- ]}- />- )}-- {/* Params tips when tab slider and params tab is active */}- {nodeId && showTabSlider && currType === 'params' && (- <div className="px-4 py-2">- <ParamsTips />- </div>- )}-- {/* User settings only header */}- {userSettingsOnly && (- <div className="p-4 pb-1">- <div className="system-sm-semibold-uppercase text-text-primary">- {t(($) => $['detailPanel.toolSelector.settings'], { ns: 'plugin' })}- </div>- </div>- )}-- {/* Reasoning config only header */}- {nodeId && reasoningConfigOnly && (- <div className="mb-1 p-4 pb-1">- <div className="system-sm-semibold-uppercase text-text-primary">- {t(($) => $['detailPanel.toolSelector.params'], { ns: 'plugin' })}- </div>- <ParamsTips />- </div>- )}-- {/* User settings form */}- {(currType === 'settings' || userSettingsOnly) && (- <div className="px-4 py-2">- <ToolForm- inPanel- readOnly={false}- nodeId={nodeId}- schema={settingsFormSchemas as CredentialFormSchema[]}- value={settingsValue}- onChange={onSettingsFormChange}- />- </div>- )}-- {/* Reasoning config form */}- {nodeId && (currType === 'params' || reasoningConfigOnly) && (- <ReasoningConfigForm- value={(value?.parameters || {}) as ReasoningConfigValue}- onChange={onParamsFormChange}- schemas={paramsFormSchemas}- nodeOutputVars={nodeOutputVars}- availableNodes={availableNodes}- nodeId={nodeId}- />+ >+ <TabsList className="mt-1 px-4">+ <TabsTab value="settings">+ {t(($) => $['detailPanel.toolSelector.settings'], { ns: 'plugin' })}+ </TabsTab>+ <TabsTab value="params">+ {t(($) => $['detailPanel.toolSelector.params'], { ns: 'plugin' })}+ </TabsTab>+ </TabsList>+ <TabsPanel value="settings">{settingsForm}</TabsPanel>+ <TabsPanel value="params">+ <div className="px-4 py-2">+ <ParamsTips />+ </div>+ {paramsForm}+ </TabsPanel>+ </Tabs>+ ) : (+ <>+ {userSettingsOnly && (+ <div className="p-4 pb-1 system-sm-semibold-uppercase text-text-primary">+ {t(($) => $['detailPanel.toolSelector.settings'], { ns: 'plugin' })}+ </div>+ )}+ {nodeId && reasoningConfigOnly && (+ <div className="mb-1 p-4 pb-1">+ <div className="system-sm-semibold-uppercase text-text-primary">+ {t(($) => $['detailPanel.toolSelector.params'], { ns: 'plugin' })}+ </div>+ <ParamsTips />+ </div>+ )}+ {(currType === 'settings' || userSettingsOnly) && settingsForm}+ {nodeId && (currType === 'params' || reasoningConfigOnly) && paramsForm}+ </>)}</>)