From 2b021e8752a9b8e18867634f04144859b2f6c8f4 Mon Sep 17 00:00:00 2001 From: lif <1835304752@qq.com> Date: Thu, 15 Jan 2026 17:43:00 +0800 Subject: [PATCH 1/4] fix: remove hardcoded 48-character limit from text inputs (#30156) Signed-off-by: majiayu000 <1835304752@qq.com> Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> --- .../config-var/config-modal/index.tsx | 3 -- .../app/configuration/config-var/index.tsx | 3 -- .../configuration/debug/chat-user-input.tsx | 5 +-- .../prompt-value-panel/index.tsx | 5 +-- .../panel/input-field/editor/form/hooks.ts | 3 -- .../input-field/editor/form/index.spec.tsx | 21 ---------- .../share/text-generation/index.tsx | 9 ++-- .../text-generation/run-once/index.spec.tsx | 42 +++++++++++++++++++ .../share/text-generation/run-once/index.tsx | 3 +- web/config/index.ts | 3 -- web/utils/var.ts | 2 +- 11 files changed, 52 insertions(+), 47 deletions(-) diff --git a/web/app/components/app/configuration/config-var/config-modal/index.tsx b/web/app/components/app/configuration/config-var/config-modal/index.tsx index 5ffa87375c..7ea784baa3 100644 --- a/web/app/components/app/configuration/config-var/config-modal/index.tsx +++ b/web/app/components/app/configuration/config-var/config-modal/index.tsx @@ -21,7 +21,6 @@ import CodeEditor from '@/app/components/workflow/nodes/_base/components/editor/ import FileUploadSetting from '@/app/components/workflow/nodes/_base/components/file-upload-setting' import { CodeLanguage } from '@/app/components/workflow/nodes/code/types' import { ChangeType, InputVarType, SupportUploadFileTypes } from '@/app/components/workflow/types' -import { DEFAULT_VALUE_MAX_LEN } from '@/config' import ConfigContext from '@/context/debug-configuration' import { AppModeEnum, TransferMethod } from '@/types/app' import { checkKeys, getNewVarInWorkflow, replaceSpaceWithUnderscoreInVarNameInput } from '@/utils/var' @@ -198,8 +197,6 @@ const ConfigModal: FC = ({ if (type === InputVarType.multiFiles) draft.max_length = DEFAULT_FILE_UPLOAD_SETTING.max_length } - if (type === InputVarType.paragraph) - draft.max_length = DEFAULT_VALUE_MAX_LEN }) setTempPayload(newPayload) }, [tempPayload]) diff --git a/web/app/components/app/configuration/config-var/index.tsx b/web/app/components/app/configuration/config-var/index.tsx index 4a38fc92a6..1a8810f7cd 100644 --- a/web/app/components/app/configuration/config-var/index.tsx +++ b/web/app/components/app/configuration/config-var/index.tsx @@ -15,7 +15,6 @@ import Confirm from '@/app/components/base/confirm' import Toast from '@/app/components/base/toast' import Tooltip from '@/app/components/base/tooltip' import { InputVarType } from '@/app/components/workflow/types' -import { DEFAULT_VALUE_MAX_LEN } from '@/config' import ConfigContext from '@/context/debug-configuration' import { useEventEmitterContextContext } from '@/context/event-emitter' import { useModalContext } from '@/context/modal-context' @@ -58,8 +57,6 @@ const buildPromptVariableFromInput = (payload: InputVar): PromptVariable => { key: variable, name: label as string, } - if (payload.type === InputVarType.textInput) - nextItem.max_length = nextItem.max_length || DEFAULT_VALUE_MAX_LEN if (payload.type !== InputVarType.select) delete nextItem.options diff --git a/web/app/components/app/configuration/debug/chat-user-input.tsx b/web/app/components/app/configuration/debug/chat-user-input.tsx index 11189751e0..3f9fdc32be 100644 --- a/web/app/components/app/configuration/debug/chat-user-input.tsx +++ b/web/app/components/app/configuration/debug/chat-user-input.tsx @@ -7,7 +7,6 @@ import Input from '@/app/components/base/input' import Select from '@/app/components/base/select' import Textarea from '@/app/components/base/textarea' import BoolInput from '@/app/components/workflow/nodes/_base/components/before-run-form/bool-input' -import { DEFAULT_VALUE_MAX_LEN } from '@/config' import ConfigContext from '@/context/debug-configuration' import { cn } from '@/utils/classnames' @@ -88,7 +87,7 @@ const ChatUserInput = ({ onChange={(e) => { handleInputValueChange(key, e.target.value) }} placeholder={name} autoFocus={index === 0} - maxLength={max_length || DEFAULT_VALUE_MAX_LEN} + maxLength={max_length} /> )} {type === 'paragraph' && ( @@ -115,7 +114,7 @@ const ChatUserInput = ({ onChange={(e) => { handleInputValueChange(key, e.target.value) }} placeholder={name} autoFocus={index === 0} - maxLength={max_length || DEFAULT_VALUE_MAX_LEN} + maxLength={max_length} /> )} {type === 'checkbox' && ( diff --git a/web/app/components/app/configuration/prompt-value-panel/index.tsx b/web/app/components/app/configuration/prompt-value-panel/index.tsx index 9b61b3c7aa..613efb8710 100644 --- a/web/app/components/app/configuration/prompt-value-panel/index.tsx +++ b/web/app/components/app/configuration/prompt-value-panel/index.tsx @@ -20,7 +20,6 @@ import Select from '@/app/components/base/select' import Textarea from '@/app/components/base/textarea' import Tooltip from '@/app/components/base/tooltip' import BoolInput from '@/app/components/workflow/nodes/_base/components/before-run-form/bool-input' -import { DEFAULT_VALUE_MAX_LEN } from '@/config' import ConfigContext from '@/context/debug-configuration' import { AppModeEnum, ModelModeType } from '@/types/app' import { cn } from '@/utils/classnames' @@ -142,7 +141,7 @@ const PromptValuePanel: FC = ({ onChange={(e) => { handleInputValueChange(key, e.target.value) }} placeholder={name} autoFocus={index === 0} - maxLength={max_length || DEFAULT_VALUE_MAX_LEN} + maxLength={max_length} /> )} {type === 'paragraph' && ( @@ -170,7 +169,7 @@ const PromptValuePanel: FC = ({ onChange={(e) => { handleInputValueChange(key, e.target.value) }} placeholder={name} autoFocus={index === 0} - maxLength={max_length || DEFAULT_VALUE_MAX_LEN} + maxLength={max_length} /> )} {type === 'checkbox' && ( diff --git a/web/app/components/rag-pipeline/components/panel/input-field/editor/form/hooks.ts b/web/app/components/rag-pipeline/components/panel/input-field/editor/form/hooks.ts index 3820d5f1b8..80aa879b8f 100644 --- a/web/app/components/rag-pipeline/components/panel/input-field/editor/form/hooks.ts +++ b/web/app/components/rag-pipeline/components/panel/input-field/editor/form/hooks.ts @@ -6,7 +6,6 @@ import { useTranslation } from 'react-i18next' import { useFileSizeLimit } from '@/app/components/base/file-uploader/hooks' import { InputFieldType } from '@/app/components/base/form/form-scenarios/input-field/types' import { DEFAULT_FILE_UPLOAD_SETTING } from '@/app/components/workflow/constants' -import { DEFAULT_VALUE_MAX_LEN } from '@/config' import { PipelineInputVarType } from '@/models/pipeline' import { useFileUploadConfig } from '@/service/use-common' import { formatFileSize } from '@/utils/format' @@ -87,8 +86,6 @@ export const useConfigurations = (props: { if (type === PipelineInputVarType.multiFiles) setFieldValue('maxLength', DEFAULT_FILE_UPLOAD_SETTING.max_length) } - if (type === PipelineInputVarType.paragraph) - setFieldValue('maxLength', DEFAULT_VALUE_MAX_LEN) }, [setFieldValue]) const handleVariableNameBlur = useCallback((value: string) => { diff --git a/web/app/components/rag-pipeline/components/panel/input-field/editor/form/index.spec.tsx b/web/app/components/rag-pipeline/components/panel/input-field/editor/form/index.spec.tsx index 0470bd4c68..48df13acb2 100644 --- a/web/app/components/rag-pipeline/components/panel/input-field/editor/form/index.spec.tsx +++ b/web/app/components/rag-pipeline/components/panel/input-field/editor/form/index.spec.tsx @@ -779,27 +779,6 @@ describe('useConfigurations', () => { expect(mockSetFieldValue).toHaveBeenCalledWith('maxLength', expect.any(Number)) }) - it('should call setFieldValue when type changes to paragraph', () => { - // Arrange - const mockGetFieldValue = vi.fn() - const mockSetFieldValue = vi.fn() - - const { result } = renderHookWithProviders(() => - useConfigurations({ - getFieldValue: mockGetFieldValue, - setFieldValue: mockSetFieldValue, - supportFile: false, - }), - ) - - // Act - const typeConfig = result.current.find(config => config.variable === 'type') - typeConfig?.listeners?.onChange?.(createMockEvent(PipelineInputVarType.paragraph)) - - // Assert - expect(mockSetFieldValue).toHaveBeenCalledWith('maxLength', 48) // DEFAULT_VALUE_MAX_LEN - }) - it('should set label from variable name on blur when label is empty', () => { // Arrange const mockGetFieldValue = vi.fn().mockReturnValue('') diff --git a/web/app/components/share/text-generation/index.tsx b/web/app/components/share/text-generation/index.tsx index b793a03ce7..509687e245 100644 --- a/web/app/components/share/text-generation/index.tsx +++ b/web/app/components/share/text-generation/index.tsx @@ -26,7 +26,7 @@ import DifyLogo from '@/app/components/base/logo/dify-logo' import Toast from '@/app/components/base/toast' import Res from '@/app/components/share/text-generation/result' import RunOnce from '@/app/components/share/text-generation/run-once' -import { appDefaultIconBackground, BATCH_CONCURRENCY, DEFAULT_VALUE_MAX_LEN } from '@/config' +import { appDefaultIconBackground, BATCH_CONCURRENCY } from '@/config' import { useGlobalPublicStore } from '@/context/global-public-context' import { useWebAppStore } from '@/context/web-app-context' import { useAppFavicon } from '@/hooks/use-app-favicon' @@ -256,11 +256,10 @@ const TextGeneration: FC = ({ promptConfig?.prompt_variables.forEach((varItem, varIndex) => { if (errorRowIndex !== 0) return - if (varItem.type === 'string') { - const maxLen = varItem.max_length || DEFAULT_VALUE_MAX_LEN - if (item[varIndex].length > maxLen) { + if (varItem.type === 'string' && varItem.max_length) { + if (item[varIndex].length > varItem.max_length) { moreThanMaxLengthVarName = varItem.name - maxLength = maxLen + maxLength = varItem.max_length errorRowIndex = index + 1 return } diff --git a/web/app/components/share/text-generation/run-once/index.spec.tsx b/web/app/components/share/text-generation/run-once/index.spec.tsx index 8882253d0e..ea5ce3c902 100644 --- a/web/app/components/share/text-generation/run-once/index.spec.tsx +++ b/web/app/components/share/text-generation/run-once/index.spec.tsx @@ -236,4 +236,46 @@ describe('RunOnce', () => { const stopButton = screen.getByTestId('stop-button') expect(stopButton).toBeDisabled() }) + + describe('maxLength behavior', () => { + it('should not have maxLength attribute when max_length is not set', async () => { + const promptConfig: PromptConfig = { + prompt_template: 'template', + prompt_variables: [ + createPromptVariable({ + key: 'textInput', + name: 'Text Input', + type: 'string', + // max_length is not set + }), + ], + } + const { onInputsChange } = setup({ promptConfig, visionConfig: { ...baseVisionConfig, enabled: false } }) + await waitFor(() => { + expect(onInputsChange).toHaveBeenCalled() + }) + const input = screen.getByPlaceholderText('Text Input') + expect(input).not.toHaveAttribute('maxLength') + }) + + it('should have maxLength attribute when max_length is set', async () => { + const promptConfig: PromptConfig = { + prompt_template: 'template', + prompt_variables: [ + createPromptVariable({ + key: 'textInput', + name: 'Text Input', + type: 'string', + max_length: 100, + }), + ], + } + const { onInputsChange } = setup({ promptConfig, visionConfig: { ...baseVisionConfig, enabled: false } }) + await waitFor(() => { + expect(onInputsChange).toHaveBeenCalled() + }) + const input = screen.getByPlaceholderText('Text Input') + expect(input).toHaveAttribute('maxLength', '100') + }) + }) }) diff --git a/web/app/components/share/text-generation/run-once/index.tsx b/web/app/components/share/text-generation/run-once/index.tsx index b8193fd944..ca29ce1a98 100644 --- a/web/app/components/share/text-generation/run-once/index.tsx +++ b/web/app/components/share/text-generation/run-once/index.tsx @@ -19,7 +19,6 @@ import Textarea from '@/app/components/base/textarea' import BoolInput from '@/app/components/workflow/nodes/_base/components/before-run-form/bool-input' import CodeEditor from '@/app/components/workflow/nodes/_base/components/editor/code-editor' import { CodeLanguage } from '@/app/components/workflow/nodes/code/types' -import { DEFAULT_VALUE_MAX_LEN } from '@/config' import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints' import { cn } from '@/utils/classnames' @@ -140,7 +139,7 @@ const RunOnce: FC = ({ placeholder={item.name} value={inputs[item.key]} onChange={(e: ChangeEvent) => { handleInputsChange({ ...inputsRef.current, [item.key]: e.target.value }) }} - maxLength={item.max_length || DEFAULT_VALUE_MAX_LEN} + maxLength={item.max_length} /> )} {item.type === 'paragraph' && ( diff --git a/web/config/index.ts b/web/config/index.ts index b804629048..08ce14b264 100644 --- a/web/config/index.ts +++ b/web/config/index.ts @@ -208,7 +208,6 @@ export const VAR_ITEM_TEMPLATE = { key: '', name: '', type: 'string', - max_length: DEFAULT_VALUE_MAX_LEN, required: true, } @@ -216,7 +215,6 @@ export const VAR_ITEM_TEMPLATE_IN_WORKFLOW = { variable: '', label: '', type: InputVarType.textInput, - max_length: DEFAULT_VALUE_MAX_LEN, required: true, options: [], } @@ -225,7 +223,6 @@ export const VAR_ITEM_TEMPLATE_IN_PIPELINE = { variable: '', label: '', type: PipelineInputVarType.textInput, - max_length: DEFAULT_VALUE_MAX_LEN, required: true, options: [], } diff --git a/web/utils/var.ts b/web/utils/var.ts index 4f572d7768..1851084b2e 100644 --- a/web/utils/var.ts +++ b/web/utils/var.ts @@ -30,7 +30,7 @@ export const getNewVar = (key: string, type: string) => { } export const getNewVarInWorkflow = (key: string, type = InputVarType.textInput): InputVar => { - const { max_length: _maxLength, ...rest } = VAR_ITEM_TEMPLATE_IN_WORKFLOW + const { ...rest } = VAR_ITEM_TEMPLATE_IN_WORKFLOW if (type !== InputVarType.textInput) { return { ...rest, From 1a2fce7055830ac8690bf807b01073c4b4b1dea3 Mon Sep 17 00:00:00 2001 From: Stephen Zhou <38493346+hyoban@users.noreply.github.com> Date: Thu, 15 Jan 2026 21:49:46 +0800 Subject: [PATCH 2/4] ci: eslint annotation (#31056) --- .github/workflows/style.yml | 13 ++++++++++++- web/package.json | 7 ++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index 6c5d6f4135..b96db5a390 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -65,6 +65,9 @@ jobs: defaults: run: working-directory: ./web + permissions: + checks: write + pull-requests: read steps: - name: Checkout code @@ -103,7 +106,15 @@ jobs: if: steps.changed-files.outputs.any_changed == 'true' working-directory: ./web run: | - pnpm run lint + pnpm run lint:report + continue-on-error: true + + - name: Annotate Code + if: steps.changed-files.outputs.any_changed == 'true' + uses: DerLev/eslint-annotations@51347b3a0abfb503fc8734d5ae31c4b151297fae + with: + eslint-report: web/eslint_report.json + github-token: ${{ secrets.GITHUB_TOKEN }} - name: Web type check if: steps.changed-files.outputs.any_changed == 'true' diff --git a/web/package.json b/web/package.json index 000862204b..5ca90c75ea 100644 --- a/web/package.json +++ b/web/package.json @@ -28,9 +28,10 @@ "build:docker": "next build && node scripts/optimize-standalone.js", "start": "node ./scripts/copy-and-start.mjs", "lint": "eslint --cache --cache-location node_modules/.cache/eslint/.eslint-cache", - "lint:fix": "eslint --cache --cache-location node_modules/.cache/eslint/.eslint-cache --fix", - "lint:quiet": "eslint --cache --cache-location node_modules/.cache/eslint/.eslint-cache --quiet", - "lint:complexity": "eslint --cache --cache-location node_modules/.cache/eslint/.eslint-cache --rule 'complexity: [error, {max: 15}]' --quiet", + "lint:fix": "pnpm lint --fix", + "lint:quiet": "pnpm lint --quiet", + "lint:complexity": "pnpm lint --rule 'complexity: [error, {max: 15}]' --quiet", + "lint:report": "pnpm lint --output-file eslint_report.json --format json", "type-check": "tsc --noEmit", "type-check:tsgo": "tsgo --noEmit", "prepare": "cd ../ && node -e \"if (process.env.NODE_ENV !== 'production'){process.exit(1)} \" || husky ./web/.husky", From b06c7c8f33c76f4803978c659e5e56b0529d676c Mon Sep 17 00:00:00 2001 From: Stephen Zhou <38493346+hyoban@users.noreply.github.com> Date: Thu, 15 Jan 2026 23:04:26 +0800 Subject: [PATCH 3/4] ci: disable limit annotation (#31072) --- .github/workflows/style.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index b96db5a390..86b66bf9df 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -109,12 +109,12 @@ jobs: pnpm run lint:report continue-on-error: true - - name: Annotate Code - if: steps.changed-files.outputs.any_changed == 'true' - uses: DerLev/eslint-annotations@51347b3a0abfb503fc8734d5ae31c4b151297fae - with: - eslint-report: web/eslint_report.json - github-token: ${{ secrets.GITHUB_TOKEN }} + # - name: Annotate Code + # if: steps.changed-files.outputs.any_changed == 'true' && github.event_name == 'pull_request' + # uses: DerLev/eslint-annotations@51347b3a0abfb503fc8734d5ae31c4b151297fae + # with: + # eslint-report: web/eslint_report.json + # github-token: ${{ secrets.GITHUB_TOKEN }} - name: Web type check if: steps.changed-files.outputs.any_changed == 'true' From c98870c3f457a94e7cfa39857ccf7ee2a8d8f7a4 Mon Sep 17 00:00:00 2001 From: byteforge Date: Thu, 15 Jan 2026 18:52:53 -0500 Subject: [PATCH 4/4] refactor: always preserve marketplace search state in URL (#31069) Co-authored-by: Stephen Zhou <38493346+hyoban@users.noreply.github.com> --- .../components/plugins/marketplace/atoms.ts | 25 +++---------------- .../plugins/marketplace/hydration-client.tsx | 15 ----------- .../components/plugins/marketplace/index.tsx | 20 ++++++--------- .../plugins/plugin-page/context.tsx | 2 +- 4 files changed, 12 insertions(+), 50 deletions(-) delete mode 100644 web/app/components/plugins/marketplace/hydration-client.tsx diff --git a/web/app/components/plugins/marketplace/atoms.ts b/web/app/components/plugins/marketplace/atoms.ts index 6ca9bd1c05..b13d30407e 100644 --- a/web/app/components/plugins/marketplace/atoms.ts +++ b/web/app/components/plugins/marketplace/atoms.ts @@ -1,4 +1,3 @@ -import type { ActivePluginType } from './constants' import type { PluginsSort, SearchParamsFromCollection } from './types' import { atom, useAtom, useAtomValue, useSetAtom } from 'jotai' import { useQueryState } from 'nuqs' @@ -17,32 +16,14 @@ export function useSetMarketplaceSort() { return useSetAtom(marketplaceSortAtom) } -/** - * Preserve the state for marketplace - */ -export const preserveSearchStateInQueryAtom = atom(false) - -const searchPluginTextAtom = atom('') -const activePluginTypeAtom = atom('all') -const filterPluginTagsAtom = atom([]) - export function useSearchPluginText() { - const preserveSearchStateInQuery = useAtomValue(preserveSearchStateInQueryAtom) - const queryState = useQueryState('q', marketplaceSearchParamsParsers.q) - const atomState = useAtom(searchPluginTextAtom) - return preserveSearchStateInQuery ? queryState : atomState + return useQueryState('q', marketplaceSearchParamsParsers.q) } export function useActivePluginType() { - const preserveSearchStateInQuery = useAtomValue(preserveSearchStateInQueryAtom) - const queryState = useQueryState('category', marketplaceSearchParamsParsers.category) - const atomState = useAtom(activePluginTypeAtom) - return preserveSearchStateInQuery ? queryState : atomState + return useQueryState('category', marketplaceSearchParamsParsers.category) } export function useFilterPluginTags() { - const preserveSearchStateInQuery = useAtomValue(preserveSearchStateInQueryAtom) - const queryState = useQueryState('tags', marketplaceSearchParamsParsers.tags) - const atomState = useAtom(filterPluginTagsAtom) - return preserveSearchStateInQuery ? queryState : atomState + return useQueryState('tags', marketplaceSearchParamsParsers.tags) } /** diff --git a/web/app/components/plugins/marketplace/hydration-client.tsx b/web/app/components/plugins/marketplace/hydration-client.tsx deleted file mode 100644 index 5698db711f..0000000000 --- a/web/app/components/plugins/marketplace/hydration-client.tsx +++ /dev/null @@ -1,15 +0,0 @@ -'use client' - -import { useHydrateAtoms } from 'jotai/utils' -import { preserveSearchStateInQueryAtom } from './atoms' - -export function HydrateMarketplaceAtoms({ - preserveSearchStateInQuery, - children, -}: { - preserveSearchStateInQuery: boolean - children: React.ReactNode -}) { - useHydrateAtoms([[preserveSearchStateInQueryAtom, preserveSearchStateInQuery]]) - return <>{children} -} diff --git a/web/app/components/plugins/marketplace/index.tsx b/web/app/components/plugins/marketplace/index.tsx index 1f32ee4d29..0eb2488cef 100644 --- a/web/app/components/plugins/marketplace/index.tsx +++ b/web/app/components/plugins/marketplace/index.tsx @@ -1,7 +1,6 @@ import type { SearchParams } from 'nuqs' import { TanstackQueryInitializer } from '@/context/query-client' import Description from './description' -import { HydrateMarketplaceAtoms } from './hydration-client' import { HydrateQueryClient } from './hydration-server' import ListWrapper from './list/list-wrapper' import StickySearchAndSwitchWrapper from './sticky-search-and-switch-wrapper' @@ -10,8 +9,7 @@ type MarketplaceProps = { showInstallButton?: boolean pluginTypeSwitchClassName?: string /** - * Pass the search params from the request to prefetch data on the server - * and preserve the search params in the URL. + * Pass the search params from the request to prefetch data on the server. */ searchParams?: Promise } @@ -24,15 +22,13 @@ const Marketplace = async ({ return ( - - - - - + + + ) diff --git a/web/app/components/plugins/plugin-page/context.tsx b/web/app/components/plugins/plugin-page/context.tsx index fea78ae181..abc4408d62 100644 --- a/web/app/components/plugins/plugin-page/context.tsx +++ b/web/app/components/plugins/plugin-page/context.tsx @@ -68,7 +68,7 @@ export const PluginPageContextProvider = ({ const options = useMemo(() => { return enable_marketplace ? tabs : tabs.filter(tab => tab.value !== PLUGIN_PAGE_TABS_MAP.marketplace) }, [tabs, enable_marketplace]) - const [activeTab, setActiveTab] = useQueryState('category', { + const [activeTab, setActiveTab] = useQueryState('tab', { defaultValue: options[0].value, })