Skip to content

feat:页面按钮隐藏 - #209

Open
openjiuwen-sync-bot[bot] wants to merge 2 commits into
openJiuwen-ai:studio-2.0-devfrom
openjiuwenai:sync/pr-1783
Open

feat:页面按钮隐藏#209
openjiuwen-sync-bot[bot] wants to merge 2 commits into
openJiuwen-ai:studio-2.0-devfrom
openjiuwenai:sync/pr-1783

Conversation

@openjiuwen-sync-bot

@openjiuwen-sync-bot openjiuwen-sync-bot Bot commented Aug 4, 2026

Copy link
Copy Markdown

Paired: GitHub #209GitCode !1783

What type of PR is this?

/kind

Self-checklist:(请自检,在[ ]内打上x,我们将检视你的完成情况,否则会导致pr无法合入

    • 设计:PR对应的方案是否已经经过Maintainer评审,方案检视意见是否均已答复并完成方案修改
    • 测试:PR中的代码是否已有UT/ST测试用例进行充分的覆盖,新增测试用例是否随本PR一并上库或已经上库
    • 验证:PR描述信息中是否已包含对该PR对应的Feature、Refactor、Bugfix的预期目标达成情况的详细验证结果描述
    • 接口:是否涉及对外接口变更,相应变更已得到接口评审组织的通过,API对应的注释信息已经刷新正确
    • 文档:是否涉及官网文档修改,如果涉及请及时提交资料到Doc仓

Linked Closing Issues:

@CLAassistant

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.

@openjiuwen-collaboration-bot

openjiuwen-collaboration-bot Bot commented Aug 4, 2026

Copy link
Copy Markdown

head_sha: a2e571a10fcc7b03099b21af389bc8b97b65b895

变更摘要

此 PR 主要引入了一个全局配置项 studio_btn_show,用于在特定部署场景(非 Studio 环境)下隐藏部分页面按钮、操作入口和标签页,同时包含了对 DiffVersionModalComponent 的重大重构以及若干抽屉/模态框布局调整。

主要改动

  • 新增 studio_btn_show 配置项控制界面显隐:在 IAgentConfigs 接口中添加了 studio_btn_show?: boolean 字段,并在 AgentConfigService.setConfigs() 中将其默认值设为 trueFlowDetailHeaderComponentKnowledgeBaseSelectorComponent 等多处组件通过读取该配置决定按钮和操作入口是否展示。
  • CodeModalComponent 过滤执行方式:在初始化 radioList 时,当 studio_btn_showfalse 时过滤掉 local 执行方式,确保非 Studio 环境下不显示本地执行选项。
  • AddMultipleAgentModalComponent 过滤单智能体标签:在 ngOnInit 中根据 studio_btn_show 过滤 SINGLE_AGENT 类型的标签页,同时将抽屉结构从自定义 drawer-header/body/footer 改为 com-drawer-* 统一规范。
  • DiffVersionModalComponent 重构为 Monaco 编辑器:移除旧的 ti-diff-editor,改用 ngx-monaco-diff-editor 并新增左右版本下拉选择器(nz-select),将版本切换逻辑从 config.titleOptions 迁移到 leftOptions/rightOptions 和对应的 changeLeft/changeRight 方法。
  • TabsHeaderComponent 支持标签显隐过滤:在 ITabHeader 接口中新增 show?: boolean 属性,模板中使用 @for 配合 @if (tab.show !== false) 来过滤不需要展示的标签页。
  • 多处模态框布局规范化CreateSpaceComponent 的底部按钮迁移至 *nzModalFooterDiffVersionModalComponent 的标题迁移至 *nzModalTitle,统一使用 NG-ZORRO 模态框标准插槽。

@openjiuwen-collaboration-bot

openjiuwen-collaboration-bot Bot commented Aug 4, 2026

Copy link
Copy Markdown

head_sha: a2e571a10fcc7b03099b21af389bc8b97b65b895

代码审查

Now I have all findings covered. Let me provide the closing summary.


审查总结

本次 PR"feat:页面按钮隐藏"涉及 19 个文件的变更,核心目的是通过新增 studio_btn_show 配置项来控制 Studio 页面中多个按钮的显示/隐藏。审查共发现 4 个问题

优先级 数量 说明
P1 1 tabs-header 组件中 selectedIndex 索引错位
P2 3 setConfigs 无条件覆盖配置值(根因)、FlowDetailHeaderComponent 构造函数竞态、flow.component 静态初始化

整体风险评估:中等。核心问题(P2 Finding 1)导致按钮隐藏功能在当前实现下完全无法通过后端配置触发——setConfigs 无条件将 studio_btn_show 强制设为 true,使得所有消费者永远读到 true。修复该根因后,P1 的 tabs-header 索引问题会在 tab 被实际隐藏时暴露。其余两个 P2 问题属于配置读取的竞态/生命周期问题。


逐文件审查结果

文件 审查结论
agent-config.service.ts ⚠️ P2: setConfigs 无条件覆盖 studio_btn_show
code-modal/code-modal.component.ts ✅ 无问题(过滤逻辑正确,格式化修复)
add-multiple-agent-modal/...component.html ✅ 无问题(模板重构,标准化 class 名)
add-multiple-agent-modal/...component.less ✅ 无问题(高度调整适配新布局)
add-multiple-agent-modal/...component.ts ✅ 无问题(过滤逻辑正确,无空数组风险)
flow-detail-header/...component.html ✅ 无问题(条件渲染正确)
flow-detail-header/...component.ts ⚠️ P2: 构造函数竞态,studioBtnShow 可能永久 undefined
mcp-service-node/...component.ts ✅ 无问题(ngOnInit 中条件性添加 action)
plugin-modal/plugin-modal.component.ts ✅ 无问题(ngOnInit 中条件性添加 action)
plugin-node/plugin-node.component.ts ✅ 无问题(ngOnInit 中条件性添加 action)
flow/flow.component.ts ⚠️ P2: configHeaderTabs 静态初始化,show 固化为 undefined
knowledge-base-selector/...component.html ✅ 无问题(studioBtnShow 条件渲染按钮)
knowledge-base-selector/...component.ts ✅ 无问题(ngOnInit 中读取配置)
create-space/create-space.component.html ✅ 无问题(重构为 *nzModalFooter 标准模式)
diff-version-modal/...component.html ✅ 无问题(使用 *nzModalTitle/*nzModalFooter + Monaco diff editor)
diff-version-modal/...component.scss ✅ 无问题(移除 ::ng-deep,使用组件级样式)
diff-version-modal/...component.ts ✅ 无问题(重构版本选择器+diff 编辑器集成,onDiffInit 正确设置监听)
release-history-halfmodal/...component.ts ✅ 无问题(移除冗余 nzTitle/nzClosable,适配新 modal 模板)
tabs-header/tabs-header.component.ts ⚠️ P1: selectedIndex 在过滤后的 tabs 上索引错位
类型 数量
🔴 阻塞 1
🟡 建议 4

⛔ 需要修改

@openjiuwen-collaboration-bot

Copy link
Copy Markdown

head_sha: a2e571a10fcc7b03099b21af389bc8b97b65b895

TASK STATUS DETAILS
CodeCheck ✅SUCCESS Click here
AntiPoison ✅SUCCESS Click here
Software Composition Analysis ✅SUCCESS Click here
Npm Build ✅SUCCESS See CHECK tab
Ruff Check ✅SUCCESS See CHECK tab
UT测试 ✅SUCCESS 点此跳转

}

public setConfigs(configs: IAgentConfigs) {
configs.studio_btn_show = true;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

head_sha: a2e571a10fcc7b03099b21af389bc8b97b65b895

🟡 Medium Priority

setConfigs 方法第 77 行无条件执行 configs.studio_btn_show = true,强制覆盖后端传入的任何值(包括 false)。这意味着整个 PR 的"页面按钮隐藏"功能无法通过后端配置触发:即使后端下发 studio_btn_show: falsesetConfigs 也会将其改写为 true,所有按钮始终可见。

证据链

修复方向:改为仅在未设置时默认 true,保留后端下发的值:configs.studio_btn_show = configs.studio_btn_show ?? true;

建议:将无条件赋值改为仅在 undefined 时提供默认值:configs.studio_btn_show = configs.studio_btn_show ?? true;

this.kbQuantityLimit = this.configServ.getConfigs()?.agent_knowledge_bound_limit ?? this.kbQuantityLimit;
}

this.studioBtnShow = this.configServ.getConfigs()?.studio_btn_show;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

head_sha: a2e571a10fcc7b03099b21af389bc8b97b65b895

🟡 Medium Priority

knowledge-base-selector.component.ts 第 182 行声明 studioBtnShow = true 作为类字段默认值,但在 ngOnInit 第 223 行直接覆盖为 this.configServ.getConfigs()?.studio_btn_show

受影响行为:当 studio_btn_showundefined 时,studioBtnShow 变为 undefined(falsy),导致 HTML 模板中两处 *ngIf="... && studioBtnShow" 条件判断失败:

  • 第 30 行:创建知识库按钮被隐藏
  • 第 79 行:空数据页面的创建知识库按钮被隐藏

失败模式:与 flow-detail-header 相同——如果 setConfigs 硬编码被修复且后端未下发该字段,"创建知识库"入口会意外消失。

建议:使用空值合并运算符 ?? true 兜底:this.studioBtnShow = this.configServ.getConfigs()?.studio_btn_show ?? true;

Suggested change
this.studioBtnShow = this.configServ.getConfigs()?.studio_btn_show;
this.studioBtnShow = this.configServ.getConfigs()?.studio_btn_show ?? true;

private appFlowServe: AppFlowService,
private commonService: CommonService
) {
this.studioBtnShow = this.configServ.getConfigs()?.studio_btn_show;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

head_sha: a2e571a10fcc7b03099b21af389bc8b97b65b895

🟡 Medium Priority

studioBtnShow 在 constructor 中(第 72 行)通过 this.configServ.getConfigs()?.studio_btn_show 一次性读取,之后再也不会更新。由于 initConfigs() 是异步网络请求(在 app.component.ts 中通过 subscribe 回调调用),FlowDetailHeaderComponent 构造时 configs 很可能尚未加载,此时 getConfigs() 返回空对象 {}studio_btn_showundefined

证据链

  • setConfigs 后续被调用时,studioBtnShow 不会更新,因为没有订阅 configs$

影响:返回按钮(onClickBack())是页面导航的关键元素,被隐藏后用户无法返回上一页。

建议:改为订阅 configServ.data$ 以响应配置变更,或在 ngOnInit 中读取配置(此时配置通常已加载完成),并提供默认值兜底:this.studioBtnShow = this.configServ.getConfigs()?.studio_btn_show ?? true;

tips: '',
show: this.configServ.getConfigs()?.studio_btn_show,
},
];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

head_sha: a2e571a10fcc7b03099b21af389bc8b97b65b895

🟡 Medium Priority

configHeaderTabs 数组在第 579-593 行作为类字段静态初始化。其中 releaseManage tab 的 show 属性在初始化时读取 this.configServ.getConfigs()?.studio_btn_show,此时 configs 尚未加载(BehaviorSubject 初始值为 {}),因此 showundefined

证据链

  • 第 579-593 行:configHeaderTabs 在类字段声明时立即求值
  • setConfigs 后续被调用时,configHeaderTabs[1].show 仍是初始化时的 undefined,不会更新

影响:即使修复了 Finding 1(setConfigs 正确传递 false),releaseManage tab 也永远不会被隐藏,因为其 show 已固化为 undefined

建议:将 configHeaderTabs 的初始化移到 ngOnInit 中(此时 configs 通常已加载),或改为 getter 以动态读取最新配置值。例如在 ngOnInit 中设置 this.configHeaderTabs[1].show = this.configServ.getConfigs()?.studio_btn_show ?? true;

}
</nz-tabs>
`,
styles: [

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

head_sha: a2e571a10fcc7b03099b21af389bc8b97b65b895

🟠 High Priority

selectedIndex getter(第 48-51 行)在未过滤tabs 数组上计算激活 tab 的索引,但模板已改为使用 @if (tab.show !== false) 过滤不可见的 tab。当某个 show: false 的 tab 位于激活 tab 之前时,nzSelectedIndex 会指向错误的渲染 tab。

证据链

flow.component.ts:591 新增了 show: this.configServ.getConfigs()?.studio_btn_show,当该值为 false 时(修复 Finding 1 后),对应的 releaseManage tab 会被隐藏,若它恰好在激活 tab 之前,将触发此 bug。

建议selectedIndex 应在过滤后的可见 tab 列表上计算,而非完整 tabs 数组。同时 onSelectedIndexChange 也应在可见 tab 列表中查找。

Suggested change
styles: [
get selectedIndex(): number {
const visibleTabs = this.tabs.filter(tab => tab.show !== false);
const index = visibleTabs.findIndex(tab => tab.active);
return index >= 0 ? index : 0;
}

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants