Repository navigation
Fix: The form related to switching the dataset pipeline configuration was not rendered. - #17124
Conversation
… was not rendered.
…ne-dataset-config
…ne-dataset-config
📝 WalkthroughWalkthroughDataset settings now synchronize parser configuration with selected pipelines, preserve DSL defaults when pipeline configuration is absent, rebuild parser configuration from operator nodes, and select backend-specific parser fields during dataset creation. ChangesDataset parser configuration synchronization
Backend-specific dataset creation
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested labels: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
web/src/pages/dataset/setting/utils.ts (1)
274-306: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
isEmptycheck is scoped too broadly — Parser operator can still lose DSL defaults.The guard checks
isEmpty(pipelineParserConfig)(the whole map), not whether thisoperatorIdhas an entry. WhenpipelineParserConfighas entries for other operators but not this one,pipelineParserConfig[operatorId]isundefined. ForOperator.Parser,transformApiConfigToFormstill returns{ setups: [] }in that case (viatransformParserConfigSetups(undefined) → []), soObject.assignoverwrites the DSL template'ssetupswith an empty array — andnormalizeOperatorFormthen falls back to genericinitialParserValues.setupsinstead of the pipeline's actual DSL defaults. This reproduces the exact bug the refactor set out to fix, just scoped to operators missing from a non-empty config map (e.g. a new pipeline step added after the dataset's parser config was last saved).🐛 Proposed fix — check the specific operator entry, not the whole map
- if (!isEmpty(pipelineParserConfig)) { - // user overrides from API (now also form format) - Object.assign( - rawForm, - transformApiConfigToForm(operatorType, pipelineParserConfig[operatorId]), // Convert API config to form format, then merge (DSL template is baseline, API overrides) - ); - } + if (operatorId in pipelineParserConfig) { + // user overrides from API (now also form format) + Object.assign( + rawForm, + transformApiConfigToForm(operatorType, pipelineParserConfig[operatorId]), // Convert API config to form format, then merge (DSL template is baseline, API overrides) + ); + }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@web/src/pages/dataset/setting/utils.ts` around lines 274 - 306, Update buildOperatorNode to apply API overrides only when pipelineParserConfig contains a defined entry for the current operatorId, rather than when the overall map is non-empty. Preserve the DSL-derived rawForm unchanged for operators without a specific configuration, preventing transformApiConfigToForm from replacing their defaults with empty values.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@web/src/pages/dataset/setting/utils.ts`:
- Around line 274-306: Update buildOperatorNode to apply API overrides only when
pipelineParserConfig contains a defined entry for the current operatorId, rather
than when the overall map is non-empty. Preserve the DSL-derived rawForm
unchanged for operators without a specific configuration, preventing
transformApiConfigToForm from replacing their defaults with empty values.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2625791c-e10c-4ab1-92f3-3e1be2e5ed83
📒 Files selected for processing (4)
web/src/interfaces/database/dataset.tsweb/src/pages/dataset/setting/hooks.tsweb/src/pages/dataset/setting/index.tsxweb/src/pages/dataset/setting/utils.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
web/src/pages/datasets/dataset-creating-dialog.tsx (1)
145-150: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winReplace the inline function call with the reactive boolean.
Following the hook refactor above, use the reactive
isGoboolean here to ensure the component updates its render output correctly, and apply the renamedchunkMethodNamevariable.♻️ Proposed refactor
{parseType === ParseType.BuiltIn && - (isGoBackend() ? ( - <BuiltinPipelineItem name={ChunkMethodName} /> + (isGo ? ( + <BuiltinPipelineItem name={chunkMethodName} /> ) : ( - <ChunkMethodItem name={ChunkMethodName}></ChunkMethodItem> + <ChunkMethodItem name={chunkMethodName}></ChunkMethodItem> ))}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@web/src/pages/datasets/dataset-creating-dialog.tsx` around lines 145 - 150, Update the built-in parse-method rendering to use the reactive isGo boolean instead of calling isGoBackend() inline, and replace ChunkMethodName with the renamed chunkMethodName variable in both BuiltinPipelineItem and ChunkMethodItem.web/src/utils/backend-runtime.ts (1)
35-36: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winExport a reactive hook for reading the backend language.
React components that read
backendLanguageduring render must subscribe to its changes to avoid stale UI if the value resolves asynchronously after the component mounts. SincesubscribeBackendLanguageis already implemented, you can expose a reactive hook for components to use.♻️ Proposed refactor
+import { useEffect, useState } from 'react'; + export const isGoBackend = (): boolean => backendLanguage === 'go'; + +export const useIsGoBackend = (): boolean => { + const [isGo, setIsGo] = useState(isGoBackend()); + + useEffect(() => { + return subscribeBackendLanguage(() => { + setIsGo(isGoBackend()); + }); + }, []); + + return isGo; +};🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@web/src/utils/backend-runtime.ts` around lines 35 - 36, Export a reactive hook alongside isGoBackend that reads backendLanguage through the existing subscribeBackendLanguage mechanism, allowing React components to update when the value changes asynchronously. Reuse the established backend-language store state and subscription behavior rather than exposing only a non-reactive direct read.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@web/src/pages/datasets/dataset-creating-dialog.tsx`:
- Around line 36-43: Update InputForm to use the reactive backend-language hook
instead of calling isGoBackend() directly, so it re-renders when the backend
language becomes available. Rename the local ChunkMethodName variable to
chunkMethodName and update all references in the Zod schema and default values.
---
Nitpick comments:
In `@web/src/pages/datasets/dataset-creating-dialog.tsx`:
- Around line 145-150: Update the built-in parse-method rendering to use the
reactive isGo boolean instead of calling isGoBackend() inline, and replace
ChunkMethodName with the renamed chunkMethodName variable in both
BuiltinPipelineItem and ChunkMethodItem.
In `@web/src/utils/backend-runtime.ts`:
- Around line 35-36: Export a reactive hook alongside isGoBackend that reads
backendLanguage through the existing subscribeBackendLanguage mechanism,
allowing React components to update when the value changes asynchronously. Reuse
the established backend-language store state and subscription behavior rather
than exposing only a non-reactive direct read.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b306a30d-e369-4335-a726-0f80d811f158
📒 Files selected for processing (3)
web/src/pages/dataset/compilation/index.tsxweb/src/pages/datasets/dataset-creating-dialog.tsxweb/src/utils/backend-runtime.ts
| import { isGoBackend } from '@/utils/backend-runtime'; | ||
|
|
||
| const FormId = 'dataset-creating-form'; | ||
|
|
||
| const ChunkMethodName = 'parser_id'; | ||
|
|
||
| export function InputForm({ onOk }: IModalProps<any>) { | ||
| const { t } = useTranslation(); | ||
| const defaultModelDictionary = useFetchDefaultModelDictionary(); | ||
| const ChunkMethodName = isGoBackend() ? 'parser_id' : 'chunk_method'; |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Use a reactive hook for backend language and follow camelCase naming.
Calling isGoBackend() directly in the component body reads mutable global state without a subscription. If backendLanguage resolves after the component mounts, it will not re-render and will incorrectly display the non-Go backend fields. Use the reactive hook to properly subscribe to changes.
Additionally, use camelCase for the local variable ChunkMethodName. As per standard TS conventions and coding guidelines which reserve PascalCase for components and top-level constants, local variables should use camelCase.
🐛 Proposed fix (requires updating references in the file)
-import { isGoBackend } from '`@/utils/backend-runtime`';
+import { useIsGoBackend } from '`@/utils/backend-runtime`';
const FormId = 'dataset-creating-form';
export function InputForm({ onOk }: IModalProps<any>) {
const { t } = useTranslation();
const defaultModelDictionary = useFetchDefaultModelDictionary();
- const ChunkMethodName = isGoBackend() ? 'parser_id' : 'chunk_method';
+ const isGo = useIsGoBackend();
+ const chunkMethodName = isGo ? 'parser_id' : 'chunk_method';Ensure you also rename ChunkMethodName to chunkMethodName throughout InputForm's Zod schema and defaults.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@web/src/pages/datasets/dataset-creating-dialog.tsx` around lines 36 - 43,
Update InputForm to use the reactive backend-language hook instead of calling
isGoBackend() directly, so it re-renders when the backend language becomes
available. Rename the local ChunkMethodName variable to chunkMethodName and
update all references in the Zod schema and default values.
Source: Coding guidelines
Summary
Fix: The form related to switching the dataset pipeline configuration was not rendered.