Skip to content

Conversation

maifeeulasad
Copy link

@maifeeulasad maifeeulasad commented Jun 14, 2025

中文版模板 / Chinese template

🤔 This is a ...

  • 🆕 New feature
  • 🐞 Bug fix
  • 📝 Site / documentation improvement
  • 📽️ Demo improvement
  • 💄 Component style improvement
  • 🤖 TypeScript definition improvement
  • 📦 Bundle size optimization
  • ⚡️ Performance optimization
  • ⭐️ Feature enhancement
  • 🌐 Internationalization
  • 🛠 Refactoring
  • 🎨 Code style optimization
  • ✅ Test Case
  • 🔀 Branch merge
  • ⏩ Workflow
  • ⌨️ Accessibility improvement
  • ❓ Other (about what?)

🔗 Related Issues

💡 Background and Solution

  • We need a standardized way to surface the origin of chat content and related resources directly within X components.
  • Introducing a new references?: ChatReference[] prop allows consumer apps to pass an array of source links (with title and optional description) to the Bubble component.
  • The ChatReference interface is defined as:
    export interface ChatReference {
      title: string;
      url: string;
      description?: string;
    }
  • In the UI, an info icon will render when references is non-empty; on hover it shows a popover or modal listing each reference with title and description.
  • See the snap for outcome
    reference in antd x bubble by maifeeulasad

📝 Change Log

  • 🆕 Add optional references?: ChatReference[] prop to Bubble, enabling an info-icon trigger with popover/modal listing of sources.
  • 🤖 Introduce ChatReference TS interface (title, url, description?).
  • ⚡️ Fully opt-in, no breaking changes or side effects.
Language Changelog
🇺🇸 English - Add ChatReference interface and references?: ChatReference[] prop to Bubble component, enabling sources display.- Implement hoverable popover & modal view for listing references.- Update TypeScript definitions and doc site examples to cover new references feature.- Demo page shows inline info-icon trigger and full references list.
🇨🇳 Chinese - 在 Bubble 组件中新增 ChatReference 接口和 references?: ChatReference[] 属性,用于展示引用来源。- 实现引用列表的悬浮 Popover 和 Modal 弹窗展示。- 更新 TypeScript 定义及文档示例,覆盖 references 新特性。- 示例页增加内联信息图标触发及完整引用列表展示。

Summary by CodeRabbit

  • 新功能
    • Bubble 组件新增引用区块,支持通过 references 属性展示参考资料列表,并可点击查看详情。
  • 文档
    • Bubble 组件中英文文档新增“参考”功能演示示例,详述 references 属性及 ChatReference 接口用法。
  • 其他
    • 新增 ChatReference 接口,BubbleProps 新增 references 属性以支持引用功能。
    • 新增演示组件展示多种引用列表和头像样式组合。

Copy link
Contributor

coderabbitai bot commented Jun 14, 2025

📝 Walkthrough

"""

Walkthrough

本次更改为 Bubble 组件引入了“参考资料”功能。当传入 references 属性时,气泡将展示一个可点击的参考资料按钮与弹窗,支持标题、链接和可选描述。相关类型声明、演示用例及中英文文档均已同步更新。

Changes

文件/分组 变更摘要
components/bubble/Bubble.tsx 增加 references 属性,渲染参考资料按钮和弹窗,UI 结构调整
components/bubble/interface.ts 新增 ChatReference 接口,BubbleProps 增加 references 属性
components/bubble/demo/reference.tsx 新增带 references 属性的 Bubble 组件演示用例
components/bubble/index.en-US.md
components/bubble/index.zh-CN.md
文档分别新增 Reference/参考演示用例条目

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Bubble
    participant ReferencesOverlay
    participant Modal

    User->>Bubble: 渲染并传入 references 属性
    Bubble->>ReferencesOverlay: 检查 references,渲染参考按钮
    User->>ReferencesOverlay: 点击参考按钮
    ReferencesOverlay->>Modal: 打开参考资料弹窗
    User->>Modal: 查看/点击参考内容
Loading

Assessment against linked issues

Objective Addressed Explanation
新增 ChatReference 接口,包含 title、url、可选 description 字段 (#523)
BubbleProps 支持 references?: ChatReference[] 属性 (#523)
Bubble 组件根据 references 渲染参考资料 UI,展示来源和相关内容 (#523)
提供参考资料展示的演示用例 (#523)
文档中新增参考资料功能的相关演示条目 (#523)

Suggested reviewers

  • afc163

Poem

🐇
气泡轻弹新参考,
链接描述全都到。
按钮一点弹窗现,
资料丰富无烦恼。
代码文档同步好,
兔子点赞把歌唱!
"""


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ec28faa and 8cca016.

