Skip to content

Revert frontend changes from PR #16873 and add Go/Python runtime detection - #16948

Merged
wangq8 merged 1 commit into
infiniflow:mainfrom
xugangqiang:revert/dsl-ui
Jul 15, 2026
Merged

wangq8 merged 1 commit into
infiniflow:mainfrom
xugangqiang:revert/dsl-ui

Conversation

@xugangqiang

@xugangqiang xugangqiang commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

#16873 引入了前端改动(动态从 /api/v1/pipelines 获取解析器列表),但这个接口只存在于 Go 后端,Python 后端没有。当前端连接到 Python 后端时请求会失败。

解决方案

Go 和 Python 后端都提供 GET /api/v1/language 接口,前端根据返回值选择代码路径。

改动文件

Go 后端

  • internal/handler/system.go — 新增 Language handler,返回 {"language": "go"}
  • internal/router/router.go — 注册 GET /api/v1/language 路由

Python 后端

  • api/apps/restful_apis/system_api.py — 新增 /language 路由,返回 {"language": "python"}

前端

  • web/src/utils/backend-runtime.ts(新)— 参照 billingStatus.ts 模式的运行时检测模块
  • web/src/hooks/use-user-setting-request.tsx — useSelectParserList 根据 backend language 分支:
    • Go: 动态拉取 /api/v1/pipelines
    • Python: 使用硬编码 defaultParsers
  • web/src/utils/api.ts — 恢复 listPipelines endpoint
  • web/src/services/knowledge-service.ts — 恢复 listPipelines 方法
  • web/src/locales/en.ts — 恢复 general parser label

PR infiniflow#16873 introduced dynamic parser-list fetching from the backend
(useQuery + kbService.listPipelines), replacing the hardcoded parser
list and removing the ParserListMap/useFetchParserListOnMount hook.

This revert restores the original frontend code:
- web/src/hooks/use-user-setting-request.tsx — hardcoded parser list
- web/src/locales/en.ts — 'general' parser label removed
- web/src/services/knowledge-service.ts — listPipelines method removed
- web/src/utils/api.ts — listPipelines endpoint removed
- web/src/components/chunk-method-dialog/hooks.ts — ParserListMap
  and useFetchParserListOnMount restored

Co-Authored-By: Claude <[email protected]>
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jul 15, 2026
@coderabbitai

coderabbitai Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Parser selection now uses local defaults or tenant-configured parser IDs instead of the builtin pipeline catalog. A new hook filters available parsers by document extension, and the obsolete pipeline-list API and translation entry are removed.

Changes

Parser list flow

Layer / File(s) Summary
Replace pipeline-backed parser source
web/src/hooks/use-user-setting-request.tsx, web/src/locales/en.ts, web/src/services/knowledge-service.ts, web/src/utils/api.ts
useSelectParserList now returns localized defaults or tenant-configured parser entries directly; the builtin pipeline-list endpoint and service method are removed.
Filter parsers by document extension
web/src/components/chunk-method-dialog/hooks.ts
Adds useFetchParserListOnMount, which maps document extensions to allowed parser values and returns a memoized filtered list.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ChunkMethodDialog
  participant useFetchParserListOnMount
  participant useSelectParserList
  ChunkMethodDialog->>useFetchParserListOnMount: documentExtension
  useFetchParserListOnMount->>useSelectParserList: request parserList
  useSelectParserList-->>useFetchParserListOnMount: default or tenant parser entries
  useFetchParserListOnMount-->>ChunkMethodDialog: filtered parserList
Loading

Suggested reviewers: cike8899

Poem

A rabbit hops through parser fields,
With tidy maps and filtered yields.
Old pipeline paths fade away,
New labels guide the document’s way.
“Snip, select!” the bunny sings.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main change: reverting frontend changes from PR #16873.
Description check ✅ Passed The description matches the required Summary section and explains the revert scope and files involved.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@xugangqiang xugangqiang added the ci Continue Integration label Jul 15, 2026
@xugangqiang
xugangqiang marked this pull request as draft July 15, 2026 09:39
@xugangqiang
xugangqiang marked this pull request as ready for review July 15, 2026 09:39

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
web/src/components/chunk-method-dialog/hooks.ts (1)

76-84: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Simplify array identity checks. Both of these locations implement an identity search using Array.prototype.some. Prefer Array.prototype.includes for improved readability when performing strict equality containment checks.

  • web/src/components/chunk-method-dialog/hooks.ts#L76-L84: replace values?.some((y) => y === x.value) with values.includes(x.value) (note: the optional chaining is safe to remove because values defaults to [] at the call site).
  • web/src/components/chunk-method-dialog/hooks.ts#L89-L93: replace x.some((y) => y === documentExtension) with x.includes(documentExtension).
