feat(bubble): add provider-level box and content attributes#332
feat(bubble): add provider-level box and content attributes#332gene9831 wants to merge 1 commit intoopentiny:developfrom
Conversation
WalkthroughThis change introduces provider-level attribute injection to the Bubble chat component system. It adds optional Changes
Sequence Diagram(s)sequenceDiagram
participant App as User Application
participant Provider as BubbleProvider
participant Composable as useBubbleBoxRenderer
participant Config as Attribute Config
participant Wrapper as BubbleBoxWrapper
participant Renderer as Selected Renderer
App->>Provider: Initialize with boxAttributes config
Provider->>Composable: Call setupBubbleBoxRenderer(renderers, boxAttributes)
Composable->>Config: Provide injection key with config
Wrapper->>Composable: useBubbleBoxRenderer(message, contentIndex)
Composable->>Config: Inject and resolve attributes from config
Config-->>Composable: Return resolved attributes
Composable->>Composable: Merge provider attributes with match.attributes
Composable-->>Wrapper: Return {renderer, attributes}
Wrapper->>Renderer: Apply v-bind="attributes"
Renderer->>Renderer: Render with merged attributes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
docs/src/components/bubble.md (1)
213-226: Consider documenting the Box wrapper's reserved attributes.This section describes provider↔match merge precedence, but does not mention that the Box wrapper still applies its own
data-role/data-placement/data-shapeon top of the merged attributes (see related note onBubbleBoxWrapper.vue). If that override is intentional, a one-line callout here would prevent surprises for users who try to set those specific keys viabox-attributes.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/src/components/bubble.md` around lines 213 - 226, Add a one-line callout under the BubbleProvider attributes section clarifying that the Box wrapper applies reserved attributes and may override provider/match attributes: explicitly mention BubbleBoxWrapper.vue reserves data-role, data-placement, and data-shape on the Box and that those keys set by box-attributes or match-level attributes will be overridden by the wrapper's values; reference BubbleProvider, box-attributes, content-attributes and BubbleBoxWrapper.vue so readers know where the behavior originates.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/components/src/bubble/BubbleBoxWrapper.vue`:
- Around line 16-22: The wrapper currently binds renderer.attributes before the
explicit :data-role/:data-placement/:data-shape props, causing
props.role/placement/shape to always override any same-named entries in
renderer.attributes; either revert the order (move v-bind="renderer.attributes"
after the explicit bindings) so provider/match-supplied attributes win, or if
the override is intentional, document that BubbleBoxWrapper reserves these
structural attributes (mention renderer.renderer, renderer.attributes, and
props.role/props.placement/props.shape) and update docs to describe the
merge/precedence rule.
---
Nitpick comments:
In `@docs/src/components/bubble.md`:
- Around line 213-226: Add a one-line callout under the BubbleProvider
attributes section clarifying that the Box wrapper applies reserved attributes
and may override provider/match attributes: explicitly mention
BubbleBoxWrapper.vue reserves data-role, data-placement, and data-shape on the
Box and that those keys set by box-attributes or match-level attributes will be
overridden by the wrapper's values; reference BubbleProvider, box-attributes,
content-attributes and BubbleBoxWrapper.vue so readers know where the behavior
originates.
🪄 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: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 84913a30-f025-449e-a095-efabec5f30c5
📒 Files selected for processing (9)
docs/demos/bubble/provider-attributes.vuedocs/src/components/bubble.mdpackages/components/src/bubble/BubbleBoxWrapper.vuepackages/components/src/bubble/BubbleContentWrapper.vuepackages/components/src/bubble/BubbleProvider.vuepackages/components/src/bubble/composables/useBubbleBoxRenderer.tspackages/components/src/bubble/composables/useBubbleContentRenderer.tspackages/components/src/bubble/constants.tspackages/components/src/bubble/index.type.ts
📦 Package Previewpnpm add https://pkg.pr.new/@opentiny/tiny-robot@8e20fce pnpm add https://pkg.pr.new/@opentiny/tiny-robot-kit@8e20fce pnpm add https://pkg.pr.new/@opentiny/tiny-robot-svgs@8e20fce commit: 8e20fce |

背景
当前如果想给所有 Box / Content 统一注入 attributes,只依赖 renderer match 不够稳定,因为无法保证所有消息都会匹配到自定义 renderer。
改动
BubbleProvider新增boxAttributes和contentAttributesBox/Content两条渲染链路统一支持 attributes 合并useBubbleContentRenderer的 attributes 返回能力验证
docs/demos/bubble/provider-attributes.vueSummary by CodeRabbit
New Features
box-attributesandcontent-attributespropsDocumentation