📒 Files selected for processing (2)
  • components/bubble/index.en-US.md (3 hunks)
  • components/bubble/index.zh-CN.md (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • components/bubble/index.zh-CN.md
  • components/bubble/index.en-US.md
✨ Finishing Touches
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Commit Unit Tests in branch chat-reference-maifee
  • Post Copyable Unit Tests in Comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

github-actions bot commented Jun 14, 2025

Preview is ready

@dosubot dosubot bot added documentation Improvements or additions to documentation enhancement New feature or request labels Jun 14, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (9)
components/bubble/interface.ts (2)

19-23: 应补充字段注释与可扩展性考虑

ChatReference 作为对外暴露的新接口,建议为三个字段写入 JSDoc 注释,说明期望格式及使用示例,便于组件消费者调用。同时可以预留 icon?: ReactNode 等扩展字段,减少未来破坏性改动。


47-48: references 建议加入默认值防御

虽然类型上是可选,但在运行期仍可能出现 undefined,组件内部频繁解构读取长度。如果在 BubbleProps 默认参数中提供 references: [],可避免多处判空逻辑。

components/bubble/Bubble.tsx (3)

44-45: 属性未在文档 API 表格中体现

references 新增后,英文/中文 API 表格尚未同步,仅在 demo 中展示,易导致使用者遗漏。建议在两份文档的属性表中补充。


164-173: 无障碍与 i18n

  1. Button 未设置 aria-label,读屏软件无法描述用途。
  2. 文案硬编码英文(reference(s) usedReferences),不符合 Ant Design 国际化策略。可引入 locale 或通过 context 提供文案。

196-211: List item 使用数组索引作为 key

references 发生增删改排序时,索引 key 会导致不必要的重新渲染。若后端数据缺少唯一 id,可使用 url 作为 key。

components/bubble/demo/reference.tsx (2)

26-46: 演示数据重复且 URL 非唯一

示例中两条 GitHub 链接 URL 相同,演示效果有限。建议替换为不同链接或删除重复项,确保用户快速理解多条引用的意义。


51-53: avatar={{}} 会生成空 Avatar 组件

当仅想隐藏头像时,传入空对象会仍然渲染一个宽高为 32 的透明块。可以直接传 avatar={null} 或在组件内部判空优化,减少不必要 DOM。

components/bubble/index.zh-CN.md (1)

34-35: API 表格遗漏 references

示例链接已添加,但属性文档未同步更新,建议补充:| references | 参考资料列表 | {title, url, description?}[] | - | |

components/bubble/index.en-US.md (1)

33-34: Missing API entry for references

Same as Chinese version, please add the new prop to the English API table to keep docs consistent.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 28f8f61 and 0f8eeee.

📒 Files selected for processing (5)
  • components/bubble/Bubble.tsx (4 hunks)
  • components/bubble/demo/reference.tsx (1 hunks)
  • components/bubble/index.en-US.md (1 hunks)
  • components/bubble/index.zh-CN.md (1 hunks)
  • components/bubble/interface.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Socket Security: Pull Request Alerts
🔇 Additional comments (1)
components/bubble/Bubble.tsx (1)

4-5: 新依赖需同步到打包体积与 peerDependencies

@ant-design/iconsantdButton/Popover/Modal/List 都会被打进最终 bundle,请评估 tree-shaking 后的体积以及是否需要在 package.json peerDependencies 中声明版本范围。

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 (2)
components/bubble/demo/reference.tsx (2)

26-158: 大量重复的引用对象可读性与维护成本较高
示例中连续硬编码了二十多条结构几乎相同的 GitHub - Maifee Ul Asad 引用,既拉长文件,也削弱了示例的核心意图。可考虑:

- references={[
-   { title: 'GitHub - Maifee Ul Asad', url: 'https://github.com' },
-   { title: 'GitHub - Maifee Ul Asad', url: 'https://github.com' },
-   ...
- ]}
+ const githubRefs = Array.from({ length: 15 }).map(() => ({
+   title: 'GitHub - Maifee Ul Asad',
+   url: 'https://github.com',
+ }));
+ ...
+ references={[
+   { title: 'Ant Design', url: 'https://ant.design', description: 'Ant Design official website' },
+   { title: 'React', url: 'https://react.dev', description: 'React official documentation' },
+   ...githubRefs,
+ ]}

这样既凸显了 references API 的用法,又避免冗余。


6-18: 命名可读性小优化
fooAvatar / barAvatar 没有语义信息,改为 orangeAvatarStyle / greenAvatarStyle 等更易理解。

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0f8eeee and b93d990.

📒 Files selected for processing (2)
  • components/bubble/Bubble.tsx (4 hunks)
  • components/bubble/demo/reference.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/bubble/Bubble.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Socket Security: Pull Request Alerts
🔇 Additional comments (1)
components/bubble/demo/reference.tsx (1)

164-165: styles={{ avatar: hideAvatar }}avatar={{}} 二选一即可
styles.avatar 已将头像隐藏,再传空对象给 avatar 多余且可能掩盖组件内部默认逻辑。请确认组件优先级并保留一种写法即可。

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jun 15, 2025
Copy link

codecov bot commented Jun 16, 2025

Bundle Report

Bundle size has no change ✅

@maifeeulasad
Copy link
Author

Any additional comments? Any idea when this will be merged?

pinging: @afc163

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request lgtm This PR has been approved by a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

render sources and related content as per message item
2 participants