-
-
Notifications
You must be signed in to change notification settings - Fork 565
Fix: 修复思维链折叠问题, 增加collapsible demo #679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: 修复思维链折叠问题, 增加collapsible demo #679
Conversation
📝 WalkthroughWalkthrough该 PR 修改了 ThoughtChain 组件的行为,包括在 Changes
Sequence Diagram(s)sequenceDiagram
participant User as 用户
participant TC as ThoughtChain 组件
participant Hook as useCollapsible
participant Item as 渲染项
User->>TC: 传入 items 和 collapsible 配置(expandedKeys: ['2'])
TC->>Hook: 调用 useCollapsible,传入 customizeExpandedKeys
Hook-->>TC: 返回合并后的 expandedKeys 状态
TC->>Item: 根据 expandedKeys 渲染组件,默认展开键 '2'
Possibly related PRs
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI ⛔ Files ignored due to path filters (3)
📒 Files selected for processing (2)
🧰 Additional context used🧬 Code Definitions (1)components/thought-chain/demo/collapsible.tsx (4)
⏰ Context from checks skipped due to timeout of 90000ms (3)
🔇 Additional comments (7)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Bundle ReportBundle size has no change ✅ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
components/thought-chain/index.en-US.md (1)
60-68
: 文档信息清晰,但语法表述需要改进新增的信息详细说明了
collapsible
参数设置为true
时的默认配置,这对用户理解组件行为很有帮助。但是注意这里的英文表述:"the
default value
be like" 存在语法错误,应该修改为 "thedefault value
will be" 或 "thedefault value
is"。-:::info When the parameter `collapsible` config `true`, the `default value` be like: +:::info When the parameter `collapsible` is set to `true`, the `default value` will be:🧰 Tools
🪛 LanguageTool
[uncategorized] ~60-~60: This verb does not appear to agree with the subject. Consider using a different form.
Context: ...bleconfig
true, the
default value` be like: ```ts { expandedKeys: [], on...(AI_EN_LECTOR_REPLACEMENT_VERB_AGREEMENT)
components/thought-chain/demo/collapsible.tsx (2)
34-51
: 增加了带键值的多个示例项新增了三个带有唯一键值('2','3','4')的项目,这有助于演示和测试折叠功能。注意第一个项目没有明确设置
key
,建议为所有项目都设置明确的key
属性,以保持一致性。{ + key: '1', title: 'Click me to expand the content', description: 'Collapsible', content: mockContent, },
56-62
: 改进了collapsible属性的使用方式将
collapsible
从布尔值改为对象配置,并设置expandedKeys
为['2']
,这很好地展示了如何预先展开特定项目。这个改动与useCollapsible
钩子的修复相配合,解决了思维链无法正确折叠/展开的问题。注意注释"// items[0] key"可能会造成混淆,因为它指的是展开键值'2',而实际上'2'是
items[1]
的键值。建议更新或移除这个注释。collapsible={{ - // items[0] key + // 默认展开第二个项目(key: '2') expandedKeys: ['2'], }}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
components/thought-chain/demo/collapsible.tsx
(3 hunks)components/thought-chain/hooks/useCollapsible.ts
(1 hunks)components/thought-chain/index.en-US.md
(1 hunks)components/thought-chain/index.zh-CN.md
(1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
components/thought-chain/demo/collapsible.tsx (1)
components/thought-chain/demo/status.tsx (1)
items
(61-90)
🪛 LanguageTool
components/thought-chain/index.en-US.md
[uncategorized] ~60-~60: This verb does not appear to agree with the subject. Consider using a different form.
Context: ...bleconfig
true, the
default value` be like: ```ts { expandedKeys: [], on...
(AI_EN_LECTOR_REPLACEMENT_VERB_AGREEMENT)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: test / react component workflow
- GitHub Check: size
🔇 Additional comments (2)
components/thought-chain/index.zh-CN.md (1)
61-69
: 文档更新清晰明了新增的信息框很好地说明了
collapsible
参数设置为true
时的默认配置,使用户能够更清楚地理解组件的行为。这与组件实现的更改保持一致,有助于用户正确使用该功能。components/thought-chain/hooks/useCollapsible.ts (1)
58-58
: 修复思维链折叠问题的关键更改此更改是解决问题的核心。通过将
mergedExpandedKeys
的初始状态直接设置为customizeExpandedKeys
,而不是空数组,确保了组件能够正确地使用用户提供的初始展开键值。这解决了PR中描述的问题:之前在
useMergedState
中设置option.value
阻止了获取最新的mergedValue
,从而导致展开/折叠功能无法正常工作。现在组件可以正确响应用户点击来展开或折叠思维链。
现在的示例确实存在思维链无法展开的问题,但当前的修复是否合适我觉得可以再讨论一下:目前pr的collapsible似乎是一个默认值的作用,但从过往提交记录看,预期collapsible是起受控的作用,因此,当传入collapsible为对象且未手动更新collapsible.expandedKeys时,无论如何点击都不应该触发展开/收起行为。 |
我已经修改合并了 之前没看到这个pr 抱歉 |
@kimteayon 问题不大,解决问题就行了,这个PR的流程感觉可以讨论一下,出一个规范,页面多方去重复工作,浪费人力 |
中文版模板 / Chinese template
🤔 This is a ...
🔗 Related Issues
线上思维链可折叠demo
当前问题:点击折叠不可展开、收起
预期:点击折叠可展开、收起
💡 Background and Solution
在
useMergedState
中设置option.value
之后无法获取最新的mergedValue
,导致无法触发思维链的展开折叠功能useMergedState
📝 Change Log
修复思维链折叠问题
Summary by CodeRabbit
New Features
Documentation