🤖 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/components/chunk-method-dialog/hooks.ts` around lines 76 - 84, In
web/src/components/chunk-method-dialog/hooks.ts at lines 76-84, update
getParserList to use values.includes(x.value) instead of the identity-based some
check, removing optional chaining because values defaults to an empty array. At
lines 89-93 in the related document-extension filter, replace x.some((y) => y
=== documentExtension) with x.includes(documentExtension).
web/src/hooks/use-user-setting-request.tsx (1)

145-148: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a fallback for unlabelled tenant parsers.

If tenantInfo.parser_ids contains raw values without a colon (e.g., 'naive,qa' instead of 'naive:Naive,qa:QA'), arr[1] will be undefined. This can result in blank labels in the UI. Consider falling back to the corresponding label from defaultParsers or using the raw value as a last resort.

💡 Proposed refactor
-    return filteredArray.map((x) => {
-      const arr = x.split(':');
-      return { value: arr[0], label: arr[1] };
-    });
+    return filteredArray.map((x) => {
+      const arr = x.split(':');
+      const value = arr[0];
+      const label = arr[1] || defaultParsers.find((p) => p.value === value)?.label || value;
+      return { value, label };
+    });
🤖 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/hooks/use-user-setting-request.tsx` around lines 145 - 148, Update
the parser mapping in the hook’s filteredArray flow to handle entries without a
colon: use the matching label from defaultParsers when available, and fall back
to the raw parser value otherwise. Preserve the existing value mapping and
labels for entries that already include an explicit label.
🤖 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/components/chunk-method-dialog/hooks.ts`:
- Around line 72-74: Update the extension-to-parser mapping near the existing
json, naive/knowledge_graph, and eml/email entries to map mp3, wav, and m4a
extensions to audio. Ensure audio uploads resolve to the audio parser instead of
the fallback list.

---

Nitpick comments:
In `@web/src/components/chunk-method-dialog/hooks.ts`:
- Around line 76-84: In web/src/components/chunk-method-dialog/hooks.ts at lines
76-84, update getParserList to use values.includes(x.value) instead of the
identity-based some check, removing optional chaining because values defaults to
an empty array. At lines 89-93 in the related document-extension filter, replace
x.some((y) => y === documentExtension) with x.includes(documentExtension).

In `@web/src/hooks/use-user-setting-request.tsx`:
- Around line 145-148: Update the parser mapping in the hook’s filteredArray
flow to handle entries without a colon: use the matching label from
defaultParsers when available, and fall back to the raw parser value otherwise.
Preserve the existing value mapping and labels for entries that already include
an explicit label.
🪄 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: 5b07eaa4-0879-4197-8fe4-3ecc89e197ac

📥 Commits

Reviewing files that changed from the base of the PR and between 77d35a3 and fabf536.

📒 Files selected for processing (5)
  • web/src/components/chunk-method-dialog/hooks.ts
  • web/src/hooks/use-user-setting-request.tsx
  • web/src/locales/en.ts
  • web/src/services/knowledge-service.ts
  • web/src/utils/api.ts
💤 Files with no reviewable changes (3)
  • web/src/locales/en.ts
  • web/src/services/knowledge-service.ts
  • web/src/utils/api.ts

Comment on lines +72 to +74
[['json'], ['naive', 'knowledge_graph']],
[['eml'], ['email']],
]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Search for frontend usage of `audio` and `knowledge_graph` parsers to confirm their intended scopes.
rg -n "'audio'|'knowledge_graph'" web/src/

Repository: infiniflow/ragflow

Length of output: 1376


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== chunk-method-dialog/hooks.ts ==\n'
sed -n '1,140p' web/src/components/chunk-method-dialog/hooks.ts | cat -n

printf '\n== use-user-setting-request.tsx ==\n'
sed -n '100,170p' web/src/hooks/use-user-setting-request.tsx | cat -n

Repository: infiniflow/ragflow

Length of output: 6187


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== ParserListMap references ==\n'
rg -n "ParserListMap|mp3|m4a|wav|flac|ogg" web/src/components web/src/hooks web/src/pages -g '!**/*.map'

printf '\n== useSelectParserList definition ==\n'
rg -n "export const useSelectParserList|const useSelectParserList|function useSelectParserList" web/src -g '!**/*.map'

Repository: infiniflow/ragflow

Length of output: 27398


Map audio extensions to audio (web/src/components/chunk-method-dialog/hooks.ts:72-74). mp3/wav/m4a files fall through to the fallback list, which omits audio, so the parser never appears for those uploads.

🤖 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/components/chunk-method-dialog/hooks.ts` around lines 72 - 74, Update
the extension-to-parser mapping near the existing json, naive/knowledge_graph,
and eml/email entries to map mp3, wav, and m4a extensions to audio. Ensure audio
uploads resolve to the audio parser instead of the fallback list.

@xugangqiang
xugangqiang requested review from wangq8 and yuzhichang July 15, 2026 09:47
@wangq8
wangq8 merged commit 3d65e8d into infiniflow:main Jul 15, 2026
9 of 12 checks passed
@xugangqiang xugangqiang changed the title Revert frontend changes from PR #16873 Revert frontend changes from PR #16873 and add Go/Python runtime detection Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants