fix(console): load category tree in create model modal by EastSouthWestNorthMiddle · Pull Request #1697 · iflytek/astron-agent · GitHub
Skip to content

fix(console): load category tree in create model modal - #1697

Open
EastSouthWestNorthMiddle wants to merge 1 commit into
iflytek:mainfrom
EastSouthWestNorthMiddle:bugfix/console-personal-model-category-tree
Open

EastSouthWestNorthMiddle wants to merge 1 commit into
iflytek:mainfrom
EastSouthWestNorthMiddle:bugfix/console-personal-model-category-tree

Conversation

@EastSouthWestNorthMiddle

Copy link
Copy Markdown

Summary

修复 #1696:个人模型列表为空时,「新建模型」弹窗的必填项「模型类别」下拉恒为空,导致全新部署无法通过 UI 创建第一个模型。

Type of Change

  • Bug fix

Related Issue

Fixes #1696

Changes

  • console/frontend/src/pages/model-management/components/model-modal-components.tsx:当创建弹窗打开且 state.categoryList 为空时,从 /api/model/category-tree 补取分类树,作为 CreateModal 的 categoryTree 兜底值。

根因(详见 #1696):

  1. hooks/use-model-initializer.ts 只在 modelType === 1(官方模型)时 actions.setCategoryList(...);个人模型页调用的是 useModelInitializer(2),因此 state.categoryList 从不被填充。
  2. 个人模型列表为空时,空态页的「新建模型」按钮打开的是页面级 ModelModalComponents,它直接把 state.categoryList 传给 CreateModal → categoryTree 恒为 [] → 必填的「模型类别」下拉为空、提交按钮永久禁用。
  3. 真正请求分类树的只有 components/model-card-list.tsx(自己 getCategoryTree() 存本地 state),而它只在列表非空时渲染 → 所以「列表非空」时不复现,属「空列表首建」这条边角路径被遗漏。

为什么选择在弹窗层兜底,而不是直接改 use-model-initializer:个人模型页的筛选逻辑走 filterType,modelType === 1 这个判断很可能是刻意为之(避免把官方模型合并出的分类树注入个人页筛选)。在弹窗层按需补取是最小改动、影响面最小,也不改变官方模型页的既有行为。

Testing

⚠️ 说明:我没有该前端的完整运行环境(需要 console-hub + MySQL + Casdoor 全栈),因此只做了静态检查,没有做浏览器端 E2E。界面侧请帮忙跑一次确认。

已在 console/frontend 下执行:

命令 结果
npx prettier --list-different <改动文件> 无输出(满足 CI 的格式门禁)
npx eslint <改动文件> --quiet 无 error
npx tsc --noEmit 改动文件、以及整个 src/pages/model-management/ 目录 0 个类型错误

关于 tsc:全仓库基线仍有 3763 个既有类型错误(与本改动无关,CI 中 tsc --noEmit 也是 continue-on-error)。本次改动未新增任何类型错误。

未执行:npm run test:unit、界面 E2E。

建议回归路径:

  1. 全新部署(或清空个人模型,使其列表为 0 条)
  2. 控制台 → 模型管理 → 个人模型 → 空态点「新建模型」
  3. 「模型类别」下拉应正常展示分类树并可提交

Checklist

  • Code follows project coding standards(prettier / eslint 已过)
  • Self-review completed
  • Documentation updated (if needed) —— 不涉及
  • Breaking changes documented —— 无破坏性变更

@CLAassistant

CLAassistant commented Oct 3, 2026 •

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

The create-model modal rendered from the page level reads
state.categoryList, which use-model-initializer only fills for official
models (modelType === 1). When the personal model list is empty, the
empty-state "create model" button opens that page-level modal, so the
required "model category" select stays empty and the form can never be
submitted.

Fetch the category tree from the API as a fallback when the modal opens
and state.categoryList is empty.

Fixes iflytek#1696

Signed-off-by: EastSouthWestNorthMiddle <283185948+EastSouthWestNorthMiddle@users.noreply.github.com>
@EastSouthWestNorthMiddle
EastSouthWestNorthMiddle force-pushed the bugfix/console-personal-model-category-tree branch from 0ae0f39 to f85abbf Compare October 3, 2026 18:17
@FenjuFu

FenjuFu commented Oct 4, 2026

Copy link
Copy Markdown
Member

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] 个人模型列表为空时,新建模型弹窗的「模型类别」下拉恒为空,无法创建第一个模型

3 participants